diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6cbe56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..e3f094e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +project \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..fc132b2 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5d19981 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f0d7c37 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..e50614a --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.2" + + defaultConfig { + applicationId "com.dt.project" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.1.1' + compile 'com.android.support:support-v4:23.1.1' + compile 'com.android.support:design:23.1.1' + compile 'com.google.android.gms:play-services:8.4.0' + compile 'com.android.support:recyclerview-v7:23.1.1' + compile 'com.android.support:cardview-v7:23.1.1' + compile 'com.squareup.picasso:picasso:2.3.2' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..675623a --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in D:\Programs\Android\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# 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 *; +#} diff --git a/app/src/androidTest/java/com/dt/project/ApplicationTest.java b/app/src/androidTest/java/com/dt/project/ApplicationTest.java new file mode 100644 index 0000000..cad874b --- /dev/null +++ b/app/src/androidTest/java/com/dt/project/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.dt.project; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e54beb5 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/dt/project/AsyncTasks/AutoCompleteAsyncTask.java b/app/src/main/java/com/dt/project/AsyncTasks/AutoCompleteAsyncTask.java new file mode 100644 index 0000000..c304d04 --- /dev/null +++ b/app/src/main/java/com/dt/project/AsyncTasks/AutoCompleteAsyncTask.java @@ -0,0 +1,83 @@ +package com.dt.project.AsyncTasks; + +import android.os.AsyncTask; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + + +//Start an asynctask the bring all the information on the user options when he types +public class AutoCompleteAsyncTask extends AsyncTask { + + private Callbacks callbacks; + private String errorMessage = null; + + public AutoCompleteAsyncTask(Callbacks callbacks) { + this.callbacks = callbacks; + } + + protected String doInBackground(URL... params) { + + try { + + URL url = params[0]; + + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + int httpStatusCode = connection.getResponseCode(); + + if (httpStatusCode == HttpURLConnection.HTTP_BAD_REQUEST) { + errorMessage = "No Such Symbol"; + return null; + } + if (httpStatusCode != HttpURLConnection.HTTP_OK) { + errorMessage = connection.getResponseMessage(); + return null; + } + + InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + String result = ""; + + String oneLine = bufferedReader.readLine(); + + while (oneLine != null) { + result += oneLine + "\n"; + oneLine = bufferedReader.readLine(); + } + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + + return result; + + } catch (Exception ex) { + errorMessage = ex.getMessage(); + return null; + } + } + + protected void onPostExecute(String result) { + + if (errorMessage != null) { + callbacks.onError(errorMessage); + } else { + try { + callbacks.onSuccessWords(result); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public interface Callbacks { + + void onSuccessWords(String result); + + void onError(String errorMessage); + } +} diff --git a/app/src/main/java/com/dt/project/AsyncTasks/DownloadImageAsyncTask.java b/app/src/main/java/com/dt/project/AsyncTasks/DownloadImageAsyncTask.java new file mode 100644 index 0000000..d907a3c --- /dev/null +++ b/app/src/main/java/com/dt/project/AsyncTasks/DownloadImageAsyncTask.java @@ -0,0 +1,39 @@ +package com.dt.project.AsyncTasks; + + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.AsyncTask; +import android.util.Log; +import java.io.InputStream; + +//Taking url String and preform AsyncTask in order to show the image +public class DownloadImageAsyncTask extends AsyncTask { + + private Callbacks callbacks; + + public DownloadImageAsyncTask(Callbacks callbacks) { + this.callbacks = callbacks; + } + + protected Bitmap doInBackground(String... urls) { + String url = urls[0]; + Bitmap mIcon11 = null; + try { + InputStream in = new java.net.URL(url).openStream(); + mIcon11 = BitmapFactory.decodeStream(in); + } catch (Exception ex) { + Log.e("Error", ex.getMessage()); + ex.printStackTrace(); + } + + return mIcon11; + } + + protected void onPostExecute(Bitmap result) { + callbacks.onSuccess(result); + } + public interface Callbacks{ + void onSuccess(Bitmap result); + } +} diff --git a/app/src/main/java/com/dt/project/AsyncTasks/InfoOnPlaceAsyncTask.java b/app/src/main/java/com/dt/project/AsyncTasks/InfoOnPlaceAsyncTask.java new file mode 100644 index 0000000..dd41fdb --- /dev/null +++ b/app/src/main/java/com/dt/project/AsyncTasks/InfoOnPlaceAsyncTask.java @@ -0,0 +1,90 @@ +package com.dt.project.AsyncTasks; + + +import android.os.AsyncTask; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +//Searching more information on the place and manage the information in callbacks +public class InfoOnPlaceAsyncTask extends AsyncTask { + + private Callbacks callbacks; + private String errorMessage = null; + + public InfoOnPlaceAsyncTask(Callbacks callbacks) { + this.callbacks = callbacks; + } + + protected void onPreExecute() { + callbacks.onAboutToStart(); + } + + protected String doInBackground(URL... params) { + + try { + + URL url = params[0]; + + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + int httpStatusCode = connection.getResponseCode(); + + if (httpStatusCode == HttpURLConnection.HTTP_BAD_REQUEST) { + errorMessage = "No Such Symbol"; + return null; + } + if (httpStatusCode != HttpURLConnection.HTTP_OK) { + errorMessage = connection.getResponseMessage(); + return null; + } + + InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + String result = ""; + + String oneLine = bufferedReader.readLine(); + + while (oneLine != null) { + result += oneLine + "\n"; + oneLine = bufferedReader.readLine(); + } + + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + + return result; + + } catch (Exception ex) { + errorMessage = ex.getMessage(); + return null; + } + } + + protected void onPostExecute(String result) { + + if (errorMessage != null) { + callbacks.onError(errorMessage); + } else { + try { + callbacks.onSuccessInfoOnPlace(result); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public interface Callbacks { + void onAboutToStart(); + + void onSuccessInfoOnPlace(String result); + + void onError(String errorMessage); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dt/project/AsyncTasks/SearchByTextAsyncTask.java b/app/src/main/java/com/dt/project/AsyncTasks/SearchByTextAsyncTask.java new file mode 100644 index 0000000..0294f1e --- /dev/null +++ b/app/src/main/java/com/dt/project/AsyncTasks/SearchByTextAsyncTask.java @@ -0,0 +1,88 @@ +package com.dt.project.AsyncTasks; + + +import android.os.AsyncTask; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +//searching by user text word +public class SearchByTextAsyncTask extends AsyncTask { + + private Callbacks callbacks; + private String errorMessage = null; + + public SearchByTextAsyncTask(Callbacks callbacks) { + this.callbacks = callbacks; + } + + protected void onPreExecute() { + callbacks.onAboutToStart(); + } + + protected String doInBackground(URL... params) { + + try { + + URL url = params[0]; + + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + int httpStatusCode = connection.getResponseCode(); + + if (httpStatusCode == HttpURLConnection.HTTP_BAD_REQUEST) { + errorMessage = "No Such Symbol"; + return null; + } + if (httpStatusCode != HttpURLConnection.HTTP_OK) { + errorMessage = connection.getResponseMessage(); + return null; + } + + InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + String result = ""; + + String oneLine = bufferedReader.readLine(); + + while (oneLine != null) { + result += oneLine + "\n"; + oneLine = bufferedReader.readLine(); + } + + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + + return result; + + } catch (Exception ex) { + errorMessage = ex.getMessage(); + return null; + } + } + + protected void onPostExecute(String result) { + + if (errorMessage != null) { + callbacks.onError(errorMessage); + } else { + try { + callbacks.onSuccessSearchByTextAsyncTask(result); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public interface Callbacks { + void onAboutToStart(); + + void onSuccessSearchByTextAsyncTask(String result); + + void onError(String errorMessage); + } +} diff --git a/app/src/main/java/com/dt/project/AsyncTasks/SearchNearYouAsyncTask.java b/app/src/main/java/com/dt/project/AsyncTasks/SearchNearYouAsyncTask.java new file mode 100644 index 0000000..6b8e984 --- /dev/null +++ b/app/src/main/java/com/dt/project/AsyncTasks/SearchNearYouAsyncTask.java @@ -0,0 +1,89 @@ +package com.dt.project.AsyncTasks; + + +import android.os.AsyncTask; +import org.json.JSONException; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +//search near user by types or location +public class SearchNearYouAsyncTask extends AsyncTask { + + private Callbacks callbacks; + private String errorMessage = null; + + public SearchNearYouAsyncTask(Callbacks callbacks) { + this.callbacks = callbacks; + } + + protected void onPreExecute() { + callbacks.onAboutToStart(); + } + + protected String doInBackground(URL... params) { + + try { + + URL url = params[0]; + + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + int httpStatusCode = connection.getResponseCode(); + + if (httpStatusCode == HttpURLConnection.HTTP_BAD_REQUEST) { + errorMessage = "No Such Symbol"; + return null; + } + if (httpStatusCode != HttpURLConnection.HTTP_OK) { + errorMessage = connection.getResponseMessage(); + return null; + } + + InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + String result = ""; + + String oneLine = bufferedReader.readLine(); + + while (oneLine != null) { + result += oneLine + "\n"; + oneLine = bufferedReader.readLine(); + } + + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + + return result; + + } catch (Exception ex) { + errorMessage = ex.getMessage(); + return null; + } + } + + protected void onPostExecute(String result) { + + if (errorMessage != null) { + callbacks.onError(errorMessage); + } else { + try { + callbacks.onSuccess(result); + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + + public interface Callbacks { + void onAboutToStart(); + + void onSuccess(String result) throws JSONException; + + void onError(String errorMessage); + } +} diff --git a/app/src/main/java/com/dt/project/CircleTransformPicasso/CircleTransform.java b/app/src/main/java/com/dt/project/CircleTransformPicasso/CircleTransform.java new file mode 100644 index 0000000..dbc8ec2 --- /dev/null +++ b/app/src/main/java/com/dt/project/CircleTransformPicasso/CircleTransform.java @@ -0,0 +1,44 @@ +package com.dt.project.CircleTransformPicasso; + +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Paint; + +import com.squareup.picasso.Transformation; + +//using canvas in order to show the image as circle calling this class only in picasso +public class CircleTransform implements Transformation { + @Override + public Bitmap transform(Bitmap source) { + int size = Math.min(source.getWidth(), source.getHeight()); + + int x = (source.getWidth() - size) / 2; + int y = (source.getHeight() - size) / 2; + + Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size); + if (squaredBitmap != source) { + source.recycle(); + } + + Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig()); + + Canvas canvas = new Canvas(bitmap); + Paint paint = new Paint(); + BitmapShader shader = new BitmapShader(squaredBitmap, + BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); + paint.setShader(shader); + paint.setAntiAlias(true); + + float r = size / 2f; + canvas.drawCircle(r, r, r, paint); + + squaredBitmap.recycle(); + return bitmap; + } + + @Override + public String key() { + return "circle"; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dt/project/DataBase/BaseLogic.java b/app/src/main/java/com/dt/project/DataBase/BaseLogic.java new file mode 100644 index 0000000..a0fdd50 --- /dev/null +++ b/app/src/main/java/com/dt/project/DataBase/BaseLogic.java @@ -0,0 +1,26 @@ +package com.dt.project.DataBase; + + +import android.app.Activity; + +// The base class for all business logic classes: +public abstract class BaseLogic { + + // The dal object: + protected DAL dal; + + // constructor: + public BaseLogic(Activity activity) { + dal = new DAL(activity); + } + + // Open the database: + public void open() { + dal.open(); + } + + // close the database: + public void close() { + dal.close(); + } +} diff --git a/app/src/main/java/com/dt/project/DataBase/DAL.java b/app/src/main/java/com/dt/project/DataBase/DAL.java new file mode 100644 index 0000000..582b164 --- /dev/null +++ b/app/src/main/java/com/dt/project/DataBase/DAL.java @@ -0,0 +1,62 @@ +package com.dt.project.DataBase; + +import android.app.Activity; +import android.content.ContentValues; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +public class DAL extends SQLiteOpenHelper { + + // An object which can access the database: + private SQLiteDatabase database; + + // Constructor: + public DAL(Activity activity) { + super(activity, DB.NAME, null, DB.VERSION); + } + + // Will be called when the app is first running: + public void onCreate(SQLiteDatabase db) { + db.execSQL(DB.Places.CREATION_STATEMENT); // Execute sql statement + + db.execSQL(DB.FavoritePlaces.CREATION_STATEMENT); // Execute sql statement + } + + // Will be called when the app is being upgraded if our version will be different: + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + + db.execSQL(DB.Places.DELETION_STATEMENT); + db.execSQL(DB.Places.CREATION_STATEMENT); + + db.execSQL(DB.FavoritePlaces.DELETION_STATEMENT); + db.execSQL(DB.FavoritePlaces.CREATION_STATEMENT); + } + + // Opening the database for any action: + public void open() { + database = getWritableDatabase(); // This is the open method. + } + + // Closing the database: + public void close() { + super.close(); // This is the close method. + } + + // Add a new row to a table: + public long insert(String tableName, ContentValues values) { + return database.insert(tableName, null, values); + } + //delete + public long delete(String tableName, String where) { + return database.delete(tableName, where, null); + } + // We then can advanced the cursor to the next line + public Cursor getTable(String tableName, String[] columns, String where, String orderBy) { + return database.query(tableName, columns, where, null, null, null, orderBy); + } + // The update will return the number of rows affected. + public long update(String tableName, ContentValues values, String where) { + return (long) database.update(tableName, values, where, null); + } +} diff --git a/app/src/main/java/com/dt/project/DataBase/DB.java b/app/src/main/java/com/dt/project/DataBase/DB.java new file mode 100644 index 0000000..ecb96cf --- /dev/null +++ b/app/src/main/java/com/dt/project/DataBase/DB.java @@ -0,0 +1,87 @@ +package com.dt.project.DataBase; + + +public class DB { + public static final String NAME = "PlacesDatabase.db"; // Database file name. + public static final int VERSION = 1; // Places Database version. + + // Inner Class Places + public static class Places { + + public static final String TABLE_NAME = "Places"; // Table name. + public static final String SQL_ID = "sqlID"; // id column name (this is the primary key) + public static final String PLACE_ID = "placeId"; // id of the place column + public static final String PLACE_NAME = "placeName"; // name of the place column + public static final String PLACE_VICINITY = "placeVicinity"; // vicinity of the place column + public static final String PLACE_LATITUDE = "placeLatitude"; // latitude of the place column + public static final String PLACE_LONGITUDE = "placeLongitude"; // longitude of the place column + public static final String PLACE_DISTANCE = "placeDistance"; // distance of the place column + public static final String PLACE_REFERENCE = "placeReference"; // reference of the place column + public static final String PLACE_WEBSITE = "placeWebSite"; // website of the place column + public static final String PLACE_OPEN_HOURS = "placeOpenHours"; // open hours of the place column + public static final String PLACE_PHONE = "placePhone"; // phone of the place column + public static final String PLACE_PHOTO = "placePhoto"; // photo of the place column + public static final String PLACE_RATING = "placeRating"; // rating of the place column + + + public static final String[] ALL_COLUMNS = new String[]{SQL_ID, PLACE_ID, PLACE_NAME, PLACE_VICINITY,PLACE_LATITUDE,PLACE_LONGITUDE, PLACE_DISTANCE, PLACE_REFERENCE,PLACE_WEBSITE,PLACE_OPEN_HOURS,PLACE_PHONE, PLACE_PHOTO, PLACE_RATING}; + + // the creation table is a string. + public static final String CREATION_STATEMENT = "CREATE TABLE " + TABLE_NAME + + " ( " + SQL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + PLACE_ID + " TEXT, " + + PLACE_NAME + " TEXT, " + + PLACE_VICINITY + " TEXT, " + + PLACE_LATITUDE + " NUMERIC, " + + PLACE_LONGITUDE + " NUMERIC, " + + PLACE_DISTANCE + " NUMERIC, " + + PLACE_REFERENCE + " TEXT, " + + PLACE_WEBSITE + " TEXT, " + + PLACE_OPEN_HOURS + " TEXT, " + + PLACE_PHONE + " TEXT, " + + PLACE_PHOTO + " TEXT, " + + PLACE_RATING + " NUMERIC ) "; + + public static final String DELETION_STATEMENT = "DROP TABLE IF EXISTS " + TABLE_NAME; + } + + // Inner Class FavoritePlaces + public static class FavoritePlaces { + + public static final String TABLE_NAME = "FavoritePlaces"; // Table name. + public static final String SQL_ID = "sqlID"; // id column name (this is the primary key) + public static final String PLACE_ID = "placeId"; // id of the place column + public static final String PLACE_NAME = "placeName"; // name of the place column + public static final String PLACE_VICINITY = "placeVicinity"; // vicinity of the place column + public static final String PLACE_LATITUDE = "placeLatitude"; // latitude of the place column + public static final String PLACE_LONGITUDE = "placeLongitude"; // longitude of the place column + public static final String PLACE_DISTANCE = "placeDistance"; // distance of the place column + public static final String PLACE_REFERENCE = "placeReference"; // reference of the place column + public static final String PLACE_WEBSITE = "placeWebSite"; // website of the place column + public static final String PLACE_OPEN_HOURS = "placeOpenHours"; // open hours of the place column + public static final String PLACE_PHONE = "placePhone"; // phone of the place column + public static final String PLACE_PHOTO = "placePhoto"; // photo of the place column + public static final String PLACE_RATING = "placeRating"; // rating of the place column + + + public static final String[] ALL_COLUMNS = new String[]{SQL_ID, PLACE_ID, PLACE_NAME, PLACE_VICINITY,PLACE_LATITUDE,PLACE_LONGITUDE, PLACE_DISTANCE, PLACE_REFERENCE,PLACE_WEBSITE,PLACE_OPEN_HOURS,PLACE_PHONE, PLACE_PHOTO,PLACE_RATING}; + + // the creation table is a string. + public static final String CREATION_STATEMENT = "CREATE TABLE " + TABLE_NAME + + " ( " + SQL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + PLACE_ID + " TEXT, " + + PLACE_NAME + " TEXT, " + + PLACE_VICINITY + " TEXT, " + + PLACE_LATITUDE + " NUMERIC, " + + PLACE_LONGITUDE + " NUMERIC, " + + PLACE_DISTANCE + " NUMERIC, " + + PLACE_REFERENCE + " TEXT, " + + PLACE_WEBSITE + " TEXT, " + + PLACE_OPEN_HOURS + " TEXT, " + + PLACE_PHONE + " TEXT, " + + PLACE_PHOTO + " TEXT, " + + PLACE_RATING + " NUMERIC ) "; + + public static final String DELETION_STATEMENT = "DROP TABLE IF EXISTS " + TABLE_NAME; + } +} diff --git a/app/src/main/java/com/dt/project/DataBase/FavoritePlaceLogic.java b/app/src/main/java/com/dt/project/DataBase/FavoritePlaceLogic.java new file mode 100644 index 0000000..3af2362 --- /dev/null +++ b/app/src/main/java/com/dt/project/DataBase/FavoritePlaceLogic.java @@ -0,0 +1,111 @@ +package com.dt.project.DataBase; + +import android.app.Activity; +import android.content.ContentValues; +import android.database.Cursor; + +import com.dt.project.FavoritePlace.FavoritePlace; + +import java.util.ArrayList; + + +public class FavoritePlaceLogic extends BaseLogic{ + + public FavoritePlaceLogic(Activity activity) { + super(activity); + } + // adding the values of a favoritePlace to the DB + public long addFavoritePlace(FavoritePlace favoritePlace) { + + ContentValues contentValues = new ContentValues(); + contentValues.put(DB.FavoritePlaces.PLACE_ID, favoritePlace.getPlaceID()); + contentValues.put(DB.FavoritePlaces.PLACE_NAME, favoritePlace.getPlaceName()); + contentValues.put(DB.FavoritePlaces.PLACE_VICINITY, favoritePlace.getPlaceAddress()); + contentValues.put(DB.FavoritePlaces.PLACE_LATITUDE, favoritePlace.getPlaceLatitude()); + contentValues.put(DB.FavoritePlaces.PLACE_LONGITUDE, favoritePlace.getPlaceLongitude()); + contentValues.put(DB.FavoritePlaces.PLACE_DISTANCE, favoritePlace.getPlaceDistance()); + contentValues.put(DB.FavoritePlaces.PLACE_REFERENCE, favoritePlace.getPlaceReference()); + contentValues.put(DB.FavoritePlaces.PLACE_WEBSITE, favoritePlace.getPlaceWebSite()); + contentValues.put(DB.FavoritePlaces.PLACE_OPEN_HOURS, favoritePlace.getPlaceOpenHours()); + contentValues.put(DB.FavoritePlaces.PLACE_PHONE, favoritePlace.getPlacePhone()); + contentValues.put(DB.FavoritePlaces.PLACE_PHOTO, favoritePlace.getPlacePhoto()); + contentValues.put(DB.FavoritePlaces.PLACE_RATING, favoritePlace.getPlaceRating()); + + long createdId = dal.insert(DB.FavoritePlaces.TABLE_NAME, contentValues); + return createdId; + } +//geting all the favorite places from the DB + public ArrayList getFavoritePlaces(String where, String orderBy) { + + ArrayList places = new ArrayList<>(); + + Cursor cursor = dal.getTable(DB.FavoritePlaces.TABLE_NAME, DB.FavoritePlaces.ALL_COLUMNS,where,orderBy); + + while (cursor.moveToNext()) { + + int idIndex = cursor.getColumnIndex(DB.FavoritePlaces.SQL_ID); + long sqlID = cursor.getLong(idIndex); + String placeId = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_ID)); + String placeName = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_NAME)); + String placeVicinity = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_VICINITY)); + double placeLatitude = cursor.getDouble(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_LATITUDE)); + double placeLongitude = cursor.getDouble(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_LONGITUDE)); + double placeDistance = cursor.getDouble(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_DISTANCE)); + String placeReference = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_REFERENCE)); + String placeWebSite = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_WEBSITE)); + String placeOpenHours = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_OPEN_HOURS)); + String placePhone = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_PHONE)); + String placePhoto = cursor.getString(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_PHOTO)); + float placeRating = cursor.getFloat(cursor.getColumnIndex(DB.FavoritePlaces.PLACE_RATING)); + + FavoritePlace favoritePlace = new FavoritePlace(sqlID,placeId,placeName,placeVicinity,placeLatitude,placeLongitude,placeDistance,placeReference,placeWebSite,placeOpenHours,placePhone,placePhoto,placeRating); + places.add(favoritePlace); + + } + cursor.close(); + return places; + } +//delete all items from DB + public long deleteAllFavorites() { + + long affectedRows = dal.delete(DB.FavoritePlaces.TABLE_NAME,null); + + return affectedRows; + } +// delete one item from DB + public long deleteOneItemFavorite(long sql_id) { + String where =DB.FavoritePlaces.SQL_ID+" = "+sql_id; + + long affectedRows = dal.delete(DB.FavoritePlaces.TABLE_NAME,where); + + return affectedRows; + } + //updating favorite place +public long updateFavoritePlace(FavoritePlace favoritePlace){ + ContentValues contentValues = new ContentValues(); + contentValues.put(DB.FavoritePlaces.PLACE_ID, favoritePlace.getPlaceID()); + contentValues.put(DB.FavoritePlaces.PLACE_NAME, favoritePlace.getPlaceName()); + contentValues.put(DB.FavoritePlaces.PLACE_VICINITY, favoritePlace.getPlaceAddress()); + contentValues.put(DB.FavoritePlaces.PLACE_LATITUDE, favoritePlace.getPlaceLatitude()); + contentValues.put(DB.FavoritePlaces.PLACE_LONGITUDE, favoritePlace.getPlaceLongitude()); + contentValues.put(DB.FavoritePlaces.PLACE_DISTANCE, favoritePlace.getPlaceDistance()); + contentValues.put(DB.FavoritePlaces.PLACE_REFERENCE, favoritePlace.getPlaceReference()); + contentValues.put(DB.FavoritePlaces.PLACE_WEBSITE, favoritePlace.getPlaceWebSite()); + contentValues.put(DB.FavoritePlaces.PLACE_OPEN_HOURS, favoritePlace.getPlaceOpenHours()); + contentValues.put(DB.FavoritePlaces.PLACE_PHONE, favoritePlace.getPlacePhone()); + contentValues.put(DB.FavoritePlaces.PLACE_PHOTO, favoritePlace.getPlacePhoto()); + contentValues.put(DB.FavoritePlaces.PLACE_RATING, favoritePlace.getPlaceRating()); + + String where = DB.FavoritePlaces.SQL_ID + "=" + favoritePlace.getSqlID(); + + long affectedRows = dal.update(DB.FavoritePlaces.TABLE_NAME, contentValues, where); + + return affectedRows; + +} + +//bring all the favorite places by the distance + public ArrayList getAllPlaces(){ + return getFavoritePlaces(null, DB.FavoritePlaces.PLACE_DISTANCE); + } +} diff --git a/app/src/main/java/com/dt/project/DataBase/PlaceLogic.java b/app/src/main/java/com/dt/project/DataBase/PlaceLogic.java new file mode 100644 index 0000000..0352491 --- /dev/null +++ b/app/src/main/java/com/dt/project/DataBase/PlaceLogic.java @@ -0,0 +1,102 @@ +package com.dt.project.DataBase; + + +import android.app.Activity; +import android.content.ContentValues; +import android.database.Cursor; + +import com.dt.project.Place.Place; + +import java.util.ArrayList; + +public class PlaceLogic extends BaseLogic { + + public PlaceLogic(Activity activity) { + super(activity); + } + + // adding the values of a place to the DB + public long addPlace(Place place) { + + ContentValues contentValues = new ContentValues(); + contentValues.put(DB.Places.PLACE_ID, place.getPlaceID()); + contentValues.put(DB.Places.PLACE_NAME, place.getPlaceName()); + contentValues.put(DB.Places.PLACE_VICINITY, place.getPlaceAddress()); + contentValues.put(DB.Places.PLACE_LATITUDE, place.getPlaceLatitude()); + contentValues.put(DB.Places.PLACE_LONGITUDE, place.getPlaceLongitude()); + contentValues.put(DB.Places.PLACE_DISTANCE, place.getPlaceDistance()); + contentValues.put(DB.Places.PLACE_REFERENCE, place.getPlaceReference()); + contentValues.put(DB.Places.PLACE_WEBSITE, place.getPlaceWebSite()); + contentValues.put(DB.Places.PLACE_OPEN_HOURS, place.getPlaceOpenHours()); + contentValues.put(DB.Places.PLACE_PHONE, place.getPlacePhone()); + contentValues.put(DB.Places.PLACE_PHOTO, place.getPlacePhoto()); + contentValues.put(DB.Places.PLACE_RATING, place.getPlaceRating()); + + long createdId = dal.insert(DB.Places.TABLE_NAME, contentValues); + return createdId; + } +//bring all places from the DB + public ArrayList getPlaces(String where,String orderBy) { + + ArrayList places = new ArrayList<>(); + + Cursor cursor = dal.getTable(DB.Places.TABLE_NAME, DB.Places.ALL_COLUMNS,where,orderBy); + + while (cursor.moveToNext()) { + + int idIndex = cursor.getColumnIndex(DB.Places.SQL_ID); + long sqlID = cursor.getLong(idIndex); + String placeId = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_ID)); + String placeName = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_NAME)); + String placeVicinity = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_VICINITY)); + double placeLatitude = cursor.getDouble(cursor.getColumnIndex(DB.Places.PLACE_LATITUDE)); + double placeLongitude = cursor.getDouble(cursor.getColumnIndex(DB.Places.PLACE_LONGITUDE)); + double placeDistance = cursor.getDouble(cursor.getColumnIndex(DB.Places.PLACE_DISTANCE)); + String placeReference = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_REFERENCE)); + String placeWebSite = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_WEBSITE)); + String placeOpenHours = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_OPEN_HOURS)); + String placePhone = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_PHONE)); + String placePhoto = cursor.getString(cursor.getColumnIndex(DB.Places.PLACE_PHOTO)); + float placeRating = cursor.getFloat(cursor.getColumnIndex(DB.Places.PLACE_RATING)); + + Place place = new Place(sqlID,placeId,placeName,placeVicinity,placeLatitude,placeLongitude,placeDistance,placeReference,placeWebSite,placeOpenHours,placePhone,placePhoto,placeRating); + places.add(place); + } + cursor.close(); + return places; + } +// delete all places + public long deleteAll() { + + long affectedRows = dal.delete(DB.Places.TABLE_NAME,null); + + return affectedRows; + } + //updating the place information +public long updatePlace(Place place){ + ContentValues contentValues = new ContentValues(); + contentValues.put(DB.Places.PLACE_ID, place.getPlaceID()); + contentValues.put(DB.Places.PLACE_NAME, place.getPlaceName()); + contentValues.put(DB.Places.PLACE_VICINITY, place.getPlaceAddress()); + contentValues.put(DB.Places.PLACE_LATITUDE, place.getPlaceLatitude()); + contentValues.put(DB.Places.PLACE_LONGITUDE, place.getPlaceLongitude()); + contentValues.put(DB.Places.PLACE_DISTANCE, place.getPlaceDistance()); + contentValues.put(DB.Places.PLACE_REFERENCE, place.getPlaceReference()); + contentValues.put(DB.Places.PLACE_WEBSITE, place.getPlaceWebSite()); + contentValues.put(DB.Places.PLACE_OPEN_HOURS, place.getPlaceOpenHours()); + contentValues.put(DB.Places.PLACE_PHONE, place.getPlacePhone()); + contentValues.put(DB.Places.PLACE_PHOTO, place.getPlacePhoto()); + contentValues.put(DB.Places.PLACE_RATING, place.getPlaceRating()); + + String where = DB.Places.SQL_ID + "=" + place.getSqlID(); + + long affectedRows = dal.update(DB.Places.TABLE_NAME, contentValues, where); + + return affectedRows; +} +//brings all the places by distance + public ArrayList getAllPlaces(){ + return getPlaces(null,DB.Places.PLACE_DISTANCE); + } + +} diff --git a/app/src/main/java/com/dt/project/FavoritePlace/FavoriteHolder.java b/app/src/main/java/com/dt/project/FavoritePlace/FavoriteHolder.java new file mode 100644 index 0000000..1981ee2 --- /dev/null +++ b/app/src/main/java/com/dt/project/FavoritePlace/FavoriteHolder.java @@ -0,0 +1,204 @@ +package com.dt.project.FavoritePlace; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.dt.project.AsyncTasks.InfoOnPlaceAsyncTask; +import com.dt.project.CircleTransformPicasso.CircleTransform; +import com.dt.project.DataBase.FavoritePlaceLogic; +import com.dt.project.Helper; +import com.dt.project.MainActivity; +import com.dt.project.Phone.MapAndInfoPhoneActivity; +import com.dt.project.R; +import com.squareup.picasso.Picasso; + +import java.net.URL; + + +public class FavoriteHolder extends RecyclerView.ViewHolder { + private Activity activity; + private TextView textViewFavoriteName; + private TextView textViewFavoriteAddress; + private ImageView imageViewFavoritePlace; + private ImageView imageViewFavoriteDrive; + private ImageView imageViewFavoriteWebPage; + private ImageView imageViewFavoritePhone; + private ImageView imageViewFavoriteShare; + private ImageView imageViewFavoriteDelete; + private View itemView; + private final static int UPDATE_INFORMATION = 3; + private FavoritePlaceLogic favoritePlaceLogic; + private Callbacks callbacks; + + + public FavoriteHolder(Activity activity, View itemView, Callbacks callbacks) { + super(itemView); + this.activity = activity; + this.itemView = itemView; + //finding the views + textViewFavoriteName = (TextView) itemView.findViewById(R.id.textViewFavoriteName); + textViewFavoriteAddress = (TextView) itemView.findViewById(R.id.textViewFavoriteAddress); + imageViewFavoritePlace = (ImageView) itemView.findViewById(R.id.imageViewFavoritePlace); + imageViewFavoriteDrive = (ImageView) itemView.findViewById(R.id.imageViewFravoriteDrive); + imageViewFavoriteWebPage = (ImageView) itemView.findViewById(R.id.imageViewFavoriteWebPage); + imageViewFavoritePhone = (ImageView) itemView.findViewById(R.id.imageViewFavoritePhone); + imageViewFavoriteShare = (ImageView) itemView.findViewById(R.id.imageViewFaviteShare); + imageViewFavoriteDelete = (ImageView) itemView.findViewById(R.id.imageViewFavoriteDelete); + + this.callbacks = callbacks; + } + + public void bindPlace(final FavoritePlace favoritePlace) { + + String placeName = favoritePlace.getPlaceName(); + String placeAddress = favoritePlace.getPlaceAddress(); + //setting name address and other information from the DB info + textViewFavoriteName.setText(placeName); + textViewFavoriteAddress.setText(placeAddress); + // Handles user press item in the recycler + itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //if device not a tablet open intent with result + if (!Helper.isTablet(activity)) { + Intent intent = new Intent(activity, MapAndInfoPhoneActivity.class); + Bundle bundle = new Bundle(); + bundle.putSerializable("place", favoritePlace); + intent.putExtras(bundle); + activity.startActivityForResult(intent, UPDATE_INFORMATION); + } + //if the device is tablet execute an async task that brings more info on the press place (the implements in MainActivity) + if (Helper.isTablet(activity)) { + + try { + URL url = new URL("https://maps.googleapis.com/maps/api/place/details/json?placeid=" + favoritePlace.getPlaceID() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + InfoOnPlaceAsyncTask infoOnPlaceAsyncTask = new InfoOnPlaceAsyncTask(((MainActivity) activity)); + infoOnPlaceAsyncTask.execute(url); + } catch (Exception e) { + Toast.makeText(activity, e.getMessage(), Toast.LENGTH_LONG).show(); + } + } + } + }); + //default action when there is no photo to show in the intent + imageViewFavoritePlace.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(activity, R.string.no_image, Toast.LENGTH_LONG).show(); + } + }); + //setting the default photo in case there is no photo of the place + imageViewFavoritePlace.setImageDrawable(activity.getResources().getDrawable(R.drawable.map)); + // if there is photo use picasso to set the image + if (favoritePlace.getPlacePhoto() != null) { + Picasso.with(activity) + .load("https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + favoritePlace.getPlacePhoto() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII") + .error(R.drawable.map)//setting that image if error happens + .placeholder(R.drawable.map)//show this pic before load + .transform(new CircleTransform())//make it round + .into(imageViewFavoritePlace); + //show the image of the place in normal size when you click on the image(intent) + showImageFavoritePlace(favoritePlace); + } + //Deleting item when user press trash + deleteOneFavoriteItem(favoritePlace); + //navigation to the favorite place + driveFavoritePlace(favoritePlace); + //if the favorite place have this data put visibility VISIBLE else it stays GONE + if (favoritePlace.getPlacePhone() != null) { + imageViewFavoritePhone.setVisibility(View.VISIBLE); + //calling the favorite place + callFavoritePlace(favoritePlace); + } + //if the favorite place have this data put visibility VISIBLE else it stays GONE + if (favoritePlace.getPlaceWebSite() != null) { + imageViewFavoriteWebPage.setVisibility(View.VISIBLE); + //open a web page with the website of the favorite place + webSiteFavoritePlace(favoritePlace); + } + //Share the name and address of the favorite place + imageViewFavoriteShare.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //using helper to trigger an intent + Helper.sharePlace(activity, favoritePlace); + } + }); + } + + //Callbacks in order to transfer data and refresh the adapter + public interface Callbacks { + void refreshAdapter(int position); + } + + //delete one item from favorite and notify the adapter that one item removed + public void deleteOneFavoriteItem(final FavoritePlace favoritePlace) { + imageViewFavoriteDelete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + favoritePlaceLogic = new FavoritePlaceLogic(activity); + favoritePlaceLogic.open(); + favoritePlaceLogic.deleteOneItemFavorite(favoritePlace.getSqlID()); + callbacks.refreshAdapter(getAdapterPosition()); + favoritePlaceLogic.close(); + } + }); + } + + //using intent to make a phone call if user press this + public void callFavoritePlace(final FavoritePlace favoritePlace) { + imageViewFavoritePhone.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //using helper to trigger an intent + Helper.sharePhoneNumber(activity, favoritePlace); + } + }); + } + + //using intent to open browser with the place website + public void webSiteFavoritePlace(final FavoritePlace favoritePlace) { + imageViewFavoriteWebPage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse("" + favoritePlace.getPlaceWebSite())); + activity.startActivity(browse); + } + }); + } + + //sharing the geo location of the place and can navigate + public void driveFavoritePlace(final FavoritePlace favoritePlace) { + imageViewFavoriteDrive.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(android.content.Intent.ACTION_VIEW, + Uri.parse("http://maps.google.com/maps?daddr=" + favoritePlace.getPlaceLatitude() + "," + favoritePlace.getPlaceLongitude())); + activity.startActivity(intent); + } + }); + } + + // show the image by using intent + public void showImageFavoritePlace(final FavoritePlace favoritePlace) { + imageViewFavoritePlace.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String url = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + favoritePlace.getPlacePhoto() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"; + Intent intent = new Intent(); + intent.setAction(android.content.Intent.ACTION_VIEW); + intent.addCategory(android.content.Intent.CATEGORY_DEFAULT); + intent.setDataAndType(Uri.parse(url), "image/*"); + activity.startActivity(intent); + } + }); + } + +} diff --git a/app/src/main/java/com/dt/project/FavoritePlace/FavoritePlace.java b/app/src/main/java/com/dt/project/FavoritePlace/FavoritePlace.java new file mode 100644 index 0000000..4d9e3cc --- /dev/null +++ b/app/src/main/java/com/dt/project/FavoritePlace/FavoritePlace.java @@ -0,0 +1,13 @@ +package com.dt.project.FavoritePlace; + +import com.dt.project.Place.Place; + +//favorite place +public class FavoritePlace extends Place { + + public FavoritePlace(long sqlID, String placeID, String placeName, String placeAddress, double placeLatitude, double placeLongitude, double placeDistance, String placeReference, String placeWebSite, String placeOpenHours, String placePhone, String placePhoto, float placeRating) { + super(sqlID, placeID, placeName, placeAddress, placeLatitude, placeLongitude, placeDistance, placeReference, placeWebSite, placeOpenHours, placePhone, placePhoto, placeRating); + + } + +} diff --git a/app/src/main/java/com/dt/project/FavoritePlace/FavoritePlaceAdapter.java b/app/src/main/java/com/dt/project/FavoritePlace/FavoritePlaceAdapter.java new file mode 100644 index 0000000..eb0bbb6 --- /dev/null +++ b/app/src/main/java/com/dt/project/FavoritePlace/FavoritePlaceAdapter.java @@ -0,0 +1,56 @@ +package com.dt.project.FavoritePlace; + +import android.app.Activity; +import android.content.Context; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; +import com.dt.project.R; +import java.util.ArrayList; + + +public class FavoritePlaceAdapter extends RecyclerView.Adapter implements FavoriteHolder.Callbacks { + private Activity activity; + private ArrayList places; + + + public FavoritePlaceAdapter(Activity activity, ArrayList places) { + this.activity = activity; + this.places = places; + } + + @Override + public FavoriteHolder onCreateViewHolder(ViewGroup parent, int viewType) { + LayoutInflater layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + View linearLayout = layoutInflater.inflate(R.layout.favorite_item, null); + + return new FavoriteHolder(activity, linearLayout, this); + } + + @Override + public void onBindViewHolder(FavoriteHolder holder, int position) { + FavoritePlace favoritePlace = places.get(position); + + holder.bindPlace(favoritePlace); + } + + @Override + public int getItemCount() { + return places.size(); + } + + //this function being called when the user try to delete one item from the list + @Override + public void refreshAdapter(int position) { + try { + places.remove(position); + notifyItemRemoved(position); + } catch (Exception ex) { + Toast.makeText(activity, ex.getMessage(), Toast.LENGTH_LONG).show(); + } + } + +} diff --git a/app/src/main/java/com/dt/project/Helper.java b/app/src/main/java/com/dt/project/Helper.java new file mode 100644 index 0000000..5b330a3 --- /dev/null +++ b/app/src/main/java/com/dt/project/Helper.java @@ -0,0 +1,232 @@ +package com.dt.project; + + +import android.Manifest; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Color; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.Uri; +import android.provider.Settings; +import android.support.design.widget.Snackbar; +import android.support.v4.app.ActivityCompat; +import android.util.Log; +import android.view.View; +import android.widget.Toast; + +import com.dt.project.DataBase.FavoritePlaceLogic; +import com.dt.project.DataBase.PlaceLogic; +import com.dt.project.FavoritePlace.FavoritePlace; +import com.dt.project.Place.Place; +import com.google.android.gms.maps.model.LatLng; + +import org.json.JSONArray; +import org.json.JSONObject; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +public class Helper { +//Calculating the air distance between user location and place location + public static double calculationByDistance(LatLng startPoint, LatLng endPoint) { + int Radius = 6371;// radius of earth in Km + double lat1 = startPoint.latitude; + double lat2 = endPoint.latitude; + double lon1 = startPoint.longitude; + double lon2 = endPoint.longitude; + double dLat = Math.toRadians(lat2 - lat1); + double dLon = Math.toRadians(lon2 - lon1); + double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(Math.toRadians(lat1)) + * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 2) + * Math.sin(dLon / 2); + double c = 2 * Math.asin(Math.sqrt(a)); + double valueResult = Radius * c; + double km = valueResult / 1; + DecimalFormat newFormat = new DecimalFormat("####"); + int kmInDec = Integer.valueOf(newFormat.format(km)); + double meter = valueResult % 1000; + int meterInDec = Integer.valueOf(newFormat.format(meter)); + Log.i("Radius Value", "" + valueResult + " KM " + kmInDec + + " Meter " + meterInDec); + return Radius * c; + } + +//taking the result string from the async task and retrieve all the data on the specific place + public static ArrayList placeInformation(String result, LatLng startPoint,Activity activity) { + ArrayList places = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.getJSONArray("results"); + + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject JO = jsonArray.getJSONObject(i); + String id = JO.getString("place_id"); + // URL icon = new URL(JO.getString("icon")); + String name = JO.getString("name"); + String vicinity = JO.getString("vicinity"); + String reference = JO.getString("reference"); + float rating; + try { + rating = (float) JO.getDouble("rating"); + } catch (Exception ex) { + rating = 0; + } + + double latitude = JO.getJSONObject("geometry").getJSONObject("location").getDouble("lat"); + double longitude = JO.getJSONObject("geometry").getJSONObject("location").getDouble("lng"); + + String photo; + try { + JSONArray jsonArrayPhoto = JO.getJSONArray("photos"); + JSONObject JoPhotos = jsonArrayPhoto.getJSONObject(0); + photo = JoPhotos.getString("photo_reference"); + } catch (Exception e) { + photo = null; + } + + LatLng endPoint = new LatLng(latitude, longitude); + double distance = calculationByDistance(startPoint, endPoint); + //calculating 3 digits in order to show km + double placeDistanceInKm = (int) (distance * 1000) / 1000.0; + // putting null because those items don't have value in this search + Place place = new Place(id, name, vicinity, latitude, longitude, placeDistanceInKm, reference, null, null, null, photo, rating); + places.add(place); + } + } catch (Exception ex) { + Toast.makeText(activity, ex.getMessage(), Toast.LENGTH_SHORT).show(); + } + return places; + } +// checking if there is network connection + public static boolean isNetworkAvailable(Activity activity) { + ConnectivityManager connectivityManager + = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); + return activeNetworkInfo != null && activeNetworkInfo.isConnected(); + } +// taking the result of the async task and retrieve the information (lists of predictions ) + public static ArrayList autoComplete(String result) { + ArrayList words = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.getJSONArray("predictions"); + + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject JO = jsonArray.getJSONObject(i); + String description = JO.getString("description"); + words.add(description); + } + } catch (Exception ex) { + + } + // remove duplication words in the list + Set removeDuplication = new HashSet<>(); + removeDuplication.addAll(words); + words.clear(); + //Adding the array list back with out duplication + words.addAll(removeDuplication); + return words; + } +// taking the result of the async task and retrieve the information of the place from a text search + public static void PlaceInformationByText(String result, PlaceLogic placeLogic, LatLng startPoint) { + //clear the data base from information + placeLogic.open(); + placeLogic.deleteAll(); + try { + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.getJSONArray("results"); + + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject JO = jsonArray.getJSONObject(i); + String id = JO.getString("place_id"); + // URL icon = new URL(JO.getString("icon")); + String name = JO.getString("name"); + String address = JO.getString("formatted_address"); + String reference = JO.getString("reference"); + float rating; + try { + rating = (float) JO.getDouble("rating"); + } catch (Exception ex) { + rating = 0; + } + + double latitude = JO.getJSONObject("geometry").getJSONObject("location").getDouble("lat"); + double longitude = JO.getJSONObject("geometry").getJSONObject("location").getDouble("lng"); + + String photo; + try { + JSONArray jsonArrayPhoto = JO.getJSONArray("photos"); + JSONObject JoPhotoes = jsonArrayPhoto.getJSONObject(0); + photo = JoPhotoes.getString("photo_reference"); + } catch (Exception e) { + photo = null; + } + + LatLng endPoint = new LatLng(latitude, longitude); + double distance = calculationByDistance(startPoint, endPoint); + //calculating 3 digits in order to show km + double placeDistanceInKm = (int) (distance * 1000) / 1000.0; + + Place place = new Place(id, name, address, latitude, longitude, placeDistanceInKm, reference, null, null, null, photo, rating); + placeLogic.addPlace(place); + } + } catch (Exception ex) { + + } + placeLogic.close(); + } +//sharing the place name and address + public static void sharePlace(Activity activity, Place place) { + Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, "Name: " + place.getPlaceName() + "\n" + "Address: " + place.getPlaceAddress()); + sendIntent.setType("text/plain"); + activity.startActivity(sendIntent); + } + +// checking if the device of the user is tablet + public static boolean isTablet(Activity activity) { + return ((activity.getResources().getConfiguration().screenLayout + & Configuration.SCREENLAYOUT_SIZE_MASK) + >= Configuration.SCREENLAYOUT_SIZE_LARGE); + //Check if landscape + + } +//make a call if there is a phone number + public static void sharePhoneNumber(Activity activity, Place place) { + Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + place.getPlacePhone())); + + if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { + return; + } + activity.startActivity(intent); + } +// adding a place to the favorite place DB + public static void addToFavoriteDB(Activity activity, Place place) { + FavoritePlaceLogic favoritePlaceLogic = new FavoritePlaceLogic(activity); + favoritePlaceLogic.open(); + FavoritePlace favoritePlace = new FavoritePlace(place.getSqlID(), place.getPlaceID(), place.getPlaceName(), place.getPlaceAddress(), place.getPlaceLatitude(), place.getPlaceLongitude(), place.getPlaceDistance(), place.getPlaceReference(), place.getPlaceWebSite(), place.getPlaceOpenHours(), place.getPlacePhone(), place.getPlacePhoto(), place.getPlaceRating()); + favoritePlaceLogic.addFavoritePlace(favoritePlace); + favoritePlaceLogic.close(); + } +// snack bar notification that let the user option to turn on wifi + public static void snackBarWifiSetting(final Activity activity){ + Snackbar.make(activity.findViewById(android.R.id.content), R.string.no_connection, Snackbar.LENGTH_LONG) + .setActionTextColor(Color.RED) + .setAction(R.string.try_wifi, new View.OnClickListener() { + @Override + public void onClick(View view) { + activity.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + } + }).show(); + } + +} + diff --git a/app/src/main/java/com/dt/project/MainActivity.java b/app/src/main/java/com/dt/project/MainActivity.java new file mode 100644 index 0000000..e67f1a7 --- /dev/null +++ b/app/src/main/java/com/dt/project/MainActivity.java @@ -0,0 +1,643 @@ +package com.dt.project; + +import android.Manifest; +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.ComponentName; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.location.LocationProvider; +import android.provider.Settings; +import android.support.design.widget.TabLayout; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.FragmentManager; +import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.SearchView; +import android.widget.Toast; + +import com.dt.project.AsyncTasks.AutoCompleteAsyncTask; +import com.dt.project.AsyncTasks.InfoOnPlaceAsyncTask; +import com.dt.project.AsyncTasks.SearchByTextAsyncTask; +import com.dt.project.AsyncTasks.SearchNearYouAsyncTask; +import com.dt.project.DataBase.FavoritePlaceLogic; +import com.dt.project.DataBase.PlaceLogic; +import com.dt.project.Place.Place; +import com.dt.project.Place.PlaceHolder; +import com.dt.project.Receiver.PhoneReceiver; +import com.dt.project.Tablet.MapFragment; +import com.dt.project.ViewPager.ViewPagerAdapter; +import com.dt.project.ViewPager.ZoomOutPageTransformer; +import com.google.android.gms.maps.model.LatLng; + +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Locale; + +import layout.FavoriteFragment; +import layout.ResultFragment; +import layout.SearchFragment; + +public class MainActivity extends ActionBarActivity implements SearchNearYouAsyncTask.Callbacks, LocationListener, SearchFragment.Callbacks, AutoCompleteAsyncTask.Callbacks, SearchByTextAsyncTask.Callbacks, InfoOnPlaceAsyncTask.Callbacks, PlaceHolder.Callbacks { + + //Data members + private ViewPager viewPagerHolder; + private LocationManager locationManager; + private ProgressDialog progressDialog; + private double latitude = 0; + private double longitude = 0; + private final static int FAVORITE_FRAGMENT = 0; + private final static int RESULT_FRAGMENT = 2; + private final static int SEARCH_FRAGMENT = 1; + private static final int UPDATE_PLACE = 5; + private static final int TWO_MINUTES = 1000 * 60 * 2; + private static final int MIN_AND_A_HALF = 90000; + private static final int TEN_METERS = 10; + private PlaceLogic placeLogic; + private ResultFragment resultFragment; + private FavoriteFragment favoriteFragment; + private SearchFragment searchFragment; + private SearchView searchView; + private ListView autoCompleteListView; + private ArrayList words; + private int FIRST_TIME_SEARCH = 0; + private static MapFragment mapFragment; + private ViewPagerAdapter viewPagerAdapter; + private Location currentBestLocation = null; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + //open DB + placeLogic = new PlaceLogic(this); + + if (savedInstanceState != null) { + FIRST_TIME_SEARCH = savedInstanceState.getInt("FIRST_TIME_SEARCH"); + //only happens if the device is tablet + + longitude = savedInstanceState.getDouble("longitude"); + latitude = savedInstanceState.getDouble("latitude"); + if (Helper.isTablet(this)) { + //opens the map with the user location + if (mapFragment == null) + mapFragment = new MapFragment(); + Bundle bundle = new Bundle(); + bundle.putDouble("latitude", latitude); + bundle.putDouble("longitude", longitude); + mapFragment.setArguments(bundle); + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.fragmentMap, mapFragment) + .commit(); + } + } + + //finding views + locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + viewPagerHolder = (ViewPager) findViewById(R.id.viewPagerHolder); + + TabLayout tabLayoutHeaders = (TabLayout) findViewById(R.id.tabLayoutHeaders); + searchView = (SearchView) findViewById(R.id.searchView); + autoCompleteListView = (ListView) findViewById(R.id.autoCompleteListView); + //Setting view holder in order to let the user navigate between fragments and tabs + FragmentManager fragmentManager = getSupportFragmentManager(); + viewPagerAdapter = new ViewPagerAdapter(fragmentManager, this); + + //finding the result fragment and favorite fragment (making them static) not loosing data while rotate + resultFragment = (ResultFragment) viewPagerAdapter.getItem(RESULT_FRAGMENT); + favoriteFragment = (FavoriteFragment) viewPagerAdapter.getItem(FAVORITE_FRAGMENT); + searchFragment = (SearchFragment) viewPagerAdapter.getItem(SEARCH_FRAGMENT); + + + viewPagerHolder.setAdapter(viewPagerAdapter); + tabLayoutHeaders.setupWithViewPager(viewPagerHolder); + + // Setting the default tab to start in ResultFragment = tab "result" + viewPagerHolder.setCurrentItem(RESULT_FRAGMENT); + //setting animation when the user move from page result to search to favorite etc, + viewPagerHolder.setPageTransformer(true, new ZoomOutPageTransformer()); + //open DB + placeLogic.open(); + //checks if gps enable and if no , notify user with dialog + checkIfGpsEnabled(); + // find Current Location of the user + getUserLocation(); + //Calling this function will put search view on click (that contain autocomplete and search) + SearchViewOnClick(); + + } + + // inflate the custom menu + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + protected void onDestroy() { + placeLogic.close(); + super.onDestroy(); + } + + // triggered when the user rotate the screen and save the values (latitude,longitude,FIRST_TIME_SEARCH) + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + } + + // handel the setting user have 3 options exit,change km to mile ,delete all favorite + @Override + public boolean onOptionsItemSelected(MenuItem item) { + SharedPreferences sharedPreferences = getSharedPreferences("preference", MODE_PRIVATE); + final SharedPreferences.Editor editor = sharedPreferences.edit(); + switch (item.getItemId()) { + //handel the user chose with alert dialog + case R.id.distancePreference: + android.app.AlertDialog dialog = new android.app.AlertDialog.Builder(this).create(); + dialog.setTitle(R.string.choose_unit); + dialog.setButton(Dialog.BUTTON_NEUTRAL, "Km", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + editor.putString("units", "km"); + editor.apply(); + } + }); + dialog.setButton(Dialog.BUTTON_POSITIVE, "Miles", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + editor.putString("units", "miles"); + editor.apply(); + } + }); + dialog.setCancelable(true); + dialog.show(); + break; + //delete all favorite + case R.id.deleteAll: + FavoritePlaceLogic favoritePlaceLogic = new FavoritePlaceLogic(this); + favoritePlaceLogic.open(); + favoritePlaceLogic.deleteAllFavorites(); + favoritePlaceLogic.close(); + favoriteFragment.refreshAdapter(); + break; + //exit the app + case R.id.exit: + finish(); + break; + } + return super.onOptionsItemSelected(item); + } + + @Override + protected void onPause() { + super.onPause(); + // placeLogic.close(); + //turn of the receiver (that check connection) + try { + ComponentName component = new ComponentName(this, PhoneReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP); + } catch (IllegalArgumentException e) { + Log.d("receiver", e.toString()); + } + // After we have the location of the user , remove the request for updating the user location + try { + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + return; + } + locationManager.removeUpdates(this); + } catch (Exception e) { + + } + } + + @Override + protected void onResume() { + super.onResume(); + //Start PhoneReceiver and Read phone state + ComponentName component = new ComponentName(this, PhoneReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + + //finding user location and update if need to + getUserLocation(); + } + + //before tha async task starts open progress dialog + @Override + public void onAboutToStart() { + progressDialog = new ProgressDialog(this); + progressDialog.setTitle("Searching"); + progressDialog.setMessage("Please wait..."); + progressDialog.show(); + + } + + //on success of the info on place async task (work on tablet) sent the result string to trigger an intent + // white the place information + @Override + public void onSuccessInfoOnPlace(String result) { + progressDialog.dismiss(); + mapFragment.markerOnClickInformation(result); + } + + //on success of search by text async task that use helper to retrieve the information from the result string + @Override + public void onSuccessSearchByTextAsyncTask(String result) { + progressDialog.dismiss(); + //opens the DB access + placeLogic.open(); + placeLogic.deleteAll(); + //in order to Calculate distance in km from the user location to the place we need the startPoint = user location + LatLng startPoint = new LatLng(latitude, longitude); + // Taking the AsyncTask result string and use his information in order to create a place and add it to the Data Base + Helper.PlaceInformationByText(result, placeLogic, startPoint); + //refresh the result fragment adapter + resultFragment.refreshAdapter(); + //moving the uset to the result tab + viewPagerHolder.setCurrentItem(RESULT_FRAGMENT); + } + + // on success words async task taking the result and put in auto complete then create array list of string + //if the user press it puts the word in the search view and execute a search + @Override + public void onSuccessWords(String result) { + //Create an Array list of strings with the Helper function + words = Helper.autoComplete(result); + //only if there are items make the list visible + if (words.size() > 0) { + autoCompleteListView.setVisibility(View.VISIBLE); + } else { + autoCompleteListView.setVisibility(View.GONE); + } + ArrayAdapter adapter = new ArrayAdapter<>(this, + android.R.layout.simple_list_item_1, words); + autoCompleteListView.setAdapter(adapter); + // if the user press on a prediction word it activate an async task and search the place by the pressed prediction + autoCompleteListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + try { + //getting the String of the list from the position that the user pressed and turn it into a UTF-8 encode string for internet search + String text = URLEncoder.encode(words.get(position), "UTF-8"); + SearchByTextAsyncTask searchByTextAsyncTask = new SearchByTextAsyncTask(MainActivity.this); + URL url = new URL("https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + text + "&location=" + latitude + "," + longitude + "&radius=50000&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + searchByTextAsyncTask.execute(url); + } catch (Exception ex) { + Toast.makeText(MainActivity.this, R.string.error, Toast.LENGTH_LONG).show(); + } + //Clear the text search and close the search view + searchView.setIconified(true); + searchView.clearFocus(); + searchView.onActionViewCollapsed(); + } + }); + } + + //on success async task of Search near you + public void onSuccess(String result) { + progressDialog.dismiss(); + ArrayList places = new ArrayList<>(); + //Calculating distance in km from the user location to the place + LatLng startPoint = new LatLng(latitude, longitude); + // Taking the AsyncTask result string and use his information in order to create a place and add it to the Data Base + places.addAll(Helper.placeInformation(result, startPoint, this)); + if (places.size() == 0) { + Toast.makeText(this, "Places not found , please try again", Toast.LENGTH_LONG).show(); + viewPagerHolder.setCurrentItem(SEARCH_FRAGMENT); + } + //Delete DB and insert the new results + try { + placeLogic.deleteAll(); + } catch (Exception e) { + placeLogic.open(); + } finally { + for (int i = 0; i < places.size(); i++) { + placeLogic.addPlace(places.get(i)); + } + } + //refresh the result adapter + resultFragment.takeFromDataBaseAndRefeshList(); + //setting the user in the result tab + viewPagerHolder.setCurrentItem(RESULT_FRAGMENT); + //In the first time opens the map in tablet + if (Helper.isTablet(this)) { + mapFragment = new MapFragment(); + Bundle bundle = new Bundle(); + bundle.putDouble("latitude", latitude); + bundle.putDouble("longitude", longitude); + mapFragment.setArguments(bundle); + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.fragmentMap, mapFragment) + .commit(); + } + } + + //Showing the error that happened in the asyncTask + @Override + public void onError(String errorMessage) { + if (progressDialog != null) { + progressDialog.dismiss(); + } + Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show(); + } + + + //getting the user location + //-------------------------------------------------------------------------------- + private void getUserLocation() { + // Activate getUserLocation function in order to bring the latitude and longitude of the user location. + String providerNetwork = null; + String providerGps = null; + // Create the desired provider: + try { + providerNetwork = LocationManager.NETWORK_PROVIDER; + } catch (Exception ex) { + Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show(); + } + try { + providerGps = LocationManager.GPS_PROVIDER; + } catch (Exception e) { + Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); + } + + // I had to add this code in order to get the latitude and longitude + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + return; + } + //use network + locationManager.requestLocationUpdates(providerNetwork, MIN_AND_A_HALF, TEN_METERS, this); + //use gps + locationManager.requestLocationUpdates(providerGps, TWO_MINUTES, TEN_METERS, this); + // in order to bring the best location + } + + //wakes in order to get the user location & can update his location if need to. + @Override + public void onLocationChanged(Location location) { + //using the best location we got from the user + if (isBetterLocation(location, currentBestLocation)) { + currentBestLocation = location; + latitude = location.getLatitude(); + longitude = location.getLongitude(); + } + //a flag that allow the search by location run only on time after the program started + if (FIRST_TIME_SEARCH == 0) { + searchNearYou(null); + FIRST_TIME_SEARCH = 1; + } + + } + + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { +// as we talked no need for toast here + } + + @Override + public void onProviderEnabled(String provider) { + // as we talked no need for toast here + + } + + @Override + public void onProviderDisabled(String provider) { + // as we talked no need for toast here + + } + //------------------------------------------------------------------------------------- + + //save those value when the screen rotate + @Override + public void onSaveInstanceState(Bundle outState) { + outState.putInt("FIRST_TIME_SEARCH", FIRST_TIME_SEARCH); + outState.putDouble("latitude", latitude); + outState.putDouble("longitude", longitude); + super.onSaveInstanceState(outState); + } + + //Handles the onClick of current location to get the list of places near you + public void currentLocation_onClick(View view) { + //Calling the function to activate async task only by location(not with types search) this why we send null (null=no types) + searchNearYou(null); + } + + // A function to call the async task of searching a place by location and types + public void searchNearYou(String searchType) { + + try { + //Searching in the device language + String language = Locale.getDefault().getLanguage(); + + URL url = new URL("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + latitude + "," + longitude + "&radius=5000&language=" + language + "&types=" + searchType + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + //Checking if there is an internet connection + if (Helper.isNetworkAvailable(this)) { + SearchNearYouAsyncTask searchNearYouAsyncTask = new SearchNearYouAsyncTask(this); + searchNearYouAsyncTask.execute(url); + } else { + //opens a snack bar that says no connection and give the user option to turn on wifi settings + Helper.snackBarWifiSetting(this); + } + + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + + } + + //Searching by Images and types (Callbacks of the user press) returns string and activate asyncTask search by the user chose. + @Override + public void popularSearchType(String searchType) { + //Calling the search near you function that starts async task , and get the string to search by it . + searchNearYou(searchType); + } + + //Handle all the search view situations autocomplete and text search query + public void SearchViewOnClick() { + searchView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewPagerHolder.setCurrentItem(SEARCH_FRAGMENT); + } + }); + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String query) { + try { + //getting the String and turn it into a UTF-8 encode string for internet search + String text = URLEncoder.encode(query, "UTF-8"); + URL url = new URL("https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + text + "&location=" + latitude + "," + longitude + "&radius=50000&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + //Checking if there is an internet connection + if (Helper.isNetworkAvailable(MainActivity.this)) { + SearchByTextAsyncTask searchByTextAsyncTask = new SearchByTextAsyncTask(MainActivity.this); + searchByTextAsyncTask.execute(url); + } else { + Toast.makeText(MainActivity.this, R.string.no_connection, Toast.LENGTH_LONG).show(); + } + + } catch (Exception ex) { + Toast.makeText(MainActivity.this, R.string.error, Toast.LENGTH_LONG).show(); + } + //Clear the text search and close the search view + searchView.setIconified(true); + searchView.clearFocus(); + searchView.onActionViewCollapsed(); + return false; + } + + @Override + public boolean onQueryTextChange(String newText) { + try { + URL url = new URL("https://maps.googleapis.com/maps/api/place/autocomplete/json?input=" + newText.replace(" ", "+") + "&location=32.044,34.926&radius=10000&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + if (Helper.isNetworkAvailable(MainActivity.this)) { + AutoCompleteAsyncTask autoCompleteAsyncTask = new AutoCompleteAsyncTask(MainActivity.this); + autoCompleteAsyncTask.execute(url); + } else { + Toast.makeText(MainActivity.this, R.string.no_connection, Toast.LENGTH_LONG).show(); + } + } catch (MalformedURLException e) { + Toast.makeText(MainActivity.this, R.string.error, Toast.LENGTH_LONG).show(); + } + return false; + } + }); + } + + //setting the new place that the user chose and add all markers from 0 in order to mark the place in red + @Override + public void showPressedLocation(Place place) { + mapFragment.showNewPlace(place); + } + + //checking if there is gps on if no i use dialog to offer the use to unable the GPS + public void checkIfGpsEnabled() { + LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + boolean gps_enabled = false; + boolean network_enabled = false; + try { + gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); + } catch (Exception ex) { + } + + try { + network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + } catch (Exception ex) { + } + + if (!gps_enabled && !network_enabled) { + // notify user with dialog + AlertDialog.Builder dialog = new AlertDialog.Builder(this); + dialog.setMessage(getResources().getString(R.string.Gps_network_not_enabled)); + dialog.setPositiveButton(getResources().getString(R.string.Open_location_settings), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface paramDialogInterface, int paramInt) { + Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + startActivity(myIntent); + //get gps + } + }); + dialog.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface paramDialogInterface, int paramInt) { + + } + }); + dialog.show(); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (resultCode != RESULT_OK) { + return; + } + if (requestCode == UPDATE_PLACE) { + //UPDATE the place add website and phone if have + favoriteFragment.refreshAdapter(); + } + } + + //checking the best location of the user + protected boolean isBetterLocation(Location location, Location currentBestLocation) { + if (currentBestLocation == null) { + // A new location is always better than no location + return true; + } + + // Check whether the new location fix is newer or older + long timeDelta = location.getTime() - currentBestLocation.getTime(); + boolean isSignificantlyNewer = timeDelta > TWO_MINUTES; + boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES; + boolean isNewer = timeDelta > 0; + + // If it's been more than two minutes since the current location, use the new location + // because the user has likely moved + if (isSignificantlyNewer) { + return true; + // If the new location is more than two minutes older, it must be worse + } else if (isSignificantlyOlder) { + return false; + } + + // Check whether the new location fix is more or less accurate + int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy()); + boolean isLessAccurate = accuracyDelta > 0; + boolean isMoreAccurate = accuracyDelta < 0; + boolean isSignificantlyLessAccurate = accuracyDelta > 200; + + // Check if the old and new location are from the same provider + boolean isFromSameProvider = isSameProvider(location.getProvider(), + currentBestLocation.getProvider()); + + // Determine location quality using a combination of timeliness and accuracy + if (isMoreAccurate) { + return true; + } else if (isNewer && !isLessAccurate) { + return true; + } else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) { + return true; + } + return false; + } + + /** + * Checks whether two providers are the same + */ + private boolean isSameProvider(String provider1, String provider2) { + if (provider1 == null) { + return provider2 == null; + } + return provider1.equals(provider2); + } + + +} + diff --git a/app/src/main/java/com/dt/project/Phone/InfoPlaceActivity.java b/app/src/main/java/com/dt/project/Phone/InfoPlaceActivity.java new file mode 100644 index 0000000..046a04c --- /dev/null +++ b/app/src/main/java/com/dt/project/Phone/InfoPlaceActivity.java @@ -0,0 +1,264 @@ +package com.dt.project.Phone; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.ComponentName; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.widget.CardView; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.dt.project.AsyncTasks.DownloadImageAsyncTask; +import com.dt.project.AsyncTasks.InfoOnPlaceAsyncTask; +import com.dt.project.DataBase.FavoritePlaceLogic; +import com.dt.project.DataBase.PlaceLogic; +import com.dt.project.FavoritePlace.FavoritePlace; +import com.dt.project.Helper; +import com.dt.project.Place.Place; +import com.dt.project.R; +import com.dt.project.Receiver.PhoneReceiver; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.net.URL; +import java.util.ArrayList; + +public class InfoPlaceActivity extends Activity implements InfoOnPlaceAsyncTask.Callbacks, DownloadImageAsyncTask.Callbacks { + private ProgressDialog progressDialog; + private PlaceLogic placeLogic; + private ImageView imageViewHeader; + private TextView placeName; + private TextView placeAddress; + private TextView placePhone; + private TextView placeOpenHours; + private TextView placeWeb; + private TextView placeRating; + private Place place; + private CardView cardViewAddress; + private CardView cardViewWeb; + private CardView cardViewPhone; + private CardView cardViewOpenHours; + private CardView cardViewRating; + private CardView cardViewExit; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_info); + //finding the views + placeName = (TextView) findViewById(R.id.textViewName); + placeAddress = (TextView) findViewById(R.id.textViewAddress); + placePhone = (TextView) findViewById(R.id.textViewPhone); + placeOpenHours = (TextView) findViewById(R.id.textViewOpenHours); + placeWeb = (TextView) findViewById(R.id.textViewWebSite); + placeRating = (TextView) findViewById(R.id.textViewRating); + imageViewHeader = (ImageView) findViewById(R.id.imageViewPhoto); + cardViewWeb = (CardView) findViewById(R.id.cardViewWeb); + cardViewAddress = (CardView) findViewById(R.id.cardViewAddress); + cardViewPhone = (CardView) findViewById(R.id.cardViewPhone); + cardViewOpenHours = (CardView) findViewById(R.id.cardViewOpenHours); + cardViewRating = (CardView) findViewById(R.id.cardViewRating); + cardViewExit = (CardView) findViewById(R.id.cardViewExit); + //open DB + placeLogic = new PlaceLogic(this); + placeLogic.open(); + //getting the place + Intent intent = getIntent(); + Bundle bundle = intent.getExtras(); + place = (Place) bundle.getSerializable("place"); + //setting the place name if not null + assert place != null; + placeName.setText(place.getPlaceName()); + //retrieving more info on the current place + try { + URL url = new URL("https://maps.googleapis.com/maps/api/place/details/json?placeid=" + place.getPlaceID() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + InfoOnPlaceAsyncTask infoOnPlaceAsyncTask = new InfoOnPlaceAsyncTask(this); + infoOnPlaceAsyncTask.execute(url); + } catch (Exception e) { + Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); + } + //setting the place image + try { + String url = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + place.getPlacePhoto() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"; + DownloadImageAsyncTask infoOnPlaceAsyncTask = new DownloadImageAsyncTask(this); + infoOnPlaceAsyncTask.execute(url); + } catch (Exception e) { + Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); + } + } + + //before starting the async tasks + @Override + public void onAboutToStart() { + progressDialog = new ProgressDialog(this); + progressDialog.setTitle("Download"); + progressDialog.setMessage("Please wait..."); + progressDialog.show(); + } + + //after finish that async task take the result info and put in the user (checking and taking information that found ) + @Override + public void onSuccessInfoOnPlace(String result) { + progressDialog.dismiss(); + String openHours = null; + String phone_number = null; + String webSite = null; + JSONObject jsonObject = null; + +// checking what values we got + try { + jsonObject = new JSONObject(result).getJSONObject("result"); + } catch (JSONException e) { + e.printStackTrace(); + } + if (jsonObject != null) { + try { + phone_number = jsonObject.getString("formatted_phone_number"); + } catch (JSONException e) { + e.printStackTrace(); + } + try { + webSite = jsonObject.getString("website"); + } catch (JSONException e) { + e.printStackTrace(); + } + JSONArray jsonArray = null; + try { + jsonArray = jsonObject.getJSONObject("opening_hours").getJSONArray("weekday_text"); + } catch (JSONException e) { + e.printStackTrace(); + } + if (jsonArray != null) + for (int i = 0; i < jsonArray.length(); i++) { + if (i == 0) { + try { + openHours = jsonArray.getString(i) + "\n"; + } catch (JSONException e) { + e.printStackTrace(); + } + } + try { + openHours += jsonArray.getString(i) + "\n"; + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + //checking if there are values that not null if it not null set visibility VISIBLE else GONE + if (place.getPlaceAddress() != null) { + cardViewAddress.setVisibility(View.VISIBLE); + placeAddress.setText(place.getPlaceAddress()); + } + //checking if there are values that not null if it not null set visibility VISIBLE else GONE + if (phone_number != null) { + place.setPlacePhone(phone_number); + cardViewPhone.setVisibility(View.VISIBLE); + placePhone.setText(place.getPlacePhone()); + } + //checking if there are values that not null if it not null set visibility VISIBLE else GONE + if (openHours != null) { + place.setPlaceOpenHours(openHours); + cardViewOpenHours.setVisibility(View.VISIBLE); + placeOpenHours.setText(place.getPlaceOpenHours()); + } + //checking if there are values that not null if it not null set visibility VISIBLE else GONE + if (webSite != null) { + place.setPlaceWebSite(webSite); + cardViewWeb.setVisibility(View.VISIBLE); + } + //checking if there are values that not null if it not null set visibility VISIBLE else GONE + if (place.getPlaceRating() != 0) { + cardViewRating.setVisibility(View.VISIBLE); + placeRating.setText(String.format("%s", place.getPlaceRating())); + } + + //Setting the website intent in order to let the user open the internet page + placeWeb.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse("" + place.getPlaceWebSite())); + startActivity(browse); + } + }); + //if user press the phone number that trigger an intent to make a phone call + placePhone.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //activate the intent + Helper.sharePhoneNumber(InfoPlaceActivity.this, place); + } + }); + //exit the current screen and go back to map + cardViewExit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + //Updating place information in the DB website,open hours, phone etc, + placeLogic.updatePlace(place); +// checking if we have this place in favorite place and update that place + FavoritePlaceLogic favoritePlaceLogic = new FavoritePlaceLogic(this); + favoritePlaceLogic.open(); + ArrayList favoritePlaces = favoritePlaceLogic.getAllPlaces(); + for (int i = 0; i < favoritePlaces.size(); i++) { + // checking if they have the same id if do set result ok to trigger favorite place to refresh adapter + if (favoritePlaces.get(i).getPlaceID().equals(place.getPlaceID())) { + FavoritePlace favoritePlace = new FavoritePlace(favoritePlaces.get(i).getSqlID(), place.getPlaceID(), place.getPlaceName(), place.getPlaceAddress(), place.getPlaceLatitude(), place.getPlaceLongitude(), place.getPlaceDistance(), place.getPlaceReference(), place.getPlaceWebSite(), place.getPlaceOpenHours(), place.getPlacePhone(), place.getPlacePhoto(), place.getPlaceRating()); + favoritePlaceLogic.updateFavoritePlace(favoritePlace); + setResult(RESULT_OK); + } + } + favoritePlaceLogic.close(); + } + + @Override + public void onError(String errorMessage) { + progressDialog.dismiss(); + } + + //if there is image setting it . + @Override + public void onSuccess(Bitmap result) { + imageViewHeader.setVisibility(View.VISIBLE); + imageViewHeader.setImageBitmap(result); + } + + @Override + protected void onPause() { + super.onPause(); + //turn of the receiver (that check connection) + try { + ComponentName component = new ComponentName(this, PhoneReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP); + } catch (IllegalArgumentException e) { + Log.d("receiver", e.toString()); + } + } + + @Override + protected void onResume() { + super.onResume(); + //Start PhoneReceiver and Read phone state + ComponentName component = new ComponentName(this, PhoneReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + + } +} + diff --git a/app/src/main/java/com/dt/project/Phone/MapAndInfoPhoneActivity.java b/app/src/main/java/com/dt/project/Phone/MapAndInfoPhoneActivity.java new file mode 100644 index 0000000..65aa671 --- /dev/null +++ b/app/src/main/java/com/dt/project/Phone/MapAndInfoPhoneActivity.java @@ -0,0 +1,125 @@ +package com.dt.project.Phone; + +import android.content.ComponentName; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.MenuItem; +import android.view.View; +import android.widget.Toast; + +import com.dt.project.Tablet.MapFragment; +import com.dt.project.Place.Place; +import com.dt.project.R; +import com.dt.project.Receiver.PhoneReceiver; + +public class MapAndInfoPhoneActivity extends AppCompatActivity { + private static final int UPDATE_PLACE = 4; + private Place place; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_map_and_info); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + //getting the place information + Intent intent = getIntent(); + Bundle bundle = intent.getExtras(); + place = (Place) bundle.getSerializable("place"); +//setting the map by the user chose + MapFragment mapFragment = new MapFragment(); + Bundle bundleMap = new Bundle(); + bundleMap.putSerializable("place", place); + mapFragment.setArguments(bundleMap); + + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.fragmentMap, mapFragment) + .commit(); + //Sending the place information the the info activity to show more info on the place + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(MapAndInfoPhoneActivity.this, InfoPlaceActivity.class); + Bundle bundle = new Bundle(); + bundle.putSerializable("place", place); + intent.putExtras(bundle); + startActivityForResult(intent, UPDATE_PLACE); + } + }); + + //Adding a back button + try { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } catch (Exception e) { + Toast.makeText(this, R.string.error, Toast.LENGTH_LONG).show(); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + //closing the activity + finish(); + break; + } + return super.onOptionsItemSelected(item); + } + + //checking if the place being update if it does if set result ok (in order to let the main activity handle this) + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (resultCode != RESULT_OK) { + return; + } + if (requestCode == UPDATE_PLACE) { + setResult(RESULT_OK); + } + } + + @Override + public void onBackPressed() { + finish(); + } + @Override + protected void onPause() { + super.onPause(); + //turn of the receiver (that check connection) + try { + ComponentName component = new ComponentName(this, PhoneReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP); + } catch (IllegalArgumentException e) { + Log.d("receiver", e.toString()); + } + } + + @Override + protected void onResume() { + super.onResume(); + //Start PhoneReceiver and Read phone state + ComponentName component = new ComponentName(this, PhoneReceiver.class); + getPackageManager() + .setComponentEnabledSetting(component, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + + } + public void setPlace(Place place) { + this.place = place; + } +} + + + diff --git a/app/src/main/java/com/dt/project/Place/Place.java b/app/src/main/java/com/dt/project/Place/Place.java new file mode 100644 index 0000000..8511d2d --- /dev/null +++ b/app/src/main/java/com/dt/project/Place/Place.java @@ -0,0 +1,154 @@ +package com.dt.project.Place; + + +import java.io.Serializable; +import java.lang.Override; +import java.lang.String; + +//Place data members +public class Place implements Serializable { + private long sqlID; + private String placeName; + private String placeAddress; + private String placeID; + private String PlaceReference; + private String placePhoto; + private String placeOpenHours; + private String placeWebSite; + private String placePhone; + private double placeDistance; + private double placeLatitude; + private double placeLongitude; + private float placeRating; + + public Place(long sqlID, String placeID, String placeName, String placeAddress, double placeLatitude, double placeLongitude, double placeDistance, String placeReference, String placeWebSite, String placeOpenHours, String placePhone, String placePhoto, float placeRating) { + this(placeID, placeName, placeAddress, placeLatitude, placeLongitude, placeDistance, placeReference, placeWebSite, placeOpenHours, placePhone, placePhoto, placeRating); + setSqlID(sqlID); + + } + + public Place(String placeID, String placeName, String placeAddress, double placeLatitude, double placeLongitude, double placeDistance, String placeReference, String placeWebSite, String placeOpenHours, String placePhone, String placePhoto, float placeRating) { + setPlaceName(placeName); + setPlaceAddress(placeAddress); + setPlaceDistance(placeDistance); + setPlaceID(placeID); + setPlaceReference(placeReference); + setPlacePhoto(placePhoto); + setPlaceRating(placeRating); + setPlaceLatitude(placeLatitude); + setPlaceLongitude(placeLongitude); + setPlaceWebSite(placeWebSite); + setPlaceOpenHours(placeOpenHours); + setPlacePhone(placePhone); + } + + public String getPlaceOpenHours() { + return placeOpenHours; + } + + public void setPlaceOpenHours(String placeOpenHours) { + this.placeOpenHours = placeOpenHours; + } + + public String getPlacePhone() { + return placePhone; + } + + public void setPlacePhone(String placePhone) { + this.placePhone = placePhone; + } + + public String getPlaceWebSite() { + return placeWebSite; + } + + public void setPlaceWebSite(String placeWebSite) { + this.placeWebSite = placeWebSite; + } + + public double getPlaceLatitude() { + return placeLatitude; + } + + public void setPlaceLatitude(double placeLatitude) { + this.placeLatitude = placeLatitude; + } + + public double getPlaceLongitude() { + return placeLongitude; + } + + public void setPlaceLongitude(double placeLongitude) { + this.placeLongitude = placeLongitude; + } + + public long getSqlID() { + return sqlID; + } + + public void setSqlID(long sqlID) { + this.sqlID = sqlID; + } + + public String getPlaceID() { + return placeID; + } + + public void setPlaceID(String placeID) { + this.placeID = placeID; + } + + public String getPlaceName() { + return placeName; + } + + public void setPlaceName(String placeName) { + this.placeName = placeName; + } + + public String getPlaceAddress() { + return placeAddress; + } + + public void setPlaceAddress(String placeAddress) { + this.placeAddress = placeAddress; + } + + public double getPlaceDistance() { + return placeDistance; + } + + public void setPlaceDistance(double placeDistance) { + this.placeDistance = placeDistance; + } + + public String getPlaceReference() { + return PlaceReference; + } + + public void setPlaceReference(String placeReference) { + PlaceReference = placeReference; + } + + public String getPlacePhoto() { + return placePhoto; + } + + public void setPlacePhoto(String placePhoto) { + this.placePhoto = placePhoto; + } + + public float getPlaceRating() { + return placeRating; + } + + public void setPlaceRating(float placeRating) { + this.placeRating = placeRating; + } + + @Override + public String toString() { + return "Name: " + placeName + " Address: " + placeAddress + " Distance " + placeDistance; + } + +} diff --git a/app/src/main/java/com/dt/project/Place/PlaceAdapter.java b/app/src/main/java/com/dt/project/Place/PlaceAdapter.java new file mode 100644 index 0000000..c14733a --- /dev/null +++ b/app/src/main/java/com/dt/project/Place/PlaceAdapter.java @@ -0,0 +1,48 @@ +package com.dt.project.Place; + + +import android.app.Activity; +import android.content.Context; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.dt.project.Place.Place; +import com.dt.project.Place.PlaceHolder; +import com.dt.project.R; + +import java.util.ArrayList; + + +public class PlaceAdapter extends RecyclerView.Adapter { + private Activity activity; + private ArrayList places; + + public PlaceAdapter(Activity activity, ArrayList places) { + this.activity = activity; + this.places = places; + } + + @Override + public PlaceHolder onCreateViewHolder(ViewGroup parent, int viewType) { + + LayoutInflater layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + View linearLayout = layoutInflater.inflate(R.layout.place_item, null); + + return new PlaceHolder(activity, linearLayout); + } + + @Override + public void onBindViewHolder(PlaceHolder holder, int position) { + Place place = places.get(position); + holder.bindPlace(place); + } + + @Override + public int getItemCount() { + return places.size(); + } + +} diff --git a/app/src/main/java/com/dt/project/Place/PlaceHolder.java b/app/src/main/java/com/dt/project/Place/PlaceHolder.java new file mode 100644 index 0000000..2f27505 --- /dev/null +++ b/app/src/main/java/com/dt/project/Place/PlaceHolder.java @@ -0,0 +1,162 @@ +package com.dt.project.Place; + + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.widget.RecyclerView; +import android.view.MenuItem; +import android.view.View; +import android.widget.ImageView; +import android.widget.PopupMenu; +import android.widget.TextView; +import android.widget.Toast; +import com.dt.project.AsyncTasks.InfoOnPlaceAsyncTask; +import com.dt.project.CircleTransformPicasso.CircleTransform; +import com.dt.project.Helper; +import com.dt.project.MainActivity; +import com.dt.project.Phone.MapAndInfoPhoneActivity; +import com.dt.project.R; +import com.squareup.picasso.Picasso; + +import java.net.URL; + +public class PlaceHolder extends RecyclerView.ViewHolder { + private static final int UPDATE_PLACE = 5; + private Activity activity; + private TextView textViewPlaceName; + private TextView textViewPlaceAddress; + private TextView textViewPlaceDistance; + private View itemView; + private ImageView imageViewPlace; + + public PlaceHolder(Activity activity, View itemView) { + super(itemView); + this.activity = activity; + this.itemView = itemView; + //finding the views + textViewPlaceName = (TextView) itemView.findViewById(R.id.placeName); + textViewPlaceAddress = (TextView) itemView.findViewById(R.id.placeAddress); + textViewPlaceDistance = (TextView) itemView.findViewById(R.id.placeDistance); + imageViewPlace = (ImageView) itemView.findViewById(R.id.imageViewPlace); + } + + public void bindPlace(final Place place) { + //actions that had to do in order to use picasso in the right way and preventing images mixed between items + //default action when there is no photo to show in the intent + imageViewPlace.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(activity,R.string.no_image,Toast.LENGTH_LONG).show(); + } + }); + //setting the default photo in case there is no photo of the place + imageViewPlace.setImageDrawable(activity.getResources().getDrawable(R.drawable.map)); + // if there is photo use picasso to set the image + if(place.getPlacePhoto()!=null) { + Picasso.with(activity) + .load("https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + place.getPlacePhoto() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII") + .error(R.drawable.map) + .placeholder(R.drawable.map)// show this pic before load + .transform(new CircleTransform())//make it round + .into(imageViewPlace); + //show the image of the place in normal size when you click on the image + showImageFavoritePlace(place); + } +// Handles user press item in the recycler + itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //if device not a tablet open intent with result + if (!Helper.isTablet(activity)) { + Intent intent = new Intent(activity, MapAndInfoPhoneActivity.class); + Bundle bundle = new Bundle(); + bundle.putSerializable("place", place); + intent.putExtras(bundle); + activity.startActivityForResult(intent, UPDATE_PLACE); + } + //if the device is tablet execute an async task that brings more info on the press place (the implements in MainActivity) + if (Helper.isTablet(activity)) { + Callbacks callbacks = (Callbacks) (activity); + //using call backs to mark the press location on the map + callbacks.showPressedLocation(place); + try { + URL url = new URL("https://maps.googleapis.com/maps/api/place/details/json?placeid=" + place.getPlaceID() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + InfoOnPlaceAsyncTask infoOnPlaceAsyncTask = new InfoOnPlaceAsyncTask(((MainActivity) activity)); + infoOnPlaceAsyncTask.execute(url); + } catch (Exception e) { + Toast.makeText(activity, e.getMessage(), Toast.LENGTH_LONG).show(); + } + } + } + }); + //in case of long press there are 2 options share the place name and address or add to favorite (using Popup) + itemView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + PopupMenu popupMenu = new PopupMenu(activity, v); + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + switch (item.getItemId()) { + case R.id.shareItem: + //Sharing the name and address of the chosen place + Helper.sharePlace(activity, place); + break; + case R.id.addToFavorite: + //Saving the place into the favorites + Helper.addToFavoriteDB(activity, place); + break; + } + return false; + } + }); + popupMenu.inflate(R.menu.long_click_menu); + popupMenu.show(); + return true; + } + }); + + String placeName = place.getPlaceName(); + String placeAddress = place.getPlaceAddress(); + + String placeDistance; + //checking the user chose (Show Km or Show Miles ) + //and calculating the distance + SharedPreferences sharedPreferences = activity.getSharedPreferences("preference", Context.MODE_PRIVATE); + String units = sharedPreferences.getString("units", "km"); + double oneMileFromKM = 0.621371192; + double distance = place.getPlaceDistance(); + if (units.equals("miles")) + placeDistance = "" + Math.floor((distance * oneMileFromKM) * 100) / 100 + " miles"; + else + placeDistance = ((int) (distance)) == 0 ? ("" + ((int) (distance * 1000)) + " meter") : ("" + (distance) + " km"); + +//setting the name ,address and distance after calculating + textViewPlaceName.setText(placeName); + textViewPlaceAddress.setText(placeAddress); + textViewPlaceDistance.setText(placeDistance); + + } +//using call backs to transfer data and mark the chosen place (if its tablet) + public interface Callbacks { + void showPressedLocation(Place place); + } +// show the image of the place in intent (only if the user press this) else he will see it in circle + public void showImageFavoritePlace(final Place place){ + imageViewPlace.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String url = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" + place.getPlacePhoto() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"; + Intent intent = new Intent(); + intent.setAction(android.content.Intent.ACTION_VIEW); + intent.addCategory(android.content.Intent.CATEGORY_DEFAULT); + intent.setDataAndType(Uri.parse(url), "image/*"); + activity.startActivity(intent); + } + }); + } +} diff --git a/app/src/main/java/com/dt/project/Receiver/PhoneReceiver.java b/app/src/main/java/com/dt/project/Receiver/PhoneReceiver.java new file mode 100644 index 0000000..1c40a80 --- /dev/null +++ b/app/src/main/java/com/dt/project/Receiver/PhoneReceiver.java @@ -0,0 +1,27 @@ +package com.dt.project.Receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.widget.Toast; +//checking if the phone or tablet is connected to power +public class PhoneReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + + if (intent.getAction() != null) { + + String state = intent.getAction(); + + if (state.equals(Intent.ACTION_POWER_CONNECTED)) { + + Toast.makeText(context,"Connected", Toast.LENGTH_LONG).show(); + } else if (state.equals(Intent.ACTION_POWER_DISCONNECTED)) { + Toast.makeText(context,"Disconnected", Toast.LENGTH_LONG).show(); + + } + } + + } + } + diff --git a/app/src/main/java/com/dt/project/Tablet/MapFragment.java b/app/src/main/java/com/dt/project/Tablet/MapFragment.java new file mode 100644 index 0000000..fa02d8f --- /dev/null +++ b/app/src/main/java/com/dt/project/Tablet/MapFragment.java @@ -0,0 +1,173 @@ +package com.dt.project.Tablet; + + +import android.Manifest; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import com.dt.project.AsyncTasks.InfoOnPlaceAsyncTask; +import com.dt.project.DataBase.PlaceLogic; +import com.dt.project.Helper; +import com.dt.project.MainActivity; +import com.dt.project.Phone.MapAndInfoPhoneActivity; +import com.dt.project.Place.Place; +import com.dt.project.R; +import com.google.android.gms.maps.CameraUpdate; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.OnMapReadyCallback; +import com.google.android.gms.maps.SupportMapFragment; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; + +public class MapFragment extends Fragment implements OnMapReadyCallback, GoogleMap.OnMarkerClickListener { + + private GoogleMap googleMap; + private PlaceLogic placeLogic; + private ArrayList places = new ArrayList<>(); + private Place place; + private LatLng currentItem; + private HashMap markersId = new HashMap<>(); + private double latitude; + private double longitude; + + public MapFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_map, container, false); + Bundle bundle = getArguments(); + //if the device not a tablet + if (!Helper.isTablet(getActivity())) + place = (Place) bundle.getSerializable("place"); + //if the device a tablet + if (Helper.isTablet(getActivity())) { + latitude = bundle.getDouble("latitude"); + longitude = bundle.getDouble("longitude"); + } + + // Object for updating our UI: + SupportMapFragment supportMapFragment = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.fragmentMap)); + // Send the object for updating the UI: + supportMapFragment.getMapAsync(this); + placeLogic = new PlaceLogic(getActivity()); + + return view; + } + + @Override + public void onMapReady(GoogleMap googleMap) { + this.googleMap = googleMap; + //Calling add markers function + addMarkers(); + } + + // open the data base and take all the places in order to add there location to the map as markers + public void addMarkers() { + if (googleMap == null) { + return; + } +//open DB and clear array list + placeLogic.open(); + places.clear(); + places.addAll(placeLogic.getAllPlaces()); + //Adding 1 by 1 and if the location the user pressed is true the mark of his location will be marked as red + for (int i = 0; i < places.size(); i++) { + Place placeToMark = places.get(i); + LatLng location = new LatLng(placeToMark.getPlaceLatitude(), placeToMark.getPlaceLongitude()); + MarkerOptions markerOptions = new MarkerOptions() + .position(location) + .snippet(placeToMark.getPlaceAddress()) + .title(placeToMark.getPlaceName()); + Marker marker; + //checking the place id to find match to the user press + if (place != null && places.get(i).getPlaceID().equals(place.getPlaceID())) { + //taking the item location (user chose) and mark him red + currentItem = location; + markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)) + .alpha(1f); + marker = googleMap.addMarker(markerOptions); + //open the window of the place + marker.showInfoWindow(); + } else { + markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)) + .alpha(0.6f); + marker = googleMap.addMarker(markerOptions); + } +//if no place pressed (happens in tablet) use the user location + if (place == null) { + currentItem = new LatLng(latitude, longitude); + } + //setting onclick to all of the markers + googleMap.setOnMarkerClickListener(this); + //putting the place id in each marker + markersId.put(marker.getId(), placeToMark.getPlaceID()); + } + CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentItem, 12); + //a must have check + if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + return; + } + googleMap.setMyLocationEnabled(true); + try { + googleMap.animateCamera(cameraUpdate); + } catch (Exception e) { + + } + + } +// when user press on the markers + @Override + public boolean onMarkerClick(Marker marker) { + String id = markersId.get(marker.getId()); + //checking the place id and the marker id that we entered before in order to find a match + for (int i = 0; i < places.size(); i++) { + if (places.get(i).getPlaceID().equals(id)) + place = places.get(i); + //trigger a function that update the user chosen marker and bring info on the new place + if (getActivity() instanceof MapAndInfoPhoneActivity) + ((MapAndInfoPhoneActivity) getActivity()).setPlace(place); + } + // if the devise is tablet use async task to get plae information such as phone web ,etc (implement on main activity) + if (Helper.isTablet(getActivity())) { + try { + URL url = new URL("https://maps.googleapis.com/maps/api/place/details/json?placeid=" + place.getPlaceID() + "&key=AIzaSyBSg3o7puUY7kYHvIOg-VxKWX6c1cjjSII"); + InfoOnPlaceAsyncTask infoOnPlaceAsyncTask = new InfoOnPlaceAsyncTask(((MainActivity) getActivity())); + infoOnPlaceAsyncTask.execute(url); + } catch (Exception e) { + Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); + } + } + return false; + } + + //Happens only when the AsyncTask success the take the result and take the info and checks what info of the place we got and if we don't have its visibility stays Gone + public void markerOnClickInformation(String result) { + TabletPlaceInfo tabletPlaceInfo = new TabletPlaceInfo(getActivity(), result, place); + tabletPlaceInfo.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; + tabletPlaceInfo.show(); + } +//setting the new place that the user chose and add all markers from 0 in order to mark the place in red + public void showNewPlace(Place place) { + this.place = place; + googleMap.clear(); + addMarkers(); + } +} diff --git a/app/src/main/java/com/dt/project/Tablet/TabletPlaceInfo.java b/app/src/main/java/com/dt/project/Tablet/TabletPlaceInfo.java new file mode 100644 index 0000000..8cb6429 --- /dev/null +++ b/app/src/main/java/com/dt/project/Tablet/TabletPlaceInfo.java @@ -0,0 +1,162 @@ +package com.dt.project.Tablet; + +import android.app.Activity; +import android.app.Dialog; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.dt.project.Helper; +import com.dt.project.Place.Place; +import com.dt.project.R; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +//only in tablet +public class TabletPlaceInfo extends Dialog { + private LinearLayout linearLayoutPhone; + private LinearLayout linearLayoutFavorite; + private LinearLayout linearLayoutOpenHours; + private LinearLayout linearLayoutShare; + private LinearLayout linearLayoutWeb; + private Place place; + private String result; + private Activity activity; + private Button buttonCancel; + private TextView textViewInformationName; + + //taking the place and result string of the info async task + public TabletPlaceInfo(Activity activity, String result, Place place) { + super(activity); + this.activity = activity; + this.result = result; + this.place = place; + + } + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_tablet_place_info); +//finding the views + linearLayoutPhone = (LinearLayout) findViewById(R.id.linearLayoutPhone); + linearLayoutFavorite = (LinearLayout) findViewById(R.id.linearLayoutFavorite); + linearLayoutOpenHours = (LinearLayout) findViewById(R.id.linearLayoutOpenHours); + linearLayoutShare = (LinearLayout) findViewById(R.id.linearLayoutShare); + linearLayoutWeb = (LinearLayout) findViewById(R.id.linearLayoutWeb); + buttonCancel = (Button) findViewById(R.id.buttonCancel); + textViewInformationName = (TextView) findViewById(R.id.textViewInformationName); + TextView textViewDialogAddFavorite = (TextView) findViewById(R.id.textViewDialogAddFavorite); + TextView textViewDialogOpenHours = (TextView) findViewById(R.id.textViewDialogOpenHours); + TextView textViewDialogPhone = (TextView) findViewById(R.id.textViewDialogPhone); +//using the result string to find more information of the place and show it to the user + String openHours = null; + String phone_number = null; + String webSite = null; + JSONObject jsonObject = null; + + + try { + jsonObject = new JSONObject(result).getJSONObject("result"); + } catch (JSONException e) { + e.printStackTrace(); + } + if (jsonObject != null) { + try { + phone_number = jsonObject.getString("formatted_phone_number"); + } catch (JSONException e) { + e.printStackTrace(); + } + try { + webSite = jsonObject.getString("website"); + } catch (JSONException e) { + e.printStackTrace(); + } + JSONArray jsonArray = null; + try { + jsonArray = jsonObject.getJSONObject("opening_hours").getJSONArray("weekday_text"); + } catch (JSONException e) { + e.printStackTrace(); + } + if (jsonArray != null) + for (int i = 0; i < jsonArray.length(); i++) { + if (i == 0) { + try { + openHours = jsonArray.getString(i) + "\n"; + } catch (JSONException e) { + e.printStackTrace(); + } + } + try { + openHours += jsonArray.getString(i) + "\n"; + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + textViewInformationName.setText(place.getPlaceName()); + //checking those values if it's null visibility stays GONE else its VISIBLE + if (phone_number != null) { + place.setPlacePhone(phone_number); + linearLayoutPhone.setVisibility(View.VISIBLE); + textViewDialogPhone.setText(place.getPlacePhone()); + } + //checking those values if it's null visibility stays GONE else its VISIBLE + if (openHours != null) { + place.setPlaceOpenHours(openHours); + linearLayoutOpenHours.setVisibility(View.VISIBLE); + textViewDialogOpenHours.setText(place.getPlaceOpenHours()); + } + //checking those values if it's null visibility stays GONE else its VISIBLE + if (webSite != null) { + place.setPlaceWebSite(webSite); + linearLayoutWeb.setVisibility(View.VISIBLE); + } + //checking those values if it's null visibility stays GONE else its VISIBLE + if (place.getPlaceRating() != 0) { + linearLayoutFavorite.setVisibility(View.VISIBLE); + textViewDialogAddFavorite.setText(String.format("%s", place.getPlaceRating())); + } + //Setting the website intent in order to let the user open the internet page + linearLayoutWeb.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse("" + place.getPlaceWebSite())); + activity.startActivity(browse); + } + }); + + //Share the name and address of the place + linearLayoutShare.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Helper.sharePlace(activity, place); + } + }); + + //Share the number of the place + linearLayoutPhone.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Helper.sharePhoneNumber(activity, place); + } + }); + //closing the dialog + buttonCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + } + }); + + } +} + + diff --git a/app/src/main/java/com/dt/project/ViewPager/ViewPagerAdapter.java b/app/src/main/java/com/dt/project/ViewPager/ViewPagerAdapter.java new file mode 100644 index 0000000..c0fb1b7 --- /dev/null +++ b/app/src/main/java/com/dt/project/ViewPager/ViewPagerAdapter.java @@ -0,0 +1,70 @@ +package com.dt.project.ViewPager; + + +import android.app.Activity; +import android.os.Parcel; +import android.os.Parcelable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; + +import layout.FavoriteFragment; +import layout.ResultFragment; +import layout.SearchFragment; + + +public class ViewPagerAdapter extends FragmentStatePagerAdapter { + private final static int FAVORITE_FRAGMENT = 0; + private final static int SEARCH_FRAGMENT = 1; + private final static int RESULT_FRAGMENT = 2; + private Activity activity; + private FavoriteFragment favoriteFragment = new FavoriteFragment(); + private ResultFragment resultFragment = new ResultFragment(); + private SearchFragment searchFragment = new SearchFragment(); + + public ViewPagerAdapter(FragmentManager fm, Activity activity) { + super(fm); + this.activity = activity; + } + + @Override + public Fragment getItem(int position) { + //setting the fragments order + switch (position) { + case FAVORITE_FRAGMENT: + return favoriteFragment; + case SEARCH_FRAGMENT: + return searchFragment; + case RESULT_FRAGMENT: + return resultFragment; + } + return null; + } + + + @Override + public int getCount() { + + return 3; + } + + @Override + public CharSequence getPageTitle(int position) { + //Matching the name of the tabs to the fragment + switch (position) { + case FAVORITE_FRAGMENT: + return "Favorite"; + case SEARCH_FRAGMENT: + return "Search"; + case RESULT_FRAGMENT: + return "Result"; + } + return ""; + } + + @Override + public Parcelable saveState() { + //Don't save new state after rotation + return null; + } +} diff --git a/app/src/main/java/com/dt/project/ViewPager/ZoomOutPageTransformer.java b/app/src/main/java/com/dt/project/ViewPager/ZoomOutPageTransformer.java new file mode 100644 index 0000000..5efb99c --- /dev/null +++ b/app/src/main/java/com/dt/project/ViewPager/ZoomOutPageTransformer.java @@ -0,0 +1,43 @@ +package com.dt.project.ViewPager; + +import android.support.v4.view.ViewPager; +import android.view.View; +//setting the animation of the view pager +public class ZoomOutPageTransformer implements ViewPager.PageTransformer { + private static final float MIN_SCALE = 0.85f; + private static final float MIN_ALPHA = 0.5f; + + public void transformPage(View view, float position) { + int pageWidth = view.getWidth(); + int pageHeight = view.getHeight(); + + if (position < -1) { // [-Infinity,-1) + // This page is way off-screen to the left. + view.setAlpha(0); + + } else if (position <= 1) { // [-1,1] + // Modify the default slide transition to shrink the page as well + float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); + float verticalMargin = pageHeight * (1 - scaleFactor) / 2; + float horizontalMargin = pageWidth * (1 - scaleFactor) / 2; + if (position < 0) { + view.setTranslationX(horizontalMargin - verticalMargin / 2); + } else { + view.setTranslationX(-horizontalMargin + verticalMargin / 2); + } + + // Scale the page down (between MIN_SCALE and 1) + view.setScaleX(scaleFactor); + view.setScaleY(scaleFactor); + + // Fade the page relative to its size. + view.setAlpha(MIN_ALPHA + + (scaleFactor - MIN_SCALE) / + (1 - MIN_SCALE) * (1 - MIN_ALPHA)); + + } else { // (1,+Infinity] + // This page is way off-screen to the right. + view.setAlpha(0); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/layout/FavoriteFragment.java b/app/src/main/java/layout/FavoriteFragment.java new file mode 100644 index 0000000..9caed95 --- /dev/null +++ b/app/src/main/java/layout/FavoriteFragment.java @@ -0,0 +1,57 @@ +package layout; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import com.dt.project.DataBase.FavoritePlaceLogic; +import com.dt.project.FavoritePlace.FavoritePlace; +import com.dt.project.FavoritePlace.FavoritePlaceAdapter; +import com.dt.project.R; +import java.util.ArrayList; + +/** + * A simple {@link Fragment} subclass. + */ +public class FavoriteFragment extends Fragment{ + + private FavoritePlaceLogic favoritePlaceLogic; + private FavoritePlaceAdapter adapter; + private ArrayList favoritePlaces; + + public FavoriteFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View linearLayoutRoot = inflater.inflate(R.layout.fragment_favorite, container, false); + + RecyclerView recyclerViewFavoritePlaces = (RecyclerView) linearLayoutRoot.findViewById(R.id.recyclerViewFavoritePlaces); + recyclerViewFavoritePlaces.setLayoutManager(new LinearLayoutManager(getActivity())); + + favoritePlaceLogic = new FavoritePlaceLogic(getActivity()); + favoritePlaceLogic.open(); +//bring all favorite places from DB + favoritePlaces = favoritePlaceLogic.getAllPlaces(); + adapter = new FavoritePlaceAdapter(getActivity(), favoritePlaces); + recyclerViewFavoritePlaces.setAdapter(adapter); + + return linearLayoutRoot; + } +//refresh the adapter + public void refreshAdapter() { + favoritePlaceLogic.open(); + //getting all the places from the data base + favoritePlaces.clear(); + favoritePlaces.addAll(favoritePlaceLogic.getAllPlaces()); + adapter.notifyDataSetChanged(); + } +} diff --git a/app/src/main/java/layout/ResultFragment.java b/app/src/main/java/layout/ResultFragment.java new file mode 100644 index 0000000..ec900a1 --- /dev/null +++ b/app/src/main/java/layout/ResultFragment.java @@ -0,0 +1,115 @@ +package layout; + + +import android.os.Bundle; + +import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import com.dt.project.DataBase.PlaceLogic; +import com.dt.project.Helper; +import com.dt.project.Place.Place; +import com.dt.project.Place.PlaceAdapter; +import com.dt.project.R; +import java.util.ArrayList; + +public class ResultFragment extends Fragment{ + + private int SEARCH_ON_START = 0; + private PlaceLogic placeLogic; + private PlaceAdapter adapter; + private RecyclerView recyclerViewPlaces; + private ArrayList places = new ArrayList<>(); + + public ResultFragment() { + // Required empty public constructor + + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + // Inflate the layout for this fragment + View linearLayoutRoot = inflater.inflate(R.layout.fragment_result, container, false); + //finding the recycler view components + recyclerViewPlaces = (RecyclerView) linearLayoutRoot.findViewById(R.id.recyclerViewPlaces); + + recyclerViewPlaces.setLayoutManager(new LinearLayoutManager(getActivity())); + //Access to the data base + placeLogic = new PlaceLogic(getActivity()); + placeLogic.open(); + //getting all the places from the data base + places = placeLogic.getAllPlaces(); + + adapter = new PlaceAdapter(getActivity(), places); + + recyclerViewPlaces.setAdapter(adapter); + + return linearLayoutRoot; + } +//refresh adapter if place logic null open new one + public void refreshAdapter() { + if (placeLogic!=null) + placeLogic.open(); + else { + placeLogic = new PlaceLogic(getActivity()); + placeLogic.open(); + } + //getting all the places from the data base + places.clear(); + places.addAll(placeLogic.getAllPlaces()); + adapter.notifyDataSetChanged(); + } + public void takeFromDataBaseAndRefeshList() { + //Get all places from DB to places arrayList + try { + ArrayList placesFromDB = placeLogic.getAllPlaces(); + places.clear(); + places.addAll(placesFromDB); + + } catch (Exception e) { + PlaceLogic placeLogic = new PlaceLogic(getActivity()); + placeLogic.open(); + ArrayList placesFromDB = placeLogic.getAllPlaces(); + placesFromDB.clear(); + places.addAll(placesFromDB); + } + //Refresh adapter + if (adapter != null) + adapter.notifyDataSetChanged(); + } + + @Override + public void onResume() { + super.onResume(); + // placeLogic.open(); + } + + @Override + public void onPause() { + super.onPause(); + // placeLogic.close(); + } + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + //Refresh adapter + adapter.notifyDataSetChanged(); + + if (SEARCH_ON_START == 0 && Helper.isNetworkAvailable(getActivity()) == false) { + //If it's first search and the is connection get all places from DB + takeFromDataBaseAndRefeshList(); + } + SEARCH_ON_START = 1; + } + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + //Save SEARCH_ON_START on rotation + outState.putInt("searchOnStart", SEARCH_ON_START); + } +} diff --git a/app/src/main/java/layout/SearchFragment.java b/app/src/main/java/layout/SearchFragment.java new file mode 100644 index 0000000..7d7a62a --- /dev/null +++ b/app/src/main/java/layout/SearchFragment.java @@ -0,0 +1,61 @@ +package layout; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.Toast; + +import com.dt.project.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class SearchFragment extends Fragment implements View.OnClickListener { + + + public SearchFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + LinearLayout linearLayoutRoot = (LinearLayout) inflater.inflate(R.layout.fragment_search, container, false); + + LinearLayout linearLayoutItems = (LinearLayout) linearLayoutRoot.findViewById(R.id.linearLayoutItems); + + // finding the layout that hold the tag of the search types + for (int i = 0; i < linearLayoutItems.getChildCount(); i++) { + LinearLayout linearLayout = (LinearLayout) linearLayoutItems.getChildAt(i); + for (int j = 0; j < linearLayout.getChildCount(); j++) { + linearLayout.getChildAt(j).setOnClickListener(this); + } + } + + + return linearLayoutRoot; + } +//passing to main activity the user pressed by callback + @Override + public void onClick(View v) { + try { + //getting the tag of the layout then we know what item the user pressed + String searchType = ((LinearLayout) v).getTag().toString(); + Callbacks callbacks = (Callbacks) getActivity(); + callbacks.popularSearchType(searchType); + } catch (Exception e) { + Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + + public interface Callbacks { + void popularSearchType(String searchType); + + } +} diff --git a/app/src/main/res/chrome.png b/app/src/main/res/chrome.png new file mode 100644 index 0000000..bee4c59 Binary files /dev/null and b/app/src/main/res/chrome.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_account_balance_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_account_balance_black_48dp.png new file mode 100644 index 0000000..2dcbf0a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_account_balance_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_alarm_on_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_alarm_on_black_48dp.png new file mode 100644 index 0000000..d7a329f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_alarm_on_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..1f0559f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_delete_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_delete_black_48dp.png new file mode 100644 index 0000000..6d7cb81 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_delete_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_drive_eta_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_drive_eta_black_48dp.png new file mode 100644 index 0000000..dd8b9da Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_drive_eta_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_favorite_border_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_favorite_border_black_48dp.png new file mode 100644 index 0000000..3d3036e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_favorite_border_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_fitness_center_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_fitness_center_black_48dp.png new file mode 100644 index 0000000..1bc103f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_fitness_center_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_grade_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_grade_black_48dp.png new file mode 100644 index 0000000..54d3065 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_grade_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..2e86cc2 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_info_outline_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_info_outline_black_48dp.png new file mode 100644 index 0000000..3847a9f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_info_outline_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_language_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_language_black_48dp.png new file mode 100644 index 0000000..68608c7 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_language_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_airport_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_airport_black_48dp.png new file mode 100644 index 0000000..dcc2a5a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_airport_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_atm_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_atm_black_48dp.png new file mode 100644 index 0000000..ffb6761 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_atm_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_bar_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_bar_black_48dp.png new file mode 100644 index 0000000..d789750 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_bar_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_cafe_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_cafe_black_48dp.png new file mode 100644 index 0000000..ce2aade Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_cafe_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_gas_station_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_gas_station_black_48dp.png new file mode 100644 index 0000000..1c7b0dd Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_gas_station_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_hospital_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_hospital_black_48dp.png new file mode 100644 index 0000000..003934f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_hospital_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..deda51b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_phone_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_phone_black_48dp.png new file mode 100644 index 0000000..7c9d1b0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_phone_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_restaurant_menu_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_restaurant_menu_black_48dp.png new file mode 100644 index 0000000..5316cb7 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_restaurant_menu_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..784933a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_shopping_cart_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_shopping_cart_black_48dp.png new file mode 100644 index 0000000..f9121f5 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_shopping_cart_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_spa_black_48dp.png b/app/src/main/res/drawable-hdpi/ic_spa_black_48dp.png new file mode 100644 index 0000000..945c694 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_spa_black_48dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_star_rate_black_18dp.png b/app/src/main/res/drawable-hdpi/ic_star_rate_black_18dp.png new file mode 100644 index 0000000..cd18bed Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_star_rate_black_18dp.png differ diff --git a/app/src/main/res/drawable-hdpi/map.png b/app/src/main/res/drawable-hdpi/map.png new file mode 100644 index 0000000..70057a3 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/map.png differ diff --git a/app/src/main/res/drawable-ldrtl-hdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-ldrtl-hdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..f60959b Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-hdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-mdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-ldrtl-mdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..fc367fa Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-mdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xhdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-ldrtl-xhdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..fe9e899 Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xhdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxhdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxhdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..d81812d Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxhdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-hdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-hdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..784933a Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-hdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-mdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-mdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..81c80b7 Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-mdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xhdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xhdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..5a8544c Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xhdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xxhdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xxhdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..97f607b Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xxhdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xxxhdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xxxhdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..2ab8108 Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxxhdpi/drawable-xxxhdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-ldrtl-xxxhdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-ldrtl-xxxhdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..8836f84 Binary files /dev/null and b/app/src/main/res/drawable-ldrtl-xxxhdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_account_balance_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_account_balance_black_48dp.png new file mode 100644 index 0000000..3372ace Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_account_balance_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_alarm_on_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_alarm_on_black_48dp.png new file mode 100644 index 0000000..4aea803 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_alarm_on_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..6073eec Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_delete_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_delete_black_48dp.png new file mode 100644 index 0000000..796ccd2 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_delete_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_drive_eta_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_drive_eta_black_48dp.png new file mode 100644 index 0000000..7b4d0df Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_drive_eta_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_favorite_border_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_favorite_border_black_48dp.png new file mode 100644 index 0000000..6c157b7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_favorite_border_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_fitness_center_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_fitness_center_black_48dp.png new file mode 100644 index 0000000..a14eec3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_fitness_center_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_grade_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_grade_black_48dp.png new file mode 100644 index 0000000..f649a5d Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_grade_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..dcdcfc0 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_info_outline_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_info_outline_black_48dp.png new file mode 100644 index 0000000..b706f0d Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_info_outline_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_language_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_language_black_48dp.png new file mode 100644 index 0000000..5ed4a92 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_language_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_airport_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_airport_black_48dp.png new file mode 100644 index 0000000..8d5097b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_airport_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_atm_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_atm_black_48dp.png new file mode 100644 index 0000000..44017d8 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_atm_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_bar_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_bar_black_48dp.png new file mode 100644 index 0000000..0bd5819 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_bar_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_cafe_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_cafe_black_48dp.png new file mode 100644 index 0000000..53e3862 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_cafe_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_gas_station_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_gas_station_black_48dp.png new file mode 100644 index 0000000..45b2d1a Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_gas_station_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_hospital_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_hospital_black_48dp.png new file mode 100644 index 0000000..abdd083 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_hospital_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..e401f1f Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_phone_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_phone_black_48dp.png new file mode 100644 index 0000000..99f28bb Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_phone_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_restaurant_menu_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_restaurant_menu_black_48dp.png new file mode 100644 index 0000000..f5c20a7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_restaurant_menu_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..81c80b7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_shopping_cart_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_shopping_cart_black_48dp.png new file mode 100644 index 0000000..3da6027 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_shopping_cart_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_spa_black_48dp.png b/app/src/main/res/drawable-mdpi/ic_spa_black_48dp.png new file mode 100644 index 0000000..b992454 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_spa_black_48dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_star_rate_black_18dp.png b/app/src/main/res/drawable-mdpi/ic_star_rate_black_18dp.png new file mode 100644 index 0000000..d6496ab Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_star_rate_black_18dp.png differ diff --git a/app/src/main/res/drawable-mdpi/map.png b/app/src/main/res/drawable-mdpi/map.png new file mode 100644 index 0000000..3e453c4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/map.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_account_balance_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_account_balance_black_48dp.png new file mode 100644 index 0000000..b89db1e Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_account_balance_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_alarm_on_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_alarm_on_black_48dp.png new file mode 100644 index 0000000..3de8d45 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_alarm_on_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..7726760 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_black_48dp.png new file mode 100644 index 0000000..f2b75c3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_drive_eta_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_drive_eta_black_48dp.png new file mode 100644 index 0000000..8ef7b99 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_drive_eta_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_favorite_border_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_favorite_border_black_48dp.png new file mode 100644 index 0000000..96e0b9e Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_favorite_border_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_fitness_center_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_fitness_center_black_48dp.png new file mode 100644 index 0000000..c5300f3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_fitness_center_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_grade_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_grade_black_48dp.png new file mode 100644 index 0000000..edc662a Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_grade_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..04e2b26 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_info_outline_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_info_outline_black_48dp.png new file mode 100644 index 0000000..c1e2a03 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_info_outline_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_language_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_language_black_48dp.png new file mode 100644 index 0000000..48997ba Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_language_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_airport_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_airport_black_48dp.png new file mode 100644 index 0000000..0a55d7d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_airport_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_atm_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_atm_black_48dp.png new file mode 100644 index 0000000..fa0cb43 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_atm_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_bar_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_bar_black_48dp.png new file mode 100644 index 0000000..923940a Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_bar_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_cafe_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_cafe_black_48dp.png new file mode 100644 index 0000000..f748dc3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_cafe_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_gas_station_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_gas_station_black_48dp.png new file mode 100644 index 0000000..50a6ebf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_gas_station_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_hospital_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_hospital_black_48dp.png new file mode 100644 index 0000000..fbe3374 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_hospital_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..15abba2 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_phone_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_phone_black_48dp.png new file mode 100644 index 0000000..61b0e70 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_phone_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_restaurant_menu_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_restaurant_menu_black_48dp.png new file mode 100644 index 0000000..7bcb121 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_restaurant_menu_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..5a8544c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_shopping_cart_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_shopping_cart_black_48dp.png new file mode 100644 index 0000000..6edc956 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_shopping_cart_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_spa_black_48dp.png b/app/src/main/res/drawable-xhdpi/ic_spa_black_48dp.png new file mode 100644 index 0000000..3c1b874 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_spa_black_48dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_star_rate_black_18dp.png b/app/src/main/res/drawable-xhdpi/ic_star_rate_black_18dp.png new file mode 100644 index 0000000..33a02af Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_star_rate_black_18dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/map.png b/app/src/main/res/drawable-xhdpi/map.png new file mode 100644 index 0000000..2323ab9 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/map.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_account_balance_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_account_balance_black_48dp.png new file mode 100644 index 0000000..6a8b8f2 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_account_balance_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_alarm_on_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_alarm_on_black_48dp.png new file mode 100644 index 0000000..b4e05b6 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_alarm_on_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..8f6b56e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_black_48dp.png new file mode 100644 index 0000000..2b7e77f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_drive_eta_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_drive_eta_black_48dp.png new file mode 100644 index 0000000..2a4085f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_drive_eta_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_favorite_border_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_favorite_border_black_48dp.png new file mode 100644 index 0000000..a042d30 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_favorite_border_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_fitness_center_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_fitness_center_black_48dp.png new file mode 100644 index 0000000..9c6bdaa Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_fitness_center_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_grade_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_grade_black_48dp.png new file mode 100644 index 0000000..6daf7cc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_grade_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..d66401c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_info_outline_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_info_outline_black_48dp.png new file mode 100644 index 0000000..f41f401 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_info_outline_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_language_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_language_black_48dp.png new file mode 100644 index 0000000..586f3ea Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_language_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_airport_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_airport_black_48dp.png new file mode 100644 index 0000000..5dfdebc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_airport_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_atm_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_atm_black_48dp.png new file mode 100644 index 0000000..948ae3b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_atm_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_bar_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_bar_black_48dp.png new file mode 100644 index 0000000..e4dc51c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_bar_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_cafe_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_cafe_black_48dp.png new file mode 100644 index 0000000..9a2616c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_cafe_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_gas_station_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_gas_station_black_48dp.png new file mode 100644 index 0000000..17209dc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_gas_station_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_hospital_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_hospital_black_48dp.png new file mode 100644 index 0000000..9d3f9cd Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_hospital_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..e46eb94 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_phone_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_phone_black_48dp.png new file mode 100644 index 0000000..5fee5f0 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_phone_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_restaurant_menu_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_restaurant_menu_black_48dp.png new file mode 100644 index 0000000..beb4de1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_restaurant_menu_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..97f607b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_shopping_cart_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_shopping_cart_black_48dp.png new file mode 100644 index 0000000..a58a87e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_shopping_cart_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_spa_black_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_spa_black_48dp.png new file mode 100644 index 0000000..0a50b43 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_spa_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_star_rate_black_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_star_rate_black_18dp.png new file mode 100644 index 0000000..658b08d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_star_rate_black_18dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/map.png b/app/src/main/res/drawable-xxhdpi/map.png new file mode 100644 index 0000000..bbc2f30 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/map.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-hdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/drawable-hdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..2e86cc2 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-hdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-hdpi/nophoto.jpg b/app/src/main/res/drawable-xxxhdpi/drawable-hdpi/nophoto.jpg new file mode 100644 index 0000000..ba6ee20 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-hdpi/nophoto.jpg differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-mdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/drawable-mdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..dcdcfc0 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-mdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-mdpi/nophoto.jpg b/app/src/main/res/drawable-xxxhdpi/drawable-mdpi/nophoto.jpg new file mode 100644 index 0000000..b66b908 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-mdpi/nophoto.jpg differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-xhdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/drawable-xhdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..04e2b26 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-xhdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-xhdpi/nophoto.jpg b/app/src/main/res/drawable-xxxhdpi/drawable-xhdpi/nophoto.jpg new file mode 100644 index 0000000..d0ea4de Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-xhdpi/nophoto.jpg differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-xxhdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/drawable-xxhdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..d66401c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-xxhdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-xxhdpi/nophoto.jpg b/app/src/main/res/drawable-xxxhdpi/drawable-xxhdpi/nophoto.jpg new file mode 100644 index 0000000..63aa1bf Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-xxhdpi/nophoto.jpg differ diff --git a/app/src/main/res/drawable-xxxhdpi/drawable-xxxhdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/drawable-xxxhdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..8fac2c3 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/drawable-xxxhdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_account_balance_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_account_balance_black_48dp.png new file mode 100644 index 0000000..02d63e3 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_account_balance_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_alarm_on_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_alarm_on_black_48dp.png new file mode 100644 index 0000000..48247dc Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_alarm_on_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_black_48dp.png new file mode 100644 index 0000000..8ead592 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_black_48dp.png new file mode 100644 index 0000000..c259012 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_delete_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_drive_eta_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_drive_eta_black_48dp.png new file mode 100644 index 0000000..22d769e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_drive_eta_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_favorite_border_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_favorite_border_black_48dp.png new file mode 100644 index 0000000..c7825a2 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_favorite_border_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_fitness_center_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_fitness_center_black_48dp.png new file mode 100644 index 0000000..e016964 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_fitness_center_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_grade_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_grade_black_48dp.png new file mode 100644 index 0000000..9bb93d2 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_grade_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_home_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_home_black_48dp.png new file mode 100644 index 0000000..8fac2c3 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_home_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_info_outline_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_info_outline_black_48dp.png new file mode 100644 index 0000000..e7751f9 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_info_outline_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_language_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_language_black_48dp.png new file mode 100644 index 0000000..823938f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_language_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_airport_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_airport_black_48dp.png new file mode 100644 index 0000000..6797d67 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_airport_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_atm_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_atm_black_48dp.png new file mode 100644 index 0000000..aef4d85 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_atm_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_bar_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_bar_black_48dp.png new file mode 100644 index 0000000..66c0651 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_bar_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_cafe_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_cafe_black_48dp.png new file mode 100644 index 0000000..6ea5ce7 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_cafe_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_gas_station_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_gas_station_black_48dp.png new file mode 100644 index 0000000..c671a08 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_gas_station_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_hospital_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_hospital_black_48dp.png new file mode 100644 index 0000000..95ce54c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_hospital_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..15cd45e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_phone_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_phone_black_48dp.png new file mode 100644 index 0000000..8487d0c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_phone_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_restaurant_menu_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_restaurant_menu_black_48dp.png new file mode 100644 index 0000000..2bdffcf Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_restaurant_menu_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_share_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_share_black_48dp.png new file mode 100644 index 0000000..2ab8108 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_share_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_shopping_cart_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_shopping_cart_black_48dp.png new file mode 100644 index 0000000..4a4d9cf Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_shopping_cart_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_spa_black_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_spa_black_48dp.png new file mode 100644 index 0000000..e945402 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_spa_black_48dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_star_rate_black_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_star_rate_black_18dp.png new file mode 100644 index 0000000..1823bbb Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_star_rate_black_18dp.png differ diff --git a/app/src/main/res/drawable/drawable-hdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable/drawable-hdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..deda51b Binary files /dev/null and b/app/src/main/res/drawable/drawable-hdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable/drawable-mdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable/drawable-mdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..e401f1f Binary files /dev/null and b/app/src/main/res/drawable/drawable-mdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable/drawable-xhdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable/drawable-xhdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..15abba2 Binary files /dev/null and b/app/src/main/res/drawable/drawable-xhdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable/drawable-xxhdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable/drawable-xxhdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..e46eb94 Binary files /dev/null and b/app/src/main/res/drawable/drawable-xxhdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable/drawable-xxxhdpi/ic_local_movies_black_48dp.png b/app/src/main/res/drawable/drawable-xxxhdpi/ic_local_movies_black_48dp.png new file mode 100644 index 0000000..15cd45e Binary files /dev/null and b/app/src/main/res/drawable/drawable-xxxhdpi/ic_local_movies_black_48dp.png differ diff --git a/app/src/main/res/drawable/hyperlink_underline.xml b/app/src/main/res/drawable/hyperlink_underline.xml new file mode 100644 index 0000000..3c5f793 --- /dev/null +++ b/app/src/main/res/drawable/hyperlink_underline.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/map.png b/app/src/main/res/drawable/map.png new file mode 100644 index 0000000..6c02fa1 Binary files /dev/null and b/app/src/main/res/drawable/map.png differ diff --git a/app/src/main/res/layout-sw600dp-land/activity_main.xml b/app/src/main/res/layout-sw600dp-land/activity_main.xml new file mode 100644 index 0000000..72fbd61 --- /dev/null +++ b/app/src/main/res/layout-sw600dp-land/activity_main.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-sw600dp/activity_main.xml b/app/src/main/res/layout-sw600dp/activity_main.xml new file mode 100644 index 0000000..7fd7056 --- /dev/null +++ b/app/src/main/res/layout-sw600dp/activity_main.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_info.xml b/app/src/main/res/layout/activity_info.xml new file mode 100644 index 0000000..2f05922 --- /dev/null +++ b/app/src/main/res/layout/activity_info.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..8d724aa --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_map_and_info.xml b/app/src/main/res/layout/activity_map_and_info.xml new file mode 100644 index 0000000..0ef087c --- /dev/null +++ b/app/src/main/res/layout/activity_map_and_info.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_tablet_place_info.xml b/app/src/main/res/layout/activity_tablet_place_info.xml new file mode 100644 index 0000000..d6ed3dd --- /dev/null +++ b/app/src/main/res/layout/activity_tablet_place_info.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +