From 5e7ec8efb8389a4d6d4b9cfaa1e2de30e8024628 Mon Sep 17 00:00:00 2001
From: fanhuitong <981964879@qq.com>
Date: Tue, 13 Dec 2022 12:08:29 +0800
Subject: [PATCH] =?UTF-8?q?version:6.8=20fix:=20update:=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=8C=E6=9B=B4=E6=8D=A2=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../aios/fragment/custom/CustomFragment.java | 58 +
.../java/com/uiui/aios/utils/DataUtil.java | 38 +
.../main/res/layout-land/fragment_custom.xml | 1049 ++++++++-------
.../main/res/layout-port/fragment_custom.xml | 1188 +++++++++--------
4 files changed, 1246 insertions(+), 1087 deletions(-)
create mode 100644 app/src/main/java/com/uiui/aios/utils/DataUtil.java
diff --git a/app/src/main/java/com/uiui/aios/fragment/custom/CustomFragment.java b/app/src/main/java/com/uiui/aios/fragment/custom/CustomFragment.java
index 51484ad..3640dcd 100644
--- a/app/src/main/java/com/uiui/aios/fragment/custom/CustomFragment.java
+++ b/app/src/main/java/com/uiui/aios/fragment/custom/CustomFragment.java
@@ -69,6 +69,7 @@ import com.uiui.aios.network.URLAddress;
import com.uiui.aios.tpush.MessageReceiver;
import com.uiui.aios.utils.ApkUtils;
import com.uiui.aios.utils.AppUtil;
+import com.uiui.aios.utils.DataUtil;
import com.uiui.aios.utils.NetStateUtils;
import com.uiui.aios.utils.SchemeUtils;
import com.uiui.aios.utils.ToastUtil;
@@ -76,6 +77,8 @@ import com.uiui.aios.utils.Utils;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import butterknife.BindView;
@@ -148,6 +151,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
// TextView tv_name;
@BindView(R.id.iv_app)
ImageView iv_app;
+ @BindView(R.id.tv_time)
+ TextView tv_time;
private String TAG = CustomFragment.class.getSimpleName();
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
@@ -353,6 +358,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
registerBatteryReceiver();
registerAlarmClockReceiver();
+ registTimeReceiver();
+ tv_time.setText(DataUtil.formatDateDay() + "\t" + getWeek());
mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
if (Settings.Global.getInt(mCRv, "is_aihealth", 0) == 1) {
cl_appstore.setVisibility(View.GONE);
@@ -911,6 +918,56 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
}
+ /**
+ * 时间
+ */
+ private void registTimeReceiver() {
+ if (null == mTimeReceiver) {
+ mTimeReceiver = new TimeReceiver();
+ }
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_DATE_CHANGED);
+ filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
+ filter.addAction(Intent.ACTION_TIME_CHANGED);
+ filter.addAction(Intent.ACTION_TIME_TICK);
+ mContext.registerReceiver(mTimeReceiver, filter);
+ }
+
+ private void unRegistTimeReceiver() {
+ if (null != mTimeReceiver) {
+ mContext.unregisterReceiver(mTimeReceiver);
+ }
+ }
+
+ private TimeReceiver mTimeReceiver;
+
+ class TimeReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action.equals(Intent.ACTION_DATE_CHANGED)
+ || action.equals(Intent.ACTION_TIMEZONE_CHANGED)
+ || action.equals(Intent.ACTION_TIME_CHANGED)
+ || action.equals(Intent.ACTION_TIME_TICK)
+ ) {
+ tv_time.setText(DataUtil.formatDateDay() + "\t" + getWeek());
+ }
+ }
+ }
+
+ // 根据日期取得星期几
+ public static String getWeek() {
+ Date date = new Date();
+ String[] weeks = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1;
+ if (weekIndex < 0) {
+ weekIndex = 0;
+ }
+ return weeks[weekIndex];
+ }
+
@Override
public void onDestroy() {
super.onDestroy();
@@ -925,5 +982,6 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
if (mAlarmClockReceiver != null) {
mContext.unregisterReceiver(mAlarmClockReceiver);
}
+ unRegistTimeReceiver();
}
}
diff --git a/app/src/main/java/com/uiui/aios/utils/DataUtil.java b/app/src/main/java/com/uiui/aios/utils/DataUtil.java
new file mode 100644
index 0000000..1fc8c6b
--- /dev/null
+++ b/app/src/main/java/com/uiui/aios/utils/DataUtil.java
@@ -0,0 +1,38 @@
+package com.uiui.aios.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * 作者 mjsheng
+ * 日期 2018/8/31 09:50
+ * 邮箱 501802639@qq.com
+ * 来自:
+ */
+
+public class DataUtil {
+ private static SimpleDateFormat day = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ private static SimpleDateFormat hour = new SimpleDateFormat("HH:mm");
+ private static SimpleDateFormat minute = new SimpleDateFormat("mm");
+
+ /**
+ * 格式化日期(精确到天)
+ */
+ public static String formatDateDay() {
+ return day.format(new Date());
+ }
+
+ /**
+ * 格式化日期(hour)
+ */
+ public static String formatDateHour() {
+ return hour.format(new Date());
+ }
+
+ /**
+ * 格式化日期(minute)
+ */
+ public static String formatDateMinute() {
+ return minute.format(new Date());
+ }
+}
diff --git a/app/src/main/res/layout-land/fragment_custom.xml b/app/src/main/res/layout-land/fragment_custom.xml
index 362976e..4cd7c18 100644
--- a/app/src/main/res/layout-land/fragment_custom.xml
+++ b/app/src/main/res/layout-land/fragment_custom.xml
@@ -5,566 +5,597 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
+
-
+
-
+
-
+
+
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_weight="1"
+ android:background="@drawable/custom_bg_guard">
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout-port/fragment_custom.xml b/app/src/main/res/layout-port/fragment_custom.xml
index 3c6c380..756c6eb 100644
--- a/app/src/main/res/layout-port/fragment_custom.xml
+++ b/app/src/main/res/layout-port/fragment_custom.xml
@@ -5,627 +5,659 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:orientation="vertical"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/constraintLayout5">
+ android:orientation="horizontal">
-
-
-
-
+ android:layout_weight="3"
+ android:background="@drawable/custom_bg_weather"
+ android:visibility="visible">
-
-
-
-
-
+ app:layout_constraintEnd_toStartOf="@+id/tv_temp"
+ app:layout_constraintTop_toBottomOf="@+id/textView3"
+ app:layout_constraintVertical_bias="0.506" />
+ app:layout_constraintTop_toTopOf="parent" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file