# 保留R下面的资源
-keep class **.R$* {*;}
+# 保留反射内容
+-keep class com.ic.launcher.data.repository.* {*;}
-keepclassmembers class **.R$* {
public static <fields>;
}
package com.ic.launcher.adapter;
+import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
+import com.ic.iclooger.ICLogger;
import com.ic.launcher.R;
import com.ic.launcher.data.AppItem;
-
+import com.ic.launcher.utils.SystemUtils;
import com.ic.launcher.view.MainPageView;
+import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
@NonNull
@Override
public InnerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View itemView;
+ View itemView = null;
//创建Item
if (viewType == TYPE_MAIN) {
+ try {
+ String idNum = SystemUtils.getSystemProperties("persist.sys.id_num");
+ String protocol = SystemUtils.getSystemProperties("persist.sys.protocol_no");
+ ICLogger.d("property ==> " + idNum);
+ ICLogger.d("protocol ==> " + protocol);
+ String targetName = "com.ic.launcher.view.pager.MainPageView" + idNum + "P" + protocol;
+ ICLogger.d("targetName ==> " + targetName);
+ Class<?> clazz = Class.forName(targetName);
+ Constructor<?> constructor = clazz.getConstructor(Context.class);
+ itemView = (View) constructor.newInstance(parent.getContext());
+ } catch (Exception e) {
+ e.printStackTrace();
+ itemView = null;
+ }
+ //MainPageViewC5P3
//主页面
- itemView = new MainPageView(parent.getContext());
- ((MainPageView) itemView).initViewModel();
+ if (itemView == null) {
+ itemView = new MainPageView(parent.getContext());
+ }
ViewPager2.LayoutParams layoutParams = new ViewPager2.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
/**
* 此类不可以被混淆,由反射去创建
*/
-public class AppsC53Repository implements IAppListRepository {
+public class AppsC5P3Repository implements IAppListRepository {
@Override
public List<AppItem> getAppList() {
//动态创建即可
//App列表目录,动态创建
//注意不要混淆了,否则反射就没用了
- //data/repository/Apps+numID+protocol+Repository,比如说:AppsC57Repository ,numberId = C5,7为协议号
+ //data/repository/Apps+numID+P+protocol+Repository,比如说:AppsC57Repository ,numberId = C5,P7为协议号
try {
String idNum = SystemUtils.getSystemProperties("persist.sys.id_num");
String protocol = SystemUtils.getSystemProperties("persist.sys.protocol_no");
ICLogger.d("property ==> " + idNum);
ICLogger.d("protocol ==> " + protocol);
if (!TextUtils.isEmpty(idNum) && !TextUtils.isEmpty(protocol)) {
- String targetName = "com.ic.launcher.data.repository.Apps" + idNum + protocol + "Repository";
+ String targetName = "com.ic.launcher.data.repository.Apps" + idNum +"P"+ protocol + "Repository";
ICLogger.d("target reposition ==> " + targetName);
appListRepository = (IAppListRepository) Class.forName(targetName).newInstance();
ICLogger.d("create repository okay..");
public MutableLiveData<String> bodyTempValue = new MutableLiveData<>();
//环境温度
public MutableLiveData<String> envTempValue = new MutableLiveData<>();
+ //步数
+ public MutableLiveData<String> stepCountValue = new MutableLiveData<>();
private final Context mContext;
updateTime(null);
//注册广播,监听灭屏和亮屏
listenerScreenState();
+ //获取步数
+ getStepCount();
+ }
+
+ private void getStepCount() {
+ getValue(KEY_STEP_COUNT);
}
private final BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
updateEnvTemp();
}
});
+ context.getContentResolver().registerContentObserver(Uri.parse(SETTINGS + ".sport_step_count"),
+ true, new ContentObserver(null) {
+ @Override
+ public void onChange(boolean selfChange) {
+ //更新血压
+ getStepCount();
+ }
+ });
}
private void getValueByKey(String key) {
public static final String KEY_HEART_RATE = "heart_rate";
public static final String KEY_ENV_TEMP = "env_temperature";
public static final String KEY_TEMP = "body_temperature";
+ public static final String KEY_STEP_COUNT = "sport_step_count";
private void updateTemperature() {
R.layout.item_main_page, this
);
initView();
+ initViewModel();
}
- public void initViewModel() {
+ private void initViewModel() {
ICLogger.d("initViewModel...");
mainPagerPresenter = MainPagePresenter.getInstance(getContext());
mainPagerPresenter.dateValue.observeForever(dateValue -> {
--- /dev/null
+package com.ic.launcher.view.pager;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.ic.iclooger.ICLogger;
+import com.ic.launcher.R;
+import com.ic.launcher.presenter.MainPagePresenter;
+
+public class MainPageViewC5P3 extends LinearLayout {
+
+ private MainPagePresenter mainPagerPresenter;
+ private TextView dateView;
+ private TextView timeView;
+ private TextView weekView;
+ private TextView heartRateView;
+ private TextView bloodOxygenView;
+ private TextView stepCountView;
+
+ public MainPageViewC5P3(@NonNull Context context) {
+ this(context, null);
+ }
+
+ public MainPageViewC5P3(@NonNull Context context, @Nullable AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public MainPageViewC5P3(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ LayoutInflater.from(getContext()).inflate(
+ R.layout.item_main_page_c5, this
+ );
+ initView();
+ initViewModel();
+ }
+
+ public void initViewModel() {
+ ICLogger.d("initViewModel...");
+ mainPagerPresenter = MainPagePresenter.getInstance(getContext());
+ mainPagerPresenter.dateValue.observeForever(dateValue -> {
+ //ICLogger.d("dateValue == > " + dateValue);
+ dateView.setText(dateValue);
+ });
+ mainPagerPresenter.timeValue.observeForever(timeValue -> {
+ //ICLogger.d("timeValue == > " + timeValue);
+ timeView.setText(timeValue);
+ });
+ mainPagerPresenter.weekValue.observeForever(weekValue -> {
+ weekView.setText(weekValue);
+ });
+ mainPagerPresenter.bodyTempValue.observeForever(bodyTempValue -> {
+ stepCountView.setText(bodyTempValue);
+ });
+ mainPagerPresenter.oxygenValue.observeForever(oxygenValue -> {
+ bloodOxygenView.setText(oxygenValue);
+ });
+ mainPagerPresenter.heartRate.observeForever(heartRate -> {
+ heartRateView.setText(heartRate);
+ });
+ mainPagerPresenter.stepCountValue.observeForever(stepCount -> {
+ stepCountView.setText(stepCount);
+ });
+ }
+
+ private void initView() {
+ dateView = findViewById(R.id.date_tv);
+ timeView = findViewById(R.id.time_tv);
+ weekView = findViewById(R.id.week_date_tv);
+ heartRateView = findViewById(R.id.heart_rate_tv);
+ bloodOxygenView = findViewById(R.id.blood_oxygen_tv);
+ stepCountView = findViewById(R.id.step_count_tv);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/time_tv"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:includeFontPadding="false"
+ android:text="--:--"
+ android:textColor="@color/white"
+ android:textSize="120sp" />
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="22dp"
+ android:layout_marginRight="22dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/date_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:includeFontPadding="false"
+ android:text="||-||"
+ android:textColor="@color/white"
+ android:textSize="40sp" />
+
+ <TextView
+ android:id="@+id/week_date_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:includeFontPadding="false"
+ android:text="星期#"
+ android:textColor="@color/white"
+ android:textSize="40sp" />
+
+ </FrameLayout>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:orientation="horizontal">
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/heart_rate" />
+
+ <TextView
+ android:id="@+id/heart_rate_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="00"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/spo2" />
+
+ <TextView
+ android:id="@+id/blood_oxygen_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="00"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/icon_pedometer" />
+
+ <TextView
+ android:id="@+id/step_count_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="00"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+ </LinearLayout>
+
+
+</LinearLayout>
\ No newline at end of file