2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/11303 - Change copy login origin to open in browser

This commit is contained in:
ekager 2020-07-07 13:31:05 -04:00 committed by Emily Kager
parent e69b1e06f1
commit ddf56f9bc6
7 changed files with 114 additions and 55 deletions

View File

@ -28,5 +28,6 @@ enum class BrowserDirection(@IdRes val fragmentId: Int) {
FromAddNewDeviceFragment(R.id.addNewDeviceFragment),
FromAddSearchEngineFragment(R.id.addSearchEngineFragment),
FromEditCustomSearchEngineFragment(R.id.editCustomSearchEngineFragment),
FromAddonDetailsFragment(R.id.addonDetailsFragment)
FromAddonDetailsFragment(R.id.addonDetailsFragment),
FromLoginDetailFragment(R.id.loginDetailFragment)
}

View File

@ -53,6 +53,7 @@ import mozilla.components.support.utils.SafeIntent
import mozilla.components.support.utils.toSafeIntent
import mozilla.components.support.webextensions.WebExtensionPopupFeature
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.addons.AddonDetailsFragmentDirections
import org.mozilla.fenix.browser.UriOpenedObserver
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager
@ -81,6 +82,7 @@ import org.mozilla.fenix.session.NotificationSessionObserver
import org.mozilla.fenix.settings.SettingsFragmentDirections
import org.mozilla.fenix.settings.TrackingProtectionFragmentDirections
import org.mozilla.fenix.settings.about.AboutFragmentDirections
import org.mozilla.fenix.settings.logins.LoginDetailFragmentDirections
import org.mozilla.fenix.settings.logins.SavedLoginsAuthFragmentDirections
import org.mozilla.fenix.settings.search.AddSearchEngineFragmentDirections
import org.mozilla.fenix.settings.search.EditCustomSearchEngineFragmentDirections
@ -165,14 +167,24 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
if (isActivityColdStarted(intent, savedInstanceState)) {
externalSourceIntentProcessors.any { it.process(intent, navHost.navController, this.intent) }
externalSourceIntentProcessors.any {
it.process(
intent,
navHost.navController,
this.intent
)
}
}
Performance.processIntentIfPerformanceTest(intent, this)
if (settings().isTelemetryEnabled) {
lifecycle.addObserver(BreadcrumbsRecorder(components.analytics.crashReporter,
navHost.navController, ::getBreadcrumbMessage))
lifecycle.addObserver(
BreadcrumbsRecorder(
components.analytics.crashReporter,
navHost.navController, ::getBreadcrumbMessage
)
)
val safeIntent = intent?.toSafeIntent()
safeIntent
@ -209,7 +221,10 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
components.backgroundServices.accountManager.initAsync().await()
// If we're authenticated, kick-off a sync and a device state refresh.
components.backgroundServices.accountManager.authenticatedAccount()?.let {
components.backgroundServices.accountManager.syncNowAsync(SyncReason.Startup, debounce = true)
components.backgroundServices.accountManager.syncNowAsync(
SyncReason.Startup,
debounce = true
)
}
}
}
@ -241,8 +256,10 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
super.onNewIntent(intent)
intent ?: return
val intentProcessors = listOf(CrashReporterIntentProcessor()) + externalSourceIntentProcessors
val intentHandled = intentProcessors.any { it.process(intent, navHost.navController, this.intent) }
val intentProcessors =
listOf(CrashReporterIntentProcessor()) + externalSourceIntentProcessors
val intentHandled =
intentProcessors.any { it.process(intent, navHost.navController, this.intent) }
browsingModeManager.mode = getModeFromIntentOrLastKnown(intent)
if (intentHandled) {
@ -474,7 +491,9 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
BrowserDirection.FromEditCustomSearchEngineFragment ->
EditCustomSearchEngineFragmentDirections.actionGlobalBrowser(customTabSessionId)
BrowserDirection.FromAddonDetailsFragment ->
EditCustomSearchEngineFragmentDirections.actionGlobalBrowser(customTabSessionId)
AddonDetailsFragmentDirections.actionGlobalBrowser(customTabSessionId)
BrowserDirection.FromLoginDetailFragment ->
LoginDetailFragmentDirections.actionGlobalBrowser(customTabSessionId)
}
private fun load(
@ -563,13 +582,14 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
@VisibleForTesting
internal fun isActivityColdStarted(startingIntent: Intent, activityIcicle: Bundle?): Boolean =
internal fun isActivityColdStarted(startingIntent: Intent, activityIcicle: Bundle?): Boolean {
// First time opening this activity in the task.
// Cold start / start from Recents after back press.
activityIcicle == null &&
// Activity was restarted from Recents after it was destroyed by Android while in background
// in cases of memory pressure / "Don't keep activities".
startingIntent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY == 0
return activityIcicle == null &&
// Activity was restarted from Recents after it was destroyed by Android while in background
// in cases of memory pressure / "Don't keep activities".
startingIntent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY == 0
}
companion object {
const val OPEN_TO_BROWSER = "open_to_browser"

View File

@ -7,12 +7,12 @@ package org.mozilla.fenix.settings.logins
import android.content.DialogInterface
import android.os.Bundle
import android.text.InputType
import android.view.MenuItem
import android.view.MenuInflater
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.LayoutInflater
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
@ -21,23 +21,26 @@ import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_login_detail.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.launch
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import mozilla.components.concept.storage.Login
import mozilla.components.lib.state.ext.consumeFrom
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.ext.redirectToReAuth
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
@ -119,6 +122,7 @@ class LoginDetailFragment : Fragment(R.layout.fragment_login_detail) {
private fun setUpPasswordReveal() {
passwordText.inputType =
InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
revealPasswordButton.increaseTapArea(BUTTON_INCREASE_DPS)
revealPasswordButton.setOnClickListener {
togglePasswordReveal()
}
@ -126,9 +130,13 @@ class LoginDetailFragment : Fragment(R.layout.fragment_login_detail) {
private fun setUpCopyButtons() {
webAddressText.text = login?.origin
copyWebAddress.setOnClickListener(
CopyButtonListener(login?.origin, R.string.logins_site_copied)
)
openWebAddress.increaseTapArea(BUTTON_INCREASE_DPS)
copyUsername.increaseTapArea(BUTTON_INCREASE_DPS)
copyPassword.increaseTapArea(BUTTON_INCREASE_DPS)
openWebAddress.setOnClickListener {
navigateToBrowser(requireNotNull(login?.origin))
}
usernameText.text = login?.username
copyUsername.setOnClickListener(
@ -189,6 +197,14 @@ class LoginDetailFragment : Fragment(R.layout.fragment_login_detail) {
else -> false
}
private fun navigateToBrowser(address: String) {
(activity as HomeActivity).openToBrowserAndLoad(
address,
newTab = true,
from = BrowserDirection.FromLoginDetailFragment
)
}
private fun editLogin() {
val directions =
LoginDetailFragmentDirections
@ -281,4 +297,8 @@ class LoginDetailFragment : Fragment(R.layout.fragment_login_detail) {
}
}
}
private companion object {
private const val BUTTON_INCREASE_DPS = 24
}
}

View File

@ -3,12 +3,12 @@
- 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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="14"
android:viewportHeight="17"
android:width="14dp"
android:height="17dp">
android:width="17dp"
android:height="20dp"
android:viewportWidth="17"
android:viewportHeight="20">
<path
android:pathData="M13.707 9.143l-3-3C10.52 5.955 10.265 5.85 10 5.85H9v-1c0-0.265-0.105-0.52-0.293-0.707l-3-3C5.52 0.955 5.265 0.85 5 0.85H2c-1.105 0-2 0.895-2 2v7c0 1.105 0.895 2 2 2h3v3c0 1.105 0.895 2 2 2h5c1.105 0 2-0.895 2-2v-5c0-0.265-0.105-0.52-0.293-0.707zM11.586 9.85H10V8.264l1.586 1.586zm-5-5H5V3.264L6.586 4.85zM5 7.85v2H2v-7h2v2.5c0 0.276 0.224 0.5 0.5 0.5H7c-1.105 0-2 0.895-2 2zm2 7v-7h2v2.5c0 0.276 0.224 0.5 0.5 0.5H12v4H7z"
android:fillColor="?primaryText"
android:fillAlpha="0.8" />
android:fillType="nonZero"
android:pathData="M10.69,3A3.313,3.313 0,0 1,14 6.31v10.38A3.313,3.313 0,0 1,10.69 20L3.31,20A3.313,3.313 0,0 1,0 16.69L0,6.31A3.313,3.313 0,0 1,3.31 3h7.38zM10.69,5L3.31,5C2.587,5 2,5.587 2,6.31v10.38c0,0.723 0.587,1.31 1.31,1.31h7.38c0.723,0 1.31,-0.587 1.31,-1.31L12,6.31C12,5.587 11.413,5 10.69,5zM10.995,0A6.003,6.003 0,0 1,17 6v0.016l-0.024,8.987a2,2 0,0 1,-2.005 1.994h-0.002l0.03,-10.986L14.999,6c0,-2.21 -1.793,-4 -4.004,-4L3,2a2,2 0,0 1,2 -2h5.995z" />
</vector>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:fillColor="?primaryText"
android:fillType="evenOdd"
android:pathData="M9,0a1.005,1.005 0,1 1,0 2.012L4.557,2.012a2.55,2.55 0,0 0,-2.547 2.547v8.883a2.55,2.55 0,0 0,2.547 2.547h8.883a2.55,2.55 0,0 0,2.547 -2.547L15.987,8.97a1.006,1.006 0,1 1,2.011 0v4.472A4.564,4.564 0,0 1,13.441 18L4.558,18A4.564,4.564 0,0 1,0 13.442L0,4.559a4.564,4.564 0,0 1,4.56 -4.56zM17,0a1,1 0,0 1,1 1v4a1,1 0,1 1,-2 0L16,3.414l-5.293,5.293a0.999,0.999 0,1 1,-1.414 -1.414L14.586,2L13,2a1,1 0,1 1,0 -2z" />
</vector>

View File

@ -2,7 +2,6 @@
<!-- 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/. -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@ -11,7 +10,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="73dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="20dp">
android:layout_marginEnd="12dp">
<TextView
android:id="@+id/webAddressHeader"
@ -25,7 +24,7 @@
android:textSize="12sp"
app:fontFamily="@font/metropolis_semibold"
app:layout_constraintBottom_toTopOf="@id/webAddressText"
app:layout_constraintEnd_toStartOf="@id/copyWebAddress"
app:layout_constraintEnd_toStartOf="@id/openWebAddress"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
@ -35,10 +34,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="?primaryText"
android:textSize="16sp"
android:paddingTop="@dimen/saved_logins_detail_menu_vertical_padding"
android:paddingBottom="@dimen/saved_logins_detail_menu_vertical_padding"
android:textColor="?primaryText"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@id/webAddressHeader"
app:layout_constraintStart_toStartOf="@id/webAddressHeader"
app:layout_constraintTop_toBottomOf="@id/webAddressHeader"
@ -46,15 +45,15 @@
tools:text="Info" />
<ImageButton
android:id="@+id/copyWebAddress"
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/openWebAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/saved_login_copy_site"
android:contentDescription="@string/saved_login_open_site"
app:layout_constraintBottom_toBottomOf="@id/webAddressText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/webAddressText"
app:srcCompat="@drawable/ic_copy"
app:srcCompat="@drawable/ic_open_in_new"
app:tint="?android:colorAccent" />
<TextView
@ -78,12 +77,12 @@
android:id="@+id/usernameText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="?primaryText"
android:textSize="16sp"
android:layout_marginTop="1dp"
android:gravity="center_vertical"
android:paddingTop="@dimen/saved_logins_detail_menu_vertical_padding"
android:paddingBottom="@dimen/saved_logins_detail_menu_vertical_padding"
android:textColor="?primaryText"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@id/usernameHeader"
app:layout_constraintStart_toStartOf="@id/usernameHeader"
app:layout_constraintTop_toBottomOf="@id/usernameHeader"
@ -92,12 +91,13 @@
<ImageButton
android:id="@+id/copyUsername"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/saved_login_copy_username"
app:layout_constraintBottom_toBottomOf="@id/usernameText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toEndOf="@id/openWebAddress"
app:layout_constraintStart_toStartOf="@id/openWebAddress"
app:layout_constraintTop_toTopOf="@id/usernameText"
app:srcCompat="@drawable/ic_copy"
app:tint="?android:colorAccent" />
@ -106,12 +106,12 @@
android:id="@+id/passwordHeader"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_marginTop="12dp"
android:gravity="center_vertical"
android:letterSpacing="0.05"
android:text="@string/preferences_passwords_saved_logins_password"
android:textColor="?primaryText"
android:textSize="12sp"
android:layout_marginTop="12dp"
app:fontFamily="@font/metropolis_semibold"
app:layout_constraintBottom_toTopOf="@id/passwordText"
app:layout_constraintEnd_toStartOf="@id/revealPasswordButton"
@ -123,14 +123,14 @@
android:id="@+id/passwordText"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginTop="2dp"
android:gravity="center_vertical"
android:letterSpacing="0.01"
android:lineSpacingExtra="8sp"
android:layout_marginTop="2dp"
android:textColor="?primaryText"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/passwordHeader"
app:layout_constraintEnd_toStartOf="@id/revealPasswordButton"
app:layout_constraintStart_toStartOf="@id/passwordHeader"
app:layout_constraintTop_toBottomOf="@id/passwordHeader"
app:layout_constraintVertical_chainStyle="packed"
@ -138,25 +138,27 @@
<ImageButton
android:id="@+id/revealPasswordButton"
android:layout_width="48dp"
android:layout_height="30dp"
android:layout_marginBottom="2dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="36dp"
android:background="@null"
android:contentDescription="@string/saved_login_reveal_password"
app:layout_constraintBottom_toBottomOf="@id/passwordText"
app:layout_constraintEnd_toStartOf="@id/copyPassword"
app:layout_constraintTop_toTopOf="@id/passwordText"
app:srcCompat="@drawable/mozac_ic_password_reveal"
app:tint="?android:colorAccent" />
<ImageButton
android:id="@+id/copyPassword"
android:layout_width="48dp"
android:layout_height="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/saved_logins_copy_password"
app:layout_constraintBottom_toBottomOf="@id/revealPasswordButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/revealPasswordButton"
app:layout_constraintBottom_toBottomOf="@id/passwordText"
app:layout_constraintEnd_toEndOf="@id/openWebAddress"
app:layout_constraintStart_toStartOf="@id/openWebAddress"
app:layout_constraintTop_toTopOf="@id/passwordText"
app:srcCompat="@drawable/ic_copy"
app:tint="?android:colorAccent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1255,6 +1255,8 @@
<string name="saved_login_copy_username">Copy username</string>
<!-- Content Description (for screenreaders etc) read for the button to copy a site in logins -->
<string name="saved_login_copy_site">Copy site</string>
<!-- Content Description (for screenreaders etc) read for the button to open a site in logins -->
<string name="saved_login_open_site">Open site in browser</string>
<!-- Content Description (for screenreaders etc) read for the button to reveal a password in logins -->
<string name="saved_login_reveal_password">Show password</string>
<!-- Content Description (for screenreaders etc) read for the button to hide a password in logins -->