This commit is contained in:
parent
c2704c3fec
commit
583b954c5a
|
@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- #1955 - Added a confirmation dialog for QR code and barcode searches
|
||||
- #1874 - Added a "Turn on Sync" fragment for Firefox Accounts login and sign up
|
||||
- #2308 - Update the deprecated BitmapDrawable constructor
|
||||
- #1874 - Added TOP info panel dialog for custom tabs.
|
||||
|
||||
### Changed
|
||||
- #1429 - Updated site permissions ui for MVP
|
||||
|
|
|
@ -247,10 +247,20 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|||
view = view
|
||||
)
|
||||
|
||||
val accentHighContrastColor = DefaultThemeManager.resolveAttribute(R.attr.accentHighContrast, requireContext())
|
||||
|
||||
sitePermissionsFeature.set(
|
||||
feature = SitePermissionsFeature(
|
||||
anchorView = view.findInPageView,
|
||||
sessionManager = sessionManager
|
||||
context = requireContext(),
|
||||
sessionManager = sessionManager,
|
||||
fragmentManager = requireFragmentManager(),
|
||||
promptsStyling = SitePermissionsFeature.PromptsStyling(
|
||||
gravity = getAppropriateLayoutGravity(),
|
||||
shouldWidthMatchParent = true,
|
||||
positiveButtonBackgroundColor = accentHighContrastColor,
|
||||
positiveButtonTextColor = R.color.photonWhite
|
||||
),
|
||||
sessionId = customTabSessionId
|
||||
) { permissions ->
|
||||
requestPermissions(permissions, REQUEST_CODE_APP_PERMISSIONS)
|
||||
},
|
||||
|
@ -658,7 +668,8 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|||
url = session.url,
|
||||
isSecured = session.securityInfo.secure,
|
||||
isTrackingProtectionOn = Settings.getInstance(context!!).shouldUseTrackingProtection,
|
||||
sitePermissions = sitePermissions
|
||||
sitePermissions = sitePermissions,
|
||||
gravity = getAppropriateLayoutGravity()
|
||||
)
|
||||
quickSettingsSheet.sitePermissions = sitePermissions
|
||||
quickSettingsSheet.show(
|
||||
|
|
|
@ -4,15 +4,21 @@
|
|||
|
||||
package org.mozilla.fenix.settings.quicksettings
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager.PERMISSION_GRANTED
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity.BOTTOM
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
|
@ -34,14 +40,16 @@ private const val KEY_URL = "KEY_URL"
|
|||
private const val KEY_IS_SECURED = "KEY_IS_SECURED"
|
||||
private const val KEY_SITE_PERMISSIONS = "KEY_SITE_PERMISSIONS"
|
||||
private const val KEY_IS_TP_ON = "KEY_IS_TP_ON"
|
||||
private const val KEY_DIALOG_GRAVITY = "KEY_DIALOG_GRAVITY"
|
||||
private const val REQUEST_CODE_QUICK_SETTINGS_PERMISSIONS = 4
|
||||
|
||||
@SuppressWarnings("TooManyFunctions")
|
||||
class QuickSettingsSheetDialogFragment : BottomSheetDialogFragment(), CoroutineScope {
|
||||
class QuickSettingsSheetDialogFragment : AppCompatDialogFragment(), CoroutineScope {
|
||||
private val safeArguments get() = requireNotNull(arguments)
|
||||
private val url: String by lazy { safeArguments.getString(KEY_URL) }
|
||||
private val isSecured: Boolean by lazy { safeArguments.getBoolean(KEY_IS_SECURED) }
|
||||
private val isTrackingProtectionOn: Boolean by lazy { safeArguments.getBoolean(KEY_IS_TP_ON) }
|
||||
private val promptGravity: Int by lazy { safeArguments.getInt(KEY_DIALOG_GRAVITY) }
|
||||
private lateinit var quickSettingsComponent: QuickSettingsComponent
|
||||
private lateinit var job: Job
|
||||
|
||||
|
@ -62,23 +70,53 @@ class QuickSettingsSheetDialogFragment : BottomSheetDialogFragment(), CoroutineS
|
|||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
return inflateRootView(container)
|
||||
}
|
||||
|
||||
private fun inflateRootView(container: ViewGroup? = null): View {
|
||||
val contextThemeWrapper = ContextThemeWrapper(
|
||||
activity,
|
||||
(activity as HomeActivity).themeManager.currentThemeResource
|
||||
)
|
||||
val localInflater = inflater.cloneInContext(contextThemeWrapper)
|
||||
return localInflater.inflate(
|
||||
return LayoutInflater.from(contextThemeWrapper).inflate(
|
||||
R.layout.fragment_quick_settings_dialog_sheet,
|
||||
container,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val customDialog = if (promptGravity == BOTTOM) {
|
||||
return BottomSheetDialog(requireContext(), this.theme)
|
||||
} else {
|
||||
Dialog(requireContext())
|
||||
}
|
||||
return customDialog.applyCustomizationsForTopDialog(inflateRootView())
|
||||
}
|
||||
|
||||
private fun Dialog.applyCustomizationsForTopDialog(rootView: View): Dialog {
|
||||
addContentView(
|
||||
rootView,
|
||||
LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
)
|
||||
|
||||
window?.apply {
|
||||
setGravity(promptGravity)
|
||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
// This must be called after addContentView, or it won't fully fill to the edge.
|
||||
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun onViewCreated(rootView: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(rootView, savedInstanceState)
|
||||
quickSettingsComponent = QuickSettingsComponent(
|
||||
rootView as ConstraintLayout, ActionBusFactory.get(this),
|
||||
rootView as NestedScrollView, ActionBusFactory.get(this),
|
||||
QuickSettingsState(
|
||||
QuickSettingsState.Mode.Normal(
|
||||
url,
|
||||
|
@ -97,7 +135,8 @@ class QuickSettingsSheetDialogFragment : BottomSheetDialogFragment(), CoroutineS
|
|||
url: String,
|
||||
isSecured: Boolean,
|
||||
isTrackingProtectionOn: Boolean,
|
||||
sitePermissions: SitePermissions?
|
||||
sitePermissions: SitePermissions?,
|
||||
gravity: Int = BOTTOM
|
||||
): QuickSettingsSheetDialogFragment {
|
||||
|
||||
val fragment = QuickSettingsSheetDialogFragment()
|
||||
|
@ -108,6 +147,7 @@ class QuickSettingsSheetDialogFragment : BottomSheetDialogFragment(), CoroutineS
|
|||
putBoolean(KEY_IS_SECURED, isSecured)
|
||||
putBoolean(KEY_IS_TP_ON, isTrackingProtectionOn)
|
||||
putParcelable(KEY_SITE_PERMISSIONS, sitePermissions)
|
||||
putInt(KEY_DIALOG_GRAVITY, gravity)
|
||||
}
|
||||
fragment.arguments = arguments
|
||||
return fragment
|
||||
|
|
|
@ -3,154 +3,161 @@
|
|||
- 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"
|
||||
android:id="@+id/quick_action_sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?foundation"
|
||||
android:contentDescription="@string/quick_settings_sheet">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
style="@style/QuickSettingsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="https://wikipedia.org" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/security_info"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/url"
|
||||
tools:drawableStartCompat="@drawable/mozac_ic_lock"
|
||||
tools:drawableTint="@color/photonGreen50"
|
||||
tools:text="Secure connection" />
|
||||
|
||||
<View
|
||||
android:id="@+id/line_divider_security"
|
||||
<androidx.core.widget.NestedScrollView
|
||||
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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?neutralFaded"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/security_info" />
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/tracking_protection"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:drawableStart="@drawable/ic_tracking_protection"
|
||||
android:paddingEnd="24dp"
|
||||
android:text="@string/preferences_tracking_protection"
|
||||
app:layout_constraintBottom_toTopOf="@id/report_problem"
|
||||
app:layout_constraintTop_toBottomOf="@id/line_divider_security" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/quick_action_sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?foundation"
|
||||
android:contentDescription="@string/quick_settings_sheet">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/report_problem"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:gravity="top"
|
||||
android:paddingStart="48dp"
|
||||
android:text="@string/browser_menu_report_issue"
|
||||
android:textColor="?accentBright"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/line_divider"
|
||||
app:layout_constraintTop_toBottomOf="@id/tracking_protection" />
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
style="@style/QuickSettingsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="https://wikipedia.org"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/line_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?neutralFaded"
|
||||
app:layout_constraintBottom_toTopOf="@id/camera_icon"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<TextView
|
||||
android:id="@+id/security_info"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/url"
|
||||
tools:drawableStartCompat="@drawable/mozac_ic_lock"
|
||||
tools:drawableTint="@color/photonGreen50"
|
||||
tools:text="Secure connection"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/camera_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_camera"
|
||||
app:drawableStartCompat="@drawable/ic_camera"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/line_divider" />
|
||||
<View
|
||||
android:id="@+id/line_divider_security"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?neutralFaded"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/security_info"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/camera_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/line_divider"
|
||||
tools:text="Allowed" />
|
||||
<Switch
|
||||
android:id="@+id/tracking_protection"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:drawableStart="@drawable/ic_tracking_protection"
|
||||
android:paddingEnd="24dp"
|
||||
android:text="@string/preferences_tracking_protection"
|
||||
app:layout_constraintBottom_toTopOf="@id/report_problem"
|
||||
app:layout_constraintTop_toBottomOf="@id/line_divider_security"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/microphone_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_microphone"
|
||||
app:drawableStartCompat="@drawable/ic_microphone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/camera_icon" />
|
||||
<TextView
|
||||
android:id="@+id/report_problem"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:gravity="top"
|
||||
android:paddingStart="48dp"
|
||||
android:text="@string/browser_menu_report_issue"
|
||||
android:textColor="?accentBright"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/line_divider"
|
||||
app:layout_constraintTop_toBottomOf="@id/tracking_protection"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/line_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?neutralFaded"
|
||||
app:layout_constraintBottom_toTopOf="@id/camera_icon"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/camera_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_camera"
|
||||
app:drawableStartCompat="@drawable/ic_camera"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/line_divider"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/camera_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/line_divider"
|
||||
tools:text="Allowed"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/microphone_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_microphone"
|
||||
app:drawableStartCompat="@drawable/ic_microphone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/camera_icon"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/microphone_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/camera_action_label"
|
||||
tools:text="Blocked by Android" />
|
||||
<TextView
|
||||
android:id="@+id/microphone_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/camera_action_label"
|
||||
tools:text="Blocked by Android"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/notification_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_notification"
|
||||
app:drawableStartCompat="@drawable/ic_notification"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/microphone_icon" />
|
||||
<TextView
|
||||
android:id="@+id/notification_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_notification"
|
||||
app:drawableStartCompat="@drawable/ic_notification"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/microphone_icon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/notification_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/microphone_action_label"
|
||||
tools:text="Blocked" />
|
||||
<TextView
|
||||
android:id="@+id/notification_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/microphone_action_label"
|
||||
tools:text="Blocked"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/location_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_location"
|
||||
app:drawableStartCompat="@drawable/ic_location"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/notification_icon" />
|
||||
<TextView
|
||||
android:id="@+id/location_icon"
|
||||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
android:text="@string/preference_phone_feature_location"
|
||||
app:drawableStartCompat="@drawable/ic_location"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/notification_icon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/location_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/notification_action_label"
|
||||
tools:text="Blocked" />
|
||||
<TextView
|
||||
android:id="@+id/location_action_label"
|
||||
style="@style/QuickSettingsText.PermissionItemEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/notification_action_label"
|
||||
tools:text="Blocked"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
Loading…
Reference in New Issue
Block a user