parent
f71106cb51
commit
2441592ef2
|
@ -58,25 +58,24 @@ class SearchWidgetProvider : AppWidgetProvider() {
|
|||
}
|
||||
|
||||
private fun getLayoutSize(dp: Int) = when {
|
||||
dp >= DP_EXTRA_LARGE -> SearchWidgetProviderSize.EXTRA_LARGE
|
||||
dp >= DP_LARGE -> SearchWidgetProviderSize.LARGE
|
||||
dp >= DP_MEDIUM -> SearchWidgetProviderSize.MEDIUM
|
||||
dp >= DP_SMALL -> SearchWidgetProviderSize.SMALL
|
||||
else -> SearchWidgetProviderSize.EXTRA_SMALL
|
||||
dp >= DP_EXTRA_SMALL -> SearchWidgetProviderSize.EXTRA_SMALL_V2
|
||||
else -> SearchWidgetProviderSize.EXTRA_SMALL_V1
|
||||
}
|
||||
|
||||
private fun getLayout(size: SearchWidgetProviderSize) = when (size) {
|
||||
SearchWidgetProviderSize.EXTRA_LARGE -> R.layout.search_widget_extra_large
|
||||
SearchWidgetProviderSize.LARGE -> R.layout.search_widget_large
|
||||
SearchWidgetProviderSize.MEDIUM -> R.layout.search_widget_medium
|
||||
SearchWidgetProviderSize.SMALL -> R.layout.search_widget_small
|
||||
SearchWidgetProviderSize.EXTRA_SMALL -> R.layout.search_widget_extra_small
|
||||
SearchWidgetProviderSize.EXTRA_SMALL_V2 -> R.layout.search_widget_extra_small_v2
|
||||
SearchWidgetProviderSize.EXTRA_SMALL_V1 -> R.layout.search_widget_extra_small_v1
|
||||
}
|
||||
|
||||
private fun getText(layout: SearchWidgetProviderSize, context: Context) = when (layout) {
|
||||
SearchWidgetProviderSize.MEDIUM -> context.getString(R.string.search_widget_text_short)
|
||||
SearchWidgetProviderSize.LARGE,
|
||||
SearchWidgetProviderSize.EXTRA_LARGE -> context.getString(R.string.search_widget_text_long)
|
||||
SearchWidgetProviderSize.LARGE -> context.getString(R.string.search_widget_text_long)
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
@ -107,7 +106,8 @@ class SearchWidgetProvider : AppWidgetProvider() {
|
|||
): RemoteViews {
|
||||
return RemoteViews(context.packageName, layout).apply {
|
||||
when (layout) {
|
||||
R.layout.search_widget_extra_small -> {
|
||||
R.layout.search_widget_extra_small_v1,
|
||||
R.layout.search_widget_extra_small_v2 -> {
|
||||
setOnClickPendingIntent(R.id.button_search_widget_new_tab, textSearchIntent)
|
||||
}
|
||||
R.layout.search_widget_small -> {
|
||||
|
@ -115,11 +115,10 @@ class SearchWidgetProvider : AppWidgetProvider() {
|
|||
setOnClickPendingIntent(R.id.button_search_widget_voice, voiceSearchIntent)
|
||||
}
|
||||
R.layout.search_widget_medium,
|
||||
R.layout.search_widget_large,
|
||||
R.layout.search_widget_extra_large -> {
|
||||
R.layout.search_widget_large -> {
|
||||
setOnClickPendingIntent(R.id.button_search_widget_new_tab, textSearchIntent)
|
||||
setOnClickPendingIntent(R.id.button_search_widget_voice, voiceSearchIntent)
|
||||
setTextViewText(R.id.text_search_widget, text)
|
||||
setTextViewText(R.id.button_search_widget_new_tab, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,19 +126,19 @@ class SearchWidgetProvider : AppWidgetProvider() {
|
|||
|
||||
// Cell sizes obtained from the actual dimensions listed in search widget specs
|
||||
companion object {
|
||||
private const val DP_EXTRA_SMALL = 64
|
||||
private const val DP_SMALL = 100
|
||||
private const val DP_MEDIUM = 192
|
||||
private const val DP_LARGE = 256
|
||||
private const val DP_EXTRA_LARGE = 360
|
||||
private const val REQUEST_CODE_NEW_TAB = 0
|
||||
private const val REQUEST_CODE_VOICE = 1
|
||||
}
|
||||
}
|
||||
|
||||
enum class SearchWidgetProviderSize {
|
||||
EXTRA_SMALL,
|
||||
EXTRA_SMALL_V1,
|
||||
EXTRA_SMALL_V2,
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE,
|
||||
EXTRA_LARGE
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout android:layout_width="360dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="9dp"
|
||||
android:id="@+id/button_search_widget_new_tab">
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/text_search_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
android:textSize="15dp"
|
||||
android:textColor="@color/search_widget_text"
|
||||
android:letterSpacing="-0.025"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_search_widget_voice"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_microphone_widget"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/button_search_widget_new_tab"
|
||||
android:layout_marginRight="9dp"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,25 +0,0 @@
|
|||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout android:layout_width="64dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/button_search_widget_new_tab"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="5dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -0,0 +1,18 @@
|
|||
<?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"
|
||||
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">
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
|
@ -0,0 +1,18 @@
|
|||
<?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"
|
||||
android:id="@id/button_search_widget_new_tab"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
|
@ -3,43 +3,32 @@
|
|||
- 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<RelativeLayout android:layout_width="256dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
<TextView
|
||||
android:id="@+id/button_search_widget_new_tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/search_widget_text"
|
||||
android:letterSpacing="-0.025"
|
||||
android:drawableStart="@drawable/ic_logo_widget"
|
||||
android:drawablePadding="12dp"
|
||||
android:layout_marginStart="9dp"
|
||||
android:layout_marginTop="9dp"/>
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="9dp"
|
||||
android:id="@+id/button_search_widget_new_tab">
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/text_search_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
android:textSize="15dp"
|
||||
android:textColor="@color/search_widget_text"
|
||||
android:letterSpacing="-0.025"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_search_widget_voice"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_microphone_widget"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/button_search_widget_new_tab"
|
||||
android:layout_marginRight="9dp"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</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>
|
|
@ -3,43 +3,32 @@
|
|||
- 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="192dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<RelativeLayout android:layout_width="192dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
<TextView
|
||||
android:id="@+id/button_search_widget_new_tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/search_widget_text"
|
||||
android:letterSpacing="-0.025"
|
||||
android:drawableStart="@drawable/ic_logo_widget"
|
||||
android:drawablePadding="12dp"
|
||||
android:layout_marginStart="9dp"
|
||||
android:layout_marginTop="9dp"/>
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="9dp"
|
||||
android:id="@+id/button_search_widget_new_tab">
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/text_search_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
android:textSize="15dp"
|
||||
android:textColor="@color/search_widget_text"
|
||||
android:letterSpacing="-0.025"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_search_widget_voice"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_microphone_widget"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/button_search_widget_new_tab"
|
||||
android:layout_marginRight="9dp"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</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>
|
|
@ -3,35 +3,32 @@
|
|||
- 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/rounded_white_corners"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<RelativeLayout android:layout_width="100dp"
|
||||
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">
|
||||
|
||||
<LinearLayout android:id="@+id/button_search_widget_new_tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="9dp">
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:layout_marginRight="12dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_search_widget_voice"
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_microphone_widget"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/button_search_widget_new_tab"
|
||||
android:layout_marginRight="9dp"/>
|
||||
</RelativeLayout>
|
||||
android:background="@drawable/ic_logo_widget"
|
||||
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>
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue