diff options
author | Luca Stefani <luca.stefani.ge1@gmail.com> | 2020-03-07 13:43:59 +0100 |
---|---|---|
committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2020-03-07 13:43:59 +0100 |
commit | 0007a046cf4f4bfed563aa52ffab9ec5e94ee6f0 (patch) | |
tree | 2bc4acf2f54df560a34dcc7b7844d9d18cc58131 /src/com/android/launcher3/util/ConfigMonitor.java | |
parent | 744d192669a148bde24d36bef02deb05c2f7a1fa (diff) | |
parent | 02826bbe04d9dc1e6111f5d6ffd8706ac1f8f908 (diff) | |
download | packages_apps_Trebuchet-0007a046cf4f4bfed563aa52ffab9ec5e94ee6f0.tar.gz packages_apps_Trebuchet-0007a046cf4f4bfed563aa52ffab9ec5e94ee6f0.tar.bz2 packages_apps_Trebuchet-0007a046cf4f4bfed563aa52ffab9ec5e94ee6f0.zip |
Merge tag 'android-10.0.0_r31' into HEAD
Android 10.0.0 release 31
* tag 'android-10.0.0_r31': (218 commits)
Increase drag distance threshold when drag starts from deep press
Fix shortcut componentname in workspace layout logging
Fix shortcut componentname in workspace layout logging
perform accessbility focus when the recyclerview doesn't gain focus after fragment replacement in SettingsActivity
Persist predicted items when dragged to workspace
Import translations. DO NOT MERGE
Import translations. DO NOT MERGE
Align badging logic with platform IconDrawableFactory.
Fix bug where icon remains invisible after returning home.
Fix quick switch from home biased towards returning home
Fix recents scale sometimes lagging behind window scale
Fix folder open/close animation when grid size is small.
fix custom shortcut test
Improve quick switch from home by tracking both x and y motion
Move shelf peeking anim code to ShelfPeekAnim class
Fix folder available height calculation
Tapl: AllApps: ensuring a minimal vertical size of an icon
Enable a11y scrolling with item drag
disable custom shortcut test in oop
include predicted_rank in app launch logging
...
Change-Id: Id824c350cd133c4c8fa91de0f8793faed9003393
Diffstat (limited to 'src/com/android/launcher3/util/ConfigMonitor.java')
-rw-r--r-- | src/com/android/launcher3/util/ConfigMonitor.java | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/src/com/android/launcher3/util/ConfigMonitor.java b/src/com/android/launcher3/util/ConfigMonitor.java index 12d35e962..0f8152057 100644 --- a/src/com/android/launcher3/util/ConfigMonitor.java +++ b/src/com/android/launcher3/util/ConfigMonitor.java @@ -16,20 +16,15 @@ package com.android.launcher3.util; * limitations under the License. */ +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.graphics.Point; -import android.hardware.display.DisplayManager; -import android.hardware.display.DisplayManager.DisplayListener; -import android.os.Handler; import android.util.Log; -import android.view.Display; -import android.view.WindowManager; - -import com.android.launcher3.MainThreadExecutor; import java.util.function.Consumer; @@ -37,7 +32,8 @@ import java.util.function.Consumer; * {@link BroadcastReceiver} which watches configuration changes and * notifies the callback in case changes which affect the device profile occur. */ -public class ConfigMonitor extends BroadcastReceiver implements DisplayListener { +public class ConfigMonitor extends BroadcastReceiver implements + DefaultDisplay.DisplayInfoChangeListener { private static final String TAG = "ConfigMonitor"; @@ -61,24 +57,19 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener mFontScale = config.fontScale; mDensity = config.densityDpi; - Display display = getDefaultDisplay(context); - mDisplayId = display.getDisplayId(); - - mRealSize = new Point(); - display.getRealSize(mRealSize); + DefaultDisplay display = DefaultDisplay.INSTANCE.get(context); + display.addChangeListener(this); + DefaultDisplay.Info displayInfo = display.getInfo(); + mDisplayId = displayInfo.id; - mSmallestSize = new Point(); - mLargestSize = new Point(); - display.getCurrentSizeRange(mSmallestSize, mLargestSize); + mRealSize = new Point(displayInfo.realSize); + mSmallestSize = new Point(displayInfo.smallestSize); + mLargestSize = new Point(displayInfo.largestSize); mCallback = callback; // Listen for configuration change mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); - - // Listen for display manager change - mContext.getSystemService(DisplayManager.class) - .registerDisplayListener(this, new Handler(UiThreadHelper.getBackgroundLooper())); } @Override @@ -91,26 +82,19 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener } @Override - public void onDisplayAdded(int displayId) { } - - @Override - public void onDisplayRemoved(int displayId) { } - - @Override - public void onDisplayChanged(int displayId) { - if (displayId != mDisplayId) { + public void onDisplayInfoChanged(DefaultDisplay.Info info, int flags) { + if (info.id != mDisplayId) { return; } - Display display = getDefaultDisplay(mContext); - display.getRealSize(mTmpPoint1); - + mTmpPoint1.set(info.realSize.x, info.realSize.y); if (!mRealSize.equals(mTmpPoint1) && !mRealSize.equals(mTmpPoint1.y, mTmpPoint1.x)) { Log.d(TAG, String.format("Display size changed from %s to %s", mRealSize, mTmpPoint1)); notifyChange(); return; } - display.getCurrentSizeRange(mTmpPoint1, mTmpPoint2); + mTmpPoint1.set(info.smallestSize.x, info.smallestSize.y); + mTmpPoint2.set(info.largestSize.x, info.largestSize.y); if (!mSmallestSize.equals(mTmpPoint1) || !mLargestSize.equals(mTmpPoint2)) { Log.d(TAG, String.format("Available size changed from [%s, %s] to [%s, %s]", mSmallestSize, mLargestSize, mTmpPoint1, mTmpPoint2)); @@ -122,18 +106,15 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener if (mCallback != null) { Consumer<Context> callback = mCallback; mCallback = null; - new MainThreadExecutor().execute(() -> callback.accept(mContext)); + MAIN_EXECUTOR.execute(() -> callback.accept(mContext)); } } - private Display getDefaultDisplay(Context context) { - return context.getSystemService(WindowManager.class).getDefaultDisplay(); - } - public void unregister() { try { mContext.unregisterReceiver(this); - mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this); + DefaultDisplay display = DefaultDisplay.INSTANCE.get(mContext); + display.removeChangeListener(this); } catch (Exception e) { Log.e(TAG, "Failed to unregister config monitor", e); } |