Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Closes #5141: Remove FeatureFlags.isMvp
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo authored and mergify[bot] committed Aug 16, 2021
1 parent 16e08ff commit 550b876
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
Expand All @@ -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()) { }
Expand All @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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())
}
}
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/java/org/mozilla/focus/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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+
Expand All @@ -55,17 +49,8 @@ class AddToHomescreenDialogFragment : DialogFragment() {
iconView.setImageBitmap(iconBitmap)

val blockIcon = dialogView.findViewById<ImageView>(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<ConstraintLayout>(R.id.homescreen_dialog_warning_layout)
} else {
dialogView.findViewById<LinearLayout>(R.id.homescreen_dialog_warning_layout)
}
blockIcon.setImageResource(R.drawable.ic_tracking_protection_disabled2)
val warning = dialogView.findViewById<ConstraintLayout>(R.id.homescreen_dialog_warning_layout)
warning.visibility = if (blockingEnabled) View.GONE else View.VISIBLE

val editableTitle = dialogView.findViewById<EditText>(R.id.edit_title)
Expand Down
30 changes: 9 additions & 21 deletions app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -236,9 +234,7 @@ class BrowserFragment :
)

customizeToolbar(view)
if (FeatureFlags.isMvp) {
customizeFindInPage(view)
}
customizeFindInPage(view)

val customTabConfig = tab.ifCustomTab()?.config
if (customTabConfig != null) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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))
}
}

Expand Down
18 changes: 4 additions & 14 deletions app/src/main/java/org/mozilla/focus/fragment/UrlInputFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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

Expand Down
21 changes: 2 additions & 19 deletions app/src/main/java/org/mozilla/focus/menu/home/HomeMenuAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -25,19 +24,7 @@ class HomeMenuAdapter(
private val listener: View.OnClickListener
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

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<MenuItem> = optionalWhatsNew + listOf(
private val items: List<MenuItem> = 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))
)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/org/mozilla/focus/utils/FeatureFlags.kt

This file was deleted.

Loading

0 comments on commit 550b876

Please sign in to comment.