Commit 494bb9f5 authored by Marcel Odumorek's avatar Marcel Odumorek

v2

parent 12510d69
/build /build
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
} }
dependencies { dependencies {
classpath 'io.fabric.tools:gradle:1.+' classpath 'io.fabric.tools:gradle:1.+'
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
} }
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.1" buildToolsVersion "29.0.1"
defaultConfig { defaultConfig {
applicationId "com.creanet.najdidefibrilator" applicationId "com.creanet.najdidefibrilator"
minSdkVersion 20 minSdkVersion 20
targetSdkVersion 29 targetSdkVersion 29
versionCode 1 versionCode 1
versionName "0.0.1" versionName "0.0.2"
multiDexEnabled true multiDexEnabled true
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} vectorDrawables.useSupportLibrary = true
buildTypes { }
release { buildTypes {
minifyEnabled false release {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' minifyEnabled false
} proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
repositories { }
maven { url 'https://maven.fabric.io/public' } repositories {
} maven { url 'https://maven.fabric.io/public' }
android { }
compileOptions { android {
sourceCompatibility JavaVersion.VERSION_1_8 compileOptions {
targetCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
} targetCompatibility JavaVersion.VERSION_1_8
} }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0' implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12' implementation 'androidx.appcompat:appcompat:1.1.0'
androidTestImplementation 'androidx.test:runner:1.2.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' testImplementation 'junit:junit:4.12'
implementation 'androidx.cardview:cardview:1.0.0' androidTestImplementation 'androidx.test:runner:1.2.0'
implementation 'com.github.bumptech.glide:glide:4.0.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.github.bumptech.glide:glide:4.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.1' implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.android.support:appcompat-v7:24.2.1' // appcompat library implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.android.support:design:24.2.1'
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.1') {
// Mapbox Services SDK dependency to retrieve direction routes exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-telemetry'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.8.0' }
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0' implementation 'com.android.support:appcompat-v7:24.2.1'
// Mapbox Buildings Plugin for showing and customizing 3D buildin // Mapbox Services SDK dependency to retrieve direction routes
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v7:0.5.0' implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.8.0'
implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v8:0.3.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.6.0' // Mapbox Buildings Plugin for showing and customizing 3D buildin
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v8:0.9.0' // implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v7:0.5.0'
implementation('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar') { implementation 'com.google.android.gms:play-services-location:17.0.0'
transitive = true // implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v8:0.3.0'
} // implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.6.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.11.0' // implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v8:0.9.0'
implementation 'com.google.code.gson:gson:2.8.6' implementation('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar') {
implementation 'com.github.arimorty:floatingsearchview:2.1.1' transitive = true
implementation 'com.squareup.retrofit2:retrofit:2.5.0' }
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.11.0'
} implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
}
#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. #Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
#Wed Oct 16 15:49:14 CEST 2019 #Wed Oct 16 15:49:14 CEST 2019
apiSecret=a897cb301be7312f7de24ba0d903fbdaccf0fc1087de5476d4aec21a8e638c79 apiSecret=a897cb301be7312f7de24ba0d903fbdaccf0fc1087de5476d4aec21a8e638c79
# Add project specific ProGuard rules here. # Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the # You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle. # proguardFiles setting in build.gradle.
# #
# For more details, see # For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html # http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following # If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface # and specify the fully qualified class name to the JavaScript interface
# class: # class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *; # public *;
#} #}
# Uncomment this to preserve the line number information for # Uncomment this to preserve the line number information for
# debugging stack traces. # debugging stack traces.
#-keepattributes SourceFile,LineNumberTable #-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
package com.creanet.najdidefibrilator; package com.creanet.najdidefibrilator;
import android.content.Context; import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* Instrumented test, which will execute on an Android device. * Instrumented test, which will execute on an Android device.
* *
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/ */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest { public class ExampleInstrumentedTest {
@Test @Test
public void useAppContext() { public void useAppContext() {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.creanet.najdidefibrilator", appContext.getPackageName()); assertEquals("com.creanet.najdidefibrilator", appContext.getPackageName());
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.creanet.najdidefibrilator"> package="com.creanet.najdidefibrilator">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" /> <application
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> android:allowBackup="true"
<application android:icon="@mipmap/ic_launcher"
android:allowBackup="true" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name" android:supportsRtl="true"
android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/AppTheme"
android:supportsRtl="true" android:usesCleartextTraffic="true">
android:theme="@style/AppTheme" <activity android:name=".Splash">
android:usesCleartextTraffic="true"> <intent-filter>
<activity android:name=".Splash"> <action android:name="android.intent.action.MAIN" />
<intent-filter> <category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" /> </intent-filter>
</activity>
<category android:name="android.intent.category.LAUNCHER" /> <activity android:name=".MainActivity">
</intent-filter> <intent-filter>
</activity> <category android:name="android.intent.category.DEFAULT" />
<activity android:name=".MainActivity"> </intent-filter>
<intent-filter> </activity>
<activity android:name=".ItemDetailActivity">
<category android:name="android.intent.category.DEFAULT" /> <intent-filter>
</intent-filter> <category android:name="android.intent.category.DEFAULT" />
</activity> </intent-filter>
<activity android:name=".ItemDetailActivity" </activity>
android:parentActivityName=".MainActivity">
<!-- The meta-data tag is required if you support API level 15 and lower --> <meta-data
<meta-data android:name="io.fabric.ApiKey"
android:name="android.support.PARENT_ACTIVITY" android:value="cdab3bede992f0330e60a95ffa2ace1493d99414" />
android:value=".MainActivity" /> </application>
<intent-filter> <meta-data
android:name="io.fabric.ApiKey"
<category android:name="android.intent.category.DEFAULT" /> android:value="cdab3bede992f0330e60a95ffa2ace1493d99414" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="cdab3bede992f0330e60a95ffa2ace1493d99414" />
</application>
<meta-data
android:name="io.fabric.ApiKey"
android:value="cdab3bede992f0330e60a95ffa2ace1493d99414" />
</manifest> </manifest>
\ No newline at end of file
This diff is collapsed.
package com.creanet.najdidefibrilator;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.gson.JsonSyntaxException;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class BottomSheetListFragment extends BottomSheetDialogFragment implements View.OnClickListener {
private Context context;
private FeatureCollection featureCollection;
public static final String TAG = "ActionBottomDialog";
private ItemClickListener mListener;
public static BottomSheetListFragment newInstance() {
return new BottomSheetListFragment();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.bottom_sheet, container, false);
}
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ListView listView = (ListView) getView().findViewById(R.id.list_bottom_sheet);
try {
getFeatureCollectionFromJson();
} catch (Exception exception) {
Log.e("MapActivity", "onCreate: " + exception);
Toast.makeText(context, "Failed to load file", Toast.LENGTH_LONG).show();
}
List<Feature> featureList = featureCollection.features();
ArrayList<DefibrilatorModel> defibrilatorModels = new ArrayList<DefibrilatorModel>();
DefAdapter adapter = new DefAdapter(getApplicationContext(),defibrilatorModels );
for (int x = 0; x < featureList.size(); x++) {
Feature singleLocation = featureList.get(x);
String singleLocationPerson = singleLocation.getStringProperty("person");
String singleLocationDesc = singleLocation.getStringProperty("description");
String singleLocationCity = singleLocation.getStringProperty("city");
String singleLocationAddress = singleLocation.getStringProperty("address");
String singleLocationTel = singleLocation.getStringProperty("tel");
String singleLocationEmail = singleLocation.getStringProperty("email");
String singleLocationHours = singleLocation.getStringProperty("hours");
String singleLocationImage = singleLocation.getStringProperty("images");
Number singleLocationId = singleLocation.getNumberProperty("id");
Point singleLocationPosition = (Point) singleLocation.geometry();
LatLng singleLocationLatLng = new LatLng(singleLocationPosition.latitude(), singleLocationPosition.longitude());
defibrilatorModels.add(new DefibrilatorModel(
singleLocationLatLng,
singleLocationPerson,
singleLocationDesc,
singleLocationCity,
singleLocationAddress,
singleLocationTel,
singleLocationEmail,
singleLocationHours,
singleLocationImage,
singleLocationId
));
}
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
}
});
}
private void getFeatureCollectionFromJson() throws IOException {
File initialFile = new File(getApplicationContext().getFilesDir().getPath() + "/Locations", "locations.geojson");
try {
featureCollection = FeatureCollection.fromJson(loadGeoJson());
Log.e("gFCFJ", "JSON OPENED SUCCESFULLY");
} catch (IllegalStateException | JsonSyntaxException exception) {
Log.e("gFCFJK", "getFeatureCollectionFromJson error");
exception.printStackTrace();
}
}
private String loadGeoJson() {
try {
File root = new File(getApplicationContext().getFilesDir().getPath() + "/Locations", "locations.geojson");
InputStream is = new FileInputStream(root);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
return new String(buffer, "UTF-8");
} catch (Exception exception) {
Log.e("MapActivity", "Exception Loading GeoJSON: " + exception.toString());
exception.printStackTrace();
return null;
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof ItemClickListener) {
mListener = (ItemClickListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement ItemClickListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
@Override public void onClick(View view) {
TextView tvSelected = (TextView) view;
mListener.onItemClick(tvSelected.getText().toString());
Log.e("BottomSheetDialog","Clicked on item");
}
public interface ItemClickListener {
void onItemClick(String item);
}
}
package com.creanet.najdidefibrilator;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class DefAdapter extends ArrayAdapter<DefibrilatorModel> {
private String imageName;
public DefAdapter(Context context,ArrayList<DefibrilatorModel> def){
super(context,0,def);
}
@Override
public View getView(int position,View convertView,ViewGroup parent){
DefibrilatorModel defibrilatorModel = getItem(position);
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.single_item, parent, false);
}
// try {
// URL url = new URL(defibrilatorModel.getImage());
// URLConnection conn = url.openConnection();
// InputStream in = conn.getInputStream();
// } catch (IOException e) {
// e.printStackTrace();
// }
DefibrilatorModel model = getItem(position);
ImageView image = convertView.findViewById(R.id.emoji);
if (model != null) {
Picasso.get().load(model.getImage()).into(image);
}
Button detail = (Button) convertView.findViewById(R.id.detailbutton);
detail.setTag(position);
detail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = (Integer) view.getTag();
Context context = view.getContext();
DefibrilatorModel defibrilatorModel1 = getItem(position);
Intent intent = new Intent(context,ItemDetailActivity.class);
intent.putExtra("title",defibrilatorModel.getId().toString());
intent.putExtra("desc",defibrilatorModel.getDesc());
intent.putExtra("address",defibrilatorModel.getAddress());
intent.putExtra("image",defibrilatorModel.getImage());
context.startActivity(intent);
}
});
TextView address = (TextView) convertView.findViewById(R.id.address);
TextView id = (TextView) convertView.findViewById(R.id.city);
ImageView img = (ImageView) convertView.findViewById(R.id.emoji);
address.setText(defibrilatorModel.getAddress());
id.setText(defibrilatorModel.getId().toString());
// img.setImageBitmap(loadImageFromStorage(directory.getAbsolutePath()));
// new DownloadImages().execute(defibrilatorModel.getImage());
imageName = defibrilatorModel.getId().toString();
return convertView;
}
// private class DownloadImages extends AsyncTask<String, Void, Bitmap> {
// private String TAG = "DownloadImage";
// private Bitmap downloadImageBitmap(String sUrl) {
// Bitmap bitmap = null;
// try {
// InputStream inputStream = new URL(sUrl).openStream(); // Download Image from URL
// bitmap = BitmapFactory.decodeStream(inputStream); // Decode Bitmap
// inputStream.close();
// } catch (Exception e) {
// Log.d(TAG, "Exception 1, Something went wrong!");
// e.printStackTrace();
// }
// return bitmap;
// }
//
// @Override
// protected Bitmap doInBackground(String... params) {
// return downloadImageBitmap(params[0]);
// }
//
// protected void onPostExecute(Bitmap result) {
// saveImages(result);
// }
// }
//
// private String saveImages(Bitmap bitmapImage){
// Context base;
// ContextWrapper cw = new ContextWrapper(getApplicationContext());
// File directory = cw.getDir("images",Context.MODE_PRIVATE);
// File path = new File(directory,imageName+".jpg");
//
// FileOutputStream fos = null;
// try {
// fos = new FileOutputStream(path);
// bitmapImage.compress(Bitmap.CompressFormat.JPEG,100,fos);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } finally {
// try {
// fos.close();
// Log.e("Adapter",directory.getAbsolutePath());
// } catch (IOException e){
// e.printStackTrace();
// }
// }
// return directory.getAbsolutePath();
// }
// private void loadImageFromStorage(String path){
// try {
// File f = new File(path,imageName+".jpg");
// Bitmap b = BitmapFactory.decodeStream(new FileInputStream(f));
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// }
}
package com.creanet.najdidefibrilator; package com.creanet.najdidefibrilator;
import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLng;
public class DefibrilatorModel { import org.json.JSONObject;
private LatLng location; public class DefibrilatorModel {
private String name;
private String address; private LatLng location;
private String city; private String person;
private String desc; private String address1;
private String tel; private String city;
private String email; private String desc;
private String hours; private String tel;
private String image; private String email;
private Number id; private String hours;
private String image;
public DefibrilatorModel(LatLng location,String name,String address,String city,String desc,String tel,String email,String hours, String image, Number id){ private Number id;
this.location = location; private String distance;
this.name = name;
this.address = address; public DefibrilatorModel(LatLng location,String person,String address,String city,String desc,String tel,String email,String hours, String image, Number id){
this.city = city; this.location = location;
this.desc = desc; this.person = person;
this.tel = tel; this.address1 = address;
this.email = email; this.city = city;
this.hours = hours; this.desc = desc;
this.image = image; this.tel = tel;
this.id = id; this.email = email