diff --git a/app/build.gradle b/app/build.gradle index 80183cad..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 { @@ -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' 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/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/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/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/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java b/app/src/main/java/org/gophillygo/app/tasks/GeofenceTransitionWorker.java index 53d1d53c..0a65da12 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) @@ -176,12 +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) - .addAction(R.drawable.ic_beenhere_blue_24dp, - context.getString(R.string.place_nearby_been_button), - beenPendingIntent) - .setGroupSummary(true); + .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) + .setPriority(NotificationCompat.PRIORITY_HIGH); if (imageBitmap != null) { notificationBuilder = notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle() 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; } 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 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