“添加Alarm”UI在分屏模式下被剪切(“Add alarm“ UI is cut part when in split screen mode)

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}

修改后效果如图:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值