From 32a13a2c1ba926adba63669403dc7363b15e0de8 Mon Sep 17 00:00:00 2001 From: acrown-msft Date: Tue, 6 Oct 2020 16:30:00 -0700 Subject: [PATCH 1/6] Remove Embedded Social --- BUILD.md | 13 -- PERMISSIONS.md | 1 - onebusaway-android/build.gradle | 44 ---- onebusaway-android/proguard-project.txt | 50 ----- .../android/io/test/ObaTestCase.java | 4 - .../onebusaway/android/mock/MockRegion.java | 8 - .../util/test/EmbeddedSocialUtilTest.java | 45 ---- .../android/util/test/UIUtilTest.java | 134 ++---------- .../src/main/AndroidManifest.xml | 15 -- .../onebusaway/android/app/Application.java | 44 ---- .../android/io/elements/ObaRegionElement.java | 9 +- .../android/provider/ObaContract.java | 1 - .../report/ui/util/SocialReportHandler.java | 87 -------- .../android/ui/ArrivalsListActivity.java | 15 -- .../android/ui/ArrivalsListAdapterStyleB.java | 22 -- .../android/ui/ArrivalsListFragment.java | 88 +------- .../android/ui/ArrivalsListHeader.java | 25 --- .../onebusaway/android/ui/HomeActivity.java | 203 ------------------ .../android/ui/NavigationDrawerFragment.java | 94 +------- .../android/ui/PreferencesActivity.java | 22 -- .../android/ui/TripPlanActivity.java | 11 - .../android/ui/social/SocialAppProfile.java | 32 --- .../social/SocialNavigationDrawerHandler.java | 54 ----- .../android/util/EmbeddedSocialUtils.java | 163 -------------- .../android/util/GetRestrictionsReceiver.java | 96 --------- .../onebusaway/android/util/RegionUtils.java | 2 - .../org/onebusaway/android/util/UIUtils.java | 9 - .../main/res/drawable-hdpi/es_ic_comment.png | Bin 450 -> 0 bytes .../main/res/drawable-mdpi/es_ic_comment.png | Bin 332 -> 0 bytes .../main/res/drawable-xhdpi/es_ic_comment.png | Bin 401 -> 0 bytes .../res/drawable-xxhdpi/es_ic_comment.png | Bin 624 -> 0 bytes .../ic_drawer_activity_feed.png | Bin 610 -> 0 bytes .../res/drawable-xxhdpi/ic_drawer_pin.png | Bin 863 -> 0 bytes .../res/drawable-xxhdpi/ic_drawer_popular.png | Bin 578 -> 0 bytes .../res/drawable-xxxhdpi/es_ic_comment.png | Bin 605 -> 0 bytes .../main/res/layout/arrivals_list_header.xml | 19 -- .../res/layout/arrivals_list_item_style_b.xml | 16 -- .../layout/navdrawer_separator_special.xml | 32 --- .../src/main/res/layout/stop_list_item.xml | 15 -- .../src/main/res/raw/embedded_social_config | 30 --- .../src/main/res/values-es/strings.xml | 22 -- .../src/main/res/values/colors.xml | 11 - .../src/main/res/values/donottranslate.xml | 14 +- .../src/main/res/values/strings.xml | 22 -- .../src/main/res/xml/preferences.xml | 7 - 45 files changed, 27 insertions(+), 1452 deletions(-) delete mode 100644 onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/EmbeddedSocialUtilTest.java delete mode 100644 onebusaway-android/src/main/java/org/onebusaway/android/report/ui/util/SocialReportHandler.java delete mode 100644 onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialAppProfile.java delete mode 100644 onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialNavigationDrawerHandler.java delete mode 100644 onebusaway-android/src/main/java/org/onebusaway/android/util/EmbeddedSocialUtils.java delete mode 100644 onebusaway-android/src/main/java/org/onebusaway/android/util/GetRestrictionsReceiver.java delete mode 100644 onebusaway-android/src/main/res/drawable-hdpi/es_ic_comment.png delete mode 100644 onebusaway-android/src/main/res/drawable-mdpi/es_ic_comment.png delete mode 100644 onebusaway-android/src/main/res/drawable-xhdpi/es_ic_comment.png delete mode 100644 onebusaway-android/src/main/res/drawable-xxhdpi/es_ic_comment.png delete mode 100644 onebusaway-android/src/main/res/drawable-xxhdpi/ic_drawer_activity_feed.png delete mode 100644 onebusaway-android/src/main/res/drawable-xxhdpi/ic_drawer_pin.png delete mode 100644 onebusaway-android/src/main/res/drawable-xxhdpi/ic_drawer_popular.png delete mode 100644 onebusaway-android/src/main/res/drawable-xxxhdpi/es_ic_comment.png delete mode 100644 onebusaway-android/src/main/res/layout/navdrawer_separator_special.xml delete mode 100644 onebusaway-android/src/main/res/raw/embedded_social_config diff --git a/BUILD.md b/BUILD.md index c8aac7cb7..6c455fcb5 100644 --- a/BUILD.md +++ b/BUILD.md @@ -50,19 +50,6 @@ Add the following to `onebusaway-android/gradle.properties`: ...where `XXXXXX` is your API key. Note that the suffix of `_oba` can be changed to configure API keys for other build flavors. -### Configuration the Embedded Social SDK API key (Optional) - -If you want the Embedded Social features to show up within the OneBusAway app, you'll need to add an Embedded Social API key. - -To do this, you'll need these lines in `gradle.properties` in the `onebusaway-android` folder: - -``` -EmbeddedSocialApiKey_oba=xxxxxx -EmbeddedSocialTelemetryKey_oba=xxxxxx -``` - -This step is optional if you're just looking to build and test the project for development purposes - if you don't include the keys in the config file, the social features will be hidden. - ### Release builds To build a release build, you need to create a `gradle.properties` file that points to a `secure.properties` file, and a `secure.properties` file that points to your keystore and alias. diff --git a/PERMISSIONS.md b/PERMISSIONS.md index ceaad0aea..e3cc63aed 100644 --- a/PERMISSIONS.md +++ b/PERMISSIONS.md @@ -10,5 +10,4 @@ In order to support certain features in OneBusAway, we need to request various p * **View network connections** - Used to create more descriptive error messages if there is a problem with loading stops or arrivals (e.g., do you have airplane mode on?) * **Install shortcuts** - Used to create icons on your home screen for a specific stop, so you can tap on that stop icon from your home screen and immediately see arrivals * **Control vibration** - Used to vibrate your phone when a reminder is triggered -* **Find accounts on the device** - Used to make sure that if the user removes a Google account from the device that they are logged out of the social features (Embedded Social) of OneBusAway. diff --git a/onebusaway-android/build.gradle b/onebusaway-android/build.gradle index 7c9f56600..1e74e6c75 100644 --- a/onebusaway-android/build.gradle +++ b/onebusaway-android/build.gradle @@ -34,14 +34,6 @@ repositories { // CUTR Releases url "https://github.com/CUTR-at-USF/cutr-mvn-repo/raw/master/snapshots" } - maven { - // for EmbeddedSocial SDK - url "http://dl.bintray.com/acrowntest/ES_SDK" - metadataSources { - mavenPom() - artifact() - } - } mavenCentral() } @@ -108,8 +100,6 @@ android { manifestPlaceholders = [databaseAuthority: "com.joulespersecond.oba"] buildConfigField "int", "ARRIVAL_INFO_STYLE", "0" // Defined in BuildFlavorConstants buildConfigField "boolean", "USE_FIXED_REGION", "false" // Supports multi-region - buildConfigField "String", "EMBEDDED_SOCIAL_API_KEY", "\"" + getEmbeddedSocialKey("ApiKey", name) + "\"" - buildConfigField "String", "EMBEDDED_SOCIAL_TELEMETRY_KEY", "\"" + getEmbeddedSocialKey("TelemetryKey", name) + "\"" buildConfigField "boolean", "USE_PELIAS_GEOCODING", "true" buildConfigField "String", "PELIAS_API_KEY", "\"" + getPeliasKey(name) + "\"" // Below fields need to be defined so flavor builds, but will not be used by app @@ -125,7 +115,6 @@ android { buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_DISCOVERY_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_REALTIME_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_SIRI_REALTIME_APIS", "false" - buildConfigField "boolean", "FIXED_REGION_SUPPORTS_EMBEDDEDSOCIAL", "false" buildConfigField "String", "FIXED_REGION_TWITTER_URL", "null" buildConfigField "String", "FIXED_REGION_STOP_INFO_URL", "null" buildConfigField "String", "FIXED_REGION_OPEN311_JURISDICTION_ID", "null" @@ -157,8 +146,6 @@ android { manifestPlaceholders = [databaseAuthority: applicationId.toString() + '.provider'] buildConfigField "int", "ARRIVAL_INFO_STYLE", "0" // Defined in BuildFlavorConstants buildConfigField "boolean", "USE_FIXED_REGION", "false" // Supports multi-region - buildConfigField "String", "EMBEDDED_SOCIAL_API_KEY", "\"" + getEmbeddedSocialKey("ApiKey", name) + "\"" - buildConfigField "String", "EMBEDDED_SOCIAL_TELEMETRY_KEY", "\"" + getEmbeddedSocialKey("TelemetryKey", name) + "\"" buildConfigField "boolean", "USE_PELIAS_GEOCODING", "true" buildConfigField "String", "PELIAS_API_KEY", "\"" + getPeliasKey(name) + "\"" // Below fields need to be defined so flavor builds, but will not be used by app @@ -174,7 +161,6 @@ android { buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_DISCOVERY_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_REALTIME_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_SIRI_REALTIME_APIS", "false" - buildConfigField "boolean", "FIXED_REGION_SUPPORTS_EMBEDDEDSOCIAL", "false" buildConfigField "String", "FIXED_REGION_TWITTER_URL", "null" buildConfigField "String", "FIXED_REGION_STOP_INFO_URL", "null" buildConfigField "String", "FIXED_REGION_OPEN311_JURISDICTION_ID", "null" @@ -197,8 +183,6 @@ android { manifestPlaceholders = [databaseAuthority: applicationId.toString() + '.provider'] buildConfigField "int", "ARRIVAL_INFO_STYLE", "1" // Defined in BuildFlavorConstants buildConfigField "boolean", "USE_FIXED_REGION", "true" // Does not support multi-region - buildConfigField "String", "EMBEDDED_SOCIAL_API_KEY", "\"" + getEmbeddedSocialKey("ApiKey", name) + "\"" - buildConfigField "String", "EMBEDDED_SOCIAL_TELEMETRY_KEY", "\"" + getEmbeddedSocialKey("TelemetryKey", name) + "\"" buildConfigField "boolean", "USE_PELIAS_GEOCODING", "true" buildConfigField "String", "PELIAS_API_KEY", "\"" + getPeliasKey(name) + "\"" // Fixed region info that the app will use @@ -215,7 +199,6 @@ android { buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_DISCOVERY_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_REALTIME_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_SIRI_REALTIME_APIS", "false" - buildConfigField "boolean", "FIXED_REGION_SUPPORTS_EMBEDDEDSOCIAL", "false" buildConfigField "String", "FIXED_REGION_TWITTER_URL", "\"http://mobile.twitter.com/OBA_tampa\"" buildConfigField "String", "FIXED_REGION_STOP_INFO_URL", "null" @@ -241,8 +224,6 @@ android { manifestPlaceholders = [databaseAuthority: applicationId.toString() + '.provider'] buildConfigField "int", "ARRIVAL_INFO_STYLE", "1" // Defined in BuildFlavorConstants buildConfigField "boolean", "USE_FIXED_REGION", "true" // Does not support multi-region - buildConfigField "String", "EMBEDDED_SOCIAL_API_KEY", "\"" + getEmbeddedSocialKey("ApiKey", name) + "\"" - buildConfigField "String", "EMBEDDED_SOCIAL_TELEMETRY_KEY", "\"" + getEmbeddedSocialKey("TelemetryKey", name) + "\"" buildConfigField "boolean", "USE_PELIAS_GEOCODING", "false" buildConfigField "String", "PELIAS_API_KEY", "\"" + getPeliasKey(name) + "\"" // Fixed region info that the app will use @@ -259,7 +240,6 @@ android { buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_DISCOVERY_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_OBA_REALTIME_APIS", "true" buildConfigField "boolean", "FIXED_REGION_SUPPORTS_SIRI_REALTIME_APIS", "false" - buildConfigField "boolean", "FIXED_REGION_SUPPORTS_EMBEDDEDSOCIAL", "false" buildConfigField "String", "FIXED_REGION_TWITTER_URL", "\"https://twitter.com/YRTViva\"" buildConfigField "String", "FIXED_REGION_STOP_INFO_URL", "null" @@ -302,9 +282,7 @@ android { // http://stackoverflow.com/questions/20673625/gradle-0-7-0-duplicate-files-during-packaging-of-apk packagingOptions { exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE' - exclude 'META-INF/NOTICE.txt' } lintOptions { @@ -385,17 +363,6 @@ android { useLibrary 'android.test.mock' } -/** - * Returns the Embedded Social key (e.g. "ApiKey" or "TelemetryKey") from gradle.properties for the given product flavor (e.g., "oba"), or returns the empty string if the key is not found - */ -def getEmbeddedSocialKey(keyType, productFlavor) { - def keyName = "EmbeddedSocial" + keyType + "_" + productFlavor - if (project.hasProperty(keyName)) { - return project.property(keyName) - } else { - return "" - } -} /** * Gets the Pelias geocoding API key for the given product flavor * @param productFlavor the product flavor being built @@ -434,15 +401,6 @@ task copyMapsApiV2Classes { preBuild.dependsOn copyMapsApiV2Classes -tasks.whenTaskAdded { theTask -> - // Make sure that OBA release builds always have an Embedded Social API key (#907) - def runningTask = project.gradle.startParameter.taskNames - - if ((runningTask.toString().toLowerCase().matches("(.*)oba(.*)release(.*)") || runningTask.toString().toLowerCase().contains("assemblerelease") ) && !project.hasProperty('EmbeddedSocialApiKey_oba')) { - throw new InvalidUserDataException("gradle.properties must contain an EmbeddedSocialApiKey_oba API key for oba release builds") - } -} - // Exclude all classes from dependencies that conflict with Android platform classes (#849) configurations { all { @@ -492,8 +450,6 @@ dependencies { googleImplementation 'com.google.android.libraries.places:places-compat:1.1.0' // Amazon Maps (only for Amazon flavor) amazonImplementation 'com.amazon.android:amazon-maps-api:2.0' - // Embedded Social SDK - implementation('com.acrowntest.ES_SDK:sdk:0.7.6') // Autocomplete text views with clear button for trip planning implementation 'com.google.android.material:material:1.1.0' // Required to support multidex for minSdkVersion <= 20 diff --git a/onebusaway-android/proguard-project.txt b/onebusaway-android/proguard-project.txt index fadeb754a..1f547040d 100644 --- a/onebusaway-android/proguard-project.txt +++ b/onebusaway-android/proguard-project.txt @@ -61,57 +61,7 @@ # Keep Open311 library (needed for unit tests) -keep class edu.usf.cutr.open311client.** { *; } --keep class com.microsoft.embeddedsocial.** { *; } - -# annotations --dontwarn javax.annotation.** - --dontwarn sun.misc.Unsafe - -# for joda DateTime --dontwarn org.joda.convert.** --dontwarn org.joda.time.** --keep class org.joda.time.** { *; } --keep interface org.joda.time.** { *;} - -# for picasso --dontwarn com.squareup.okhttp.** - --dontwarn okhttp3.** --dontwarn okio.** - --dontwarn retrofit2.** - --dontwarn uk.co.senab.photoview.** - --keep interface java.lang.Method { *; } --keep class org.codehaus.mojo.** { *; } - -# for parcelables for reflection --keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { - public static final *** NULL; -} - -# prevent renaming of Parcelable/SafeParcelable classes --keep class com.google.android.gms.common.internal.ReflectedParcelable --keepnames class * implements com.google.android.gms.common.internal.ReflectedParcelable --keepclassmembers class * implements android.os.Parcelable { - public static final *** CREATOR; -} - -# for Google auth scopes --keep class com.google.android.gms.common.api.Scope - -# for android LifecyleOwner --keep class android.arch.** { *; } - # for AndroidSlidingUpPanel and compiling with API 28 (see https://github.com/OneBusAway/onebusaway-android/issues/944#issuecomment-446340531) -dontwarn com.sothree.** -keep class com.sothree.** -keep interface com.sothree.** - -# for TabLayout in EmbeddedSocial SDK and compiling with API 28 (see https://github.com/OneBusAway/onebusaway-android/issues/944#issuecomment-446345133) --dontwarn com.microsoft.embeddedsocial.sdk.ui.TabbedDrawerHandler - -# for EmbeddedSocial SDK --dontwarn com.microsoft.rest.Validator \ No newline at end of file diff --git a/onebusaway-android/src/androidTest/java/org/onebusaway/android/io/test/ObaTestCase.java b/onebusaway-android/src/androidTest/java/org/onebusaway/android/io/test/ObaTestCase.java index 848feebfa..aaf028f11 100644 --- a/onebusaway-android/src/androidTest/java/org/onebusaway/android/io/test/ObaTestCase.java +++ b/onebusaway-android/src/androidTest/java/org/onebusaway/android/io/test/ObaTestCase.java @@ -45,10 +45,6 @@ public static void assertOK(ObaResponse response) { @Before public void before() { - // Workaround for #940 - when Embedded Social no longer runs services in the background the - // call to setUpSocial() can be removed here in favor of early init in Application (see #957) - Application.get().setUpSocial(); - // The theme needs to be set when using "attr/?" elements - see #279 getTargetContext().setTheme(R.style.Theme_OneBusAway); diff --git a/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java b/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java index 47d4dd126..0edf989f0 100644 --- a/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java +++ b/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java @@ -90,7 +90,6 @@ public static ObaRegion getRegionWithPathNoSeparator(Context context) { null, null, false, - false, "co.bytemark.hart", null, null, @@ -130,7 +129,6 @@ public static ObaRegion getRegionNoSeparator(Context context) { null, null, false, - false, null, null, null, @@ -170,7 +168,6 @@ public static ObaRegion getRegionWithPort(Context context) { null, null, false, - false, "co.bytemark.hart", null, null, @@ -210,7 +207,6 @@ public static ObaRegion getRegionNoScheme(Context context) { null, null, false, - false, "co.bytemark.hart", null, null, @@ -250,7 +246,6 @@ public static ObaRegion getRegionWithHttps() { null, null, false, - false, "co.bytemark.hart", null, null, @@ -290,7 +285,6 @@ public static ObaRegion getRegionWithHttpsAndPort() { null, null, false, - false, "co.bytemark.hart", null, null, @@ -328,7 +322,6 @@ public static ObaRegion getRegionWithoutObaApis(Context context) { null, null, false, - false, "co.bytemark.hart", null, null, @@ -366,7 +359,6 @@ public static ObaRegion getInactiveRegion(Context context) { null, null, false, - false, "co.bytemark.hart", null, null, diff --git a/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/EmbeddedSocialUtilTest.java b/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/EmbeddedSocialUtilTest.java deleted file mode 100644 index de6b15acb..000000000 --- a/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/EmbeddedSocialUtilTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Copyright (c) 2017, Microsoft Corporation. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.onebusaway.android.util.test; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onebusaway.android.util.EmbeddedSocialUtils; - -import androidx.test.runner.AndroidJUnit4; - -import static junit.framework.Assert.assertEquals; - -/** - * Tests embedded social utilities - */ -@RunWith(AndroidJUnit4.class) -public class EmbeddedSocialUtilTest { - - @Test - public void testDiscussionTitles() { - long regionId; - String stopId; - String actual; - String expected; - - regionId = 0; - stopId = "Hello world \\ # % + / ? \u0082"; - actual = EmbeddedSocialUtils.createStopDiscussionTitle(regionId, stopId); - expected = "stop_0_Hello world XA== Iw== JQ== Kw== Lw== Pw== woI="; - assertEquals(expected, actual); - } -} diff --git a/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/UIUtilTest.java b/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/UIUtilTest.java index e571ae9d1..63e220eea 100644 --- a/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/UIUtilTest.java +++ b/onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/UIUtilTest.java @@ -38,7 +38,6 @@ import org.onebusaway.android.provider.ObaContract; import org.onebusaway.android.ui.ArrivalInfo; import org.onebusaway.android.util.ArrivalInfoUtils; -import org.onebusaway.android.util.EmbeddedSocialUtils; import org.onebusaway.android.util.UIUtils; import android.graphics.Color; @@ -217,12 +216,7 @@ public void testBuildTripOptions() { List options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Add star to route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); @@ -231,20 +225,11 @@ public void testBuildTripOptions() { assertEquals(options.get(5), "Show route schedule"); assertEquals(options.get(6), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(7), "Join discussion"); - } - // "Show only this route" should toggle to "Show all routes" when hasRouteFilter is true hasRouteFilter = true; options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Add star to route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); @@ -252,9 +237,6 @@ public void testBuildTripOptions() { assertEquals(options.get(4), "Show all routes"); assertEquals(options.get(5), "Show route schedule"); assertEquals(options.get(6), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(7), "Join discussion"); - } // "Reset hasRouteFilter to false to remaining tests hasRouteFilter = false; @@ -263,12 +245,7 @@ public void testBuildTripOptions() { // Now we should see route schedules and *edit* the reminder options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Add star to route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); @@ -276,9 +253,6 @@ public void testBuildTripOptions() { assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Show route schedule"); assertEquals(options.get(6), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(7), "Join discussion"); - } // Get a PSTA response - PSTA test data doesn't include route schedule URLs ObaArrivalInfoResponse response2 = @@ -307,42 +281,26 @@ public void testBuildTripOptions() { // user to set a reminder but NOT view the route schedule options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(6, options.size()); - } else { - assertEquals(7, options.size()); - } + assertEquals(6, options.size()); assertEquals(options.get(0), "Add star to route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Set a reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - } isReminderVisible = true; // Now we should see *edit* the reminder, and still no route schedule options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(6, options.size()); - } else { - assertEquals(7, options.size()); - } + assertEquals(6, options.size()); assertEquals(options.get(0), "Add star to route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Edit this reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - } // Now change route to favorite, and do all the above over again isRouteFavorite = true; @@ -354,12 +312,7 @@ public void testBuildTripOptions() { // a reminder and view the route schedule options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); @@ -367,21 +320,13 @@ public void testBuildTripOptions() { assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Show route schedule"); assertEquals(options.get(6), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(7), "Join discussion"); - } isReminderVisible = true; // Now we should see route schedules and *edit* the reminder options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); @@ -389,9 +334,6 @@ public void testBuildTripOptions() { assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Show route schedule"); assertEquals(options.get(6), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(7), "Join discussion"); - } // PSTA isReminderVisible = false; // We don't have views here, so just fake it @@ -400,42 +342,26 @@ public void testBuildTripOptions() { // user to set a reminder but NOT view the route schedule options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(6, options.size()); - } else { - assertEquals(7, options.size()); - } + assertEquals(6, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Set a reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - } isReminderVisible = true; // Now we should see *edit* the reminder, and still no route schedule options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(6, options.size()); - } else { - assertEquals(7, options.size()); - } + assertEquals(6, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Edit this reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - } // // Test occupancy in the menu @@ -446,72 +372,42 @@ public void testBuildTripOptions() { occupancyState = OccupancyState.HISTORICAL; options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Edit this reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - assertEquals(options.get(7), "About historical occupancy"); - } else { - assertEquals(options.get(6), "About historical occupancy"); - } + assertEquals(options.get(6), "About historical occupancy"); // PREDICTED occupancy = Occupancy.EMPTY; occupancyState = OccupancyState.PREDICTED; options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Edit this reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - assertEquals(options.get(7), "About occupancy"); - } else { - assertEquals(options.get(6), "About occupancy"); - } + assertEquals(options.get(6), "About occupancy"); // REALTIME (should be same as PREDICTED) occupancy = Occupancy.EMPTY; occupancyState = OccupancyState.REALTIME; options = UIUtils .buildTripOptions(getTargetContext(), isRouteFavorite, hasUrl2, isReminderVisible, hasRouteFilter, occupancy, occupancyState); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - // Developer hasn't configured ES SDK key (or we're on Travis), so it doesn't include that menu item. - assertEquals(7, options.size()); - } else { - assertEquals(8, options.size()); - } + assertEquals(7, options.size()); assertEquals(options.get(0), "Remove star from route"); assertEquals(options.get(1), "Show route on map"); assertEquals(options.get(2), "Show trip status"); assertEquals(options.get(3), "Edit this reminder"); assertEquals(options.get(4), "Show only this route"); assertEquals(options.get(5), "Report arrival time problem"); - if (EmbeddedSocialUtils.isSocialEnabled()) { - assertEquals(options.get(6), "Join discussion"); - assertEquals(options.get(7), "About occupancy"); - } else { - assertEquals(options.get(6), "About occupancy"); - } + assertEquals(options.get(6), "About occupancy"); } @Test diff --git a/onebusaway-android/src/main/AndroidManifest.xml b/onebusaway-android/src/main/AndroidManifest.xml index 186be6b84..53e459deb 100644 --- a/onebusaway-android/src/main/AndroidManifest.xml +++ b/onebusaway-android/src/main/AndroidManifest.xml @@ -43,13 +43,7 @@ the HomeActivity's onCreate() method--> - - - - - - - - @@ -332,9 +320,6 @@ - - mFragment.showRouteOnMap(stopInfo)); - // Setup discussion - discussBtn.setOnClickListener(v -> { - ObaAnalytics.reportUiEvent(FirebaseAnalytics.getInstance(getContext()), - context.getString(R.string.analytics_label_button_press_social_route_style_b), - null); - mFragment.openRouteDiscussion(arrivalInfo.getRouteId()); - }); - - ObaRegion currentRegion = Application.get().getCurrentRegion(); - if (currentRegion != null && !EmbeddedSocialUtils.isSocialEnabled()) { - discussBtn.setVisibility(View.GONE); - } - // Setup more routeMoreInfo.setOnClickListener(new View.OnClickListener() { @Override diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java index edb99a319..076d854fe 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java @@ -51,8 +51,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.util.Pair; import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentTransaction; import androidx.loader.app.LoaderManager; import androidx.loader.content.CursorLoader; import androidx.loader.content.Loader; @@ -65,7 +63,6 @@ import org.onebusaway.android.io.ObaApi; import org.onebusaway.android.io.elements.ObaArrivalInfo; import org.onebusaway.android.io.elements.ObaReferences; -import org.onebusaway.android.io.elements.ObaRegion; import org.onebusaway.android.io.elements.ObaRoute; import org.onebusaway.android.io.elements.ObaSituation; import org.onebusaway.android.io.elements.ObaStop; @@ -81,7 +78,6 @@ import org.onebusaway.android.util.ArrivalInfoUtils; import org.onebusaway.android.util.BuildFlavorUtils; import org.onebusaway.android.util.DBUtil; -import org.onebusaway.android.util.EmbeddedSocialUtils; import org.onebusaway.android.util.FragmentUtils; import org.onebusaway.android.util.LocationUtils; import org.onebusaway.android.util.PreferenceUtils; @@ -110,8 +106,6 @@ public class ArrivalsListFragment extends ListFragment public static final String STOP_DIRECTION = ".StopDir"; - public static final String DISCUSSION = ".Discussion"; - /** * Comma-delimited set of routes that serve this stop * See {@link UIUtils#serializeRouteDisplayNames(ObaStop, @@ -350,17 +344,6 @@ public void onActivityCreated(Bundle savedInstanceState) { UIUtils.getNoArrivalsMessage(getActivity(), getArrivalsLoader().getMinutesAfter(), false, false) ); - - if (mHeader != null) { - mHeader.refresh(); - if (getStopId() != null) { - Bundle extras = getActivity().getIntent().getExtras(); - if (extras != null && extras.containsKey(DISCUSSION)) { - String discussionTitle = extras.getString(DISCUSSION); - displaySocialFragment(discussionTitle, false); - } - } - } } @Override @@ -601,11 +584,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public void onPrepareOptionsMenu(Menu menu) { - if (!isAdded()) { - // not attached to an activity (possibly due to screen rotation) - return; - } - String title = mFavorite ? getString(R.string.stop_info_option_removestar) : getString(R.string.stop_info_option_addstar); @@ -749,7 +727,6 @@ public void showListItemMenu(View v, final ArrivalInfo arrivalInfo) { List icons = UIUtils.buildTripOptionsIcons(isRouteFavorite, hasUrl, occupancy); ListAdapter adapter = new ArrayAdapterWithIcon(getActivity(), items, icons); - final boolean isSocialEnabled = EmbeddedSocialUtils.isSocialEnabled(); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { @@ -806,14 +783,8 @@ public void onClick(DialogInterface dialog, int which) { InfrastructureIssueActivity.startWithService(getActivity(), intent, getString(R.string.ri_selected_service_trip), arrivalInfo.getInfo(), agencyName, blockId); - } else if (isSocialEnabled && ((!hasUrl && which == 6) || (hasUrl && which == 7))) { - ObaAnalytics.reportUiEvent(mFirebaseAnalytics, - getActivity().getString(R.string.analytics_label_button_press_social_route_options), - null); - openRouteDiscussion(arrivalInfo.getInfo().getRouteId()); } else if (occupancy != null && - (((!hasUrl && !isSocialEnabled && which == 6) || (hasUrl && !isSocialEnabled && which == 7)) || - ((!hasUrl && isSocialEnabled && which == 7) || (hasUrl && isSocialEnabled && which == 8)))) { + ((!hasUrl && which == 6) || (hasUrl && which == 7))) { ObaAnalytics.reportUiEvent(mFirebaseAnalytics, getActivity().getString(R.string.analytics_label_button_press_about_occupancy), null); @@ -826,63 +797,6 @@ public void onClick(DialogInterface dialog, int which) { dialog.show(); } - /** - * Opens the discussion item related to this route ID - * @param routeId route ID to use - */ - public void openRouteDiscussion(String routeId) { - String discussionTitle = ""; - ObaRegion region = Application.get().getCurrentRegion(); - if (region != null) { - discussionTitle = EmbeddedSocialUtils.createRouteDiscussionTitle(region.getId(), routeId); - } - openDiscussion(discussionTitle); - } - - /** - * Opens the discussion item related to the currently selected stop - */ - public void openStopDiscussion() { - String discussionTitle = ""; - ObaRegion region = Application.get().getCurrentRegion(); - if (region != null) { - discussionTitle = EmbeddedSocialUtils.createStopDiscussionTitle(region.getId(), getStopId()); - } - openDiscussion(discussionTitle); - } - - /** - * Opens a discussion item in an ArrivalsListActivity - * @param discussionTitle title of the Embedded Social topic - */ - private void openDiscussion(String discussionTitle) { - if (getActivity() instanceof ArrivalsListActivity) { - // do not create a new instance of ArrivalsListActivity - if (getFragmentManager().findFragmentByTag(discussionTitle) == null) { - // only fetch this fragment if it is not already displayed - displaySocialFragment(discussionTitle, true); - } - } else { - ArrivalsListActivity.start(getContext(), getStopId(), getStopName(), getStopDirection(), discussionTitle); - } - } - - /** - * Displays a social fragment - * @param discussionTitle title of the Embedded Social topic - * @param addToBackStack true if this transaction should be added to the back stack - */ - public void displaySocialFragment(String discussionTitle, boolean addToBackStack) { - Fragment discussionFragment = EmbeddedSocialUtils.getDiscussionFragment(discussionTitle); - - final FragmentTransaction transaction = getFragmentManager().beginTransaction(); - transaction.add(R.id.listContainer, discussionFragment, discussionTitle); - if (addToBackStack) { - transaction.addToBackStack(null); - } - transaction.commit(); - } - private void setCallbackToDialogFragment(RouteFavoriteDialogFragment routeDialog) { routeDialog.setCallback(new RouteFavoriteDialogFragment.Callback() { @Override diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListHeader.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListHeader.java index ecfdb7b80..43030caf1 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListHeader.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListHeader.java @@ -62,7 +62,6 @@ import org.onebusaway.android.io.elements.Status; import org.onebusaway.android.provider.ObaContract; import org.onebusaway.android.util.ArrivalInfoUtils; -import org.onebusaway.android.util.EmbeddedSocialUtils; import org.onebusaway.android.util.UIUtils; import java.util.ArrayList; @@ -133,11 +132,6 @@ interface Controller { * Triggers a full refresh of arrivals from the OBA server */ void refresh(); - - /** - * Opens the discussion item related to the currently selected stop - */ - void openStopDiscussion(); } private static final String TAG = "ArrivalsListHeader"; @@ -169,8 +163,6 @@ interface Controller { private ImageButton mStopFavorite; - private ImageButton mStopDiscussion; - private View mFilterGroup; private TextView mShowAllView; @@ -345,11 +337,6 @@ void initView(View view) { mEditNameView = (EditText) mView.findViewById(R.id.edit_name); mStopFavorite = (ImageButton) mView.findViewById(R.id.stop_favorite); mStopFavorite.setColorFilter(mView.getResources().getColor(R.color.header_text_color)); - mStopDiscussion = (ImageButton) mView.findViewById(R.id.stop_discussion); - mStopDiscussion.setColorFilter(mView.getResources().getColor(R.color.header_text_color)); - if (!EmbeddedSocialUtils.isSocialEnabled()) { - mStopDiscussion.setVisibility(View.GONE); - } mFilterGroup = mView.findViewById(R.id.filter_group); @@ -454,16 +441,6 @@ public void onClick(View v) { } }); - mStopDiscussion.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ObaAnalytics.reportUiEvent(mFirebaseAnalytics, - mContext.getString(R.string.analytics_label_button_press_social_stop), - null); - mController.openStopDiscussion(); - } - }); - mNameView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1417,7 +1394,6 @@ synchronized void beginNameEdit(String initial) { mNameContainerView.setVisibility(View.GONE); mFilterGroup.setVisibility(View.GONE); mStopFavorite.setVisibility(View.GONE); - mStopDiscussion.setVisibility(View.GONE); mEtaContainer1.setVisibility(View.GONE); mEtaSeparator.setVisibility(View.GONE); mEtaContainer2.setVisibility(View.GONE); @@ -1455,7 +1431,6 @@ synchronized void endNameEdit() { mNameContainerView.setVisibility(View.VISIBLE); mEditNameContainerView.setVisibility(View.GONE); mStopFavorite.setVisibility(View.VISIBLE); - mStopDiscussion.setVisibility(View.VISIBLE); mExpandCollapse.setVisibility(cachedExpandCollapseViewVisibility); mNoArrivals.setVisibility(View.VISIBLE); if (mHasError || mHasWarning) { diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java index ea66fa6a5..8c6030176 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java @@ -65,10 +65,6 @@ import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.firebase.analytics.FirebaseAnalytics; -import com.microsoft.embeddedsocial.sdk.EmbeddedSocial; -import com.microsoft.embeddedsocial.ui.fragment.ActivityFeedFragment; -import com.microsoft.embeddedsocial.ui.fragment.MyProfileFragment; -import com.microsoft.embeddedsocial.ui.fragment.PinsFragment; import com.sothree.slidinguppanel.SlidingUpPanelLayout; import org.onebusaway.android.BuildConfig; @@ -104,18 +100,14 @@ import java.util.HashMap; import java.util.List; -import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_ACTIVITY_FEED; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_HELP; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_MY_REMINDERS; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_NEARBY; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_OPEN_SOURCE; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PAY_FARE; -import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PINS; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PLAN_TRIP; -import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PROFILE; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_SEND_FEEDBACK; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_SETTINGS; -import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_SIGN_IN; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_STARRED_STOPS; import static org.onebusaway.android.ui.NavigationDrawerFragment.NavigationDrawerCallbacks; import static org.onebusaway.android.util.PermissionUtils.LOCATION_PERMISSIONS; @@ -222,12 +214,6 @@ interface SlidingPanelController { MyRemindersFragment mMyRemindersFragment; - PinsFragment mMyPinsFragment; - - ActivityFeedFragment mActivityFeedFragment; - - MyProfileFragment mMyProfileFragment; - /** * Control which menu options are shown per fragment menu groups */ @@ -363,9 +349,6 @@ public void onCreate(Bundle savedInstanceState) { mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); - // Workaround to make sure ES SDK is initialized in case we startup to ES Fragments (#953) - Application.get().setUpSocial(); - setContentView(R.layout.main); mActivityWeakRef = new WeakReference<>(this); @@ -522,38 +505,6 @@ private void goToNavDrawerItem(int item) { case NAVDRAWER_ITEM_PAY_FARE: UIUtils.launchPayMyFareApp(this); break; - case NAVDRAWER_ITEM_SIGN_IN: - ObaAnalytics.reportLoginEvent(mFirebaseAnalytics, - getString(R.string.analytics_login_embedded_social)); - EmbeddedSocial.launchSignInActivity(this); - break; - case NAVDRAWER_ITEM_PROFILE: - if (mCurrentNavDrawerPosition != NAVDRAWER_ITEM_PROFILE) { - showMyProfileFragment(); - mCurrentNavDrawerPosition = item; - ObaAnalytics.reportUiEvent(mFirebaseAnalytics, - getString(R.string.analytics_label_button_press_social_profile), - null); - } - break; - case NAVDRAWER_ITEM_PINS: - if (mCurrentNavDrawerPosition != NAVDRAWER_ITEM_PINS) { - showPinsFragment(); - mCurrentNavDrawerPosition = item; - ObaAnalytics.reportUiEvent(mFirebaseAnalytics, - getString(R.string.analytics_label_button_press_social_pins), - null); - } - break; - case NAVDRAWER_ITEM_ACTIVITY_FEED: - if (mCurrentNavDrawerPosition != NAVDRAWER_ITEM_ACTIVITY_FEED) { - showActivityFeedFragment(); - mCurrentNavDrawerPosition = item; - ObaAnalytics.reportUiEvent(mFirebaseAnalytics, - getString(R.string.analytics_label_button_press_social_activity_feed), - null); - } - break; case NAVDRAWER_ITEM_SETTINGS: Intent preferences = new Intent(HomeActivity.this, PreferencesActivity.class); startActivity(preferences); @@ -562,9 +513,6 @@ private void goToNavDrawerItem(int item) { null); break; case NAVDRAWER_ITEM_HELP: - if (noActiveFragments()) { - showMapFragment(); - } showDialog(HELP_DIALOG); ObaAnalytics.reportUiEvent(mFirebaseAnalytics, getString(R.string.analytics_label_button_press_help), @@ -588,11 +536,6 @@ private void goToNavDrawerItem(int item) { invalidateOptionsMenu(); } - // Return true if this HomeActivity has no active content fragments - private boolean noActiveFragments() { - return mMapFragment == null && mMyStarredStopsFragment == null && mMyRemindersFragment == null; - } - private void handleNearbySelection() { } @@ -603,9 +546,6 @@ private void showMapFragment() { */ hideStarredStopsFragment(); hideReminderFragment(); - hidePinsFragment(); - hideActivityFeedFragment(); - hideMyProfileFragment(); mShowStarredStopsMenu = false; /** * Show fragment (we use show instead of replace to keep the map state) @@ -663,9 +603,6 @@ private void showStarredStopsFragment() { hideMapFragment(); hideReminderFragment(); hideSlidingPanel(); - hidePinsFragment(); - hideActivityFeedFragment(); - hideMyProfileFragment(); mShowArrivalsMenu = false; showZoomControls(false); @@ -700,9 +637,6 @@ private void showMyRemindersFragment() { hideStarredStopsFragment(); hideMapFragment(); hideSlidingPanel(); - hidePinsFragment(); - hideActivityFeedFragment(); - hideMyProfileFragment(); mShowArrivalsMenu = false; mShowStarredStopsMenu = false; showZoomControls(false); @@ -726,114 +660,6 @@ private void showMyRemindersFragment() { setTitle(getResources().getString(R.string.navdrawer_item_my_reminders)); } - private void showPinsFragment() { - FragmentManager fm = getSupportFragmentManager(); - /** - * Hide everything that shouldn't be shown - */ - hideFloatingActionButtons(); - hideMapProgressBar(); - hideMapFragment(); - hideStarredStopsFragment(); - hideReminderFragment(); - hideActivityFeedFragment(); - hideMyProfileFragment(); - hideSlidingPanel(); - mShowArrivalsMenu = false; - showZoomControls(false); - /** - * Show fragment (we use show instead of replace to keep the map state) - */ - mShowStarredStopsMenu = false; - if (mMyPinsFragment == null) { - // First check to see if an instance of PinsFragment already exists (see #356) - mMyPinsFragment = (PinsFragment) fm - .findFragmentByTag(PinsFragment.TAG); - - if (mMyPinsFragment == null) { - // No existing fragment was found, so create a new one - Log.d(TAG, "Creating new PinsFragment"); - mMyPinsFragment = new PinsFragment(); - fm.beginTransaction().add(R.id.main_fragment_container, mMyPinsFragment, - PinsFragment.TAG).commit(); - } - } - fm.beginTransaction().show(mMyPinsFragment).commit(); - setTitle(getResources().getString(R.string.navdrawer_item_pin)); - } - - private void showActivityFeedFragment() { - FragmentManager fm = getSupportFragmentManager(); - /** - * Hide everything that shouldn't be shown - */ - hideFloatingActionButtons(); - hideMapProgressBar(); - hideMapFragment(); - hideStarredStopsFragment(); - hideReminderFragment(); - hidePinsFragment(); - hideMyProfileFragment(); - hideSlidingPanel(); - mShowArrivalsMenu = false; - showZoomControls(false); - /** - * Show fragment (we use show instead of replace to keep the map state) - */ - mShowStarredStopsMenu = false; - if (mActivityFeedFragment == null) { - // First check to see if an instance of PinsFragment already exists (see #356) - mActivityFeedFragment = (ActivityFeedFragment) fm - .findFragmentByTag(ActivityFeedFragment.TAG); - - if (mActivityFeedFragment == null) { - // No existing fragment was found, so create a new one - Log.d(TAG, "Creating new ActivityFeedFragment"); - mActivityFeedFragment = new ActivityFeedFragment(); - fm.beginTransaction().add(R.id.main_fragment_container, mActivityFeedFragment, - ActivityFeedFragment.TAG).commit(); - } - } - fm.beginTransaction().show(mActivityFeedFragment).commit(); - setTitle(getResources().getString(R.string.navdrawer_item_activity_feed)); - } - - private void showMyProfileFragment() { - FragmentManager fm = getSupportFragmentManager(); - /** - * Hide everything that shouldn't be shown - */ - hideFloatingActionButtons(); - hideMapProgressBar(); - hideMapFragment(); - hideStarredStopsFragment(); - hideReminderFragment(); - hidePinsFragment(); - hideActivityFeedFragment(); - hideSlidingPanel(); - mShowArrivalsMenu = false; - showZoomControls(false); - /** - * Show fragment (we use show instead of replace to keep the map state) - */ - mShowStarredStopsMenu = false; - if (mMyProfileFragment == null) { - // First check to see if an instance of PinsFragment already exists (see #356) - mMyProfileFragment = (MyProfileFragment) fm - .findFragmentByTag(MyProfileFragment.TAG); - - if (mMyProfileFragment == null) { - // No existing fragment was found, so create a new one - Log.d(TAG, "Creating new MyProfileFragment"); - mMyProfileFragment = new MyProfileFragment(); - fm.beginTransaction().add(R.id.main_fragment_container, mMyProfileFragment, - MyProfileFragment.TAG).commit(); - } - } - fm.beginTransaction().show(mMyProfileFragment).commit(); - setTitle(getResources().getString(R.string.navdrawer_item_profile)); - } - private void hideMapFragment() { FragmentManager fm = getSupportFragmentManager(); mMapFragment = (BaseMapFragment) fm.findFragmentByTag(BaseMapFragment.TAG); @@ -860,33 +686,6 @@ private void hideReminderFragment() { } } - private void hidePinsFragment() { - FragmentManager fm = getSupportFragmentManager(); - mMyPinsFragment = (PinsFragment) fm.findFragmentByTag( - PinsFragment.TAG); - if (mMyPinsFragment != null && !mMyPinsFragment.isHidden()) { - fm.beginTransaction().hide(mMyPinsFragment).commit(); - } - } - - private void hideActivityFeedFragment() { - FragmentManager fm = getSupportFragmentManager(); - mActivityFeedFragment = (ActivityFeedFragment) fm.findFragmentByTag( - ActivityFeedFragment.TAG); - if (mActivityFeedFragment != null && !mActivityFeedFragment.isHidden()) { - fm.beginTransaction().hide(mActivityFeedFragment).commit(); - } - } - - private void hideMyProfileFragment() { - FragmentManager fm = getSupportFragmentManager(); - mMyProfileFragment = (MyProfileFragment) fm.findFragmentByTag( - MyProfileFragment.TAG); - if (mMyProfileFragment != null && !mMyProfileFragment.isHidden()) { - fm.beginTransaction().hide(mMyProfileFragment).commit(); - } - } - private void hideSlidingPanel() { if (mSlidingPanel != null) { mSlidingPanel.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); @@ -974,9 +773,7 @@ public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: ShowcaseViewUtils.resetAllTutorials(HomeActivity.this); - mNavigationDrawerFragment.setSavedPosition(NAVDRAWER_ITEM_NEARBY); NavHelp.goHome(HomeActivity.this, true); - break; case 1: showDialog(LEGEND_DIALOG); diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java index 20028afe6..e9a45e506 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java @@ -20,12 +20,10 @@ */ package org.onebusaway.android.ui; -import com.microsoft.embeddedsocial.sdk.EmbeddedSocial; import org.onebusaway.android.R; import org.onebusaway.android.app.Application; import org.onebusaway.android.io.elements.ObaRegion; -import org.onebusaway.android.util.EmbeddedSocialUtils; import org.onebusaway.android.util.UIUtils; import org.onebusaway.android.view.ScrimInsetsScrollView; @@ -82,28 +80,15 @@ public class NavigationDrawerFragment extends Fragment { protected static final int NAVDRAWER_ITEM_SEND_FEEDBACK = 5; protected static final int NAVDRAWER_ITEM_PLAN_TRIP = 6; - - // 7 is reserved for re-adding the Embedded Social "Popular" item - See #889 - //protected static final int NAVDRAWER_ITEM_POPULAR = 7; - protected static final int NAVDRAWER_ITEM_PINS = 8; + protected static final int NAVDRAWER_ITEM_OPEN_SOURCE = 7; - protected static final int NAVDRAWER_ITEM_ACTIVITY_FEED = 9; - - protected static final int NAVDRAWER_ITEM_PROFILE = 10; - - protected static final int NAVDRAWER_ITEM_SIGN_IN = 11; - - protected static final int NAVDRAWER_ITEM_OPEN_SOURCE = 12; - - protected static final int NAVDRAWER_ITEM_PAY_FARE = 13; + protected static final int NAVDRAWER_ITEM_PAY_FARE = 8; protected static final int NAVDRAWER_ITEM_INVALID = -1; protected static final int NAVDRAWER_ITEM_SEPARATOR = -2; - protected static final int NAVDRAWER_ITEM_SEPARATOR_SPECIAL = -3; - // Currently selected navigation drawer item (must be value of one of the constants above) private int mCurrentSelectedPosition = NAVDRAWER_ITEM_NEARBY; @@ -116,11 +101,6 @@ public class NavigationDrawerFragment extends Fragment { R.string.navdrawer_item_help, R.string.navdrawer_item_send_feedback, R.string.navdrawer_item_plan_trip, - R.string.navdrawer_item_popular, - R.string.navdrawer_item_pin, - R.string.navdrawer_item_activity_feed, - R.string.navdrawer_item_profile, - R.string.navdrawer_item_sign_in, R.string.navdrawer_item_open_source, R.string.navdrawer_item_pay_fare }; @@ -134,11 +114,6 @@ public class NavigationDrawerFragment extends Fragment { 0, // Help 0, // Send feedback R.drawable.ic_maps_directions, // Plan a trip - R.drawable.ic_drawer_popular, // Popular discussions - R.drawable.ic_drawer_pin, // Pinned discussions - R.drawable.ic_drawer_activity_feed, // Social activity feed - R.drawable.ic_username, // My profile - R.drawable.ic_username, // Sign in R.drawable.ic_drawer_github, // Open-source R.drawable.ic_payment // Pay my fare }; @@ -152,11 +127,6 @@ public class NavigationDrawerFragment extends Fragment { 0, // Help 0, // Send feedback 0, // Plan a trip - 0, // Popular discussions - 0, // Pinned discussions - 0, // Social activity feed - 0, // My profile - 0, // Sign in R.drawable.ic_drawer_link, // Open-source R.drawable.ic_drawer_link // Pay my fare }; @@ -310,7 +280,7 @@ public void run() { */ public void selectItem(int position) { setSelectedNavDrawerItem(position); - if (mDrawerLayout != null && mFragmentContainerView != null) { + if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(mFragmentContainerView); } if (mCallbacks != null) { @@ -373,15 +343,6 @@ public void onSaveInstanceState(Bundle outState) { @Override public void onResume() { super.onResume(); - if (EmbeddedSocialUtils.isSocialEnabled()) { - isSignedIn = EmbeddedSocial.isSignedIn(); - - // Do not allow unauthenticated users access fragments which require - // authentication via the back button - if(!isSignedIn && requiresSocialSignIn(mCurrentSelectedPosition)) { - selectItem(NAVDRAWER_ITEM_NEARBY); - } - } populateNavDrawer(); } @@ -435,20 +396,6 @@ public void populateNavDrawer() { if (!TextUtils.isEmpty(currentRegion.getPaymentAndroidAppId())) { mNavDrawerItems.add(NAVDRAWER_ITEM_PAY_FARE); } - - if (EmbeddedSocialUtils.isSocialEnabled()) { - // Social items - mNavDrawerItems.add(NAVDRAWER_ITEM_SEPARATOR_SPECIAL); - if (isSignedIn) { - // user is signed in to Embedded Social - mNavDrawerItems.add(NAVDRAWER_ITEM_PINS); - mNavDrawerItems.add(NAVDRAWER_ITEM_ACTIVITY_FEED); - mNavDrawerItems.add(NAVDRAWER_ITEM_PROFILE); - } else { - // user is not signed in - mNavDrawerItems.add(NAVDRAWER_ITEM_SIGN_IN); - } - } } mNavDrawerItems.add(NAVDRAWER_ITEM_SEPARATOR); @@ -476,20 +423,10 @@ private void createNavDrawerItems() { findViewById(R.id.navdrawer_items_list); containerLayout.removeAllViews(); - if (EmbeddedSocialUtils.isSocialEnabled() && isSignedIn) { - // user is signed in to Embedded Social - for (int itemId : mNavDrawerItems) { - mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, containerLayout); - containerLayout.addView(mNavDrawerItemViews[i]); - ++i; - } - } else { - // user is not signed in - for (int itemId : mNavDrawerItems) { - mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, containerLayout); - containerLayout.addView(mNavDrawerItemViews[i]); - ++i; - } + for (int itemId : mNavDrawerItems) { + mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, containerLayout); + containerLayout.addView(mNavDrawerItemViews[i]); + ++i; } } @@ -498,8 +435,6 @@ private View makeNavDrawerItem(final int itemId, ViewGroup container) { int layoutToInflate; if (itemId == NAVDRAWER_ITEM_SEPARATOR) { layoutToInflate = R.layout.navdrawer_separator; - } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) { - layoutToInflate = R.layout.navdrawer_separator_special; } else { layoutToInflate = R.layout.navdrawer_item; } @@ -586,7 +521,7 @@ private void formatNavDrawerItem(View view, int itemId, boolean selected) { } private boolean isSeparator(int itemId) { - return itemId == NAVDRAWER_ITEM_SEPARATOR || itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL; + return itemId == NAVDRAWER_ITEM_SEPARATOR; } /** @@ -604,19 +539,6 @@ private boolean isNewActivityItem(int itemId) { itemId == NAVDRAWER_ITEM_SEND_FEEDBACK || itemId == NAVDRAWER_ITEM_PLAN_TRIP || itemId == NAVDRAWER_ITEM_PAY_FARE || - itemId == NAVDRAWER_ITEM_SIGN_IN || itemId == NAVDRAWER_ITEM_OPEN_SOURCE; } - - /** - * Returns true is this is an item that requires the user to be signed in to Embedded Social - * - * @return true if this is an item that requires the user to be signed in to Embedded Social, - * false otherwise - */ - private boolean requiresSocialSignIn(int itemId) { - return itemId == NAVDRAWER_ITEM_PINS || - itemId == NAVDRAWER_ITEM_ACTIVITY_FEED || - itemId == NAVDRAWER_ITEM_PROFILE; - } } diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/PreferencesActivity.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/PreferencesActivity.java index b8c0e0a62..2d6311b56 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/PreferencesActivity.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/PreferencesActivity.java @@ -46,7 +46,6 @@ import android.widget.Toast; import com.google.firebase.analytics.FirebaseAnalytics; -import com.microsoft.embeddedsocial.sdk.EmbeddedSocial; import org.onebusaway.android.BuildConfig; import org.onebusaway.android.R; @@ -58,7 +57,6 @@ import org.onebusaway.android.travelbehavior.utils.TravelBehaviorUtils; import org.onebusaway.android.util.BackupUtils; import org.onebusaway.android.util.BuildFlavorUtils; -import org.onebusaway.android.util.EmbeddedSocialUtils; import org.onebusaway.android.util.PermissionUtils; import org.onebusaway.android.util.ShowcaseViewUtils; @@ -172,26 +170,6 @@ public void onCreate(Bundle savedInstanceState) { mAboutPref = findPreference(getString(R.string.preferences_key_about)); mAboutPref.setOnPreferenceClickListener(this); - if (EmbeddedSocialUtils.isSocialEnabled()) { - Preference socialPref = findPreference(getString(R.string.preference_key_social)); - - if (EmbeddedSocial.isSignedIn()) { - socialPref.setSummary(R.string.preferences_screen_social_summary_signed_in); - } - - socialPref.setOnPreferenceClickListener(preference -> { - ObaAnalytics.reportUiEvent(mFirebaseAnalytics, - getString(R.string.analytics_label_button_press_social_settings), - null); - - EmbeddedSocial.launchOptionsActivity(PreferencesActivity.this); - return true; - }); - } else { - // Social is not enabled so don't show related preferences - getPreferenceScreen().removePreference(findPreference(getString(R.string.preference_key_social_category))); - } - SharedPreferences settings = Application.getPrefs(); mAutoSelectInitialValue = settings .getBoolean(getString(R.string.preference_key_auto_select_region), true); diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java index 866970b97..c342c4ee3 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java @@ -24,7 +24,6 @@ import android.location.Location; import android.os.Bundle; import android.text.TextUtils; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; @@ -259,16 +258,6 @@ public void onBackPressed() { } } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - // Ensure the software and hardware back buttons have the same behavior - onBackPressed(); - return true; - } - return super.onOptionsItemSelected(item); - } - @Override public void onTripRequestReady() { diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialAppProfile.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialAppProfile.java deleted file mode 100644 index a9bf7488c..000000000 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialAppProfile.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright (c) 2017 Microsoft Corporation -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.onebusaway.android.ui.social; - -import com.microsoft.embeddedsocial.sdk.ui.AppProfile; - -import org.onebusaway.android.R; - -public class SocialAppProfile implements AppProfile { - @Override - public int getName() { - return R.string.app_name; - } - - @Override - public int getImage() { - return R.mipmap.ic_launcher; - } -} diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialNavigationDrawerHandler.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialNavigationDrawerHandler.java deleted file mode 100644 index a24d023db..000000000 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/social/SocialNavigationDrawerHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright (c) 2017 Microsoft Corporation -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.onebusaway.android.ui.social; - -import com.microsoft.embeddedsocial.sdk.INavigationDrawerHandler; - -import org.onebusaway.android.R; -import org.onebusaway.android.ui.NavigationDrawerFragment; - -import androidx.drawerlayout.widget.DrawerLayout; -import androidx.fragment.app.Fragment; - -public class SocialNavigationDrawerHandler implements INavigationDrawerHandler { - private NavigationDrawerFragment fragment; - - @Override - public Fragment getFragment() { - fragment = new NavigationDrawerFragment(); - return fragment; - } - - @Override - public void setUp(int fragmentId, DrawerLayout drawerLayout) { - fragment.setUp(fragmentId, drawerLayout); - } - - @Override - public int getBackgroundColor() { - return R.color.navdrawer_background; - } - - @Override - public int getWidth() { - return R.dimen.navigation_drawer_width; - } - - @Override - public boolean displayToolbar() { - return true; - } -} diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/util/EmbeddedSocialUtils.java b/onebusaway-android/src/main/java/org/onebusaway/android/util/EmbeddedSocialUtils.java deleted file mode 100644 index b396e885d..000000000 --- a/onebusaway-android/src/main/java/org/onebusaway/android/util/EmbeddedSocialUtils.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2017 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onebusaway.android.util; - -import android.content.Context; -import android.os.Build; -import android.os.Bundle; -import android.os.UserManager; -import android.text.TextUtils; -import android.util.Base64; - -import com.microsoft.embeddedsocial.autorest.models.PublisherType; -import com.microsoft.embeddedsocial.sdk.EmbeddedSocial; -import com.microsoft.embeddedsocial.server.exception.NotFoundException; - -import org.onebusaway.android.BuildConfig; -import org.onebusaway.android.R; -import org.onebusaway.android.app.Application; -import org.onebusaway.android.io.elements.ObaRegion; - -import java.util.HashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import androidx.fragment.app.Fragment; - -import static org.onebusaway.android.util.GetRestrictionsReceiver.EMBEDDED_SOCIAL_KEY; - -public class EmbeddedSocialUtils { - public static final String ROUTE = "route"; - public static final String ROUTE_DISCUSSION = ROUTE + "_%d_%s"; - public static final String STOP_DISCUSSION = "stop_%d_%s"; - private static final Pattern DISALLOWED_CHARS = Pattern.compile("[\\\\#%+/?\u0000-\u001F\u007F-\u009F]"); - - /** - * Generates the topic name for the given route in a region - * @param regionId the current region - * @param routeId the route ID - * @return topic name - */ - public static String createRouteDiscussionTitle(long regionId, String routeId) { - String title = String.format(ROUTE_DISCUSSION, regionId, routeId); - return sanitizeDiscussionTitle(title); - } - - /** - * Generates the topic name for the given stop in a region - * @param regionId the current region - * @param stopId the stop ID - * @return topic name - */ - public static String createStopDiscussionTitle(long regionId, String stopId) { - String title = String.format(STOP_DISCUSSION, regionId, stopId); - return sanitizeDiscussionTitle(title); - } - - private static String sanitizeDiscussionTitle(String discussionTitle) { - StringBuffer safeDiscussionTitle = new StringBuffer(); - Matcher matcher = DISALLOWED_CHARS.matcher(discussionTitle); - while (matcher.find()) { - String found = matcher.group(); - byte[] encoding = Base64.encode(found.getBytes(), Base64.NO_WRAP); - String converted = new String(encoding); - converted = converted.replace('/', '_'); - matcher.appendReplacement(safeDiscussionTitle, converted); - } - matcher.appendTail(safeDiscussionTitle); - - return safeDiscussionTitle.toString(); - } - - /** - * Checks if this topic is about a route - * @param discussionTitle topic name - * @return true if this topic is about a bus route; false otherwise - */ - public static boolean isRouteDiscussion(String discussionTitle) { - return discussionTitle.contains(EmbeddedSocialUtils.ROUTE); - } - - /** - * Fetches the fragment associated with this topic - * @param discussionTitle topic name - * @return CommentFeedFragment associated with this topic name - */ - public static Fragment getDiscussionFragment(String discussionTitle) { - HashMap errorStrings = new HashMap<>(); - errorStrings.put(NotFoundException.STATUS_CODE, isRouteDiscussion(discussionTitle) ? - R.string.es_missing_route_conversation : R.string.es_missing_stop_conversation); - - return EmbeddedSocial.getCommentFeedFragmentByName(discussionTitle, PublisherType.APP, errorStrings); - } - - /** - * Returns true if social features are restricted - */ - private static boolean isSocialRestricted() { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { - // min sdk version for user restrictions - Context context = Application.get().getApplicationContext(); - Bundle restrictionsBundle = ((UserManager)context.getSystemService(Context.USER_SERVICE)) - .getApplicationRestrictions(context.getPackageName()); - if (restrictionsBundle == null) { - restrictionsBundle = new Bundle(); - } - - if (restrictionsBundle.containsKey(EMBEDDED_SOCIAL_KEY)) { - return !restrictionsBundle.getBoolean(EMBEDDED_SOCIAL_KEY); - } - } - - return false; - } - - /** - * Returns true if the build version meets min sdk level for Embedded Social - */ - public static boolean isBuildVersionSupportedBySocial() { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; - } - - /** - * Returns true if the Embedded Social api key is non-empty - */ - public static boolean isSocialApiKeyDefined() { - String embeddedSocialApiKey = BuildConfig.EMBEDDED_SOCIAL_API_KEY; - return embeddedSocialApiKey != null && embeddedSocialApiKey.length() != 0; - } - - /** - * Returns true if social features are enabled - */ - public static boolean isSocialEnabled() { - if (!isSocialApiKeyDefined()) { - return false; - } - - if (isBuildVersionSupportedBySocial()) { - if (!TextUtils.isEmpty(Application.get().getCustomApiUrl())) { - // User has entered a custom OBA server API, which overrides the region (see #840) - return false; - } - ObaRegion currentRegion = Application.get().getCurrentRegion(); - if (currentRegion != null && currentRegion.getSupportsEmbeddedSocial()) { - return !isSocialRestricted(); - } - } - return false; - } -} diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/util/GetRestrictionsReceiver.java b/onebusaway-android/src/main/java/org/onebusaway/android/util/GetRestrictionsReceiver.java deleted file mode 100644 index 56830747b..000000000 --- a/onebusaway-android/src/main/java/org/onebusaway/android/util/GetRestrictionsReceiver.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2013-2017 The Android Open Source Project, - * Microsoft Corporation - * - * https://github.com/googlesamples/android-AppRestrictions/blob/master/Application/src/main/java/com/example/android/apprestrictions/GetRestrictionsReceiver.java - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onebusaway.android.util; - -import org.onebusaway.android.R; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.RestrictionEntry; -import android.content.res.Resources; -import android.os.Bundle; - -import java.util.ArrayList; - -@TargetApi(18) // Restricted profiles introduced in API 18 -public class GetRestrictionsReceiver extends BroadcastReceiver { - public static final String EMBEDDED_SOCIAL_KEY = "embedded_social_enabled"; - - @Override - public void onReceive(final Context context, Intent intent) { - final PendingResult result = goAsync(); - final Bundle existingRestrictions = - intent.getBundleExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE); - new Thread() { - public void run() { - createRestrictions(context, result, existingRestrictions); - } - }.start(); - } - - private static RestrictionEntry createSocialRestriction(Resources res) { - RestrictionEntry socialRestriction = new RestrictionEntry(EMBEDDED_SOCIAL_KEY, true); - socialRestriction.setType(RestrictionEntry.TYPE_BOOLEAN); - socialRestriction.setTitle(res.getString(R.string.embedded_social_restriction)); - - return socialRestriction; - } - - private ArrayList initRestrictions(Context context) { - ArrayList newRestrictions = new ArrayList<>(); - Resources res = context.getResources(); - - newRestrictions.add(createSocialRestriction(res)); - - return newRestrictions; - } - - private void createRestrictions(Context context, PendingResult result, - Bundle existingRestrictions) { - ArrayList newEntries = initRestrictions(context); - - // If app restrictions were not previously configured for the package, create the default - // restrictions entries and return them. - if (existingRestrictions == null) { - finishBroadcast(result, newEntries); - return; - } - - // Retains current restriction settings by transferring existing restriction entries to - // new ones. - for (RestrictionEntry entry : newEntries) { - final String key = entry.getKey(); - if (EMBEDDED_SOCIAL_KEY.equals(key)) { - entry.setSelectedState(existingRestrictions.getBoolean(EMBEDDED_SOCIAL_KEY)); - } - } - - finishBroadcast(result, newEntries); - } - - private void finishBroadcast(PendingResult result, ArrayList newEntries) { - Bundle extras = new Bundle(); - extras.putParcelableArrayList(Intent.EXTRA_RESTRICTIONS_LIST, newEntries); - result.setResult(Activity.RESULT_OK, null, extras); - result.finish(); - } -} diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java b/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java index 001141993..18617fc02 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java @@ -464,7 +464,6 @@ public static ArrayList getRegionsFromProvider(Context context) { c.getString(12), // OTP Base URL c.getString(13), // OTP Contact Email c.getInt(14) > 0, // Supports Otp Bikeshare - c.getInt(15) > 0, // Supports Embedded Social c.getString(16), // Android App ID for mobile fare payment app of region c.getString(17), // Payment Warning Title c.getString(18), // Payment Warning Body @@ -653,7 +652,6 @@ public static ObaRegion getRegionFromBuildFlavor() { BuildConfig.FIXED_REGION_OTP_BASE_URL, BuildConfig.FIXED_REGION_OTP_CONTACT_EMAIL, BuildConfig.FIXED_REGION_SUPPORTS_OTP_BIKESHARE, - BuildConfig.FIXED_REGION_SUPPORTS_EMBEDDEDSOCIAL, BuildConfig.FIXED_REGION_PAYMENT_ANDROID_APP_ID, BuildConfig.FIXED_REGION_PAYMENT_WARNING_TITLE, BuildConfig.FIXED_REGION_PAYMENT_WARNING_BODY, diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/util/UIUtils.java b/onebusaway-android/src/main/java/org/onebusaway/android/util/UIUtils.java index 34e8de655..34370e762 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/util/UIUtils.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/util/UIUtils.java @@ -1279,11 +1279,6 @@ public static List buildTripOptions(Context c, boolean isRouteFavorite, list.add(c.getString(R.string.bus_options_menu_report_trip_problem)); - ObaRegion currentRegion = Application.get().getCurrentRegion(); - if (currentRegion != null && EmbeddedSocialUtils.isSocialEnabled()) { - list.add(c.getString(R.string.join_discussion)); - } - if (occupancy != null) { if (occupancyState == OccupancyState.HISTORICAL) { list.add(c.getString(R.string.menu_title_about_historical_occupancy)); @@ -1320,10 +1315,6 @@ public static List buildTripOptionsIcons(boolean isRouteFavorite, boole list.add(R.drawable.ic_notification_event_note); } list.add(R.drawable.ic_alert_warning); - ObaRegion currentRegion = Application.get().getCurrentRegion(); - if (currentRegion != null && EmbeddedSocialUtils.isSocialEnabled()) { - list.add(R.drawable.es_ic_comment); - } if (occupancy != null) { list.add(R.drawable.ic_occupancy); } diff --git a/onebusaway-android/src/main/res/drawable-hdpi/es_ic_comment.png b/onebusaway-android/src/main/res/drawable-hdpi/es_ic_comment.png deleted file mode 100644 index 64e548e0571cc751871dc6ed69cbba1d3be35b61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 450 zcmV;z0X_bSP)gV3)>VE4CPn|lS=lp)1=RDN&Ptx$sa~ld6MB^W?|AuoM;ufW!Cbr`M zuW3>x#w+>J8-NDvbJwoBs&;T&iI-SD~evF;ouLP{n?4EC>4{ku#qgVns5FwtOTt&8VT#d zR1mBq5_W{uAlMRSqhNQq3WD87?pRB@L`I|~5;l$QAXr}{tTT=3T+Z^8Ji(sw2zyR< zzFfgxu!XbVHh&SjxcLKA36}}=@*CJA*3+q9%v1BPW3AGt@3Nh?_YKQ=IzG1XkWkh9 s`TbJLXKbVrmh!Y?{aHV<_0*Fw?@_~QnMtR@)Bpeg07*qoM6N<$f&^Q^4FCWD diff --git a/onebusaway-android/src/main/res/drawable-mdpi/es_ic_comment.png b/onebusaway-android/src/main/res/drawable-mdpi/es_ic_comment.png deleted file mode 100644 index d5a1d7fc713b53a5deef3b2a6f6902b80693463a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~%1|*NXY)uAIY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPdqmZbujJ@`)(?Fq{o-U3d9>?EKvE^bi6mXlb6j8~T zt4!lYx8fsW)@Y=s-K{!la-wQkatgG#K}Xqc5G-doz2g0 z(>))AubDFQdV}SKpleH~F{CT7yjxZLldHf~Eb~zj+oiHKLF)XE-fC&hS|C~=r1F+| zvrRi+5sTTO%iW5>2?`7*_bf{$Xcq`NtWtBFc&RCQVMybq`t%@Ah7#5Z%X(uBKL|KH zT0b?LbP0l+XkKCOUaj diff --git a/onebusaway-android/src/main/res/drawable-xhdpi/es_ic_comment.png b/onebusaway-android/src/main/res/drawable-xhdpi/es_ic_comment.png deleted file mode 100644 index 88741981d7a30e916f4a725d6abd18761eaec839..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 401 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nC-wj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&pI!QAku+NAlCFbOr`SIZqeIkc@k8Z&-IRISL&6_UjUbkZXgLAW87qGTCJe&W$lHu6_h8wDpKX`Q-7AKpsu3FY1w4p?xuupS_gB73h zqpbM6Us3PtIW2C_SDWC#ppwiaD4DOYQzZM_fm@&UopQKlmcnMD;~eJjR5#jN(N5-D z)t3@c{?7Yub6-s{S!>$qw)pI?%ZJwq%#EsYpJ%m|>GaZIZ^cQ=!+KlnPX?*{=kj2v z$;j3`;(y|v_=y|rCj@>><&$JQo8Eh0e!>5w1B^EqZb#3*>8WVDK)W`}vfG2HP%4qD sP%e>4u(5(gu=#_SfV#`#ixty_nLDS?ZGRQl01P|^Pgg&ebxsLQ0Cq{5`~Uy| diff --git a/onebusaway-android/src/main/res/drawable-xxhdpi/es_ic_comment.png b/onebusaway-android/src/main/res/drawable-xxhdpi/es_ic_comment.png deleted file mode 100644 index 2079a9899a20a2414dcfe8eb82a6b9c21e92e62a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmV-$0+0QPP)002t}1^@s6I8J)%00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru;sFvB6a-@i)LH-l0sTot zK~#9!?VG(XLs1xqpMLqMXh}p2V)YN$n2a@unLofJCYz+AiH*c;u-WYfj8+3NNQk5@ z6|LLU&?|Is?!9%=p7#Ep0K*YK=PFI$11JF% zTVI+6R)JIC0r30>_50-k_rM8I08%zY?Ep^$BIvK{5!m{VumrFMJP)|2-@*zeA<2Lq zwE;}Uq<_x<>p-p(S(Ct0%oe;we-Vo;D+f%+Ox7$g(uu503`ePyX)H==)C`YgNtR^w zoV4Y=mgiuM85d<$OfyOksoN5!GL$UIk}S#6=n%*_tv8PY8)MpXmd+`&q7A05k#JE~ z6ftmlPoirz&3Ex%?ZBWxC0J>W1!rv?M?+a0QUPxRKsuP zR({?O`&#)8C}KEz76-!0DgtA1Z+bzps=g=@Agkny%1TqPtRk&r!NMTRQ|X11^<8=? zsWHp?ROyA6Rn)W}EUT;@^@FMZ2A?g(896Xj4-wsinMo zpw^iE@8w$`ED+)3v}tEB%P>#{A$7q4aprWt;LMS7sZ5fbgX#@95%;M>oTN)feZ2un z_wJT4;N8R}~QBv zSi;E^0-0-Sk0Kq-AgwsokP-_Qpgqhr=2Add#X^r5Z#^S}4#k7iiD_jib{^85`FylE z5XHyN{!gI|v0+bNiR_UEY8>_T2B_YcMMD(g`(pe|bMXh#^dx;B0DR%qlmHdLGcQ61Sb-@abf6t*1$aBN&fGw9 zNiMthm)n^P4+4_UWp^*Rad^F62PvvUB!UFgAE3kGFiAlA$Rtvhfb_AGNXG=EkEJc7 zkc+exq|mzd&v0&$9)qYsmT}bh#hO%jn?Vk7AjX(UGcSQ0<1|7NJ;$jx0c8+zEes;&(g0@Ptnd-}dNg?IMVA;8NwT;>UngsCP75 zB83fv7tiYc(o?KKgHVtJ5zhaeigC?lh-V3ME*S&7MWV`}bIs}<+Vf08AzI>WN^ojh zc*xN>gDN(4J6lA01yphm9==kUX_tx$2#Ydwqz9#iFDP%$gP!7@Pva(WjUB=!bJx6M@qED~t9Vys=7FgP>|;J0zx#5{iG+2br@qfA-x#ZQZ zcZ`Ozd@Kx10u2l-3Ji=K4jdo?%-^!Q;!e@0_0PAb@0T&Dd%fH8Z%=Jp?q8RS%3JFy z!x>g}?K%3VRrc?vR;iSh5TA*0+$&e;ZDR{6%#D*?dBSpq`!0rzU0>U8u3)=h;wSNI zo*BEyr0?s~v@JXv*-p;?^ZT(_!6e3BmH#U{U5@PZ=Gtz&hEvOfXU?ti?QPaf7RoZB zDr)CKjnplj=V+*K_NB}yIcA}>L_$Vy(rJeF)+LRH9g9v`JZxFto3VAXhs&IJE{`ZZG+BJ_<$hoR|g077(TdJY<_-E?4~=;B8mK!Oa9AGkziC){-cmA zQXi1Bkxl)57H4t6$s&HJ>1-3fZ#s1Lw)PQKZ?=_^?^8=F^-lwtP}!#^O7&lJ{&@2_ z(zNm8s^@cGubj+zzIM7!^9iW){;=mZANiCpAwrK===4O#M?0ANc!dsYZ(ysDc=CQP zgZF{n{ObSrEDgBleEa0PGjIR=zcIT?zq8(9W-s}F(^s|2PUHHgq)y=@5{*p~$^in& zEL=%F4vsy78XbmAtcGq26pnF-V3RbG@cJ=J?e6}!1|6U%@eKXVHf3v^^L9=v4PZiG N@O1TaS?83{1OU*n^C|!U diff --git a/onebusaway-android/src/main/res/layout/arrivals_list_header.xml b/onebusaway-android/src/main/res/layout/arrivals_list_header.xml index 259e699e6..92e79c367 100644 --- a/onebusaway-android/src/main/res/layout/arrivals_list_header.xml +++ b/onebusaway-android/src/main/res/layout/arrivals_list_header.xml @@ -221,25 +221,6 @@ android:adjustViewBounds="true" android:padding="5dp"/> - - - - - - - - - - - - - - \ No newline at end of file diff --git a/onebusaway-android/src/main/res/layout/stop_list_item.xml b/onebusaway-android/src/main/res/layout/stop_list_item.xml index 9543e1335..56e58773f 100644 --- a/onebusaway-android/src/main/res/layout/stop_list_item.xml +++ b/onebusaway-android/src/main/res/layout/stop_list_item.xml @@ -60,19 +60,4 @@ android:layout_height="wrap_content"> - - diff --git a/onebusaway-android/src/main/res/raw/embedded_social_config b/onebusaway-android/src/main/res/raw/embedded_social_config deleted file mode 100644 index 601957713..000000000 --- a/onebusaway-android/src/main/res/raw/embedded_social_config +++ /dev/null @@ -1,30 +0,0 @@ -{ - "application" : { - "serverUrl" : "https://api.embeddedsocial.microsoft.com/", - "appKey" : "AppKey", - "numberOfCommentsToShow" : 20, - "numberOfRepliesToShow" : 20, - "searchEnabled" : "false", - "showGalleryView" : "false", - "userTopicsEnabled" : "false", - "userRelationsEnabled" : "false", - "disableNavigationDrawerForActivities" : ["Options", "SignIn", "MyProfile"] - }, - "idProviders" : { - "facebook" : { - "loginEnabled" : "true", - "clientId" : "112374949346978" - }, - "google" : { - "loginEnabled" : "true", - "clientId" : "1083736323923-0u4ns2rkmbar7taqetottco4oe0q36d5.apps.googleusercontent.com" - }, - "microsoft" : { - "loginEnabled" : "true", - "clientId" : "95ccb13b-f48b-47c5-9c73-bb0e9d25980b" - }, - "twitter" : { - "loginEnabled" : "false" - } - } -} diff --git a/onebusaway-android/src/main/res/values-es/strings.xml b/onebusaway-android/src/main/res/values-es/strings.xml index 193506dd3..63f7b0b05 100644 --- a/onebusaway-android/src/main/res/values-es/strings.xml +++ b/onebusaway-android/src/main/res/values-es/strings.xml @@ -24,11 +24,6 @@ Cerca Paradas favoritas Mis recordatorios - Mi Perfil - Iniciar Sesión - Popular - Mis Guardados - Actividad Reciente Configuración Ayuda Enviar comentarios @@ -449,10 +444,6 @@ Activando una notificación para su recordatorio… Descartando tu recordatorio… - - Social - Ingresa a la discución - Descripción del problema (opcional) Enviar @@ -556,7 +547,6 @@ Pantalla Respaldar Notificaciones - Social Avanzado Profundizar en aspectos prácticos Acerca de @@ -617,9 +607,6 @@ Guarda tus paradas y rutas favoritas y también las búsquedas recientes Restaurar desde el almacenamiento Restaurar del respaldo anterior - Social Integrado - Salir, Políticas de Privacidad, Términos y Condiciones, cuentas vinculadas, eliminar cuenta - Iniciar sesión, Políticas de Privacidad, Términos y Condiciones ¡Guardado exitosamente! No se puede guardar: %1$s ¡Esto borrará todos los datos existentes! ¿Continuar? @@ -1068,13 +1055,4 @@ Bicicleta Compartida Toca para reservar una bicicleta Toca para reservar esta bicicleta - - - Habilitar funciones sociales - No hay discusiones sociales aún disponibles para esta parada - No hay discusiones sociales aún disponibles para esta ruta - Cuenta Social Integrada creada - Sesión Iniciada en Social Integrada - Sesión Cerrada en Social Integrada - Cuenta Social Integrada eliminada diff --git a/onebusaway-android/src/main/res/values/colors.xml b/onebusaway-android/src/main/res/values/colors.xml index 187d02c2e..3c610159d 100644 --- a/onebusaway-android/src/main/res/values/colors.xml +++ b/onebusaway-android/src/main/res/values/colors.xml @@ -111,17 +111,6 @@ #FF777777 #3a4677 - - #ff999999 - @color/theme_primary - @color/theme_primary - @color/theme_primary - @color/header_text_color - @color/header_text_color - @color/header_text_faded_color - @color/header_text_color - @color/theme_primary_dark - @color/material_gray #dfffffff diff --git a/onebusaway-android/src/main/res/values/donottranslate.xml b/onebusaway-android/src/main/res/values/donottranslate.xml index a30506900..d0f59dc34 100644 --- a/onebusaway-android/src/main/res/values/donottranslate.xml +++ b/onebusaway-android/src/main/res/values/donottranslate.xml @@ -59,8 +59,6 @@ preference_vibrate_allowed preference_key_nav_test_id preference_never_show_change_location_mode_dialog - preference_category_social - preference_social never_show_payment_warning_dialog preferences_key_user_debugging_logs_category preferences_user_share_logs @@ -190,17 +188,7 @@ destination_reminder_exit_at_next_stop destination_reminder_ended - - Clicked Social Sign In - Clicked Social Profile - Clicked Social Popular Feed - Clicked Social Pins - Clicked Social Activity Feed - Clicked Social Settings - Clicked Social Stop Arrivals Header - Clicked Social Route Options - Clicked Social Route Style B Card - embedded_social + Clicked About Occupancy diff --git a/onebusaway-android/src/main/res/values/strings.xml b/onebusaway-android/src/main/res/values/strings.xml index f602a933f..cfc294302 100644 --- a/onebusaway-android/src/main/res/values/strings.xml +++ b/onebusaway-android/src/main/res/values/strings.xml @@ -24,11 +24,6 @@ Nearby Starred stops My reminders - My profile - Sign in - Popular - My pins - Activity feed Settings Help Send feedback @@ -505,10 +500,6 @@ Triggering a notification for your reminder… Dismissing your reminder… - - Social - Join discussion - Problem description (optional) Send @@ -612,7 +603,6 @@ Display Backup Notifications - Social Advanced Dig deeper into the nuts and bolts About @@ -673,9 +663,6 @@ Saves your starred and recent stops and routes Restore from storage Restores from previous save - Embedded Social - Sign out, privacy policy, terms and conditions, linked accounts, delete account - Sign in, privacy policy, terms and conditions Saved successfully! Unable to save: %1$s This will wipe out any existing data! Go ahead? @@ -1142,15 +1129,6 @@ Tap to reserve a bike Tap to reserve this bike - - Enable social features - Social discussion not yet available for this stop - Social discussion not yet available for this route - Created Embedded Social account - Signed into Embedded Social - Signed out of Embedded Social - Embedded Social account deleted - Performance Alert! Battery optimizations are enabled for this application which may decrease the performance of the application. To get the best experience diff --git a/onebusaway-android/src/main/res/xml/preferences.xml b/onebusaway-android/src/main/res/xml/preferences.xml index 21351ce27..0b95da7d5 100644 --- a/onebusaway-android/src/main/res/xml/preferences.xml +++ b/onebusaway-android/src/main/res/xml/preferences.xml @@ -96,13 +96,6 @@ android:title="@string/preferences_restore_title" android:summary="@string/preferences_restore_summary"/> - - - Date: Thu, 15 Oct 2020 12:31:29 -0700 Subject: [PATCH 2/6] Ensure fragment is added to activity before preparing options menu --- .../java/org/onebusaway/android/ui/ArrivalsListFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java index 076d854fe..7c262a2e1 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java @@ -584,6 +584,11 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public void onPrepareOptionsMenu(Menu menu) { + if (!isAdded()) { + // not attached to an activity (possibly due to screen rotation) + return; + } + String title = mFavorite ? getString(R.string.stop_info_option_removestar) : getString(R.string.stop_info_option_addstar); From 015ef6d37b75254a1e0d0120d859a10e32c75fc8 Mon Sep 17 00:00:00 2001 From: acrown-msft Date: Thu, 15 Oct 2020 12:38:30 -0700 Subject: [PATCH 3/6] Keep options item override --- .../org/onebusaway/android/ui/TripPlanActivity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java index c342c4ee3..866970b97 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java @@ -24,6 +24,7 @@ import android.location.Location; import android.os.Bundle; import android.text.TextUtils; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; @@ -258,6 +259,16 @@ public void onBackPressed() { } } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + // Ensure the software and hardware back buttons have the same behavior + onBackPressed(); + return true; + } + return super.onOptionsItemSelected(item); + } + @Override public void onTripRequestReady() { From b33d8d6f0d6a83a4a53c1d6511e3c4248949f3f4 Mon Sep 17 00:00:00 2001 From: acrown-msft Date: Thu, 15 Oct 2020 13:19:10 -0700 Subject: [PATCH 4/6] Restore database and regions API --- .../java/org/onebusaway/android/mock/MockRegion.java | 8 ++++++++ .../android/io/elements/ObaRegionElement.java | 11 +++++++++-- .../org/onebusaway/android/provider/ObaContract.java | 1 + .../java/org/onebusaway/android/util/RegionUtils.java | 2 ++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java b/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java index 0edf989f0..47d4dd126 100644 --- a/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java +++ b/onebusaway-android/src/androidTest/java/org/onebusaway/android/mock/MockRegion.java @@ -90,6 +90,7 @@ public static ObaRegion getRegionWithPathNoSeparator(Context context) { null, null, false, + false, "co.bytemark.hart", null, null, @@ -129,6 +130,7 @@ public static ObaRegion getRegionNoSeparator(Context context) { null, null, false, + false, null, null, null, @@ -168,6 +170,7 @@ public static ObaRegion getRegionWithPort(Context context) { null, null, false, + false, "co.bytemark.hart", null, null, @@ -207,6 +210,7 @@ public static ObaRegion getRegionNoScheme(Context context) { null, null, false, + false, "co.bytemark.hart", null, null, @@ -246,6 +250,7 @@ public static ObaRegion getRegionWithHttps() { null, null, false, + false, "co.bytemark.hart", null, null, @@ -285,6 +290,7 @@ public static ObaRegion getRegionWithHttpsAndPort() { null, null, false, + false, "co.bytemark.hart", null, null, @@ -322,6 +328,7 @@ public static ObaRegion getRegionWithoutObaApis(Context context) { null, null, false, + false, "co.bytemark.hart", null, null, @@ -359,6 +366,7 @@ public static ObaRegion getInactiveRegion(Context context) { null, null, false, + false, "co.bytemark.hart", null, null, diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/io/elements/ObaRegionElement.java b/onebusaway-android/src/main/java/org/onebusaway/android/io/elements/ObaRegionElement.java index 9f4d9ecc6..31e31e118 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/io/elements/ObaRegionElement.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/io/elements/ObaRegionElement.java @@ -171,6 +171,10 @@ public String toString() { private final boolean supportsOtpBikeshare; + // Embedded Social is no longer supported + @Deprecated + private final boolean supportsEmbeddedSocial; + private final String paymentAndroidAppId; private final String paymentWarningTitle; @@ -200,6 +204,7 @@ public String toString() { otpBaseUrl = ""; otpContactEmail = ""; supportsOtpBikeshare = false; + supportsEmbeddedSocial = false; paymentAndroidAppId = null; paymentWarningTitle = null; paymentWarningBody = null; @@ -225,6 +230,7 @@ public ObaRegionElement(long id, String otpBaseUrl, String otpContactEmail, boolean supportsOtpBikeshare, + boolean supportsEmbeddedSocial, String paymentAndroidAppId, String paymentWarningTitle, String paymentWarningBody, @@ -248,6 +254,7 @@ public ObaRegionElement(long id, this.otpBaseUrl = otpBaseUrl; this.otpContactEmail = otpContactEmail; this.supportsOtpBikeshare = supportsOtpBikeshare; + this.supportsEmbeddedSocial = supportsEmbeddedSocial; this.paymentAndroidAppId = paymentAndroidAppId; this.paymentWarningTitle = paymentWarningTitle; this.paymentWarningBody = paymentWarningBody; @@ -347,7 +354,7 @@ public boolean getSupportsOtpBikeshare() { @Override public boolean getSupportsEmbeddedSocial() { - return false; + return supportsEmbeddedSocial; } @Override @@ -426,7 +433,7 @@ public String toString() { ", otpBaseUrl='" + otpBaseUrl + '\'' + ", otpContactEmail='" + otpContactEmail + '\'' + ", supportsOtpBikeshare='" + supportsOtpBikeshare + '\'' + - ", supportsEmbeddedSocial=" + false + '\'' + + ", supportsEmbeddedSocial=" + supportsEmbeddedSocial + '\'' + ", paymentAndroidAppId=" + paymentAndroidAppId + '\'' + ", paymentWarningTitle=" + paymentWarningTitle + '\'' + ", paymentWarningBody=" + paymentWarningBody + '\'' + diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/provider/ObaContract.java b/onebusaway-android/src/main/java/org/onebusaway/android/provider/ObaContract.java index 2c7aa94d6..218ab0290 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/provider/ObaContract.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/provider/ObaContract.java @@ -1376,6 +1376,7 @@ public static ObaRegion get(ContentResolver cr, int id) { c.getString(12), // OtpBaseUrl c.getString(13), // OtpContactEmail c.getInt(14) > 0, // Supports OTP Bikeshare + c.getInt(15) > 0, // Supports Embedded Social c.getString(16), // Payment Android App ID c.getString(17), // Payment Warning Title c.getString(18), // Payment Warning Body diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java b/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java index 18617fc02..2a0378819 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/util/RegionUtils.java @@ -464,6 +464,7 @@ public static ArrayList getRegionsFromProvider(Context context) { c.getString(12), // OTP Base URL c.getString(13), // OTP Contact Email c.getInt(14) > 0, // Supports Otp Bikeshare + c.getInt(15) > 0, // Supports Embedded Social c.getString(16), // Android App ID for mobile fare payment app of region c.getString(17), // Payment Warning Title c.getString(18), // Payment Warning Body @@ -652,6 +653,7 @@ public static ObaRegion getRegionFromBuildFlavor() { BuildConfig.FIXED_REGION_OTP_BASE_URL, BuildConfig.FIXED_REGION_OTP_CONTACT_EMAIL, BuildConfig.FIXED_REGION_SUPPORTS_OTP_BIKESHARE, + false, BuildConfig.FIXED_REGION_PAYMENT_ANDROID_APP_ID, BuildConfig.FIXED_REGION_PAYMENT_WARNING_TITLE, BuildConfig.FIXED_REGION_PAYMENT_WARNING_BODY, From 9a6a4afb491779890c64fca6e4369ffdf9aacc35 Mon Sep 17 00:00:00 2001 From: acrown-msft Date: Thu, 15 Oct 2020 13:29:10 -0700 Subject: [PATCH 5/6] Restore null check when selecting item --- .../org/onebusaway/android/ui/NavigationDrawerFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java index e9a45e506..cb4f93804 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java @@ -280,7 +280,7 @@ public void run() { */ public void selectItem(int position) { setSelectedNavDrawerItem(position); - if (mDrawerLayout != null) { + if (mDrawerLayout != null && mFragmentContainerView != null) { mDrawerLayout.closeDrawer(mFragmentContainerView); } if (mCallbacks != null) { From 0483d387de8c3c3fab50d9da6e81cedf402f030b Mon Sep 17 00:00:00 2001 From: acrown-msft Date: Thu, 15 Oct 2020 15:44:38 -0700 Subject: [PATCH 6/6] Reserve but deprecate ES values in Navigation Drawer --- .../onebusaway/android/ui/HomeActivity.java | 9 ++++ .../android/ui/NavigationDrawerFragment.java | 45 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java index 8c6030176..223e1a660 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.java @@ -100,14 +100,18 @@ import java.util.HashMap; import java.util.List; +import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_ACTIVITY_FEED; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_HELP; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_MY_REMINDERS; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_NEARBY; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_OPEN_SOURCE; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PAY_FARE; +import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PINS; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PLAN_TRIP; +import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_PROFILE; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_SEND_FEEDBACK; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_SETTINGS; +import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_SIGN_IN; import static org.onebusaway.android.ui.NavigationDrawerFragment.NAVDRAWER_ITEM_STARRED_STOPS; import static org.onebusaway.android.ui.NavigationDrawerFragment.NavigationDrawerCallbacks; import static org.onebusaway.android.util.PermissionUtils.LOCATION_PERMISSIONS; @@ -477,6 +481,11 @@ private void goToNavDrawerItem(int item) { null); } break; + // below values are deprecated; fall through to NAVDRAWER_ITEM_NEARBY + case NAVDRAWER_ITEM_SIGN_IN: + case NAVDRAWER_ITEM_PROFILE: + case NAVDRAWER_ITEM_PINS: + case NAVDRAWER_ITEM_ACTIVITY_FEED: case NAVDRAWER_ITEM_NEARBY: if (mCurrentNavDrawerPosition != NAVDRAWER_ITEM_NEARBY) { showMapFragment(); diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java b/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java index cb4f93804..2325cab4d 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/ui/NavigationDrawerFragment.java @@ -81,9 +81,22 @@ public class NavigationDrawerFragment extends Fragment { protected static final int NAVDRAWER_ITEM_PLAN_TRIP = 6; - protected static final int NAVDRAWER_ITEM_OPEN_SOURCE = 7; + //protected static final int NAVDRAWER_ITEM_POPULAR = 7; + @Deprecated + protected static final int NAVDRAWER_ITEM_PINS = 8; - protected static final int NAVDRAWER_ITEM_PAY_FARE = 8; + @Deprecated + protected static final int NAVDRAWER_ITEM_ACTIVITY_FEED = 9; + + @Deprecated + protected static final int NAVDRAWER_ITEM_PROFILE = 10; + + @Deprecated + protected static final int NAVDRAWER_ITEM_SIGN_IN = 11; + + protected static final int NAVDRAWER_ITEM_OPEN_SOURCE = 12; + + protected static final int NAVDRAWER_ITEM_PAY_FARE = 13; protected static final int NAVDRAWER_ITEM_INVALID = -1; @@ -101,6 +114,11 @@ public class NavigationDrawerFragment extends Fragment { R.string.navdrawer_item_help, R.string.navdrawer_item_send_feedback, R.string.navdrawer_item_plan_trip, + 0, // Popular discussions + 0, // Pinned discussions + 0, // Social activity feed + 0, // My profile + 0, // Sign in R.string.navdrawer_item_open_source, R.string.navdrawer_item_pay_fare }; @@ -114,6 +132,11 @@ public class NavigationDrawerFragment extends Fragment { 0, // Help 0, // Send feedback R.drawable.ic_maps_directions, // Plan a trip + 0, // Popular discussions + 0, // Pinned discussions + 0, // Social activity feed + 0, // My profile + 0, // Sign in R.drawable.ic_drawer_github, // Open-source R.drawable.ic_payment // Pay my fare }; @@ -127,6 +150,11 @@ public class NavigationDrawerFragment extends Fragment { 0, // Help 0, // Send feedback 0, // Plan a trip + 0, // Popular discussions + 0, // Pinned discussions + 0, // Social activity feed + 0, // My profile + 0, // Sign in R.drawable.ic_drawer_link, // Open-source R.drawable.ic_drawer_link // Pay my fare }; @@ -343,6 +371,10 @@ public void onSaveInstanceState(Bundle outState) { @Override public void onResume() { super.onResume(); + if (isItemDeprecated(mCurrentSelectedPosition)) { + // Prevent access of deprecated options + selectItem(NAVDRAWER_ITEM_NEARBY); + } populateNavDrawer(); } @@ -541,4 +573,13 @@ private boolean isNewActivityItem(int itemId) { itemId == NAVDRAWER_ITEM_PAY_FARE || itemId == NAVDRAWER_ITEM_OPEN_SOURCE; } + + /** + * Returns true if the item has been deprecated. + * + * @return true if the item has been deprecated, false if the item is a valid selection. + */ + public boolean isItemDeprecated(int itemId) { + return itemId >= 7 && itemId <= 11; + } }