Merge "Import translations. DO NOT MERGE ANYWHERE" into tm-qpr-dev
diff --git a/res/layout/fragment_wallpaper_preview.xml b/res/layout/fragment_wallpaper_preview.xml
index bc73fa8..f6a9c70 100644
--- a/res/layout/fragment_wallpaper_preview.xml
+++ b/res/layout/fragment_wallpaper_preview.xml
@@ -34,6 +34,13 @@
<include layout="@layout/wallpaper_preview" />
+ <View
+ android:id="@+id/preview_scrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/wallpaper_preview_scrim_color"
+ android:importantForAccessibility="noHideDescendants" />
+
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -54,6 +61,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/set_wallpaper_button_background"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
android:gravity="center"
android:text="@string/set_wallpaper_button_text"
android:textColor="@color/text_color_on_accent"
@@ -67,6 +75,7 @@
android:layout_width="@dimen/wallpaper_control_button_size"
android:layout_height="@dimen/wallpaper_control_button_size"
android:layout_marginEnd="@dimen/wallpaper_control_button_group_margin_end"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/toolbar"
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
diff --git a/res/layout/wallpaper_control_button_group.xml b/res/layout/wallpaper_control_button_group.xml
index 6084e27..68e5c4c 100644
--- a/res/layout/wallpaper_control_button_group.xml
+++ b/res/layout/wallpaper_control_button_group.xml
@@ -27,6 +27,7 @@
android:layout_height="@dimen/wallpaper_control_button_size"
android:background="@android:color/transparent"
android:contentDescription="@string/delete_live_wallpaper"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
android:foreground="@drawable/wallpaper_control_button_delete"
android:textOff=""
android:textOn=""
@@ -38,6 +39,7 @@
android:layout_height="@dimen/wallpaper_control_button_size"
android:background="@android:color/transparent"
android:contentDescription="@string/edit_live_wallpaper"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
android:foreground="@drawable/wallpaper_control_button_edit"
android:textOff=""
android:textOn=""
@@ -49,6 +51,7 @@
android:layout_height="@dimen/wallpaper_control_button_size"
android:background="@android:color/transparent"
android:contentDescription="@string/tab_customize"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
android:foreground="@drawable/wallpaper_control_button_customize"
android:textOff=""
android:textOn=""
@@ -60,6 +63,7 @@
android:layout_height="@dimen/wallpaper_control_button_size"
android:background="@android:color/transparent"
android:contentDescription="@string/tab_effects"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
android:foreground="@drawable/wallpaper_control_button_effect"
android:textOff=""
android:textOn=""
@@ -71,6 +75,7 @@
android:layout_height="@dimen/wallpaper_control_button_size"
android:background="@android:color/transparent"
android:contentDescription="@string/tab_info"
+ android:elevation="@dimen/wallpaper_preview_buttons_elevation"
android:foreground="@drawable/wallpaper_control_button_info"
android:textOff=""
android:textOn=""
diff --git a/res/layout/wallpaper_preview_card.xml b/res/layout/wallpaper_preview_card.xml
index c655d6f..3cce126 100644
--- a/res/layout/wallpaper_preview_card.xml
+++ b/res/layout/wallpaper_preview_card.xml
@@ -36,7 +36,7 @@
android:id="@+id/wallpaper_dimming_scrim"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#4d000000"
+ android:background="@color/wallpaper_preview_scrim_color"
android:visibility="invisible"
android:importantForAccessibility="noHideDescendants" />
diff --git a/res/values-w800dp/dimens.xml b/res/values-w800dp/dimens.xml
index 3a84ad9..2321787 100644
--- a/res/values-w800dp/dimens.xml
+++ b/res/values-w800dp/dimens.xml
@@ -62,5 +62,5 @@
<!-- Clipping of the home screen overlay -->
<dimen name="home_screen_overlay_top_clipping">0dp</dimen>
- <dimen name="home_screen_overlay_bottom_clipping">110dp</dimen>
+ <dimen name="home_screen_overlay_bottom_clipping">80dp</dimen>
</resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 02dce75..4268ddf 100755
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -54,4 +54,6 @@
<color name="text_color_primary_inverse">@android:color/system_neutral1_900</color>
<color name="text_color_secondary">@color/settingslib_text_color_secondary</color>
<color name="text_color_secondary_inverse">@color/settingslib_text_color_secondary_device_default</color>
+
+ <color name="wallpaper_preview_scrim_color">#4d000000</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 502d1eb..5222e71 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -218,6 +218,7 @@
<dimen name="wallpaper_picker_entry_horizontal_padding">16dp</dimen>
<dimen name="wallpaper_picker_entry_margin_vertical">16dp</dimen>
<dimen name="wallpaper_picker_entry_card_corner_radius">12dp</dimen>
+ <dimen name="wallpaper_preview_buttons_elevation">8dp</dimen>
<!-- For the full screen preview activity's hide UI menu item -->
<dimen name="menu_item_hide_ui_background_width">46dp</dimen>
diff --git a/src/com/android/wallpaper/picker/FullPreviewActivity.java b/src/com/android/wallpaper/picker/FullPreviewActivity.java
index ccbd3ac..ae09edd 100755
--- a/src/com/android/wallpaper/picker/FullPreviewActivity.java
+++ b/src/com/android/wallpaper/picker/FullPreviewActivity.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.transition.Slide;
import android.view.Window;
@@ -29,6 +30,7 @@
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost;
import com.android.wallpaper.util.ActivityUtils;
+import com.android.wallpaper.util.DisplayUtils;
/**
* Activity that displays a full preview of a specific wallpaper and provides the ability to set the
@@ -41,7 +43,7 @@
*/
public static Intent newIntent(Context packageContext, WallpaperInfo wallpaperInfo) {
Intent intent = new Intent(packageContext, FullPreviewActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(EXTRA_WALLPAPER_INFO, wallpaperInfo);
return intent;
}
@@ -100,6 +102,10 @@
@Override
protected void onResume() {
super.onResume();
+ DisplayUtils displayUtils = InjectorProvider.getInjector().getDisplayUtils(this);
+ int orientation = displayUtils.isOnWallpaperDisplay(this)
+ ? ActivityInfo.SCREEN_ORIENTATION_USER : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+ setRequestedOrientation(orientation);
if (isInMultiWindowMode()) {
onBackPressed();
}
diff --git a/src/com/android/wallpaper/picker/TouchForwardingLayout.java b/src/com/android/wallpaper/picker/TouchForwardingLayout.java
index 2cb692d..ced5968 100644
--- a/src/com/android/wallpaper/picker/TouchForwardingLayout.java
+++ b/src/com/android/wallpaper/picker/TouchForwardingLayout.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.util.AttributeSet;
+import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
@@ -26,13 +27,22 @@
private View mView;
private boolean mForwardingEnabled;
+ private GestureDetector mGestureDetector;
public TouchForwardingLayout(Context context, AttributeSet attrs) {
super(context, attrs);
+ mGestureDetector = new GestureDetector(context,
+ new GestureDetector.SimpleOnGestureListener() {
+ @Override
+ public boolean onSingleTapConfirmed(MotionEvent e) {
+ return performClick();
+ }
+ });
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
+ mGestureDetector.onTouchEvent(ev);
if (mView != null && mForwardingEnabled) {
mView.dispatchTouchEvent(ev);
}
diff --git a/src/com/android/wallpaper/util/DisplayUtils.kt b/src/com/android/wallpaper/util/DisplayUtils.kt
index 0053572..55bd8b7 100644
--- a/src/com/android/wallpaper/util/DisplayUtils.kt
+++ b/src/com/android/wallpaper/util/DisplayUtils.kt
@@ -26,31 +26,22 @@
* Utility class to provide methods to find and obtain information about displays via {@link
* DisplayManager}
*/
-class DisplayUtils(context: Context) {
+class DisplayUtils(private val context: Context) {
companion object {
private const val TAG = "DisplayUtils"
}
- private val internalDisplays: List<Display>
-
- init {
- val appContext = context.applicationContext
- val dm = appContext.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
- val allDisplays: Array<out Display> =
- dm.getDisplays(DisplayManager.DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED)
- if (allDisplays.isEmpty()) {
- Log.e(TAG, "No displays found on context $appContext")
- throw RuntimeException("No displays found!")
- }
- internalDisplays = allDisplays.filter { it.type == Display.TYPE_INTERNAL }
+ private val displayManager: DisplayManager by lazy {
+ context.applicationContext.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
}
fun hasMultiInternalDisplays(): Boolean {
- return internalDisplays.size > 1
+ return getInternalDisplays().size > 1
}
/** Returns the {@link Display} to be used to calculate wallpaper size and cropping. */
fun getWallpaperDisplay(): Display {
+ val internalDisplays = getInternalDisplays()
return internalDisplays.maxWithOrNull { a, b -> getRealSize(a) - getRealSize(b) }
?: internalDisplays[0]
}
@@ -62,7 +53,7 @@
* display device the only display is both the wallpaper display and the current display.
*/
fun isOnWallpaperDisplay(activity: Activity): Boolean {
- return activity.display.displayId == getWallpaperDisplay().displayId
+ return activity.display.uniqueId == getWallpaperDisplay().uniqueId
}
private fun getRealSize(display: Display): Int {
@@ -70,4 +61,14 @@
display.getRealSize(p)
return p.x * p.y
}
+
+ private fun getInternalDisplays(): List<Display> {
+ val allDisplays: Array<out Display> =
+ displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED)
+ if (allDisplays.isEmpty()) {
+ Log.e(TAG, "No displays found on context ${context.applicationContext}")
+ throw RuntimeException("No displays found!")
+ }
+ return allDisplays.filter { it.type == Display.TYPE_INTERNAL }
+ }
}