version:6.8
fix: update:增加时间,更换提示
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
38
app/src/main/java/com/uiui/aios/utils/DataUtil.java
Normal file
38
app/src/main/java/com/uiui/aios/utils/DataUtil.java
Normal file
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,38 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:text="2020-01-01 00:00:00"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout5">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -30,12 +58,13 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_pic"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="180dp"
|
||||
android:layout_width="@dimen/dp_88"
|
||||
android:layout_height="@dimen/dp_88"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/he100"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tv_temp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
@@ -56,41 +85,42 @@
|
||||
android:id="@+id/tv_temp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="10℃"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_30"
|
||||
android:textSize="@dimen/sp_34"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_pic"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_pic"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_pic"
|
||||
app:layout_constraintVertical_bias="0.296" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.802"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.327" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:layout_marginBottom="@dimen/dp_8"
|
||||
android:text="位置"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textSize="@dimen/sp_8"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_temp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_temp" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_weather"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:text="天气"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_location"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_location"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_location" />
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_temp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_temp" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -326,10 +356,10 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_note_nodata"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_width="@dimen/dp_68"
|
||||
android:layout_height="@dimen/dp_68"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/home_reminder_icon"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -374,9 +404,9 @@
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:src="@drawable/more"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_app"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -400,7 +430,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_4"
|
||||
android:layout_marginBottom="@dimen/dp_4"
|
||||
android:singleLine="true"
|
||||
android:text="长按更改"
|
||||
android:text="长按设置应用"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_11"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -567,4 +597,5 @@
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.uiui.aios.view.CustomContent>
|
||||
@@ -5,10 +5,38 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:text="2020-01-01 00:00:00"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout5">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -32,13 +60,14 @@
|
||||
android:id="@+id/iv_pic"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_60"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/he100"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tv_temp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3"
|
||||
app:layout_constraintVertical_bias="0.506" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
@@ -166,9 +195,9 @@
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:src="@drawable/more"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_app"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -205,7 +234,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_4"
|
||||
android:layout_marginBottom="@dimen/dp_4"
|
||||
android:singleLine="true"
|
||||
android:text="长按更改"
|
||||
android:text="长按设置应用"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_11"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -628,4 +657,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.uiui.aios.view.CustomContent>
|
||||
Reference in New Issue
Block a user