update addon layouts

This commit is contained in:
Fabian Freund
2025-12-24 16:16:54 +01:00
parent bd77de00f4
commit 81611ab132
10 changed files with 87 additions and 57 deletions
@@ -5,17 +5,21 @@
package eu.weblibre.flutter_mozilla_components.addons
import android.content.Intent
import android.net.Uri
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.activity.SystemBarStyle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.ui.translateName
import mozilla.components.support.ktx.android.view.setupPersistentInsets
import mozilla.components.support.utils.ext.getParcelableExtraCompat
import eu.weblibre.flutter_mozilla_components.R
@@ -25,10 +29,15 @@ private const val LEARN_MORE_URL =
/**
* An activity to show the permissions of an add-on.
*/
class PermissionsDetailsActivity : AppCompatActivity(), View.OnClickListener {
class PermissionsDetailsActivity :
AppCompatActivity(),
View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge(SystemBarStyle.dark(Color.TRANSPARENT))
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_on_permissions)
window.setupPersistentInsets()
val addon = requireNotNull(
intent.getParcelableExtraCompat("add_on", Addon::class.java),
)
@@ -56,9 +65,11 @@ class PermissionsDetailsActivity : AppCompatActivity(), View.OnClickListener {
*/
class PermissionsAdapter(
private val permissions: List<String>,
) :
RecyclerView.Adapter<PermissionViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PermissionViewHolder {
) : RecyclerView.Adapter<PermissionViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int,
): PermissionViewHolder {
val context = parent.context
val inflater = LayoutInflater.from(context)
val view = inflater.inflate(R.layout.add_ons_permission_item, parent, false)
@@ -71,7 +82,10 @@ class PermissionsDetailsActivity : AppCompatActivity(), View.OnClickListener {
override fun getItemCount() = permissions.size
override fun onBindViewHolder(holder: PermissionViewHolder, position: Int) {
override fun onBindViewHolder(
holder: PermissionViewHolder,
position: Int,
) {
val permission = permissions[position]
holder.textView.text = permission
}
@@ -86,8 +100,7 @@ class PermissionsDetailsActivity : AppCompatActivity(), View.OnClickListener {
) : RecyclerView.ViewHolder(view)
override fun onClick(v: View?) {
val intent =
Intent(Intent.ACTION_VIEW).setData(Uri.parse(LEARN_MORE_URL))
val intent = Intent(Intent.ACTION_VIEW).setData(LEARN_MORE_URL.toUri())
startActivity(intent)
}
}
}
@@ -107,15 +107,15 @@
android:layout_below="@+id/last_updated_divider"
android:text="@string/mozac_feature_addons_home_page" />
<androidx.appcompat.widget.AppCompatImageView
<ImageView
android:id="@+id/home_page_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/last_updated_divider"
android:layout_alignParentEnd="true"
android:contentDescription="@string/mozac_feature_addons_home_page"
app:srcCompat="@drawable/mozac_ic_link_24"
app:tint="@android:color/black" />
android:src="@drawable/mozac_ic_link_24"
app:tint="@color/icons" />
<View
android:id="@+id/home_page_divider"
@@ -154,4 +154,4 @@
tools:text="591,642" />
</RelativeLayout>
</ScrollView>
</ScrollView>
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
<?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/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:ignore="MergeRootFrame" />
android:fitsSystemWindows="true" >
<androidx.fragment.app.FragmentContainerView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -4,11 +4,11 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<RelativeLayout 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:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".addons.PermissionsDetailsActivity">
<androidx.recyclerview.widget.RecyclerView
@@ -21,13 +21,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/add_ons_permissions"
android:background="?attr/selectableItemBackground"
app:drawableEndCompat="@drawable/mozac_ic_link_24"
android:padding="16dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground"
android:text="@string/mozac_feature_addons_learn_more"
android:textColor="@android:color/black"
app:drawableEndCompat="@drawable/mozac_ic_link_24"
app:drawableTint="@android:color/black" />
app:drawableTint="@color/icons" />
</RelativeLayout>
</RelativeLayout>
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
<?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/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/addonSettingsContainer"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:ignore="MergeRootFrame" />
android:fitsSystemWindows="true">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/addonSettingsContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!-- This Source Code Form is subject to the terms of the Mozilla Public
<?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/. -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
@@ -38,10 +39,9 @@
android:drawablePadding="10dp"
android:padding="16dp"
android:text="@string/mozac_feature_addons_settings"
android:textColor="@drawable/addon_textview_selector"
android:textSize="18sp"
app:drawableStartCompat="@drawable/mozac_ic_preferences"
app:drawableTint="@android:color/black" />
app:drawableTint="@color/icons" />
<TextView
android:id="@+id/details"
@@ -52,10 +52,9 @@
android:drawablePadding="6dp"
android:padding="16dp"
android:text="@string/mozac_feature_addons_details"
android:textColor="@drawable/addon_textview_selector"
android:textSize="18sp"
app:drawableStartCompat="@drawable/mozac_ic_information_24"
app:drawableTint="@android:color/black" />
app:drawableTint="@color/icons" />
<TextView
android:id="@+id/permissions"
@@ -66,7 +65,6 @@
android:drawablePadding="6dp"
android:padding="16dp"
android:text="@string/mozac_feature_addons_permissions"
android:textColor="@drawable/addon_textview_selector"
android:textSize="18sp"
app:drawableStartCompat="@drawable/mozac_ic_permissions" />
@@ -77,7 +75,7 @@
android:layout_gravity="center_vertical|end"
android:layout_below="@+id/permissions"
android:background="?android:attr/selectableItemBackground"
android:checked="true"
android:checked="false"
android:clickable="true"
android:focusable="true"
android:text="@string/mozac_feature_addons_settings_allow_in_private_browsing_2"
@@ -90,8 +88,7 @@
android:layout_height="wrap_content"
android:layout_below="@+id/allow_in_private_browsing_switch"
android:layout_marginTop="16dp"
android:text="@string/mozac_feature_addons_remove"
android:textAlignment="center"
android:textColor="@color/photonRed50" />
android:textColor="@color/photonRed50"
android:text="@string/mozac_feature_addons_remove" />
</RelativeLayout>
</ScrollView>
</ScrollView>
@@ -9,20 +9,22 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:orientation="vertical">
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<TextView
android:id="@+id/permission"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary"
android:paddingTop="16dp"
android:paddingBottom="16dp"
tools:text="Access your data for all websites" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:background="@color/photonGrey40"
android:importantForAccessibility="no" />
</LinearLayout>
</LinearLayout>
@@ -0,0 +1,7 @@
<?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/. -->
<resources xmlns:tools="http://schemas.android.com/tools">
<color name="icons">#ffffffff</color>
</resources>