Fix The education UI above one-handed mode isn't localized
and Display size changes Handling onConfigurationChanged() event to response system configuraiton changes. Bug: 177980234 Bug: 177222027 Bug: 177222126 Test: manual Change-Id: I93dec3e83ae287c5dabc494625929c43f44a7037
This commit is contained in:
@@ -54,8 +54,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginStart="86dp"
|
||||
android:layout_marginEnd="86dp"
|
||||
android:layout_marginStart="46dp"
|
||||
android:layout_marginEnd="46dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:fontFamily="roboto-regular"
|
||||
android:text="@string/one_handed_tutorial_description"
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package com.android.wm.shell.onehanded;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.android.wm.shell.common.annotations.ExternalThread;
|
||||
import com.android.wm.shell.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Interface to engage one handed feature.
|
||||
*/
|
||||
@@ -69,4 +67,9 @@ public interface OneHanded {
|
||||
* 3 button navigation mode only
|
||||
*/
|
||||
void registerGestureCallback(OneHandedGestureEventCallback callback);
|
||||
|
||||
/**
|
||||
* Receive onConfigurationChanged() events
|
||||
*/
|
||||
void onConfigChanged(Configuration newConfig);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.om.OverlayInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Point;
|
||||
import android.os.Handler;
|
||||
@@ -472,6 +473,16 @@ public class OneHandedController {
|
||||
}
|
||||
}
|
||||
|
||||
private void onConfigChanged(Configuration newConfig) {
|
||||
if (mTutorialHandler != null) {
|
||||
if (!mIsOneHandedEnabled
|
||||
|| newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
return;
|
||||
}
|
||||
mTutorialHandler.onConfigurationChanged(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public void dump(@NonNull PrintWriter pw) {
|
||||
final String innerPrefix = " ";
|
||||
pw.println(TAG + "states: ");
|
||||
@@ -565,5 +576,12 @@ public class OneHandedController {
|
||||
OneHandedController.this.registerGestureCallback(callback);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
mMainExecutor.execute(() -> {
|
||||
OneHandedController.this.onConfigChanged(newConfig);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.wm.shell.onehanded;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
@@ -55,12 +56,14 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
private final AccessibilityManager mAccessibilityManager;
|
||||
private final String mPackageName;
|
||||
|
||||
private Context mContext;
|
||||
private View mTutorialView;
|
||||
private Point mDisplaySize = new Point();
|
||||
private ContentResolver mContentResolver;
|
||||
private boolean mCanShowTutorial;
|
||||
private String mStartOneHandedDescription;
|
||||
private String mStopOneHandedDescription;
|
||||
private boolean mIsOneHandedMode;
|
||||
|
||||
private enum ONE_HANDED_TRIGGER_STATE {
|
||||
UNSET, ENTERING, EXITING
|
||||
@@ -92,13 +95,14 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
mTriggerState = (startValue.top == 0)
|
||||
? ONE_HANDED_TRIGGER_STATE.ENTERING : ONE_HANDED_TRIGGER_STATE.EXITING;
|
||||
if (mCanShowTutorial && mTriggerState == ONE_HANDED_TRIGGER_STATE.ENTERING) {
|
||||
createTutorialTarget();
|
||||
attachTurtorialTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public OneHandedTutorialHandler(Context context, ShellExecutor mainExecutor) {
|
||||
mContext = context;
|
||||
context.getDisplay().getRealSize(mDisplaySize);
|
||||
mPackageName = context.getPackageName();
|
||||
mContentResolver = context.getContentResolver();
|
||||
@@ -113,6 +117,7 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
mCanShowTutorial = (Settings.Secure.getInt(mContentResolver,
|
||||
Settings.Secure.ONE_HANDED_TUTORIAL_SHOW_COUNT, 0) >= MAX_TUTORIAL_SHOW_COUNT)
|
||||
? false : true;
|
||||
mIsOneHandedMode = false;
|
||||
final float offsetPercentageConfig = context.getResources().getFraction(
|
||||
R.fraction.config_one_handed_offset, 1, 1);
|
||||
final int sysPropPercentageConfig = SystemProperties.getInt(
|
||||
@@ -120,11 +125,7 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
mTutorialAreaHeight = Math.round(mDisplaySize.y * (sysPropPercentageConfig / 100.0f));
|
||||
|
||||
mainExecutor.execute(() -> {
|
||||
mTutorialView = LayoutInflater.from(context).inflate(R.layout.one_handed_tutorial,
|
||||
null);
|
||||
mTargetViewContainer = new FrameLayout(context);
|
||||
mTargetViewContainer.setClipChildren(false);
|
||||
mTargetViewContainer.addView(mTutorialView);
|
||||
recreateTutorialView(mContext);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -144,10 +145,20 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
mTriggerState = ONE_HANDED_TRIGGER_STATE.UNSET;
|
||||
}
|
||||
|
||||
private void recreateTutorialView(Context context) {
|
||||
mTutorialView = LayoutInflater.from(context).inflate(R.layout.one_handed_tutorial,
|
||||
null);
|
||||
mTargetViewContainer = new FrameLayout(context);
|
||||
mTargetViewContainer.setClipChildren(false);
|
||||
mTargetViewContainer.addView(mTutorialView);
|
||||
mTargetViewContainer.setVisibility(mIsOneHandedMode ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void updateFinished(int visible, float finalPosition) {
|
||||
if (!canShowTutorial()) {
|
||||
return;
|
||||
}
|
||||
mIsOneHandedMode = (finalPosition == 0f) ? true : false;
|
||||
mTargetViewContainer.setVisibility(visible);
|
||||
mTargetViewContainer.setTranslationY(finalPosition);
|
||||
}
|
||||
@@ -176,7 +187,7 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
* Adds the tutorial target view to the WindowManager and update its layout, so it's ready
|
||||
* to be animated in.
|
||||
*/
|
||||
private void createTutorialTarget() {
|
||||
private void attachTurtorialTarget() {
|
||||
if (!mTargetViewContainer.isAttachedToWindow()) {
|
||||
try {
|
||||
mWindowManager.addView(mTargetViewContainer, getTutorialTargetLayoutParams());
|
||||
@@ -242,4 +253,17 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback {
|
||||
mTargetViewContainer.setTransitionGroup(true);
|
||||
mTargetViewContainer.setTranslationY(value - mTargetViewContainer.getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* onConfigurationChanged events for updating tutorial text.
|
||||
* @param newConfig
|
||||
*/
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
if (!mCanShowTutorial) {
|
||||
return;
|
||||
}
|
||||
removeTutorialFromWindowManager();
|
||||
recreateTutorialView(mContext.createConfigurationContext(newConfig));
|
||||
attachTurtorialTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +315,13 @@ public final class WMShell extends SystemUI
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mConfigurationController.addCallback(new ConfigurationController.ConfigurationListener() {
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
oneHanded.onConfigChanged(newConfig);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
Reference in New Issue
Block a user