Update logic to check two pane resolution
Prior to this cl, we checked the app bounds for deciding app in two pane or not. However, this might be broken in some certain sceanrios. Currently, api will check the entire task bounds. If the width of task bounds is larger than two pane criteria, then we treat it as in two pane mode. Test: Highlighted behavior works correct. Fix: 203763572 Change-Id: Ib14851b1e3e097328874c7956bb653f50820f877
This commit is contained in:
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.activityembedding;
|
package com.android.settings.activityembedding;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityTaskManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -64,10 +67,11 @@ public class ActivityEmbeddingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Whether the screen meets two-pane resolution. */
|
/** Whether the screen meets two-pane resolution. */
|
||||||
public static boolean isTwoPaneResolution(Context context) {
|
public static boolean isTwoPaneResolution(Activity activity) {
|
||||||
final Context appContext = context.getApplicationContext();
|
final Rect currentTaskBounds =
|
||||||
final DisplayMetrics dm = appContext.getResources().getDisplayMetrics();
|
ActivityTaskManager.getInstance().getTaskBounds(activity.getTaskId());
|
||||||
return dm.widthPixels >= getMinCurrentScreenSplitWidthPx(appContext)
|
|
||||||
&& dm.heightPixels >= getMinSmallestScreenSplitWidthPx(appContext);
|
return currentTaskBounds.width() >= getMinCurrentScreenSplitWidthPx(activity)
|
||||||
|
&& currentTaskBounds.height() >= getMinSmallestScreenSplitWidthPx(activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -196,8 +196,8 @@ public class TopLevelSettings extends DashboardFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "onCreateAdapter, pref key: " + mHighlightedPreferenceKey);
|
Log.d(TAG, "onCreateAdapter, pref key: " + mHighlightedPreferenceKey);
|
||||||
mTopLevelAdapter = new HighlightableTopLevelPreferenceAdapter(preferenceScreen,
|
mTopLevelAdapter = new HighlightableTopLevelPreferenceAdapter(
|
||||||
getListView(), mHighlightedPreferenceKey);
|
getActivity(), preferenceScreen, getListView(), mHighlightedPreferenceKey);
|
||||||
return mTopLevelAdapter;
|
return mTopLevelAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.widget;
|
package com.android.settings.widget;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -53,6 +54,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
final int mIconColorHighlight;
|
final int mIconColorHighlight;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
private final Activity mActivity;
|
||||||
private final RecyclerView mRecyclerView;
|
private final RecyclerView mRecyclerView;
|
||||||
private final int mNormalBackgroundRes;
|
private final int mNormalBackgroundRes;
|
||||||
private String mHighlightKey;
|
private String mHighlightKey;
|
||||||
@@ -61,12 +63,13 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
private boolean mHighlightNeeded;
|
private boolean mHighlightNeeded;
|
||||||
private boolean mScrolled;
|
private boolean mScrolled;
|
||||||
|
|
||||||
public HighlightableTopLevelPreferenceAdapter(PreferenceGroup preferenceGroup,
|
public HighlightableTopLevelPreferenceAdapter(Activity activity,
|
||||||
RecyclerView recyclerView, String key) {
|
PreferenceGroup preferenceGroup, RecyclerView recyclerView, String key) {
|
||||||
super(preferenceGroup);
|
super(preferenceGroup);
|
||||||
mRecyclerView = recyclerView;
|
mRecyclerView = recyclerView;
|
||||||
mHighlightKey = key;
|
mHighlightKey = key;
|
||||||
mContext = preferenceGroup.getContext();
|
mContext = preferenceGroup.getContext();
|
||||||
|
mActivity = activity;
|
||||||
final TypedValue outValue = new TypedValue();
|
final TypedValue outValue = new TypedValue();
|
||||||
mContext.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
|
mContext.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
|
||||||
outValue, true /* resolveRefs */);
|
outValue, true /* resolveRefs */);
|
||||||
@@ -233,6 +236,6 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHighlightNeeded() {
|
private boolean isHighlightNeeded() {
|
||||||
return ActivityEmbeddingUtils.isTwoPaneResolution(mContext);
|
return ActivityEmbeddingUtils.isTwoPaneResolution(mActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user