Issue:
"
Reproduction Steps:
1.Put Settings app in split screen
2.Choose Alarm app as the secondary
3. Add an alarm
4. Check setting alarm UI in split screen.
"
Solution:
"Solution: In split screen, change view to spinner mode."
frameworks/base/core/java/android/widget/TimePicker.java
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index 51b1847..20135ee 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 The Android Open Source Project
+ * Copyright (c) 2022 XXX Technologies Corporation and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +22,10 @@
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.annotation.Widget;
+import android.app.Activity;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
+import android.content.ContextWrapper;
import android.content.res.TypedArray;
import android.icu.util.Calendar;
import android.os.Parcel;
@@ -45,6 +48,8 @@
import java.lang.annotation.RetentionPolicy;
import java.util.Locale;
+import com.xxx.util.XXXUtils;
+
/**
* A widget for selecting the time of day, in either 24-hour or AM/PM mode.
* <p>
@@ -92,6 +97,7 @@
@TimePickerMode
private final int mMode;
+ private boolean isInMultiWindowMode;
/**
* The callback interface used to indicate the time has been adjusted.
*/
@@ -133,12 +139,22 @@
final int requestedMode = a.getInt(R.styleable.TimePicker_timePickerMode, MODE_SPINNER);
a.recycle();
- if (requestedMode == MODE_CLOCK && isDialogMode) {
- // You want MODE_CLOCK? YOU CAN'T HANDLE MODE_CLOCK! Well, maybe
- // you can depending on your screen size. Let's check...
- mMode = context.getResources().getInteger(R.integer.time_picker_mode);
+ if(getActivity() != null){
+ isInMultiWindowMode = getActivity().isInMultiWindowMode();
} else {
- mMode = requestedMode;
+ isInMultiWindowMode = false;
+ }
+ if (XXXUtils.isXXX().orElse(false) && isInMultiWindowMode && isDialogMode) {
+ //BSPA-210116 "Add alarm" UI is cut part when in split screen mode
+ mMode = MODE_SPINNER;
+ } else {
+ if (requestedMode == MODE_CLOCK && isDialogMode) {
+ // You want MODE_CLOCK? YOU CAN'T HANDLE MODE_CLOCK! Well, maybe
+ // you can depending on your screen size. Let's check...
+ mMode = context.getResources().getInteger(R.integer.time_picker_mode);
+ } else {
+ mMode = requestedMode;
+ }
}
switch (mMode) {
@@ -160,6 +176,17 @@
});
}
+ private Activity getActivity() {
+ Context context = getContext();
+ while (context instanceof ContextWrapper) {
+ if (context instanceof Activity) {
+ return (Activity)context;
+ }
+ context = ((ContextWrapper)context).getBaseContext();
+ }
+ return null;
+ }
+
/**
* @return the picker's presentation mode, one of {@link #MODE_CLOCK} or
* {@link #MODE_SPINNER}
修改后效果如图: