From 398bbaaf7680e8ee46b1bae8444d4394816a70c7 Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Mon, 13 Aug 2018 14:29:29 -0400 Subject: [PATCH 1/7] Add been category to homescreen Closes #158. --- .../java/org/gophillygo/app/activities/HomeActivity.java | 5 +++-- .../main/java/org/gophillygo/app/data/DestinationDao.java | 4 ++++ .../org/gophillygo/app/data/models/CategoryAttraction.java | 3 ++- build.gradle | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/gophillygo/app/activities/HomeActivity.java b/app/src/main/java/org/gophillygo/app/activities/HomeActivity.java index 34c2f891..840ec4d4 100644 --- a/app/src/main/java/org/gophillygo/app/activities/HomeActivity.java +++ b/app/src/main/java/org/gophillygo/app/activities/HomeActivity.java @@ -54,7 +54,6 @@ public class HomeActivity extends BaseAttractionActivity implements DestinationR protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); - Log.d(LOG_LABEL, "onCreate"); categories = new ArrayList<>(CategoryAttraction.PlaceCategories.size()); Toolbar toolbar = findViewById(R.id.home_toolbar); @@ -94,7 +93,6 @@ public void locationOrDestinationsChanged() { @Override protected void onResume() { super.onResume(); - Log.d(LOG_LABEL, "onResume"); addScrollListener(); } @@ -227,6 +225,9 @@ private void goToFilteredPlacesList(CategoryAttraction.PlaceCategories category) case WatershedAlliance: filter.setWatershedAlliance(true); break; + case Been: + filter.setBeen(true); + break; default: Log.e(LOG_LABEL, "Unrecognized place category " + category.displayName); } diff --git a/app/src/main/java/org/gophillygo/app/data/DestinationDao.java b/app/src/main/java/org/gophillygo/app/data/DestinationDao.java index 668dfb73..3c5dea65 100644 --- a/app/src/main/java/org/gophillygo/app/data/DestinationDao.java +++ b/app/src/main/java/org/gophillygo/app/data/DestinationDao.java @@ -130,6 +130,10 @@ public LiveData> getCategoryImages() { LiveData educational = getRandomExerciseImages(); addSourceToRandomImagesLiveData(educational, CategoryAttraction.PlaceCategories.Educational, categoryAttractions, data); + + LiveData been = getRandomImagesForFlag(AttractionFlag.Option.Been.code); + addSourceToRandomImagesLiveData(been, CategoryAttraction.PlaceCategories.Been, categoryAttractions, data); + return data; } diff --git a/app/src/main/java/org/gophillygo/app/data/models/CategoryAttraction.java b/app/src/main/java/org/gophillygo/app/data/models/CategoryAttraction.java index f316ab53..fe2902d9 100644 --- a/app/src/main/java/org/gophillygo/app/data/models/CategoryAttraction.java +++ b/app/src/main/java/org/gophillygo/app/data/models/CategoryAttraction.java @@ -56,7 +56,8 @@ public enum PlaceCategories { WatershedAlliance(3, R.string.watershed_alliance_label, WATERSHED_ALLIANCE), Nature(4, R.string.nature_category_label, NATURE_API_NAME), Exercise(5, R.string.exercise_category_label, EXERCISE_API_NAME), - Educational(6, R.string.educational_category_label, EDUCATIONAL_API_NAME); + Educational(6, R.string.educational_category_label, EDUCATIONAL_API_NAME), + Been(7, R.string.place_been_option, AttractionFlag.Option.Been.apiName); private static final SparseArray map = new SparseArray<>(); static { diff --git a/build.gradle b/build.gradle index dcf52227..5341443c 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { maven { url 'https://maven.fabric.io/public' } } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 46ec62c573fced81020377c43080a107c995d0dc Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Thu, 9 Aug 2018 13:22:53 -0400 Subject: [PATCH 2/7] Bump minor package version --- app/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 80183cad..fe76aa66 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,7 +82,6 @@ dependencies { // Room implementation "android.arch.persistence.room:runtime:$roomVersion" - implementation 'com.android.support:appcompat-v7:27.1.1' annotationProcessor "android.arch.persistence.room:compiler:$roomVersion" // Android UI libraries @@ -98,7 +97,7 @@ dependencies { implementation "com.google.android.gms:play-services-maps:$playServicesVersion" // Android WorkManager - implementation 'android.arch.work:work-runtime:1.0.0-alpha04' + implementation 'android.arch.work:work-runtime:1.0.0-alpha06' // Carousel implementation 'com.synnapps:carouselview:0.1.5' From e9240f8f382fc43404795b953b2ddf0072077666 Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Thu, 9 Aug 2018 13:27:51 -0400 Subject: [PATCH 3/7] Remove notification been button Closes #157 --- .../app/activities/EventDetailActivity.java | 9 ------ .../app/activities/PlaceDetailActivity.java | 9 ------ .../app/tasks/GeofenceTransitionWorker.java | 28 +------------------ 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/app/src/main/java/org/gophillygo/app/activities/EventDetailActivity.java b/app/src/main/java/org/gophillygo/app/activities/EventDetailActivity.java index 99621358..bdb9c5be 100644 --- a/app/src/main/java/org/gophillygo/app/activities/EventDetailActivity.java +++ b/app/src/main/java/org/gophillygo/app/activities/EventDetailActivity.java @@ -119,15 +119,6 @@ protected void onCreate(Bundle savedInstanceState) { // Since we call `getDestination(...).observe(...)` every time the event is updated, // we need to remove destination observer every time it is called data.removeObservers(this); - - // Check if flag set by notification to mark event as "been" and set flag if so - if (getIntent().hasExtra(GeofenceTransitionWorker.MARK_BEEN_KEY)) { - if(getIntent().getBooleanExtra(GeofenceTransitionWorker.MARK_BEEN_KEY, false) && - !eventInfo.getFlag().getOption().id.equals(AttractionFlag.Option.Been.id)) { - - updateFlag(AttractionFlag.Option.Been.id); - } - } }); } diff --git a/app/src/main/java/org/gophillygo/app/activities/PlaceDetailActivity.java b/app/src/main/java/org/gophillygo/app/activities/PlaceDetailActivity.java index 35c81e46..d388eec5 100644 --- a/app/src/main/java/org/gophillygo/app/activities/PlaceDetailActivity.java +++ b/app/src/main/java/org/gophillygo/app/activities/PlaceDetailActivity.java @@ -95,15 +95,6 @@ protected void onCreate(Bundle savedInstanceState) { this.destinationInfo = destinationInfo; - // Check if flag set by notification to mark event as "been" and set flag if so - if (getIntent().hasExtra(GeofenceTransitionWorker.MARK_BEEN_KEY)) { - if(getIntent().getBooleanExtra(GeofenceTransitionWorker.MARK_BEEN_KEY, false) && - !destinationInfo.getFlag().getOption().id.equals(AttractionFlag.Option.Been.id)) { - - updateFlag(AttractionFlag.Option.Been.id); - } - } - // set up data binding object binding.setDestination(destinationInfo.getDestination()); binding.setDestinationInfo(destinationInfo); diff --git a/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java b/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java index 53d1d53c..0f494018 100644 --- a/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java +++ b/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java @@ -30,13 +30,10 @@ import androidx.work.Data; import androidx.work.Worker; -import static org.gophillygo.app.activities.AttractionDetailActivity.GEOFENCE_ID_KEY; -import static org.gophillygo.app.activities.AttractionDetailActivity.NOTIFICATION_ID_KEY; import static org.gophillygo.app.tasks.GeofenceTransitionBroadcastReceiver.GEOFENCE_IMAGES_KEY; public class GeofenceTransitionWorker extends Worker { - public static final String MARK_BEEN_KEY = "mark_been"; public static final String HAS_ERROR_KEY = "has_error"; public static final String ERROR_CODE_KEY = "error_code"; public static final String TRANSITION_KEY = "transition"; @@ -56,7 +53,6 @@ public class GeofenceTransitionWorker extends Worker { private static final int NOTIFICATION_IMAGE_WIDTH = 1024; private static final int NOTIFICATION_IMAGE_HEIGHT = 512; - private static final int BEEN_PENDING_INTENT_CODE = 101; private static final int DETAIL_PENDING_INTENT_CODE = 102; @NonNull @@ -127,25 +123,15 @@ public Result doWork() { // Get intent for the detail view to open on notification click. Intent intent; - Intent beenIntent; + if (isEvent) { intent = new Intent(context, EventDetailActivity.class); intent.putExtra(EventDetailActivity.EVENT_ID_KEY, (long) geofenceId); - beenIntent = new Intent(context, EventDetailActivity.class); - beenIntent.putExtra(EventDetailActivity.EVENT_ID_KEY, (long) geofenceId); } else { intent = new Intent(context, PlaceDetailActivity.class); intent.putExtra(PlaceDetailActivity.DESTINATION_ID_KEY, (long) geofenceId); - beenIntent = new Intent(context, PlaceDetailActivity.class); - beenIntent.putExtra(PlaceDetailActivity.DESTINATION_ID_KEY, (long) geofenceId); } - // When opening detail activity from 'been' button, pass key to tell - // activity to mark its model as 'been' and the notification ID, to close it - beenIntent.putExtra(MARK_BEEN_KEY, true); - beenIntent.putExtra(NOTIFICATION_ID_KEY, notificationTag); - beenIntent.putExtra(GEOFENCE_ID_KEY, geofenceId); - // Add the intent to the stack builder, which inflates the back stack TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addNextIntentWithParentStack(intent); @@ -153,21 +139,12 @@ public Result doWork() { PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(DETAIL_PENDING_INTENT_CODE, PendingIntent.FLAG_UPDATE_CURRENT); - // Create pending intent for marking place "been" - // Add the intent to the stack builder, which inflates the back stack - TaskStackBuilder beenStackBuilder = TaskStackBuilder.create(context); - beenStackBuilder.addNextIntentWithParentStack(beenIntent); - // Get the PendingIntent containing the entire back stack - PendingIntent beenPendingIntent = - beenStackBuilder.getPendingIntent(BEEN_PENDING_INTENT_CODE, PendingIntent.FLAG_UPDATE_CURRENT); - // Show notification on UI thread handler.post(() -> { String nearbyNotice = context.getString(R.string.place_nearby_notification, placeName); createNotificationChannel(context); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID) - // TODO: use app icon of some sort .setSmallIcon(R.drawable.ic_flag_blue_24dp) .setOnlyAlertOnce(false) .setContentTitle(placeName) @@ -178,9 +155,6 @@ public Result doWork() { // alert for all notifications .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) .setPriority(NotificationCompat.PRIORITY_HIGH) - .addAction(R.drawable.ic_beenhere_blue_24dp, - context.getString(R.string.place_nearby_been_button), - beenPendingIntent) .setGroupSummary(true); if (imageBitmap != null) { From 9ea49efe9bfb91ad92e5da6e03ed88a0586a4250 Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Thu, 9 Aug 2018 13:41:16 -0400 Subject: [PATCH 4/7] Minor notification modifications To improve auto-grouping behavior on APIs 24+. --- .../org/gophillygo/app/tasks/GeofenceTransitionWorker.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java b/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java index 0f494018..0a65da12 100644 --- a/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java +++ b/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java @@ -153,9 +153,8 @@ public Result doWork() { .setAutoCancel(true) // close notification when tapped .setGroup(GROUP_ID) // alert for all notifications - .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) - .setPriority(NotificationCompat.PRIORITY_HIGH) - .setGroupSummary(true); + .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) + .setPriority(NotificationCompat.PRIORITY_HIGH); if (imageBitmap != null) { notificationBuilder = notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle() From ec60789e02be1a26bd11be5bceaa8aacb563c3b0 Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Thu, 9 Aug 2018 14:04:59 -0400 Subject: [PATCH 5/7] Modify notification text --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fd20453e..97590691 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -103,7 +103,7 @@ gophillygo_user_uuid Please set location mode to \"High Accuracy\" to receive notifications when places you like or want to go are nearby. Nearby GoPhillyGo destinations you like or want to go visit - Are you visiting %1$s now? Learn more. + You are near %1$s. Learn more. I\'m there now Upcoming events General From f3bab72a5290f5c2eb8770c21196e48c858d63bc Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Thu, 9 Aug 2018 14:35:41 -0400 Subject: [PATCH 6/7] Do not check for high accuracy on API 28+ The new settings menu no longer has an option for the setting that must be enabled on lower APIs for geofencing to work. --- .../app/utils/GpgLocationUtils.java | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/gophillygo/app/utils/GpgLocationUtils.java b/app/src/main/java/org/gophillygo/app/utils/GpgLocationUtils.java index b70a64b9..345e8fb8 100644 --- a/app/src/main/java/org/gophillygo/app/utils/GpgLocationUtils.java +++ b/app/src/main/java/org/gophillygo/app/utils/GpgLocationUtils.java @@ -9,6 +9,7 @@ import android.content.IntentSender; import android.content.pm.PackageManager; import android.location.Location; +import android.os.Build; import android.provider.Settings; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; @@ -95,36 +96,40 @@ public static boolean checkFineLocationPermissions(WeakReference calle return false; // up to the activity to start this service again when permissions granted } - // Check location settings + // Check location settings on API < 28 + // Geofencing requires high accuracy location to be enabled in settings on API < 28. + // This setting no longer exists on P/28, so do not prompt on 28+. // https://developer.android.com/training/location/change-location-settings#get-settings - LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); - SettingsClient client = LocationServices.getSettingsClient(callingActivity); - Task task = client.checkLocationSettings(builder.build()); - task.addOnFailureListener(e -> { - if (e instanceof ResolvableApiException) { - try { - ResolvableApiException resolvable = (ResolvableApiException) e; - resolvable.startResolutionForResult(callingActivity, LOCATION_SETTINGS_REQUEST_ID); - } catch (IntentSender.SendIntentException e1) { - Log.e(LOG_LABEL, "Failed to prompt user for location settings changes"); - e1.printStackTrace(); + if (Build.VERSION.SDK_INT < 28) { + LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); + SettingsClient client = LocationServices.getSettingsClient(callingActivity); + Task task = client.checkLocationSettings(builder.build()); + task.addOnFailureListener(e -> { + if (e instanceof ResolvableApiException) { + try { + ResolvableApiException resolvable = (ResolvableApiException) e; + resolvable.startResolutionForResult(callingActivity, LOCATION_SETTINGS_REQUEST_ID); + } catch (IntentSender.SendIntentException e1) { + Log.e(LOG_LABEL, "Failed to prompt user for location settings changes"); + e1.printStackTrace(); + } + } else { + Log.e(LOG_LABEL, "Received unresolvable location settings exception."); + e.printStackTrace(); } - } else { - Log.e(LOG_LABEL, "Received unresolvable location settings exception."); - e.printStackTrace(); - } - }).addOnSuccessListener(locationSettingsResponse -> { - LocationSettingsStates states = locationSettingsResponse.getLocationSettingsStates(); - if (!states.isNetworkLocationPresent() || !states.isNetworkLocationUsable()) { - Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); - // TODO: a dialog would be easier to read - Toast toast = Toast.makeText(callingActivity, - callingActivity.getString(R.string.location_network_permission_rationale), - Toast.LENGTH_LONG); - toast.show(); - callingActivity.startActivity(intent); - } - }); + }).addOnSuccessListener(locationSettingsResponse -> { + LocationSettingsStates states = locationSettingsResponse.getLocationSettingsStates(); + if (!states.isNetworkLocationPresent() || !states.isNetworkLocationUsable()) { + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + // TODO: a dialog would be easier to read + Toast toast = Toast.makeText(callingActivity, + callingActivity.getString(R.string.location_network_permission_rationale), + Toast.LENGTH_LONG); + toast.show(); + callingActivity.startActivity(intent); + } + }); + } return true; } From d9d138c8b6f4384526d371506e903e3cee0422c7 Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Tue, 14 Aug 2018 14:42:11 -0400 Subject: [PATCH 7/7] Bump version to 1.1.0 First release out of beta. --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fe76aa66..8bf807ca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,8 +26,8 @@ android { applicationId "org.gophillygo.app" minSdkVersion 19 targetSdkVersion 27 - versionCode 13 - versionName "1.0.10" + versionCode 14 + versionName "1.1.0" vectorDrawables.useSupportLibrary = true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" javaCompileOptions {