apply plugin: 'com.android.application'
+static def getL02ApkBaseName() {
+ return "ICL02Hardware"
+}
+
android {
+
+ def currentVersionCode = getVersionCode()
+ def currentVersionName = releaseTime()
+
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.ic.hardware"
minSdkVersion 19
targetSdkVersion 29
- versionCode 1
- versionName "1.0"
+ versionCode currentVersionCode
+ versionName "${currentVersionName}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
enabled = true
}
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
-
sourceSets {
main {
jni.srcDirs = []
assets.srcDirs = ['src/main/assets']
}
}
+
+ signingConfigs {
+ key {
+ storeFile file("EQC_G5.jks")
+ storePassword "123456"
+ keyAlias "watch_g5"
+ keyPassword "123456"
+ }
+ }
+
+ buildTypes {
+ release {
+ zipAlignEnabled true // zip 对齐优化
+ shrinkResources true // 移除未使用的资源文件
+ signingConfig signingConfigs.key
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ renderscriptDebuggable = false
+ debuggable = false
+ jniDebuggable = false
+ manifestPlaceholders = [:]
+ }
+
+ debug {
+ signingConfig signingConfigs.key
+ }
+ }
+
+ android.applicationVariants.all { variant ->
+ variant.outputs.all {
+ if (variant.buildType.name == "release") {
+ outputFileName = "${getL02ApkBaseName()}_V${currentVersionCode}_${currentVersionName}_release.apk"
+ } else {
+ outputFileName = "${getL02ApkBaseName()}_V${currentVersionCode}_${currentVersionName}_debug.apk"
+ }
+ }
+ }
+}
+
+def getVersionCode() {
+ def versionCodeFile = file('version_code.properties')
+ if (versionCodeFile.canRead()) {
+ Properties properties = new Properties()
+ properties.load(new FileInputStream(versionCodeFile))
+ def versionCode = properties['VERSION_CODE'].toInteger()//读取version_code.properties文件存放的版本号。
+ def runTasks = gradle.startParameter.taskNames
+ def task = ':app:assembleRelease'
+ if (task in runTasks) {
+ properties['VERSION_CODE'] = (++versionCode).toString()
+ properties.store(versionCodeFile.newWriter(), null)
+ }
+
+ return versionCode
+ } else {
+ throw new GradleException("无法读取version_code.properties文件!")
+ }
+}
+
+def releaseTime() {
+ return new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("GMT+08:00"))
}
dependencies {
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
+-dontoptimize # 混合时不使用大小写混合,混合后的类名为小写
+-dontusemixedcaseclassnames # 混合时不使用大小写混合,混合后的类名为小写
+-dontskipnonpubliclibraryclasses # 不跳过library中的非public的类
+-dontskipnonpubliclibraryclassmembers # 不跳过library中的非public的类成员
+-dontpreverify # 不做预校验,preverify是proguard的四个步骤之一,Android平台不需要preverify,去掉这一步能够加快混淆速度
+-verbose # 在处理时打印冗长的信息
+
+# 保留异常表,以便编译器知道哪些异常可能被抛出
+# 保留InnerClasses,否则外部无法引用内部类
+# 保留Signature,否则无法访问泛型
+-keepattributes Exceptions,SourceFile,LineNumberTable,EnclosingMethod,Signature,*Annotation*,InnerClasses,Deprecated
+
+################################## 需要保留的公共部分 ##################################
+# 保留四大组件,自定义的Application等等这些类不被混淆
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class * extends android.view.View
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keep class android.support.** { *; }
+-keep public class * extends android.support.v4.**
+-keep public class * extends android.support.v7.**
+-keep public class * extends android.support.annotation.**
+-keep public class * extends android.app.Fragment
+-keep class com.google.** { *; }
+
+# 保留R下面的资源
+-keep class **.R$* {*;}
+-keepclassmembers class **.R$* {
+ public static <fields>;
+}
+
+# 保留本地native方法不被混淆
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+# 保留在Activity中的方法参数是view的方法,
+# 这样以来我们在layout中写的onClick就不会被影响
+-keepclassmembers class * extends android.app.Activity{
+ public void *(android.view.View);
+}
+
+# 保留我们自定义控件(继承自View)不被混淆
+-keep public class * extends android.view.View{
+ *** get*();
+ void set*(***);
+ public <init>(android.content.Context);
+ public <init>(android.content.Context, android.util.AttributeSet);
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+# 保留枚举类不被混淆
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep public interface com.ic.aidl.ped.IPedAidlInterface
+-keep public abstract interface com.ic.aidl.ped.IPedAidlInterface{
+public protected <methods>;
+}
+
+-keep public interface com.ic.aidl.ped.IPedRemoteService
+-keep public abstract interface com.ic.aidl.ped.IPedRemoteService{
+public protected <methods>;
+}
+
+# 保留Parcelable序列化类不被混淆
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
+
+# 保留Serializable序列化的类不被混淆
+-keepclassmembers class * implements java.io.Serializable {
+ static final long serialVersionUID;
+ private static final java.io.ObjectStreamField[] serialPersistentFields;
+ !static !transient <fields>;
+ !private <fields>;
+ !private <methods>;
+ private void writeObject(java.io.ObjectOutputStream);
+ private void readObject(java.io.ObjectInputStream);
+ java.lang.Object writeReplace();
+ java.lang.Object readResolve();
+}
+
+# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
+-keepclassmembers class * {
+ void *(**On*Event);
+ void *(**On*Listener);
+}
+
+
+-keep class com.sun.jna.** { *; }
+-dontwarn com.sun.jna.**
+
+-keep public class com.android.support.a
+-keep public class com.android.support.b
+-keep public class rx.internal.util
\ No newline at end of file
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+
<application
android:name=".HardwareApp"
android:allowBackup="true"
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name=".BloodActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <action android:name="android.intent.action.VIEW" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <activity android:name=".WeatherActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <action android:name="android.intent.action.VIEW" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
</application>
</manifest>
\ No newline at end of file
+++ /dev/null
-package com.ic.aidl.blood;
-
-public class BloodState {
-
- public static final int BLOOD_NULL_TIPS = -1;
- public static final int BLOOD_NOT_DEVICE = 1001;
-
- public static final int BLOOD_PLEASE_QUIET = 1002;
- public static final int BLOOD_START_CHECK= 1003;
-
- public static final int BLOOD_NOT_WEAR=1004;
- public static final int BLOOD_ING_CHECK=1005;
-
- public static final int BLOOD_STOP_CHECK=1006;
- public static final int BLOOD_NOT_DATA_CHECK=1007;
-}
+++ /dev/null
-// IWeatherAidlInterface.aidl
-package com.ic.aidl.blood;
-
-// Declare any non-default types here with import statements
-
-interface IBloodAidlInterface {
- /**
- * Demonstrates some basic types that you can use as parameters
- * and return values in AIDL.
- */
-
- void updateBloodCheckResult(int high,int low,int heart);
- void updateBloodCheckTips(int top,int bottom);
-}
+++ /dev/null
-// IWeatherRemoteService.aidl
-package com.ic.aidl.blood;
-
-// Declare any non-default types here with import statements
-
-import com.ic.aidl.blood.IBloodAidlInterface;
-
-interface IBloodRemoteService {
- /**
- * Demonstrates some basic types that you can use as parameters
- * and return values in AIDL.
- */
- void registerCallback(IBloodAidlInterface cb);
- void unregisterCallback(IBloodAidlInterface cb);
-
- void startCheckBlood();
- void stopCheckBlood();
-}
+++ /dev/null
-// IWeatherAidlInterface.aidl
-package com.ic.aidl.weather;
-
-// Declare any non-default types here with import statements
-import com.ic.aidl.weather.WeatherParcelable;
-
-interface IWeatherAidlInterface {
- /**
- * Demonstrates some basic types that you can use as parameters
- * and return values in AIDL.
- */
- void updateCurrWeather(in WeatherParcelable weather);
-
-}
+++ /dev/null
-// IWeatherRemoteService.aidl
-package com.ic.aidl.weather;
-
-// Declare any non-default types here with import statements
-
-import com.ic.aidl.weather.IWeatherAidlInterface;
-
-interface IWeatherRemoteService {
- /**
- * Demonstrates some basic types that you can use as parameters
- * and return values in AIDL.
- */
- void registerCallback(IWeatherAidlInterface cb);
- void unregisterCallback(IWeatherAidlInterface cb);
-
- void queryWeatherInfo();
-}
+++ /dev/null
-package com.ic.aidl.weather;
-
-parcelable WeatherParcelable;
\ No newline at end of file
+++ /dev/null
-package com.ic.aidl.weather;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class WeatherParcelable implements Parcelable {
- private String city;
- private String statusDay; // 白天状态,如:晴
- private String statusNight; // 晚上状态
- private String figureDay; // 状态索引
- private String figureNight;
- private String temperatureDay; // 白天温度 或 最低温度
- private String temperatureNight; // 晚上温度 或 最低温度
- private String updateTime; // 更新时间
-
- public WeatherParcelable() {
- city = "";
- statusDay = "";
- statusNight = "";
- figureDay = "";
- figureNight = "";
- temperatureDay = "";
- temperatureNight = "";
- updateTime = "";
- }
-
- public WeatherParcelable(String city,
- String statusDay, String statusNight,
- String figureDay, String figureNight,
- String temperatureDay, String temperatureNight,
- String updateTime) {
- this.city = city;
- this.statusDay = statusDay;
- this.statusNight = statusNight;
- this.figureDay = figureDay;
- this.figureNight =figureNight;
- this.temperatureDay = temperatureDay;
- this.temperatureNight = temperatureNight;
- this.updateTime =updateTime;
- }
-
- public WeatherParcelable(Parcel p) {
- this.city = p.readString();
- this.statusDay = p.readString();
- this.statusNight = p.readString();
- this.figureDay = p.readString();
- this.figureNight = p.readString();
- this.temperatureDay = p.readString();
- this.temperatureNight = p.readString();
- this.updateTime = p.readString();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(city);
- dest.writeString(statusDay);
- dest.writeString(statusNight);
- dest.writeString(figureDay);
- dest.writeString(figureNight);
- dest.writeString(temperatureDay);
- dest.writeString(temperatureNight);
- dest.writeString(updateTime);
- }
-
- public static final Creator<WeatherParcelable> CREATOR
- = new Creator<WeatherParcelable>() {
- public WeatherParcelable createFromParcel(Parcel in) {
- return new WeatherParcelable(in);
- }
-
- public WeatherParcelable[] newArray(int size) {
- return new WeatherParcelable[size];
- }
- };
-
- public String getCity() {
- return city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getStatusDay() {
- return statusDay;
- }
-
- public void setStatusDay(String statusDay) {
- this.statusDay = statusDay;
- }
-
- public String getStatusNight() {
- return statusNight;
- }
-
- public void setStatusNight(String statusNight) {
- this.statusNight = statusNight;
- }
-
- public String getFigureDay() {
- return figureDay;
- }
-
- public void setFigureDay(String figureDay) {
- this.figureDay = figureDay;
- }
-
- public String getFigureNight() {
- return figureNight;
- }
-
- public void setFigureNight(String figureNight) {
- this.figureNight = figureNight;
- }
-
- public String getTemperatureDay() {
- return temperatureDay;
- }
-
- public void setTemperatureDay(String temperatureDay) {
- this.temperatureDay = temperatureDay;
- }
-
- public String getTemperatureNight() {
- return temperatureNight;
- }
-
- public void setTemperatureNight(String temperatureNight) {
- this.temperatureNight = temperatureNight;
- }
-
- public String getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(String updateTime) {
- this.updateTime = updateTime;
- }
-}
+++ /dev/null
-package com.ic.hardware;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import android.os.Bundle;
-
-import com.ic.hardware.fragment.BloodFragment;
-
-public class BloodActivity extends AppCompatActivity {
-
- private FragmentManager fragmentManager;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_blood);
- fragmentManager = getSupportFragmentManager();
- commitFragment(BloodFragment.newInstance());
- }
-
- private void commitFragment(Fragment fragment) {
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
- fragmentTransaction.replace(R.id.main_content_fl, fragment);
- fragmentTransaction.commit();
- }
-
-
-}
import android.app.Application;
+import com.ic.hardware.util.CrashHandler;
import com.ic.hardware.util.IcLog;
import com.jakewharton.threetenabp.AndroidThreeTen;
IcLog.setLogHead("IcHardware");
AndroidThreeTen.init(this);
+
+ CrashHandler crashHandler = CrashHandler.getInstance();
+ crashHandler.init(getApplicationContext());
}
}
+++ /dev/null
-package com.ic.hardware;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import android.os.Bundle;
-
-import com.ic.hardware.fragment.WeatherFragment;
-
-public class WeatherActivity extends AppCompatActivity {
-
- private FragmentManager fragmentManager;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_weather);
- fragmentManager = getSupportFragmentManager();
- commitFragment(WeatherFragment.newInstance());
- }
-
- private void commitFragment(Fragment fragment) {
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
- fragmentTransaction.replace(R.id.weather_content_fl, fragment);
- fragmentTransaction.commit();
- }
-
-}
+++ /dev/null
-package com.ic.hardware.fragment;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.net.Uri;
-import android.nfc.Tag;
-import android.os.Bundle;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.lifecycle.ViewModelProvider;
-
-import android.os.PowerManager;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import com.ic.hardware.HardwareApp;
-import com.ic.hardware.BloodActivity;
-import com.ic.hardware.databinding.FragmentBloodBinding;
-import com.ic.hardware.model.BloodCheckModel;
-import com.ic.hardware.util.IcLog;
-
-import java.io.IOException;
-
-import pl.droidsonroids.gif.GifDrawable;
-import pl.droidsonroids.gif.GifImageView;
-
-import static android.content.Context.POWER_SERVICE;
-
-
-public class BloodFragment extends Fragment {
-
- private static final String TAG = "BloodFragment";
-
- private Context mContext;
- private HardwareApp mApp;
-
- private FragmentBloodBinding bloodBinding;
-
- private PowerManager.WakeLock mWakeLock = null;
- private BloodCheckModel bloodModel;
-
- private GifDrawable gifFromAssets;
-
- public static BloodFragment newInstance() {
- return new BloodFragment();
- }
-
- @Override
- public void onAttach(@NonNull Context context) {
- super.onAttach(context);
- this.mContext = context;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mApp = (HardwareApp) mContext.getApplicationContext();
- initWakeLock(mContext);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- bloodBinding = FragmentBloodBinding.inflate(inflater, container, false);
-
- bloodBinding.setIsShowTips(true);
-
- initBloodModel();
- setGifDrawable();
- bloodModel.registerScreenReceiver();
- return bloodBinding.getRoot();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if (mWakeLock != null) {
- mWakeLock.acquire();
- }
-
- bloodModel.startCheckBlood();
-
- gifFromAssets.start();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- bloodModel.stopCheckBlood();
- gifFromAssets.stop();
-
- releaseWakeLock();
- }
-
- private void initBloodModel() {
- BloodCheckModel.Factory factory = new BloodCheckModel.Factory(mApp);
- bloodModel= new ViewModelProvider(this, factory).get(BloodCheckModel.class);
- bloodModel.getObsBloodValue().observe(getViewLifecycleOwner(), value -> {
- bloodBinding.setIsShowTips(false);
- bloodBinding.setHighValue(value[0]);
- bloodBinding.setLowValue(value[1]);
- bloodBinding.setHeartValue(value[2]);
- });
-
- bloodModel.getObsTipsInfo().observe(getViewLifecycleOwner(),tips ->{
- bloodBinding.setIsShowTips(true);
- bloodBinding.setTopTips(tips[0]);
- bloodBinding.setBottomTips(tips[1]);
- });
-
- bloodModel.getObsCheckEnd().observe(getViewLifecycleOwner(),end ->{
- switch (end){
- case 1:
- IcLog.i(TAG,"Release WakeLock");
- releaseWakeLock();
- break;
- case 2:
- ((BloodActivity)mContext).finish();
- break;
- }
- });
- }
-
- @SuppressLint("InvalidWakeLockTag")
- private void initWakeLock(Context context) {
- PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);
- if (powerManager != null) {
- mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "BloodWakeLock");
- }
- }
-
- private void releaseWakeLock() {
- if (mWakeLock != null) {
- mWakeLock.release();
- }
- mWakeLock = null;
- }
-
- private void setGifDrawable() {
- GifImageView gifImageView = bloodBinding.icHeartGif;
- gifImageView.setScaleType(ImageView.ScaleType.CENTER);
- try {
- gifFromAssets = new GifDrawable(mContext.getAssets(), "only_hr_check.gif");
- gifImageView.setImageDrawable(gifFromAssets);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- IcLog.i(TAG,"onDestroy");
-
- bloodModel.unregisterScreenReceiver();
- bloodModel = null;
-
- if (gifFromAssets != null) {
- gifFromAssets.recycle();
- }
- }
-}
+++ /dev/null
-package com.ic.hardware.fragment;
-
-
-import android.content.Context;
-import android.os.Bundle;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
-import androidx.fragment.app.Fragment;
-import androidx.lifecycle.ViewModelProvider;
-
-import android.util.SparseArray;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.ic.hardware.HardwareApp;
-import com.ic.hardware.R;
-import com.ic.hardware.databinding.FragmentWeatherBinding;
-import com.ic.hardware.model.WeatherModel;
-
-import org.threeten.bp.OffsetDateTime;
-
-/**
- * A simple {@link Fragment} subclass.
- */
-public class WeatherFragment extends Fragment {
-
- private Context mContext;
- private HardwareApp mApp;
-
- private FragmentWeatherBinding weatherBinding;
- private WeatherModel weatherModel;
-
- public static WeatherFragment newInstance() {
- return new WeatherFragment();
- }
-
- @Override
- public void onAttach(@NonNull Context context) {
- super.onAttach(context);
- this.mContext = context;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mApp = (HardwareApp) mContext.getApplicationContext();
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- weatherBinding = FragmentWeatherBinding.inflate(inflater, container, false);
- initWeatherModel();
- return weatherBinding.getRoot();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- weatherModel.onUnBindService();
- }
-
- private void initWeatherModel() {
- WeatherModel.Factory factory = new WeatherModel.Factory(mApp);
- weatherModel = new ViewModelProvider(this, factory).get(WeatherModel.class);
-
-
- weatherModel.getObsWeatherParcelable().observe(getViewLifecycleOwner(), parcelable -> {
-
- if (parcelable == null) {
- weatherBinding.setIsShowTips(true);
- weatherBinding.setIsErrorTips(getString(R.string.tips_error_weather_no_data));
- return;
- }
-
- OffsetDateTime time = OffsetDateTime.now();
-
- boolean inNight = time.getHour() > 18;
- weatherBinding.setWeatherCity(parcelable.getCity());
- weatherBinding.setWeatherSection(
- String.format(getString(R.string.weather_temp_space_degree),
- parcelable.getTemperatureDay(),
- parcelable.getTemperatureNight()));
-
- String degree = getString(R.string.weather_temp_degree);
-
- if (inNight) {
- weatherBinding.setWeatherState(parcelable.getStatusNight());
- weatherBinding.setWeatherTemp(String.format(degree, parcelable.getTemperatureNight()));
- weatherBinding.setWeatherIcon(ContextCompat.getDrawable(mContext, getStatusImage(parcelable.getStatusNight())));
- } else {
- weatherBinding.setWeatherState(parcelable.getStatusDay());
- weatherBinding.setWeatherTemp(String.format(degree, parcelable.getTemperatureDay()));
- weatherBinding.setWeatherIcon(ContextCompat.getDrawable(mContext, getStatusImage(parcelable.getStatusDay())));
- }
- });
-
- weatherModel.onBindService();
- }
-
- public static int getStatusImage(String stuats) {
- int imageId = R.mipmap.weather_status_none;
- if (stuats != null) {
- if (stuats.contains("多云") || stuats.contains("晴")) {
- imageId = R.mipmap.weather_status_qingyun;
- } else if (stuats.contains("多云") && stuats.contains("阴")) {
- imageId = R.mipmap.weather_status_yinduoyun;
- } else if (stuats.contains("阴") && stuats.contains("雨")) {
- imageId = R.mipmap.weather_status_yinyu;
- } else if (stuats.contains("晴") && stuats.contains("雨")) {
- imageId = R.mipmap.weather_status_qingyu;
- } else if (stuats.contains("晴") && stuats.contains("雾")) {
- imageId = R.mipmap.weather_status_qingwu;
- } else if (stuats.contains("晴")) {
- imageId = R.mipmap.weather_status_qing;
- } else if (stuats.contains("多云")) {
- imageId = R.mipmap.weather_status_duoyun;
- } else if (stuats.contains("雷阵雨")) {
- imageId = R.mipmap.weather_status_leizhenyu;
- } else if (stuats.contains("阵雨")) {
- imageId = R.mipmap.weather_status_zhenyu;
- } else if (stuats.contains("小雨")) {
- imageId = R.mipmap.weather_status_xiaoyu;
- } else if (stuats.contains("中雨")) {
- imageId = R.mipmap.weather_status_zhongyu;
- } else if (stuats.contains("大雨")) {
- imageId = R.mipmap.weather_status_dayu;
- } else if (stuats.contains("暴雨")) {
- imageId = R.mipmap.weather_status_baoyu;
- } else if (stuats.contains("冰雹")) {
- imageId = R.mipmap.weather_status_bingbao;
- } else if (stuats.contains("小雪")) {
- imageId = R.mipmap.weather_status_xiaoxue;
- } else if (stuats.contains("中雪")) {
- imageId = R.mipmap.weather_status_zhongxue;
- } else if (stuats.contains("大雪")) {
- imageId = R.mipmap.weather_status_daxue;
- } else if (stuats.contains("暴雪")) {
- imageId = R.mipmap.weather_status_baoxue;
- } else if (stuats.contains("扬沙")) {
- imageId = R.mipmap.weather_status_yangsha;
- } else if (stuats.contains("沙尘")) {
- imageId = R.mipmap.weather_status_shachenbao;
- } else if (stuats.contains("雾")) {
- imageId = R.mipmap.weather_status_wu;
-
- // PARRY 2017.04.27
- } else if (stuats.contains("阴")) {
- imageId = R.mipmap.weather_status_yin;
- }
- }
-
- return imageId;
- }
-}
+++ /dev/null
-package com.ic.hardware.model;
-
-import android.app.Application;
-
-import androidx.annotation.NonNull;
-import androidx.lifecycle.AndroidViewModel;
-import androidx.lifecycle.LiveData;
-import androidx.lifecycle.ViewModel;
-import androidx.lifecycle.ViewModelProvider;
-
-import com.ic.hardware.presenter.BloodPresenter;
-
-
-public class BloodCheckModel extends AndroidViewModel {
-
- private final BloodPresenter bloodPresenter;
-
- private LiveData<String[]> mObsBloodValue;
- private LiveData<String[]> mObsTipsInfo;
- private LiveData<Integer> mObsCheckEnd;
-
- private BloodCheckModel(@NonNull Application application) {
- super(application);
- this.bloodPresenter = new BloodPresenter(application.getApplicationContext());
- mObsBloodValue = bloodPresenter.getObsBloodValue();
- mObsTipsInfo = bloodPresenter.getObsTipsInfo();
- mObsCheckEnd = bloodPresenter.getObsCheckEnd();
- }
-
- public LiveData<String[]> getObsBloodValue() {
- return mObsBloodValue;
- }
-
- public LiveData<String[]> getObsTipsInfo() {
- return mObsTipsInfo;
- }
-
- public LiveData<Integer> getObsCheckEnd() {
- return mObsCheckEnd;
- }
-
- public void startCheckBlood(){
- bloodPresenter.startCheckBlood();
- }
-
- public void stopCheckBlood(){
- bloodPresenter.stopCheckBlood();
- }
-
- public void registerScreenReceiver(){
- bloodPresenter.registerScreenReceiver();
- }
-
- public void unregisterScreenReceiver(){
- bloodPresenter.unregisterScreenReceiver();
- }
-
- public static class Factory extends ViewModelProvider.NewInstanceFactory {
-
- @NonNull
- private final Application mApplication;
-
- public Factory(@NonNull Application application) {
- mApplication = application;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- @NonNull
- public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
- return (T) new BloodCheckModel(mApplication);
- }
- }
-}
+++ /dev/null
-package com.ic.hardware.model;
-
-import android.app.Application;
-
-import androidx.annotation.NonNull;
-import androidx.lifecycle.AndroidViewModel;
-import androidx.lifecycle.LiveData;
-import androidx.lifecycle.ViewModel;
-import androidx.lifecycle.ViewModelProvider;
-
-import com.ic.aidl.weather.WeatherParcelable;
-import com.ic.hardware.presenter.WeatherPresenter;
-
-public class WeatherModel extends AndroidViewModel {
-
- private final LiveData<WeatherParcelable> weatherParcelable;
- private final WeatherPresenter weatherPresenter;
-
- private WeatherModel(@NonNull Application application) {
- super(application);
- weatherPresenter = new WeatherPresenter(application.getApplicationContext());
- weatherParcelable = weatherPresenter.getObsWeatherInfo();
- }
-
- public LiveData<WeatherParcelable> getObsWeatherParcelable() {
- return weatherParcelable;
- }
-
- public void onBindService(){
- weatherPresenter.bindService();
- }
-
- public void onUnBindService(){
- weatherPresenter.unbindService();
- }
-
- public static class Factory extends ViewModelProvider.NewInstanceFactory {
-
- @NonNull
- private final Application mApplication;
-
- public Factory(@NonNull Application application) {
- mApplication = application;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- @NonNull
- public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
- return (T) new WeatherModel(mApplication);
- }
- }
-}
+++ /dev/null
-package com.ic.hardware.presenter;
-
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.SparseArray;
-
-import androidx.lifecycle.MutableLiveData;
-
-import com.ic.aidl.blood.BloodState;
-import com.ic.aidl.blood.IBloodAidlInterface;
-import com.ic.aidl.blood.IBloodRemoteService;
-import com.ic.hardware.R;
-import com.ic.hardware.util.IcLog;
-import com.ic.hardware.util.ServiceUtil;
-
-public class BloodPresenter {
-
- private static final String TAG = "BloodPresenter";
-
- private Context mContext;
-
- private MutableLiveData<String[]> mObsBloodValue;
- private MutableLiveData<String[]> mObsTipsInfo;
- private MutableLiveData<Integer> mObsCheckEnd;
-
- private IBloodRemoteService mService;
-
- private SparseArray<String> mTipsSpares;
-
- private Handler mHandler;
-
- public BloodPresenter(Context context) {
- this.mContext = context;
- mTipsSpares = new SparseArray<String>();
- mTipsSpares.put(BloodState.BLOOD_NULL_TIPS, "");
- mTipsSpares.put(BloodState.BLOOD_NOT_DEVICE, context.getString(R.string.tips_not_device));
- mTipsSpares.put(BloodState.BLOOD_PLEASE_QUIET, context.getString(R.string.tips_quiet_please));
- mTipsSpares.put(BloodState.BLOOD_START_CHECK, context.getString(R.string.tips_start_check));
- mTipsSpares.put(BloodState.BLOOD_NOT_WEAR, context.getString(R.string.tips_not_wear));
- mTipsSpares.put(BloodState.BLOOD_ING_CHECK, context.getString(R.string.tips_ing_check));
- mTipsSpares.put(BloodState.BLOOD_STOP_CHECK, context.getString(R.string.tips_stop_check));
- mTipsSpares.put(BloodState.BLOOD_NOT_DATA_CHECK, context.getString(R.string.tips_not_data_check));
-
- mObsBloodValue = new MutableLiveData<>();
- mObsTipsInfo = new MutableLiveData<>();
- mObsCheckEnd = new MutableLiveData<>();
-
- mHandler = new Handler();
- }
-
- public MutableLiveData<String[]> getObsBloodValue() {
- return mObsBloodValue;
- }
-
- public MutableLiveData<String[]> getObsTipsInfo() {
- return mObsTipsInfo;
- }
-
- public MutableLiveData<Integer> getObsCheckEnd() {
- return mObsCheckEnd;
- }
-
- public void registerScreenReceiver() {
-
- ServiceUtil.bindServiceUtil(mContext, "com.ic.action.WORK_SERVICE", connection, 102);
-
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
- mContext.registerReceiver(screenOnOffReceiver, intentFilter);
- }
-
- public void unregisterScreenReceiver() {
-
- mContext.unregisterReceiver(screenOnOffReceiver);
-
- try {
- mService.unregisterCallback(bloodInterface);
- ServiceUtil.unBindServiceUtil(mContext, connection);
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }finally {
- mService=null;
- bloodInterface=null;
- }
-
- connection = null;
- mHandler = null;
- }
-
- public void startCheckBlood() {
- if (mService != null) {
- try {
- mService.startCheckBlood();
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }
- }
- }
-
- public void stopCheckBlood() {
- if (mService != null) {
- try {
- mService.stopCheckBlood();
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }
- }
- }
-
-
- private void updateTipsInfo(String t, String b) {
- if (mObsTipsInfo != null) {
- mObsTipsInfo.postValue(new String[]{t, b});
- }
- }
-
- private void updateBoolValue(int lv, int hv, int hh) {
- if (mObsBloodValue != null) {
- mObsBloodValue.postValue(new String[]{
- String.valueOf(hv),
- String.valueOf(lv),
- String.valueOf(hh)});
- }
- }
-
- private BroadcastReceiver screenOnOffReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
- IcLog.i(TAG, "灭屏了");
- mObsCheckEnd.setValue(2);
- }
- }
- };
-
-
- private ServiceConnection connection = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- try {
- mService = IBloodRemoteService.Stub.asInterface(service);
- mService.registerCallback(bloodInterface);
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- }
- };
-
- private IBloodAidlInterface.Stub bloodInterface = new IBloodAidlInterface.Stub() {
- @Override
- public void updateBloodCheckResult(int high, int low, int heart) throws RemoteException {
- updateBoolValue(high, low, heart);
- mHandler.postDelayed(() -> mObsCheckEnd.postValue(1), 10 * 1000);
- }
-
- @Override
- public void updateBloodCheckTips(int top, int bottom) throws RemoteException {
- updateTipsInfo(mTipsSpares.get(top), mTipsSpares.get(bottom));
- }
- };
-
-
-}
}
public void bindService(){
- ServiceUtil.bindServiceUtil(mContext, "com.ic.action.WORK_SERVICE", connection, 103);
+ ServiceUtil.bindServiceUtil(mContext, "com.ic.action.WORK_SERVICE", connection,mContext.getPackageName(), 103);
}
public void unbindService(){
+++ /dev/null
-package com.ic.hardware.presenter;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.os.RemoteException;
-
-import androidx.lifecycle.MutableLiveData;
-
-import com.ic.aidl.weather.IWeatherAidlInterface;
-import com.ic.aidl.weather.IWeatherRemoteService;
-import com.ic.aidl.weather.WeatherParcelable;
-import com.ic.hardware.util.IcLog;
-import com.ic.hardware.util.ServiceUtil;
-
-public class WeatherPresenter {
- private static final String TAG = "WeatherPresenter";
-
- private Context mContext;
-
- private MutableLiveData<WeatherParcelable> mObsWeatherInfo;
- private IWeatherRemoteService mService;
-
- public WeatherPresenter(Context context) {
- this.mContext =context;
-
- mObsWeatherInfo = new MutableLiveData<>();
- }
-
- public MutableLiveData<WeatherParcelable> getObsWeatherInfo() {
- return mObsWeatherInfo;
- }
-
- public void bindService(){
- ServiceUtil.bindServiceUtil(mContext, "com.ic.action.WORK_SERVICE", connection, 101);
- }
-
- public void unbindService(){
- try {
- mService.unregisterCallback(weatherInterface);
- ServiceUtil.unBindServiceUtil(mContext,connection);
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }finally {
- mService=null;
- weatherInterface=null;
- }
- }
-
- private void queryWeatherInfo() {
- if (mService != null) {
- try {
- mService.queryWeatherInfo();
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }
- }
- }
-
- private ServiceConnection connection = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- try {
- mService = IWeatherRemoteService.Stub.asInterface(service);
- mService.registerCallback(weatherInterface);
- queryWeatherInfo();
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- }
- };
-
- private IWeatherAidlInterface.Stub weatherInterface = new IWeatherAidlInterface.Stub() {
- @Override
- public void updateCurrWeather(WeatherParcelable weather) throws RemoteException {
- mObsWeatherInfo.postValue(weather);
- }
- };
-}
--- /dev/null
+package com.ic.hardware.util;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Environment;
+import android.os.Looper;
+import android.util.Log;
+import android.widget.Toast;
+
+
+import com.ic.hardware.R;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Field;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Created by Administrator on 2017/5/18.
+ */
+
+public class CrashHandler implements Thread.UncaughtExceptionHandler {
+ public static final String TAG = CrashHandler.class.getName();
+
+ // 系统默认的UncaughtException处理类
+ private Thread.UncaughtExceptionHandler mDefaultHandler;
+ // CrashHandler实例
+ private static CrashHandler INSTANCE = new CrashHandler();
+ // 程序的Context对象
+ private Context mContext;
+ // 用来存储设备信息和异常信息
+ private Map<String, String> infos = new HashMap<String, String>();
+ // 用于格式化日期,作为日志文件名的一部分
+ private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS", Locale.getDefault());
+ private DateFormat dateFormatDate = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
+
+ /**
+ * 保证只有一个CrashHandler实例
+ */
+ private CrashHandler() {
+ }
+
+ /**
+ * 获取CrashHandler实例 ,单例模式
+ */
+ public static CrashHandler getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * 初始化
+ *
+ * @param context
+ */
+ public void init(Context context) {
+ mContext = context;
+ // 获取系统默认的UncaughtException处理器
+ mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
+ // 设置该CrashHandler为程序的默认处理器
+ Thread.setDefaultUncaughtExceptionHandler(this);
+ }
+
+ /**
+ * 当UncaughtException发生时会转入该函数来处理
+ */
+ @Override
+ public void uncaughtException(Thread thread, Throwable ex) {
+ if (!handleException(ex) && mDefaultHandler != null) {
+ // 如果用户没有处理则让系统默认的异常处理器来处理
+ mDefaultHandler.uncaughtException(thread, ex);
+ } else {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+// Log.e(TAG, "error : " + e);
+ e.printStackTrace();
+ }
+ }
+
+ // 退出程序
+ ex.printStackTrace();
+ android.os.Process.killProcess(android.os.Process.myPid());
+ System.exit(1);
+ }
+
+ /**
+ * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.
+ *
+ * @param ex
+ * @return true:如果处理了该异常信息;否则返回false.
+ */
+ private boolean handleException(Throwable ex) {
+ if (ex == null) {
+ return false;
+ }
+ // 使用Toast来显示异常信息
+ new Thread() {
+ @Override
+ public void run() {
+ Looper.prepare();
+ if (mContext != null) {
+ Toast.makeText(mContext, R.string.program_abnormal, Toast.LENGTH_LONG)
+ .show();
+ Looper.loop();
+ }
+ }
+ }.start();
+ // 收集设备参数信息
+ collectDeviceInfo(mContext);
+ // 保存日志文件
+ saveCrashInfo2File(ex);
+ return true;
+ }
+
+ /**
+ * 收集设备参数信息
+ *
+ * @param ctx
+ */
+ public void collectDeviceInfo(Context ctx) {
+ infos.clear();
+ infos.put("===", " PackageInfo ===");
+ try {
+ PackageManager pm = ctx.getPackageManager();
+ PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
+
+ if (pi != null) {
+ String versionName = pi.versionName;
+ String versionCode = pi.versionCode + "";
+ infos.put("versionName", versionName);
+ infos.put("versionCode", versionCode);
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "an error occured when collect package info " + e);
+ }
+
+ infos.put("===", " Build ===");
+ Field[] fields = Build.class.getDeclaredFields();
+ for (Field field : fields) {
+ try {
+ field.setAccessible(true);
+ infos.put(field.getName(), field.get(null).toString());
+ Log.d(TAG, field.getName() + ":" + field.get(null));
+ } catch (Exception e) {
+ Log.e(TAG, "an error occured when collect crash info," + e);
+ }
+ }
+ }
+
+ /**
+ * 保存错误信息到文件中
+ *
+ * @param ex
+ * @return 返回文件名称, 便于将文件传送到服务器
+ */
+ private String saveCrashInfo2File(Throwable ex) {
+
+ String time = formatter.format(new Date());
+ StringBuilder sb = new StringBuilder();
+ sb.append("=== ").append(time).append(" ===\n");
+
+ Writer writer = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(writer);
+ ex.printStackTrace(printWriter);
+// ex.printStackTrace();
+ Throwable cause = ex.getCause();
+ while (cause != null) {
+ cause.printStackTrace(printWriter);
+ cause = cause.getCause();
+// cause.printStackTrace();
+ }
+ printWriter.close();
+ String result = writer.toString();
+ sb.append(result);
+ sb.append("\n");
+
+ sb.append("--- DEVICE INFO ---\n");
+ for (Map.Entry<String, String> entry : infos.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ sb.append(key).append("=").append(value).append("\n");
+ }
+ sb.append("\n\n");
+
+ try {
+ String fileName = "IcHardware-" + dateFormatDate.format(new Date()) + ".log";
+ if (Environment.getExternalStorageState().equals(
+ Environment.MEDIA_MOUNTED)) {
+ File dir = new File(Environment.getExternalStorageDirectory().getPath(), "Android/ic/crash/IcHardware");
+ String path = dir.getPath();
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+ FileOutputStream fos = new FileOutputStream(new File(path, fileName), true);
+ fos.write(sb.toString().getBytes());
+ fos.close();
+ }
+ return fileName;
+ } catch (Exception e) {
+ Log.e(TAG, "an error occured while writing file...," + e);
+ }
+ return null;
+ }
+}
public class IcLog {
private static final String DOT = ".";
- private static boolean isDebug = BuildConfig.DEBUG;
+ private static boolean isDebug = true;
private static String tagHead = "";
public static void v(String tag, String msg) {
}
}
- public static void bindServiceUtil(Context context , String action, ServiceConnection connection,int type) {
+ public static void bindServiceUtil(Context context , String action, ServiceConnection connection,String pck,int type) {
Intent in = getExplicitIntent(context, new Intent(action));
if(in != null){
+ in.setPackage(pck);
in.putExtra("REQ_TYPE",type);
context.bindService(in, connection, 0);
}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/main_content_fl"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".BloodActivity" />
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/weather_content_fl"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".PedometerActivity" />
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<layout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools">
-
- <data>
- <import type="android.view.View"/>
-
- <variable
- name="topTips"
- type="String" />
-
- <variable
- name="bottomTips"
- type="String" />
-
- <variable
- name="isShowTips"
- type="boolean" />
-
- <variable
- name="heartValue"
- type="String" />
-
- <variable
- name="highValue"
- type="String" />
-
- <variable
- name="lowValue"
- type="String" />
- </data>
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#000000">
-
- <pl.droidsonroids.gif.GifImageView
- android:id="@+id/ic_heart_gif"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center" />
-
- <TextView
- android:id="@+id/ic_tips_top"
- style="@style/bloodTextStyle"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="10dp"
- android:text="@{topTips}"
- android:visibility="@{isShowTips ? View.VISIBLE : View.GONE}"/>
-
- <TextView
- android:id="@+id/ic_tips_bottom"
- style="@style/bloodTextStyle"
- android:layout_gravity="bottom|center_horizontal"
- android:layout_marginBottom="10dp"
- android:text="@{bottomTips}"
- android:visibility="@{isShowTips ? View.VISIBLE : View.GONE}"/>
-
- <RelativeLayout
- android:id="@+id/ic_heart_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="20dp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}">
-
- <TextView
- android:id="@+id/ic_heart_name"
- style="@style/bloodTextStyle"
- android:layout_marginEnd="10dp"
- android:text="@string/ic_heart_rate" />
-
- <TextView
- style="@style/bloodTextStyle"
- android:id="@+id/ic_heart_value"
- android:layout_marginStart="10dp"
- android:layout_toEndOf="@id/ic_heart_name"
- android:text="@{heartValue}"/>
- </RelativeLayout>
-
- <RelativeLayout
- android:id="@+id/ic_high_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:layout_marginStart="30dp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}">
-
- <TextView
- android:id="@+id/ic_high_name"
- style="@style/bloodTextStyle"
- android:text="@string/ic_high_pressure" />
-
- <TextView
- android:id="@+id/ic_high_value"
- style="@style/bloodTextStyle"
- android:layout_below="@id/ic_high_name"
- android:layout_centerHorizontal="true"
- android:text="@{highValue}"/>
- </RelativeLayout>
-
- <RelativeLayout
- android:id="@+id/ic_low_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom|end"
- android:layout_marginEnd="30dp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}">
-
- <TextView
- android:id="@+id/ic_low_name"
- style="@style/bloodTextStyle"
- android:text="@string/ic_low_pressure" />
-
- <TextView
- android:id="@+id/ic_low_value"
- style="@style/bloodTextStyle"
- android:layout_below="@id/ic_low_name"
- android:layout_centerHorizontal="true"
- android:text="@{lowValue}"/>
- </RelativeLayout>
-
- </FrameLayout>
-
-</layout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<layout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools">
-
- <data>
-
- <import type="android.graphics.drawable.Drawable" />
-
- <import type="android.view.View"/>
-
- <variable
- name="weatherIcon"
- type="Drawable" />
-
- <variable
- name="weatherState"
- type="String" />
-
- <variable
- name="weatherTemp"
- type="String" />
-
- <variable
- name="weatherCity"
- type="String" />
-
- <variable
- name="weatherSection"
- type="String" />
-
- <variable
- name="isErrorTips"
- type="String" />
-
- <variable
- name="isShowTips"
- type="boolean" />
- </data>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/mainBgColor"
- tools:context=".fragment.WeatherFragment">
-
- <ImageView
- android:id="@+id/weather_icon_iv"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="20dp"
- android:src="@{weatherIcon}" />
-
- <TextView
- android:id="@+id/weather_tips_iv"
- style="@style/WeatherTextStyle"
- android:layout_below="@id/weather_icon_iv"
- android:layout_centerHorizontal="true"
- android:text="@{isErrorTips}"
- android:textSize="36sp"
- android:visibility="@{isShowTips ? View.VISIBLE : View.GONE}"/>
-
- <TextView
- android:id="@+id/weather_state_tv"
- style="@style/WeatherTextStyle"
- android:layout_below="@id/weather_icon_iv"
- android:layout_centerHorizontal="true"
- android:text="@{weatherState}"
- android:textSize="52sp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}"/>
-
- <View
- android:id="@+id/weather_sp"
- android:layout_width="1dp"
- android:layout_height="40dp"
- android:layout_below="@id/weather_state_tv"
- android:layout_centerHorizontal="true"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}"/>
-
- <TextView
- style="@style/WeatherTextStyle"
- android:layout_below="@id/weather_state_tv"
- android:layout_marginEnd="5dp"
- android:layout_toStartOf="@id/weather_sp"
- android:text="@{weatherTemp}"
- android:textColor="#FF9800"
- android:textSize="62sp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}"/>
-
- <TextView
- android:id="@+id/weather_city_tv"
- style="@style/WeatherTextStyle"
- android:layout_below="@id/weather_state_tv"
- android:layout_marginStart="5dp"
- android:layout_toEndOf="@id/weather_sp"
- android:text="@{weatherCity}"
- android:textSize="30sp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}"/>
-
- <TextView
- style="@style/WeatherTextStyle"
- android:layout_below="@id/weather_city_tv"
- android:layout_marginStart="5dp"
- android:layout_toEndOf="@id/weather_sp"
- android:text="@{weatherSection}"
- android:textSize="30sp"
- android:visibility="@{isShowTips ? View.GONE : View.VISIBLE}"/>
- </RelativeLayout>
-</layout>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
- <string name="ic_high_pressure">高压</string>
- <string name="ic_low_pressure">低压</string>
- <string name="ic_heart_rate">心率</string>
-
- <string name="tips_not_device">未检测到设备</string>
- <string name="tips_not_wear">未正确佩戴</string>
-
- <string name="tips_quiet_please">请保持安静</string>
- <string name="tips_start_check">准备测量</string>
- <string name="tips_ing_check">正在测量中</string>
- <string name="tips_stop_check">已停止测量</string>
- <string name="tips_not_data_check">未测量到数据</string>
<string name="ped_head_name">个人设置</string>
<string name="ped_height_name">身高</string>
<string name="tips_calories_unit">大卡</string>
<string name="tips_distance_unit">公里</string>
- <string name="tips_error_weather_no_data">未获取到天气</string>
- <string name="weather_temp_degree">%1$s℃</string>
- <string name="weather_temp_space_degree">%1$s~%2$s℃</string>
<string name="ped_main_today">今日</string>
<string name="ped_main_step">步</string>
+
+ <string name="program_abnormal">很抱歉,程序出现异常,即将退出</string>
</resources>
<item name="colorAccent">@color/colorAccent</item>
</style>
- <style name="bloodTextStyle">
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:textColor">#FFFFFF</item>
- <item name="android:textSize">42sp</item>
- </style>
-
<style name="RecordTextStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:includeFontPadding">false</item>
</style>
- <style name="WeatherTextStyle">
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:textColor">#FFFFFF</item>
- <item name="android:includeFontPadding">false</item>
- </style>
</resources>
--- /dev/null
+#Mon Mar 23 18:58:57 CST 2020
+VERSION_CODE=11