Merge "Add lint baseline to address NewApi errors" into sc-dev
diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
index e13d1a4..8168e88 100644
--- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
@@ -27,6 +27,7 @@
import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.util.ActivityInitListener;
@@ -139,7 +140,25 @@
@Override
public void onExitOverview(RotationTouchHelper deviceState, Runnable exitRunnable) {
- // no-op, fake landscape not supported for 3P
+ final StateManager<RecentsState> stateManager = getCreatedActivity().getStateManager();
+ if (stateManager.getState() == HOME) {
+ exitRunnable.run();
+ notifyRecentsOfOrientation(deviceState);
+ return;
+ }
+
+ stateManager.addStateListener(
+ new StateManager.StateListener<RecentsState>() {
+ @Override
+ public void onStateTransitionComplete(RecentsState toState) {
+ // Are we going from Recents to Workspace?
+ if (toState == HOME) {
+ exitRunnable.run();
+ notifyRecentsOfOrientation(deviceState);
+ stateManager.removeStateListener(this);
+ }
+ }
+ });
}
@Override
diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml
index 598041c..8259c16 100644
--- a/res/layout/widgets_list_row_header.xml
+++ b/res/layout/widgets_list_row_header.xml
@@ -15,6 +15,7 @@
-->
<com.android.launcher3.widget.picker.WidgetsListHeader xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:id="@+id/widgets_list_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -22,7 +23,8 @@
android:background="@drawable/widgets_list_middle_ripple"
android:layout_marginBottom="@dimen/widget_list_entry_bottom_margin"
android:paddingVertical="@dimen/widget_list_header_view_vertical_padding"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ launcher:appIconSize="48dp">
<ImageView
android:id="@+id/app_icon"
diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml
index e4bea50..8195cc1 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -22,14 +22,7 @@
android:key="pref_icon_badging"
android:title="@string/notification_dots_title"
android:persistent="false"
- android:widgetLayout="@layout/notification_pref_warning" >
- <intent android:action="android.settings.NOTIFICATION_SETTINGS">
- <!-- This extra highlights the "Allow notification dots" field in Notification settings -->
- <extra
- android:name=":settings:fragment_args_key"
- android:value="notification_badging" />
- </intent>
- </com.android.launcher3.settings.NotificationDotsPreference>
+ android:widgetLayout="@layout/notification_pref_warning" />
<!--
LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_ENABLED(613)
diff --git a/src/com/android/launcher3/settings/NotificationDotsPreference.java b/src/com/android/launcher3/settings/NotificationDotsPreference.java
index afcf882..0ee2744 100644
--- a/src/com/android/launcher3/settings/NotificationDotsPreference.java
+++ b/src/com/android/launcher3/settings/NotificationDotsPreference.java
@@ -85,6 +85,12 @@
Settings.Secure.getUriFor(NOTIFICATION_ENABLED_LISTENERS),
false, mListenerListObserver);
updateUI();
+
+ // Update intent
+ Bundle extras = new Bundle();
+ extras.putString(EXTRA_FRAGMENT_ARG_KEY, "notification_badging");
+ setIntent(new Intent("android.settings.NOTIFICATION_SETTINGS")
+ .putExtra(EXTRA_SHOW_FRAGMENT_ARGS, extras));
}
private void updateUI() {
diff --git a/src/com/android/launcher3/settings/PreferenceHighlighter.java b/src/com/android/launcher3/settings/PreferenceHighlighter.java
index 8ba8146..96ee216 100644
--- a/src/com/android/launcher3/settings/PreferenceHighlighter.java
+++ b/src/com/android/launcher3/settings/PreferenceHighlighter.java
@@ -24,16 +24,18 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.RectF;
import android.util.Property;
import android.view.View;
-import com.android.launcher3.util.Themes;
-
+import androidx.preference.Preference;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ItemDecoration;
import androidx.recyclerview.widget.RecyclerView.State;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
+import com.android.launcher3.util.Themes;
+
/**
* Utility class for highlighting a preference
*/
@@ -62,14 +64,16 @@
private final Paint mPaint = new Paint();
private final RecyclerView mRv;
private final int mIndex;
+ private final Preference mPreference;
+ private final RectF mDrawRect = new RectF();
private boolean mHighLightStarted = false;
private int mHighlightColor = END_COLOR;
-
- public PreferenceHighlighter(RecyclerView rv, int index) {
+ public PreferenceHighlighter(RecyclerView rv, int index, Preference preference) {
mRv = rv;
mIndex = index;
+ mPreference = preference;
}
@Override
@@ -92,7 +96,8 @@
if (!mHighLightStarted) {
// Start highlight
int colorTo = setColorAlphaBound(Themes.getColorAccent(mRv.getContext()), 66);
- ObjectAnimator anim = ObjectAnimator.ofArgb(this, HIGHLIGHT_COLOR, END_COLOR, colorTo);
+ ObjectAnimator anim = ObjectAnimator.ofArgb(this, HIGHLIGHT_COLOR, END_COLOR,
+ colorTo);
anim.setDuration(HIGHLIGHT_FADE_IN_DURATION);
anim.setRepeatMode(ValueAnimator.REVERSE);
anim.setRepeatCount(4);
@@ -108,7 +113,11 @@
View view = holder.itemView;
mPaint.setColor(mHighlightColor);
- c.drawRect(0, view.getY(), parent.getWidth(), view.getY() + view.getHeight(), mPaint);
+ mDrawRect.set(0, view.getY(), parent.getWidth(), view.getY() + view.getHeight());
+ if (mPreference instanceof HighlightDelegate) {
+ ((HighlightDelegate) mPreference).offsetHighlight(view, mDrawRect);
+ }
+ c.drawRect(mDrawRect, mPaint);
}
private void removeHighlight() {
@@ -124,4 +133,16 @@
});
anim.start();
}
+
+ /**
+ * Interface to be implemented by a preference to customize the highlight are
+ */
+ public interface HighlightDelegate {
+
+ /**
+ * Allows the preference to update the highlight area
+ */
+ void offsetHighlight(View prefView, RectF bounds);
+
+ }
}
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 5b42ac7..216510b 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -237,7 +237,9 @@
RecyclerView list = getListView();
PreferencePositionCallback callback = (PreferencePositionCallback) list.getAdapter();
int position = callback.getPreferenceAdapterPosition(mHighLightKey);
- return position >= 0 ? new PreferenceHighlighter(list, position) : null;
+ return position >= 0 ? new PreferenceHighlighter(
+ list, position, screen.findPreference(mHighLightKey))
+ : null;
}
private void requestAccessibilityFocus(@NonNull final RecyclerView rv) {
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutView.java b/src/com/android/launcher3/shortcuts/DeepShortcutView.java
index 1c1418c..cc658c9 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutView.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutView.java
@@ -30,12 +30,13 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.PopupContainerWithArrow;
+import com.android.launcher3.views.BubbleTextHolder;
/**
* A {@link android.widget.FrameLayout} that contains a {@link DeepShortcutView}.
* This lets us animate the DeepShortcutView (icon and text) separately from the background.
*/
-public class DeepShortcutView extends FrameLayout {
+public class DeepShortcutView extends FrameLayout implements BubbleTextHolder {
private static final Point sTempPoint = new Point();
@@ -64,6 +65,7 @@
mIconView = findViewById(R.id.icon);
}
+ @Override
public BubbleTextView getBubbleText() {
return mBubbleText;
}
diff --git a/src/com/android/launcher3/views/BubbleTextHolder.java b/src/com/android/launcher3/views/BubbleTextHolder.java
new file mode 100644
index 0000000..47d3563
--- /dev/null
+++ b/src/com/android/launcher3/views/BubbleTextHolder.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2021 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.launcher3.views;
+
+import com.android.launcher3.BubbleTextView;
+
+/**
+ * Views that contain {@link BubbleTextView} should implement this interface.
+ */
+public interface BubbleTextHolder {
+ BubbleTextView getBubbleText();
+}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 23c3722..96268ce 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -210,8 +210,8 @@
public static void getLocationBoundsForView(Launcher launcher, View v, boolean isOpening,
RectF outRect, Rect outViewBounds) {
boolean ignoreTransform = !isOpening;
- if (v instanceof DeepShortcutView) {
- v = ((DeepShortcutView) v).getBubbleText();
+ if (v instanceof BubbleTextHolder) {
+ v = ((BubbleTextHolder) v).getBubbleText();
ignoreTransform = false;
} else if (v.getParent() instanceof DeepShortcutView) {
v = ((DeepShortcutView) v.getParent()).getIconView();
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index bbb0d92..0670928 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -170,9 +170,9 @@
WidgetCell widget = (WidgetCell) LayoutInflater.from(getContext())
.inflate(R.layout.widget_cell, parent, false);
- WidgetImageView preview = widget.findViewById(R.id.widget_preview);
- preview.setOnClickListener(this);
- preview.setOnLongClickListener(this);
+ View preview_container = widget.findViewById(R.id.widget_preview_container);
+ preview_container.setOnClickListener(this);
+ preview_container.setOnLongClickListener(this);
widget.setAnimatePreview(false);
parent.addView(widget);
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
index 497c72e..8794a4a 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
@@ -156,6 +156,11 @@
private void applyDrawables(Drawable icon) {
icon.setBounds(0, 0, mIconSize, mIconSize);
+ LinearLayout.LayoutParams layoutParams =
+ (LinearLayout.LayoutParams) mAppIcon.getLayoutParams();
+ layoutParams.width = mIconSize;
+ layoutParams.height = mIconSize;
+ mAppIcon.setLayoutParams(layoutParams);
mAppIcon.setImageDrawable(icon);
// If the current icon is a placeholder color, animate its update.