From 550b876d599e0012a63a349d895ce1572e50775e Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Mon, 16 Aug 2021 17:30:54 +0200 Subject: [PATCH] Closes #5141: Remove FeatureFlags.isMvp --- .../focus/activity/EraseBrowsingDataTest.kt | 18 +-- .../focus/activity/MultitaskingTest.kt | 9 +- .../mozilla/focus/activity/MainActivity.kt | 7 +- .../fragment/AddToHomescreenDialogFragment.kt | 21 +-- .../mozilla/focus/fragment/BrowserFragment.kt | 30 ++-- .../focus/fragment/UrlInputFragment.kt | 18 +-- .../focus/menu/home/HomeMenuAdapter.kt | 21 +-- .../navigation/MainActivityNavigation.kt | 7 +- .../focus/settings/SettingsFragment.kt | 5 +- .../org/mozilla/focus/utils/FeatureFlags.kt | 13 -- .../java/org/mozilla/focus/utils/ViewUtils.kt | 31 +--- app/src/main/res/drawable/ic_settings.xml | 13 -- app/src/main/res/layout/fragment_urlinput.xml | 138 ------------------ 13 files changed, 30 insertions(+), 301 deletions(-) delete mode 100644 app/src/main/java/org/mozilla/focus/utils/FeatureFlags.kt delete mode 100644 app/src/main/res/drawable/ic_settings.xml delete mode 100644 app/src/main/res/layout/fragment_urlinput.xml diff --git a/app/src/androidTest/java/org/mozilla/focus/activity/EraseBrowsingDataTest.kt b/app/src/androidTest/java/org/mozilla/focus/activity/EraseBrowsingDataTest.kt index 404008f85d5..e4c999303e4 100644 --- a/app/src/androidTest/java/org/mozilla/focus/activity/EraseBrowsingDataTest.kt +++ b/app/src/androidTest/java/org/mozilla/focus/activity/EraseBrowsingDataTest.kt @@ -36,7 +36,6 @@ import org.mozilla.focus.helpers.TestHelper.verifySnackBarText import org.mozilla.focus.helpers.TestHelper.waitingTime import org.mozilla.focus.helpers.TestHelper.webPageLoadwaitingTime import org.mozilla.focus.testAnnotations.SmokeTest -import org.mozilla.focus.utils.FeatureFlags import java.io.IOException // This test erases browsing data and checks for message @@ -82,19 +81,13 @@ class EraseBrowsingDataTest { @SmokeTest @Test fun trashButtonTest() { - // Establish feedback message id - val feedbackEraseId = if (FeatureFlags.isMvp) - R.string.feedback_erase2 - else - R.string.feedback_erase - // Open a webpage searchScreen { }.loadPage(webServer.url("").toString()) { verifyPageContent("focus test page") // Press erase button, and check for message and return to the main page }.clearBrowsingData { - verifySnackBarText(getStringResource(feedbackEraseId)) + verifySnackBarText(getStringResource(R.string.feedback_erase2)) verifyEmptySearchBar() } } @@ -106,13 +99,6 @@ class EraseBrowsingDataTest { mDevice.openNotification() clearNotifications() } - - // Establish feedback message id - val feedbackEraseId = if (FeatureFlags.isMvp) - R.string.feedback_erase2 - else - R.string.feedback_erase - // Open a webpage searchScreen { }.loadPage(webServer.url("").toString()) { } @@ -124,7 +110,7 @@ class EraseBrowsingDataTest { verifySystemNotificationExists(getStringResource(R.string.notification_erase_text)) expandEraseBrowsingNotification() }.clickEraseAndOpenNotificationButton { - verifySnackBarText(getStringResource(feedbackEraseId)) + verifySnackBarText(getStringResource(R.string.feedback_erase2)) verifyEmptySearchBar() } } diff --git a/app/src/androidTest/java/org/mozilla/focus/activity/MultitaskingTest.kt b/app/src/androidTest/java/org/mozilla/focus/activity/MultitaskingTest.kt index 722ae2d5133..2db024fb16d 100644 --- a/app/src/androidTest/java/org/mozilla/focus/activity/MultitaskingTest.kt +++ b/app/src/androidTest/java/org/mozilla/focus/activity/MultitaskingTest.kt @@ -24,7 +24,6 @@ import org.mozilla.focus.helpers.TestHelper.createMockResponseFromAsset import org.mozilla.focus.helpers.TestHelper.getStringResource import org.mozilla.focus.helpers.TestHelper.verifySnackBarText import org.mozilla.focus.testAnnotations.SmokeTest -import org.mozilla.focus.utils.FeatureFlags /** * Open multiple sessions and verify that the trash icon changes to a tabs counter @@ -65,12 +64,6 @@ class MultitaskingTest { val secondPageTitle = webServer.hostName + "/tab2.html" val eraseBrowsingButtonText = getStringResource(R.string.tabs_tray_action_erase) - // Establish feedback message id - val feedbackEraseId = if (FeatureFlags.isMvp) - R.string.feedback_erase2 - else - R.string.feedback_erase - // Load website: Erase button visible, Tabs button not searchScreen { }.loadPage(firstPageUrl) { @@ -94,7 +87,7 @@ class MultitaskingTest { // Remove all tabs via the tabs tray }.eraseBrowsingHistoryFromTabsTray { - verifySnackBarText(getStringResource(feedbackEraseId)) + verifySnackBarText(getStringResource(R.string.feedback_erase2)) TestCase.assertTrue(store.state.privateTabs.isEmpty()) } } diff --git a/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt b/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt index 966e83cf384..073b6a48cdc 100644 --- a/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt +++ b/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt @@ -29,7 +29,6 @@ import org.mozilla.focus.shortcut.HomeScreen import org.mozilla.focus.state.AppAction import org.mozilla.focus.state.Screen import org.mozilla.focus.telemetry.TelemetryWrapper -import org.mozilla.focus.utils.FeatureFlags import org.mozilla.focus.utils.Settings import org.mozilla.focus.utils.SupportUtils @@ -46,11 +45,7 @@ open class MainActivity : LocaleAwareAppCompatActivity() { // Because some MVP characteristics are set from xml files we need to choose the mode of the theme // according to MVP flag and not by system theme mode - if (FeatureFlags.isMvp) { - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) - } else { - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) - } + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) if (!isTaskRoot) { if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN == intent.action) { diff --git a/app/src/main/java/org/mozilla/focus/fragment/AddToHomescreenDialogFragment.kt b/app/src/main/java/org/mozilla/focus/fragment/AddToHomescreenDialogFragment.kt index d35039f3d1f..77811ac4e55 100644 --- a/app/src/main/java/org/mozilla/focus/fragment/AddToHomescreenDialogFragment.kt +++ b/app/src/main/java/org/mozilla/focus/fragment/AddToHomescreenDialogFragment.kt @@ -14,14 +14,12 @@ import android.view.WindowManager import android.widget.Button import android.widget.EditText import android.widget.ImageView -import android.widget.LinearLayout import androidx.constraintlayout.widget.ConstraintLayout import androidx.preference.PreferenceManager import org.mozilla.focus.R import org.mozilla.focus.shortcut.HomeScreen import org.mozilla.focus.shortcut.IconGenerator import org.mozilla.focus.telemetry.TelemetryWrapper -import org.mozilla.focus.utils.FeatureFlags /** * Fragment displaying a dialog where a user can change the title for a homescreen shortcut @@ -37,12 +35,8 @@ class AddToHomescreenDialogFragment : DialogFragment() { val builder = AlertDialog.Builder(requireActivity(), R.style.DialogStyle) builder.setCancelable(true) - if (!FeatureFlags.isMvp) { - builder.setTitle(requireActivity().getString(R.string.menu_add_to_home_screen)) - } val inflater = requireActivity().layoutInflater - val layoutId = if (FeatureFlags.isMvp) R.layout.dialog_add_to_homescreen2 else R.layout.add_to_homescreen - val dialogView = inflater.inflate(layoutId, null) + val dialogView = inflater.inflate(R.layout.dialog_add_to_homescreen2, null) builder.setView(dialogView) // For the dialog we display the Pre Oreo version of the icon because the Oreo+ @@ -55,17 +49,8 @@ class AddToHomescreenDialogFragment : DialogFragment() { iconView.setImageBitmap(iconBitmap) val blockIcon = dialogView.findViewById(R.id.homescreen_dialog_block_icon) - val trackingProtectionDisabledId = if (FeatureFlags.isMvp) { - R.drawable.ic_tracking_protection_disabled2 - } else { - R.drawable.ic_tracking_protection_disabled - } - blockIcon.setImageResource(trackingProtectionDisabledId) - val warning = if (FeatureFlags.isMvp) { - dialogView.findViewById(R.id.homescreen_dialog_warning_layout) - } else { - dialogView.findViewById(R.id.homescreen_dialog_warning_layout) - } + blockIcon.setImageResource(R.drawable.ic_tracking_protection_disabled2) + val warning = dialogView.findViewById(R.id.homescreen_dialog_warning_layout) warning.visibility = if (blockingEnabled) View.GONE else View.VISIBLE val editableTitle = dialogView.findViewById(R.id.edit_title) diff --git a/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt b/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt index cf93e1ec5ce..32c813a1b85 100644 --- a/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt @@ -54,7 +54,6 @@ import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import org.mozilla.focus.R import org.mozilla.focus.activity.InstallFirefoxActivity import org.mozilla.focus.activity.MainActivity -import org.mozilla.focus.browser.BrowserMenuControllerAdapter import org.mozilla.focus.browser.DisplayToolbar import org.mozilla.focus.browser.binding.BlockingThemeBinding import org.mozilla.focus.browser.binding.TabCountBinding @@ -78,7 +77,6 @@ import org.mozilla.focus.telemetry.TelemetryWrapper import org.mozilla.focus.utils.AppPermissionCodes.REQUEST_CODE_DOWNLOAD_PERMISSIONS import org.mozilla.focus.utils.AppPermissionCodes.REQUEST_CODE_PROMPT_PERMISSIONS import org.mozilla.focus.utils.Browsers -import org.mozilla.focus.utils.FeatureFlags import org.mozilla.focus.utils.Settings import org.mozilla.focus.utils.StatusBarUtils import org.mozilla.focus.utils.SupportUtils @@ -236,9 +234,7 @@ class BrowserFragment : ) customizeToolbar(view) - if (FeatureFlags.isMvp) { - customizeFindInPage(view) - } + customizeFindInPage(view) val customTabConfig = tab.ifCustomTab()?.config if (customTabConfig != null) { @@ -269,17 +265,13 @@ class BrowserFragment : ::openInBrowser ) - if (FeatureFlags.isMvp) { - if (tab.ifCustomTab()?.config == null) { - val browserMenu = DefaultBrowserMenu( - context = requireContext(), - store = requireComponents.store, - onItemTapped = { controller.handleMenuInteraction(it) } - ) - browserToolbar.display.menuBuilder = browserMenu.menuBuilder - } - } else { - browserToolbar.display.menuController = BrowserMenuControllerAdapter(this) + if (tab.ifCustomTab()?.config == null) { + val browserMenu = DefaultBrowserMenu( + context = requireContext(), + store = requireComponents.store, + onItemTapped = { controller.handleMenuInteraction(it) } + ) + browserToolbar.display.menuBuilder = browserMenu.menuBuilder } toolbarIntegration.set( @@ -531,16 +523,12 @@ class BrowserFragment : // Notify the user their session has been erased if Talk Back is enabled: if (context != null) { val manager = context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager - val feedbackEraseId = if (FeatureFlags.isMvp) - R.string.feedback_erase2 - else - R.string.feedback_erase if (manager.isEnabled) { val event = AccessibilityEvent.obtain() event.eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT event.className = javaClass.name event.packageName = requireContext().packageName - event.text.add(getString(feedbackEraseId)) + event.text.add(getString(R.string.feedback_erase2)) } } diff --git a/app/src/main/java/org/mozilla/focus/fragment/UrlInputFragment.kt b/app/src/main/java/org/mozilla/focus/fragment/UrlInputFragment.kt index 4974381ce7a..20bbb33dfda 100644 --- a/app/src/main/java/org/mozilla/focus/fragment/UrlInputFragment.kt +++ b/app/src/main/java/org/mozilla/focus/fragment/UrlInputFragment.kt @@ -24,8 +24,8 @@ import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager import kotlinx.android.synthetic.main.firstrun_page.* import kotlinx.android.synthetic.main.firstrun_page.view.* -import kotlinx.android.synthetic.main.fragment_urlinput.* -import kotlinx.android.synthetic.main.fragment_urlinput.view.* +import kotlinx.android.synthetic.main.fragment_urlinput2.* +import kotlinx.android.synthetic.main.fragment_urlinput2.view.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers.IO @@ -56,7 +56,6 @@ import org.mozilla.focus.tips.Tip import org.mozilla.focus.tips.TipManager import org.mozilla.focus.utils.AppConstants import org.mozilla.focus.utils.Features -import org.mozilla.focus.utils.FeatureFlags import org.mozilla.focus.utils.OneShotOnPreDrawListener import org.mozilla.focus.utils.SearchUtils import org.mozilla.focus.utils.Settings @@ -295,11 +294,7 @@ class UrlInputFragment : inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? = if (FeatureFlags.isMvp) { - inflater.inflate(R.layout.fragment_urlinput2, container, false) - } else { - inflater.inflate(R.layout.fragment_urlinput, container, false) - } + ): View? = inflater.inflate(R.layout.fragment_urlinput2, container, false) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { toolbarIntegration.set( @@ -325,12 +320,7 @@ class UrlInputFragment : if (isOverlay) { keyboardLinearLayout?.visibility = View.GONE } else { - val backgroundId = if (FeatureFlags.isMvp) { - R.drawable.dark_background - } else { - R.drawable.background_gradient - } - backgroundView?.setBackgroundResource(backgroundId) + backgroundView?.setBackgroundResource(R.drawable.dark_background) dismissView?.visibility = View.GONE diff --git a/app/src/main/java/org/mozilla/focus/menu/home/HomeMenuAdapter.kt b/app/src/main/java/org/mozilla/focus/menu/home/HomeMenuAdapter.kt index 1a257d61c23..e4a2c9a5ff6 100644 --- a/app/src/main/java/org/mozilla/focus/menu/home/HomeMenuAdapter.kt +++ b/app/src/main/java/org/mozilla/focus/menu/home/HomeMenuAdapter.kt @@ -12,7 +12,6 @@ import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintLayout import kotlinx.android.synthetic.main.menu_item.view.* import org.mozilla.focus.R -import org.mozilla.focus.utils.FeatureFlags import org.mozilla.focus.whatsnew.WhatsNew /** @@ -25,19 +24,7 @@ class HomeMenuAdapter( private val listener: View.OnClickListener ) : RecyclerView.Adapter() { - private val optionalWhatsNew = if (FeatureFlags.isMvp) { - emptyList() - } else { - listOf( - MenuItem( - R.id.whats_new, - WhatsNewViewHolder.LAYOUT_ID, - context.getString(R.string.menu_whats_new) - ) - ) - } - - private val items: List = optionalWhatsNew + listOf( + private val items: List = listOf( MenuItem(R.id.help, MenuItemViewHolder.LAYOUT_ID, context.getString(R.string.menu_help)), MenuItem(R.id.settings, MenuItemViewHolder.LAYOUT_ID, context.getString(R.string.menu_settings)) ) @@ -81,11 +68,7 @@ private class MenuItemViewHolder( val iconResourceId = if (item.id == R.id.help) { R.drawable.ic_help } else { - if (FeatureFlags.isMvp) { - R.drawable.ic_settings2 - } else { - R.drawable.ic_settings - } + R.drawable.ic_settings2 } containerView.apply { id = item.id diff --git a/app/src/main/java/org/mozilla/focus/navigation/MainActivityNavigation.kt b/app/src/main/java/org/mozilla/focus/navigation/MainActivityNavigation.kt index 8eae354d072..4b64e016dc5 100644 --- a/app/src/main/java/org/mozilla/focus/navigation/MainActivityNavigation.kt +++ b/app/src/main/java/org/mozilla/focus/navigation/MainActivityNavigation.kt @@ -27,7 +27,6 @@ import org.mozilla.focus.settings.RemoveSearchEnginesSettingsFragment import org.mozilla.focus.settings.SearchSettingsFragment import org.mozilla.focus.settings.SettingsFragment import org.mozilla.focus.state.Screen -import org.mozilla.focus.utils.FeatureFlags import org.mozilla.focus.utils.ViewUtils import kotlin.collections.forEach as withEach @@ -49,12 +48,8 @@ class MainActivityNavigation( val crashReporterIsVisible = browserFragment?.crashReporterIsVisible() ?: false if (isShowingBrowser && !crashReporterIsVisible) { - val feedbackEraseId = if (FeatureFlags.isMvp) - R.string.feedback_erase2 - else - R.string.feedback_erase ViewUtils.showBrandedSnackbar(activity.findViewById(android.R.id.content), - feedbackEraseId, + R.string.feedback_erase2, activity.resources.getInteger(R.integer.erase_snackbar_delay)) } diff --git a/app/src/main/java/org/mozilla/focus/settings/SettingsFragment.kt b/app/src/main/java/org/mozilla/focus/settings/SettingsFragment.kt index 4c779351745..8ec2387cc67 100644 --- a/app/src/main/java/org/mozilla/focus/settings/SettingsFragment.kt +++ b/app/src/main/java/org/mozilla/focus/settings/SettingsFragment.kt @@ -16,7 +16,6 @@ import org.mozilla.focus.ext.requireComponents import org.mozilla.focus.state.AppAction import org.mozilla.focus.state.Screen import org.mozilla.focus.telemetry.TelemetryWrapper -import org.mozilla.focus.utils.FeatureFlags import org.mozilla.focus.utils.SupportUtils import org.mozilla.focus.whatsnew.WhatsNew @@ -66,9 +65,7 @@ class SettingsFragment : BaseSettingsFragment(), SharedPreferences.OnSharedPrefe } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - if (FeatureFlags.isMvp) { - inflater.inflate(R.menu.menu_settings_main, menu) - } + inflater.inflate(R.menu.menu_settings_main, menu) } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/org/mozilla/focus/utils/FeatureFlags.kt b/app/src/main/java/org/mozilla/focus/utils/FeatureFlags.kt deleted file mode 100644 index 8b601e045ff..00000000000 --- a/app/src/main/java/org/mozilla/focus/utils/FeatureFlags.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.mozilla.focus.utils - -import org.mozilla.focus.BuildConfig - -/** - * Feature flag for MVP - */ -object FeatureFlags { - val isMvp = BuildConfig.DEBUG -} diff --git a/app/src/main/java/org/mozilla/focus/utils/ViewUtils.kt b/app/src/main/java/org/mozilla/focus/utils/ViewUtils.kt index f63d1e84d22..fa8afb67e61 100644 --- a/app/src/main/java/org/mozilla/focus/utils/ViewUtils.kt +++ b/app/src/main/java/org/mozilla/focus/utils/ViewUtils.kt @@ -1,5 +1,4 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public +/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -9,15 +8,14 @@ import android.app.Activity import android.content.Context import android.os.Handler import android.os.Looper -import android.view.Gravity -import androidx.annotation.StringRes -import com.google.android.material.snackbar.Snackbar -import androidx.core.content.ContextCompat -import androidx.core.view.ViewCompat import android.view.MenuItem import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.TextView +import androidx.annotation.StringRes +import androidx.core.content.ContextCompat +import androidx.core.view.ViewCompat +import com.google.android.material.snackbar.Snackbar import org.mozilla.focus.R import java.lang.ref.WeakReference @@ -97,28 +95,11 @@ object ViewUtils { val snackbarView = snackbar.view val snackbarTextView = snackbarView.findViewById(R.id.snackbar_text) as TextView snackbarTextView.setTextColor(ContextCompat.getColor(context, R.color.snackbarTextColor)) - if (FeatureFlags.isMvp) { - snackbarView.setBackgroundResource(R.drawable.background_snackbar) - } else { - snackbarView.setBackgroundColor(ContextCompat.getColor(context, R.color.snackbarBackground)) - snackbarTextView.gravity = Gravity.CENTER - snackbarTextView.textAlignment = View.TEXT_ALIGNMENT_CENTER - } + snackbarView.setBackgroundResource(R.drawable.background_snackbar) view.postDelayed({ snackbar.show() }, delayMillis.toLong()) } - fun getBrandedSnackbar(view: View, @StringRes resId: Int): Snackbar { - val context = view.context - val snackbar = Snackbar.make(view, resId, Snackbar.LENGTH_LONG) - val snackbarView = snackbar.view - snackbarView.setBackgroundColor(ContextCompat.getColor(context, R.color.snackbarBackground)) - val snackbarTextView = snackbarView.findViewById(R.id.snackbar_text) - snackbarTextView.setTextColor(ContextCompat.getColor(context, R.color.snackbarTextColor)) - snackbar.setActionTextColor(ContextCompat.getColor(context, R.color.snackbarActionText)) - return snackbar - } - fun isRTL(view: View): Boolean { return ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL } diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml deleted file mode 100644 index 567091dfab5..00000000000 --- a/app/src/main/res/drawable/ic_settings.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/app/src/main/res/layout/fragment_urlinput.xml b/app/src/main/res/layout/fragment_urlinput.xml deleted file mode 100644 index 49d55f17be7..00000000000 --- a/app/src/main/res/layout/fragment_urlinput.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file