From dc7a38c12ebb948969246fa332f1366a3bb02584 Mon Sep 17 00:00:00 2001 From: TrillGates Date: Fri, 17 Sep 2021 20:39:00 +0800 Subject: [PATCH] create main page for c5 --- app/proguard-rules.pro | 2 + .../ic/launcher/adapter/MainPageAdapter.java | 27 +++- ...epository.java => AppsC5P3Repository.java} | 2 +- .../launcher/presenter/LauncherPresenter.java | 4 +- .../launcher/presenter/MainPagePresenter.java | 17 +++ .../com/ic/launcher/view/MainPageView.java | 3 +- .../launcher/view/pager/MainPageViewC5P3.java | 79 +++++++++++ app/src/main/res/layout/item_main_page_c5.xml | 124 ++++++++++++++++++ .../main/res/mipmap-mdpi/icon_pedometer.png | Bin 0 -> 5873 bytes 9 files changed, 250 insertions(+), 8 deletions(-) rename app/src/main/java/com/ic/launcher/data/repository/{AppsC53Repository.java => AppsC5P3Repository.java} (97%) create mode 100644 app/src/main/java/com/ic/launcher/view/pager/MainPageViewC5P3.java create mode 100644 app/src/main/res/layout/item_main_page_c5.xml create mode 100644 app/src/main/res/mipmap-mdpi/icon_pedometer.png diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index be4edd4..c4c0733 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -76,6 +76,8 @@ # 保留R下面的资源 -keep class **.R$* {*;} +# 保留反射内容 +-keep class com.ic.launcher.data.repository.* {*;} -keepclassmembers class **.R$* { public static ; } diff --git a/app/src/main/java/com/ic/launcher/adapter/MainPageAdapter.java b/app/src/main/java/com/ic/launcher/adapter/MainPageAdapter.java index 39bbdc2..2618fba 100644 --- a/app/src/main/java/com/ic/launcher/adapter/MainPageAdapter.java +++ b/app/src/main/java/com/ic/launcher/adapter/MainPageAdapter.java @@ -1,5 +1,6 @@ package com.ic.launcher.adapter; +import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -11,11 +12,13 @@ import androidx.lifecycle.LifecycleOwner; 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; @@ -50,12 +53,28 @@ public class MainPageAdapter extends RecyclerView.Adapter " + 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); diff --git a/app/src/main/java/com/ic/launcher/data/repository/AppsC53Repository.java b/app/src/main/java/com/ic/launcher/data/repository/AppsC5P3Repository.java similarity index 97% rename from app/src/main/java/com/ic/launcher/data/repository/AppsC53Repository.java rename to app/src/main/java/com/ic/launcher/data/repository/AppsC5P3Repository.java index 9a00163..2b0354b 100644 --- a/app/src/main/java/com/ic/launcher/data/repository/AppsC53Repository.java +++ b/app/src/main/java/com/ic/launcher/data/repository/AppsC5P3Repository.java @@ -10,7 +10,7 @@ import java.util.List; /** * 此类不可以被混淆,由反射去创建 */ -public class AppsC53Repository implements IAppListRepository { +public class AppsC5P3Repository implements IAppListRepository { @Override public List getAppList() { diff --git a/app/src/main/java/com/ic/launcher/presenter/LauncherPresenter.java b/app/src/main/java/com/ic/launcher/presenter/LauncherPresenter.java index 9c971c1..8e2c6e8 100644 --- a/app/src/main/java/com/ic/launcher/presenter/LauncherPresenter.java +++ b/app/src/main/java/com/ic/launcher/presenter/LauncherPresenter.java @@ -46,14 +46,14 @@ public class LauncherPresenter extends BasePresenter { //动态创建即可 //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.."); diff --git a/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java b/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java index def41da..2f548c3 100644 --- a/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java +++ b/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java @@ -54,6 +54,8 @@ public class MainPagePresenter extends BasePresenter { public MutableLiveData bodyTempValue = new MutableLiveData<>(); //环境温度 public MutableLiveData envTempValue = new MutableLiveData<>(); + //步数 + public MutableLiveData stepCountValue = new MutableLiveData<>(); private final Context mContext; @@ -72,6 +74,12 @@ public class MainPagePresenter extends BasePresenter { updateTime(null); //注册广播,监听灭屏和亮屏 listenerScreenState(); + //获取步数 + getStepCount(); + } + + private void getStepCount() { + getValue(KEY_STEP_COUNT); } private final BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { @@ -282,6 +290,14 @@ public class MainPagePresenter extends BasePresenter { 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) { @@ -323,6 +339,7 @@ public class MainPagePresenter extends BasePresenter { 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() { diff --git a/app/src/main/java/com/ic/launcher/view/MainPageView.java b/app/src/main/java/com/ic/launcher/view/MainPageView.java index 7cca92c..6b17865 100644 --- a/app/src/main/java/com/ic/launcher/view/MainPageView.java +++ b/app/src/main/java/com/ic/launcher/view/MainPageView.java @@ -38,9 +38,10 @@ public class MainPageView extends LinearLayout { 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 -> { diff --git a/app/src/main/java/com/ic/launcher/view/pager/MainPageViewC5P3.java b/app/src/main/java/com/ic/launcher/view/pager/MainPageViewC5P3.java new file mode 100644 index 0000000..74e1144 --- /dev/null +++ b/app/src/main/java/com/ic/launcher/view/pager/MainPageViewC5P3.java @@ -0,0 +1,79 @@ +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 diff --git a/app/src/main/res/layout/item_main_page_c5.xml b/app/src/main/res/layout/item_main_page_c5.xml new file mode 100644 index 0000000..9283ee8 --- /dev/null +++ b/app/src/main/res/layout/item_main_page_c5.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-mdpi/icon_pedometer.png b/app/src/main/res/mipmap-mdpi/icon_pedometer.png new file mode 100644 index 0000000000000000000000000000000000000000..8881488de77a48ea5e710a4f81dde7809583feaf GIT binary patch literal 5873 zcmVKLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9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