Issue #8277: Reuse app icon in widget layout.

This patch refactors the widget layouts so that we can reuse the app icon and do not have to have
another logo resource with different constraints. This will also make it easier to update the
branding in #8277 and #8278.
fennec/beta
Sebastian Kaspari 4 years ago
parent f1a3dffba2
commit ba54080177

@ -17,7 +17,7 @@ import android.view.View
import android.widget.RemoteViews
import androidx.annotation.Dimension
import androidx.annotation.Dimension.DP
import androidx.appcompat.widget.AppCompatDrawableManager
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.graphics.drawable.toBitmap
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.IntentReceiverActivity
@ -168,13 +168,13 @@ class SearchWidgetProvider : AppWidgetProvider() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
setImageViewResource(
R.id.button_search_widget_new_tab_icon,
R.drawable.ic_logo_widget)
R.drawable.ic_launcher_foreground)
} else {
setImageViewBitmap(
R.id.button_search_widget_new_tab_icon,
AppCompatDrawableManager.get().getDrawable(
AppCompatResources.getDrawable(
context,
R.drawable.ic_logo_widget
R.drawable.ic_launcher_foreground
)?.toBitmap())
}
}

File diff suppressed because one or more lines are too long

@ -4,15 +4,19 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/button_search_widget_new_tab"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/rounded_white_corners"
android:layout_gravity="center">
xmlns:tools="http://schemas.android.com/tools"
android:id="@id/button_search_widget_new_tab"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/rounded_white_corners"
android:layout_gravity="center">
<ImageView
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"/>
</FrameLayout>
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerInside"
tools:src="@drawable/ic_launcher_foreground"
android:layout_gravity="center"/>
</FrameLayout>

@ -4,6 +4,7 @@
- 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/button_search_widget_new_tab"
android:layout_width="64dp"
android:layout_height="50dp"
@ -12,7 +13,9 @@
<ImageView
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerInside"
tools:src="@drawable/ic_launcher_foreground"
android:layout_gravity="center"/>
</FrameLayout>
</FrameLayout>

@ -12,11 +12,10 @@
<ImageView
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:adjustViewBounds="true"
android:padding="12dp"/>
android:scaleType="centerInside" />
<TextView
android:id="@+id/button_search_widget_new_tab"

@ -12,11 +12,10 @@
<ImageView
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:adjustViewBounds="true"
android:padding="12dp"/>
android:scaleType="centerInside" />
<TextView
android:id="@+id/button_search_widget_new_tab"

@ -2,33 +2,23 @@
<!-- 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/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="50dp"
android:background="@drawable/rounded_white_corners"
android:orientation="horizontal">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
<ImageView
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/rounded_white_corners"
android:layout_gravity="center">
<FrameLayout android:id="@+id/button_search_widget_new_tab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="9dp">
<ImageView
android:id="@+id/button_search_widget_new_tab_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="9dp"/>
</FrameLayout>
<ImageButton
android:id="@+id/button_search_widget_voice"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@drawable/ic_microphone_widget"
android:layout_alignParentEnd="true"
android:layout_alignTop="@id/button_search_widget_new_tab"
android:layout_marginEnd="9dp"/>
</RelativeLayout>
android:scaleType="centerInside" />
<ImageView
android:id="@+id/button_search_widget_voice"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="10dp"
android:src="@drawable/ic_microphone_widget"
android:scaleType="centerInside" />
</LinearLayout>

Loading…
Cancel
Save