summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author 1 <mrcasey@google.com> 2023-04-11 20:52:04 +0000
committer 1 <mrcasey@google.com> 2023-04-17 18:44:23 +0000
commitb1c6bf9d8100906355d113986304f2b8997dba20 (patch)
tree63969fbdd879aa60527ae8d6497dc15ed4c9a225
parenta287a5e767c1911fb3705c95915b7fc698a6b3ab (diff)
Show preview content in landscape.
Make stuff smaller and less tall on landscape non-tablets. Let the system restart sharesheet on rotation to allow for resources to change. Tablet displays in landscape generally should follow the un-compressed UI of portrait phones, so the resources for that configuration have to be listed twice. This doesn't dismantle any of the code for handling orientation changes ourselves, as taking that apart may be error-prone. This is meant to a first pass, additional landscape miniturization will follow, as there still isn't a ton of room to scroll at the bottom. Bug: 267522604 Test: Testing in portrait and landscape with a variety of ShareTest payloads Change-Id: I4697ad9510526cc9ce5f9e0630080bef5fad377c
-rw-r--r--AndroidManifest.xml2
-rw-r--r--java/res/layout/chooser_action_button.xml31
-rw-r--r--java/res/layout/chooser_action_row.xml4
-rw-r--r--java/res/layout/chooser_grid_preview_image.xml2
-rw-r--r--java/res/layout/chooser_grid_preview_text.xml2
-rw-r--r--java/res/values-land/bools.xml (renamed from java/res/values-h480dp/bools.xml)6
-rw-r--r--java/res/values-land/dimens.xml4
-rw-r--r--java/res/values-land/integers.xml19
-rw-r--r--java/res/values-sw600dp/bools.xml20
-rw-r--r--java/res/values-sw600dp/dimens.xml5
-rw-r--r--java/res/values-sw600dp/integers.xml19
-rw-r--r--java/res/values/attrs.xml4
-rw-r--r--java/res/values/bools.xml2
-rw-r--r--java/res/values/dimens.xml2
-rw-r--r--java/res/values/integers.xml19
-rw-r--r--java/src/com/android/intentresolver/ChooserActivity.java3
-rw-r--r--java/src/com/android/intentresolver/widget/ChooserActionRow.kt81
-rw-r--r--java/src/com/android/intentresolver/widget/ScrollableActionRow.kt21
18 files changed, 116 insertions, 130 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5228827d..8115b2b2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -56,7 +56,7 @@
android:excludeFromRecents="true"
android:documentLaunchMode="never"
android:relinquishTaskIdentity="true"
- android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
+ android:configChanges="screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden"
android:visibleToInstantApps="true"
android:exported="true"
android:enabled="false">
diff --git a/java/res/layout/chooser_action_button.xml b/java/res/layout/chooser_action_button.xml
deleted file mode 100644
index 2b68ccca..00000000
--- a/java/res/layout/chooser_action_button.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
- ~ Copyright (C) 2019 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<Button xmlns:android="http://schemas.android.com/apk/res/android"
- android:gravity="center_vertical|start"
- android:paddingStart="12dp"
- android:paddingEnd="12dp"
- android:drawablePadding="8dp"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="12sp"
- android:maxWidth="192dp"
- android:singleLine="true"
- android:clickable="true"
- android:background="@drawable/chooser_action_button_bg"
- android:drawableTint="?android:attr/textColorPrimary"
- android:drawableTintMode="src_in"
- style="?android:attr/borderlessButtonStyle"
- />
diff --git a/java/res/layout/chooser_action_row.xml b/java/res/layout/chooser_action_row.xml
index 303426c4..f77b0e68 100644
--- a/java/res/layout/chooser_action_row.xml
+++ b/java/res/layout/chooser_action_row.xml
@@ -16,7 +16,8 @@
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<View
android:layout_width="match_parent"
@@ -29,6 +30,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
+ app:horizontalActions="@bool/horizontal_actions"
android:gravity="center"/>
<View
diff --git a/java/res/layout/chooser_grid_preview_image.xml b/java/res/layout/chooser_grid_preview_image.xml
index 68b07846..d8aa1a13 100644
--- a/java/res/layout/chooser_grid_preview_image.xml
+++ b/java/res/layout/chooser_grid_preview_image.xml
@@ -54,7 +54,7 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/chooser_edge_margin_normal_half"
android:layout_marginEnd="@dimen/chooser_edge_margin_normal_half"
- android:maxLines="6"
+ android:maxLines="@integer/text_preview_lines"
android:ellipsize="end"
android:linksClickable="false"
android:visibility="gone"
diff --git a/java/res/layout/chooser_grid_preview_text.xml b/java/res/layout/chooser_grid_preview_text.xml
index 89e961e8..e22cfbd2 100644
--- a/java/res/layout/chooser_grid_preview_text.xml
+++ b/java/res/layout/chooser_grid_preview_text.xml
@@ -80,7 +80,7 @@
android:textColor="?android:attr/textColorPrimary"
android:textAlignment="gravity"
android:textDirection="locale"
- android:maxLines="3"
+ android:maxLines="@integer/text_preview_lines"
android:focusable="true"/>
</RelativeLayout>
diff --git a/java/res/values-h480dp/bools.xml b/java/res/values-land/bools.xml
index 7896d9bf..761de1ea 100644
--- a/java/res/values-h480dp/bools.xml
+++ b/java/res/values-land/bools.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2020 The Android Open Source Project
+ ~ Copyright (C) 2023 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -16,5 +16,5 @@
-->
<resources>
- <bool name="resolver_landscape_phone">false</bool>
-</resources> \ No newline at end of file
+ <bool name="horizontal_actions">false</bool>
+</resources>
diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml
index 7e3fb9cb..e3169efd 100644
--- a/java/res/values-land/dimens.xml
+++ b/java/res/values-land/dimens.xml
@@ -20,4 +20,8 @@
<resources>
<dimen name="chooser_preview_width">412dp</dimen>
+ <dimen name="chooser_preview_image_height_tall">64dp</dimen>
+ <dimen name="chooser_view_spacing">8dp</dimen>
+ <integer name="text_preview_lines">1</integer>
+ <bool name="horizontal_actions">true</bool>
</resources>
diff --git a/java/res/values-land/integers.xml b/java/res/values-land/integers.xml
new file mode 100644
index 00000000..2e310d87
--- /dev/null
+++ b/java/res/values-land/integers.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <integer name="text_preview_lines">1</integer>
+</resources>
diff --git a/java/res/values-sw600dp/bools.xml b/java/res/values-sw600dp/bools.xml
new file mode 100644
index 00000000..761de1ea
--- /dev/null
+++ b/java/res/values-sw600dp/bools.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+ <bool name="horizontal_actions">false</bool>
+</resources>
diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml
index b397630e..6cd29747 100644
--- a/java/res/values-sw600dp/dimens.xml
+++ b/java/res/values-sw600dp/dimens.xml
@@ -20,5 +20,8 @@
<resources>
<dimen name="chooser_width">624dp</dimen>
-
+ <dimen name="chooser_preview_image_height_tall">192dp</dimen>
+ <dimen name="chooser_view_spacing">18dp</dimen>
+ <integer name="text_preview_lines">3</integer>
+ <bool name="horizontal_actions">false</bool>
</resources>
diff --git a/java/res/values-sw600dp/integers.xml b/java/res/values-sw600dp/integers.xml
new file mode 100644
index 00000000..c1693057
--- /dev/null
+++ b/java/res/values-sw600dp/integers.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <integer name="text_preview_lines">3</integer>
+</resources>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 67acb3ae..c96221ec 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -51,4 +51,8 @@
<attr name="itemOuterSpacing" format="dimension" />
<attr name="maxWidthHint" format="dimension" />
</declare-styleable>
+
+ <declare-styleable name="ScrollableActionRow">
+ <attr name="horizontalActions" format="boolean" />
+ </declare-styleable>
</resources>
diff --git a/java/res/values/bools.xml b/java/res/values/bools.xml
index a84081b6..641620d7 100644
--- a/java/res/values/bools.xml
+++ b/java/res/values/bools.xml
@@ -15,5 +15,5 @@
-->
<resources>
- <bool name="resolver_landscape_phone">@*android:bool/resolver_landscape_phone</bool>
+ <bool name="horizontal_actions">false</bool>
</resources>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 8636f742..947351d8 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -28,7 +28,6 @@
<dimen name="chooser_preview_image_font_size">20sp</dimen>
<dimen name="chooser_preview_image_border">1dp</dimen>
<dimen name="chooser_preview_image_width">120dp</dimen>
- <dimen name="chooser_preview_image_height">104dp</dimen>
<dimen name="chooser_preview_image_height_tall">192dp</dimen>
<dimen name="chooser_preview_image_max_dimen">200dp</dimen>
<dimen name="chooser_preview_width">-1px</dimen>
@@ -54,7 +53,6 @@
<dimen name="resolver_empty_state_container_padding_bottom">8dp</dimen>
<dimen name="resolver_profile_tab_margin">4dp</dimen>
- <dimen name="chooser_action_button_icon_size">18dp</dimen>
<dimen name="chooser_action_view_icon_size">22dp</dimen>
<dimen name="chooser_action_margin">0dp</dimen>
</resources>
diff --git a/java/res/values/integers.xml b/java/res/values/integers.xml
new file mode 100644
index 00000000..c1693057
--- /dev/null
+++ b/java/res/values/integers.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <integer name="text_preview_lines">3</integer>
+</resources>
diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java
index 75ee0648..6e3387dc 100644
--- a/java/src/com/android/intentresolver/ChooserActivity.java
+++ b/java/src/com/android/intentresolver/ChooserActivity.java
@@ -1621,8 +1621,7 @@ public class ChooserActivity extends ResolverActivity implements
* we instead show the content preview as a regular list item.
*/
private boolean shouldShowStickyContentPreview() {
- return shouldShowStickyContentPreviewNoOrientationCheck()
- && !getResources().getBoolean(R.bool.resolver_landscape_phone);
+ return shouldShowStickyContentPreviewNoOrientationCheck();
}
private boolean shouldShowStickyContentPreviewNoOrientationCheck() {
diff --git a/java/src/com/android/intentresolver/widget/ChooserActionRow.kt b/java/src/com/android/intentresolver/widget/ChooserActionRow.kt
deleted file mode 100644
index a4656bb5..00000000
--- a/java/src/com/android/intentresolver/widget/ChooserActionRow.kt
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.intentresolver.widget
-
-import android.annotation.LayoutRes
-import android.content.Context
-import android.os.Parcelable
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.Button
-import android.widget.LinearLayout
-import com.android.intentresolver.R
-import com.android.intentresolver.widget.ActionRow.Action
-
-class ChooserActionRow : LinearLayout, ActionRow {
- constructor(context: Context) : this(context, null)
- constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
- constructor(
- context: Context, attrs: AttributeSet?, defStyleAttr: Int
- ) : this(context, attrs, defStyleAttr, 0)
-
- constructor(
- context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int
- ) : super(context, attrs, defStyleAttr, defStyleRes) {
- orientation = HORIZONTAL
- }
-
- @LayoutRes
- private val itemLayout = R.layout.chooser_action_button
- private val itemMargin =
- context.resources.getDimensionPixelSize(R.dimen.resolver_icon_margin) / 2
- private var actions: List<Action> = emptyList()
-
- override fun onRestoreInstanceState(state: Parcelable?) {
- super.onRestoreInstanceState(state)
- setActions(actions)
- }
-
- override fun setActions(actions: List<Action>) {
- removeAllViews()
- this.actions = ArrayList(actions)
- for (action in actions) {
- addAction(action)
- }
- }
-
- private fun addAction(action: Action) {
- val b = LayoutInflater.from(context).inflate(itemLayout, null) as Button
- if (action.icon != null) {
- val size = resources
- .getDimensionPixelSize(R.dimen.chooser_action_button_icon_size)
- action.icon.setBounds(0, 0, size, size)
- b.setCompoundDrawablesRelative(action.icon, null, null, null)
- }
- b.text = action.label ?: ""
- b.setOnClickListener {
- action.onClicked.run()
- }
- b.id = action.id
- addView(b)
- }
-
- override fun generateDefaultLayoutParams(): LayoutParams =
- super.generateDefaultLayoutParams().apply {
- setMarginsRelative(itemMargin, 0, itemMargin, 0)
- }
-}
diff --git a/java/src/com/android/intentresolver/widget/ScrollableActionRow.kt b/java/src/com/android/intentresolver/widget/ScrollableActionRow.kt
index f2a8b9e8..8fdb609e 100644
--- a/java/src/com/android/intentresolver/widget/ScrollableActionRow.kt
+++ b/java/src/com/android/intentresolver/widget/ScrollableActionRow.kt
@@ -35,9 +35,16 @@ class ScrollableActionRow : RecyclerView, ActionRow {
) : super(context, attrs, defStyleAttr) {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
adapter = Adapter(context)
+
+ context.obtainStyledAttributes(
+ attrs, R.styleable.ScrollableActionRow, defStyleAttr, 0
+ ).use { a ->
+ horizontalActions = a.getBoolean(R.styleable.ScrollableActionRow_horizontalActions, false)
+ }
}
private val actionsAdapter get() = adapter as Adapter
+ private val horizontalActions: Boolean
override fun setActions(actions: List<ActionRow.Action>) {
actionsAdapter.setActions(actions)
@@ -50,7 +57,7 @@ class ScrollableActionRow : RecyclerView, ActionRow {
)
}
- private class Adapter(private val context: Context) : RecyclerView.Adapter<ViewHolder>() {
+ private inner class Adapter(private val context: Context) : RecyclerView.Adapter<ViewHolder>() {
private val iconSize: Int =
context.resources.getDimensionPixelSize(R.dimen.chooser_action_view_icon_size)
private val itemLayout = R.layout.chooser_action_view
@@ -59,7 +66,7 @@ class ScrollableActionRow : RecyclerView, ActionRow {
override fun onCreateViewHolder(parent: ViewGroup, type: Int): ViewHolder =
ViewHolder(
LayoutInflater.from(context).inflate(itemLayout, null) as TextView,
- iconSize
+ iconSize,
)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
@@ -83,8 +90,8 @@ class ScrollableActionRow : RecyclerView, ActionRow {
}
}
- private class ViewHolder(
- private val view: TextView, private val iconSize: Int
+ private inner class ViewHolder(
+ private val view: TextView, private val iconSize: Int,
) : RecyclerView.ViewHolder(view) {
fun bind(action: ActionRow.Action) {
@@ -93,7 +100,11 @@ class ScrollableActionRow : RecyclerView, ActionRow {
// some drawables (edit) does not gets tinted when set to the top of the text
// with TextView#setCompoundDrawableRelative
tintIcon(icon, view)
- view.setCompoundDrawablesRelative(null, icon, null, null)
+ if (horizontalActions) {
+ view.setCompoundDrawablesRelative(icon, null, null, null)
+ } else {
+ view.setCompoundDrawablesRelative(null, icon, null, null)
+ }
}
view.text = action.label ?: ""
view.setOnClickListener {