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

v2

parent 12510d69
/build
/build
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.creanet.najdidefibrilator"
minSdkVersion 20
targetSdkVersion 29
versionCode 1
versionName "0.0.1"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.1'
implementation 'com.android.support:appcompat-v7:24.2.1' // appcompat library
implementation 'com.android.support:design:24.2.1'
// Mapbox Services SDK dependency to retrieve direction routes
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'
// Mapbox Buildings Plugin for showing and customizing 3D buildin
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v7:0.5.0'
implementation 'com.google.android.gms:play-services-location:17.0.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'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v8:0.9.0'
implementation('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar') {
transitive = true
}
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'
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.creanet.najdidefibrilator"
minSdkVersion 20
targetSdkVersion 29
versionCode 1
versionName "0.0.2"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.1') {
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-telemetry'
}
implementation 'com.android.support:appcompat-v7:24.2.1'
// Mapbox Services SDK dependency to retrieve direction routes
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'
// Mapbox Buildings Plugin for showing and customizing 3D buildin
// implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v7:0.5.0'
implementation 'com.google.android.gms:play-services-location:17.0.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'
// implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v8:0.9.0'
implementation('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar') {
transitive = true
}
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.
#Wed Oct 16 15:49:14 CEST 2019
apiSecret=a897cb301be7312f7de24ba0d903fbdaccf0fc1087de5476d4aec21a8e638c79
#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
apiSecret=a897cb301be7312f7de24ba0d903fbdaccf0fc1087de5476d4aec21a8e638c79
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.creanet.najdidefibrilator;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.creanet.najdidefibrilator", appContext.getPackageName());
}
}
package com.creanet.najdidefibrilator;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.creanet.najdidefibrilator", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.creanet.najdidefibrilator">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".ItemDetailActivity"
android:parentActivityName=".MainActivity">
<!-- The meta-data tag is required if you support API level 15 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="cdab3bede992f0330e60a95ffa2ace1493d99414" />
</application>
<meta-data
android:name="io.fabric.ApiKey"
android:value="cdab3bede992f0330e60a95ffa2ace1493d99414" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.creanet.najdidefibrilator">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".ItemDetailActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</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>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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;
import com.mapbox.mapboxsdk.geometry.LatLng;
public class DefibrilatorModel {
private LatLng location;
private String name;
private String address;
private String city;
private String desc;
private String tel;
private String email;