修改状态栏时间格式为xxxx年x月x日 星期x xx:xx am

2023-05-16

--- a/sprd/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/sprd/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -85,7 +85,7 @@
     <integer name="def_max_sound_trigger_detection_service_ops_per_day" translatable="false">1000</integer>
     <integer name="def_sound_trigger_detection_service_op_timeout" translatable="false">15000</integer>
 
-    <bool name="def_lockscreen_disabled">false</bool>
+    <bool name="def_lockscreen_disabled">true</bool>
     <bool name="def_device_provisioned">false</bool>
     <integer name="def_dock_audio_media_enabled">1</integer>
 
diff --git a/sprd/frameworks/base/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/sprd/frameworks/base/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.
old mode 100644
new mode 100755
index bf2963c..88a6cf0
--- a/sprd/frameworks/base/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml
+++ b/sprd/frameworks/base/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml
@@ -23,13 +23,38 @@
     android:id="@+id/keyguard_clock_container"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_gravity="center_horizontal|top">
+    android:layout_gravity="center_horizontal|top"
+       >
     <FrameLayout
          android:id="@+id/clock_view"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentTop="true">
+   <!--<LinearLayout
+         android:layout_width="wrap_content"
+         android:layout_height="wrap_content"
+         android:layout_gravity="center_horizontal"
+         android:orientation="horizontal">                         
+        <TextView
+             android:id="@+id/default_clock_view2"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:layout_gravity="center_horizontal"
+             android:gravity="center_horizontal"
+             android:textSize="90dp"
+             android:textColor="?attr/wallpaperTextColor" 
+        />
+       <TextView
+             android:id="@+id/default_clock_view3"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:layout_marginTop="65dp"
+             android:textSize="20dp"
+             android:textColor="?attr/wallpaperTextColor"
+        />             
+    </LinearLayout>-->
+                
         <TextClock
              android:id="@+id/default_clock_view"
              android:layout_width="match_parent"
diff --git a/sprd/frameworks/base/packages/SystemUI/res/layout/status_bar.xml b/sprd/frameworks/base/packages/SystemUI/res/layout/status_bar.xml
old mode 100644
new mode 100755
index 4fae3c5..5cca752
--- a/sprd/frameworks/base/packages/SystemUI/res/layout/status_bar.xml
+++ b/sprd/frameworks/base/packages/SystemUI/res/layout/status_bar.xml
@@ -50,6 +50,15 @@
         android:paddingTop="@dimen/status_bar_padding_top"
         android:orientation="horizontal"
         >
+                <com.android.systemui.statusbar.policy.Clock
+                    android:id="@+id/clock"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:textAppearance="@style/TextAppearance.StatusBar.Clock"
+                    android:singleLine="true"
+                                       android:maxEms="50"
+                    android:gravity="center_horizontal"
+                />             
         <FrameLayout
             android:layout_height="match_parent"
             android:layout_width="0dp"
@@ -72,17 +81,6 @@
                     android:layout_height="match_parent"
                     android:layout="@layout/operator_name" />
 
-                <com.android.systemui.statusbar.policy.Clock
-                    android:id="@+id/clock"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Clock"
-                    android:singleLine="true"
-                    android:paddingStart="@dimen/status_bar_left_clock_starting_padding"
-                    android:paddingEnd="@dimen/status_bar_left_clock_end_padding"
-                    android:gravity="center_vertical|start"
-                />
-
                 <com.android.systemui.statusbar.AlphaOptimizedFrameLayout
                     android:id="@+id/notification_icon_area"
                     android:layout_width="0dp"
diff --git a/sprd/frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/sprd/frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardClock
old mode 100644
new mode 100755
index f745aeb..8f21356
--- a/sprd/frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
+++ b/sprd/frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
@@ -42,7 +42,10 @@ import java.util.TimeZone;
 
 import javax.inject.Inject;
 import javax.inject.Named;
-
+import android.widget.TextView;
+import java.util.Date;  
+import java.text.SimpleDateFormat;
+import java.util.Locale;
 /**
  * Switch to show plugin clock when plugin is connected, otherwise it will show default clock.
  */
@@ -88,7 +91,8 @@ public class KeyguardClockSwitch extends RelativeLayout {
      * Default clock.
      */
     private TextClock mClockView;
-
+    private TextView mClockView2;
+    private TextView mClockView3;
     /**
      * Default clock, bold version.
      * Used to transition to bold when shrinking the default clock.
@@ -185,6 +189,8 @@ public class KeyguardClockSwitch extends RelativeLayout {
     protected void onFinishInflate() {
         super.onFinishInflate();
         mClockView = findViewById(R.id.default_clock_view);
+        //mClockView2 = findViewById(R.id.default_clock_view2);
+               // mClockView3 = findViewById(R.id.default_clock_view3);                
         mClockViewBold = findViewById(R.id.default_clock_view_bold);
         mSmallClockFrame = findViewById(R.id.clock_view);
         mKeyguardStatusArea = findViewById(R.id.keyguard_status_area);
@@ -366,6 +372,46 @@ public class KeyguardClockSwitch extends RelativeLayout {
         if (mClockPlugin != null) {
             mClockPlugin.onTimeTick();
         }
+                       /*      long time=System.currentTimeMillis();
+                               Date date=new Date(time);
+                               SimpleDateFormat format=new SimpleDateFormat("yyyy年MM月dd日 EEEE");
+                               Log.e("time","time1="+format.format(date));     
+                               Locale locale = getResources().getConfiguration().locale;
+                               String language = locale.getLanguage();         
+                               String str=mClockView.getText()+"";
+               if(language.contains("en")){
+               if(str.contains("AM")){
+                                               mClockView3.setVisibility(View.VISIBLE);
+                                               str=str.substring(0,str.indexOf("AM"));
+                                               mClockView3.setText("AM");
+                                               mClockView2.setText(str);                                       
+               }else if(str.contains("PM")){
+                                               mClockView3.setVisibility(View.VISIBLE);
+                                               str=str.substring(0,str.indexOf("PM"));
+                                               mClockView3.setText("PM");
+                                               mClockView2.setText(str);
+               }else{
+                                               mClockView3.setVisibility(View.GONE);
+                                               mClockView2.setText(str);
+               }
+                               
+               }else{
+       if(str.contains("上午")){
+                   mClockView3.setVisibility(View.VISIBLE);
+                       str=str.substring(2);
+                       mClockView3.setText("AM");
+                       mClockView2.setText(format.format(date)+" "+str);
+               }else if(str.contains("下午")){
+                       mClockView3.setVisibility(View.VISIBLE);
+                       str=str.substring(2);
+            mClockView3.setText("PM");
+                       mClockView2.setText(format.format(date)+" "+str);
+       }else{
+             mClockView3.setVisibility(View.GONE);
+            mClockView2.setText(format.format(date)+" "+str);
+        }
+                          }*/
+               
         if (Build.IS_DEBUGGABLE) {
             // Log for debugging b/130888082 (sysui waking up, but clock not updating)
             Log.d(TAG, "Updating clock: " + mClockView.getText());
diff --git a/sprd/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/sprd/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/
index 31e859b..edb8d05 100755
--- a/sprd/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
+++ b/sprd/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
@@ -59,9 +59,10 @@ import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Locale;
 import java.util.TimeZone;
-
+import java.util.Date;  
 /* UNISOC: 1072085 clock add am/pm @{ */
 import com.sprd.keyguard.KeyguardSupportAmPm;
+import android.util.Log;
 /* @} */
 
 /**
@@ -331,11 +332,8 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
     public void onDensityOrFontScaleChanged() {
         FontSizeUtils.updateFontSize(this, R.dimen.status_bar_clock_size);
         setPaddingRelative(
-                mContext.getResources().getDimensionPixelSize(
-                        R.dimen.status_bar_clock_starting_padding),
-                0,
-                mContext.getResources().getDimensionPixelSize(
-                        R.dimen.status_bar_clock_end_padding),
+               800,
+                0,0,
                 0);
     }
 
@@ -383,6 +381,8 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
 
     private final CharSequence getSmallTime() {
         Context context = getContext();
+               onDensityOrFontScaleChanged();
+               Log.e("lyl","getSmallTimeaaaa");
         boolean is24 = DateFormat.is24HourFormat(context, mCurrentUserId);
         LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
 
@@ -421,8 +421,9 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
                     while (a > 0 && Character.isWhitespace(format.charAt(a-1))) {
                         a--;
                     }
-                    format = format.substring(0, a) + MAGIC1 + format.substring(a, b)
-                        + "a" + MAGIC2 + format.substring(b + 1);
+                    format = format.substring(0, a)  + format.substring(a, b)
+                        + "a"  + format.substring(b + 1);
+
                 }
             }
             mClockFormat = sdf = new SimpleDateFormat(format);
@@ -430,14 +431,17 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
         } else {
             sdf = mClockFormat;
         }
+               String str=null;
         String result = sdf.format(mCalendar.getTime());
 
         /* UNISOC: 1072085 clock add am/pm @{ */
         if(KeyguardSupportAmPm.getInstance(mContext).isEnabled()) {
-            mAmPmStyle = AM_PM_STYLE_SMALL;
+            mAmPmStyle = AM_PM_STYLE_NORMAL;
         }
         /* @} */
-
+                               long time=System.currentTimeMillis();
+                               Date date=new Date(time);
+                               SimpleDateFormat format2=new SimpleDateFormat("yyyy年MM月dd日 EEEE");
         if (mAmPmStyle != AM_PM_STYLE_NORMAL) {
             int magic1 = result.indexOf(MAGIC1);
             int magic2 = result.indexOf(MAGIC2);
@@ -454,11 +458,25 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
                     formatted.delete(magic2, magic2 + 1);
                     formatted.delete(magic1, magic1 + 1);
                 }
-                return formatted;
+                               str = formatted+"";
+                if(str.contains("上午")){
+                       str=str.substring(2)+" AM";
+                               }else if(str.contains("下午")){
+                     str=str.substring(2)+" PM";
+                               }
+                               
+                return format2.format(date)+" "+str;
             }
         }
 
-        return result;
+            str = result;
+            if(str.contains("上午")){
+                str=str.substring(2)+" AM";
+            }else if(str.contains("下午")){
+                str=str.substring(2)+" PM";
+            }
+       return format2.format(date)+" "+str;
+
 
     }

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

修改状态栏时间格式为xxxx年x月x日 星期x xx:xx am 的相关文章

随机推荐