release ICL02Launcher V149
authorsnickersun <scy@incartech.cn>
Tue, 15 Sep 2020 14:41:33 +0000 (22:41 +0800)
committersnickersun <scy@incartech.cn>
Tue, 15 Sep 2020 14:41:33 +0000 (22:41 +0800)
给H88 添加控制自由锻炼的界面

app/release/ICL02Launcher_V149_202009152105_release.apk [new file with mode: 0644]
app/release/output.json [new file with mode: 0644]
app/src/main/java/com/ic/launcher/PractiseActivity.java [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/a9_practice_l02.png [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/practice.png [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/practice_logo.png [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/practising.png [new file with mode: 0644]

diff --git a/app/release/ICL02Launcher_V149_202009152105_release.apk b/app/release/ICL02Launcher_V149_202009152105_release.apk
new file mode 100644 (file)
index 0000000..3a142f8
Binary files /dev/null and b/app/release/ICL02Launcher_V149_202009152105_release.apk differ
diff --git a/app/release/output.json b/app/release/output.json
new file mode 100644 (file)
index 0000000..dc8fd45
--- /dev/null
@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":149,"versionName":"202009152105","enabled":true,"outputFile":"ICL02Launcher_V149_202009152105_release.apk","fullName":"release","baseName":"release"},"path":"ICL02Launcher_V149_202009152105_release.apk","properties":{}}]
\ No newline at end of file
diff --git a/app/src/main/java/com/ic/launcher/PractiseActivity.java b/app/src/main/java/com/ic/launcher/PractiseActivity.java
new file mode 100644 (file)
index 0000000..57d38ca
--- /dev/null
@@ -0,0 +1,185 @@
+package com.ic.launcher;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+import android.util.TypedValue;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.ImageView;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.core.view.GestureDetectorCompat;
+
+import com.ic.launcher.databinding.ActivityQrCodeBinding;
+import com.ic.launcher.listener.MainClockGestureDetectorImpl;
+import com.ic.launcher.util.IcLog;
+import com.ic.launcher.util.QRCodeUtil;
+import com.ic.launcher.util.SystemUtils;
+
+public class PractiseActivity extends AppCompatActivity implements
+        MainClockGestureDetectorImpl.OnClockGestureFlingListener, View.OnClickListener {
+
+    final static String KeyPractiseState = "persist.sys.practising";
+    final static String ACTION_START_PRACTISE = "com.ic.action_start_practice";
+    final static String KeyPractice = "cmd";
+
+    private GestureDetectorCompat gesture;
+    private boolean practising=false;
+    ImageView imageView;
+    ActivityQrCodeBinding qrCodeBinding;
+    Handler mhandler=new Handler(){
+        @Override
+        public void handleMessage(@NonNull Message msg) {
+
+            switch (msg.what)
+            {
+                case 0:
+                    sendAction(false);
+                    qrCodeBinding.setQrCodeDrawable(ContextCompat.getDrawable(PractiseActivity.this, R.mipmap.practice));
+                    qrCodeBinding.setQrCodeText(PractiseActivity.this.getResources().getString(R.string.app_practise_stoped));
+                    break;
+                case 1:
+                    sendAction(true);
+                    qrCodeBinding.setQrCodeDrawable(ContextCompat.getDrawable(PractiseActivity.this, R.mipmap.practising));
+                    qrCodeBinding.setQrCodeText(PractiseActivity.this.getResources().getString(R.string.app_practising));
+                    break;
+            }
+            super.handleMessage(msg);
+        }
+    };
+
+
+    private void sendAction(boolean start){
+
+        Intent intent=new Intent();
+        intent.setAction(ACTION_START_PRACTISE);
+
+        if (start)
+            intent.putExtra(KeyPractice,1);
+        else
+            intent.putExtra(KeyPractice,0);
+
+        this.sendBroadcast(intent);
+    }
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        qrCodeBinding = ActivityQrCodeBinding.inflate(getLayoutInflater());
+        setContentView(qrCodeBinding.getRoot());
+        imageView=this.findViewById(R.id.qr_code_iv);
+        imageView.setOnClickListener(this);
+        String str_practising = getPrefStringPublic(this, KeyPractiseState, "false");
+
+
+        if (str_practising.equals("true")) {
+            practising=true;
+            qrCodeBinding.setQrCodeDrawable(ContextCompat.getDrawable(this, R.mipmap.practising));
+            qrCodeBinding.setQrCodeText(this.getResources().getString(R.string.app_practising));
+        }else{
+            practising=false;
+            qrCodeBinding.setQrCodeDrawable(ContextCompat.getDrawable(this, R.mipmap.practice));
+            qrCodeBinding.setQrCodeText(this.getResources().getString(R.string.app_practise_stoped));
+        }
+
+
+        gesture = new GestureDetectorCompat(this, new MainClockGestureDetectorImpl(this));
+
+        registerCloseSystemReceiver();
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterReceiver(systemReceiver);
+    }
+
+    @SuppressLint("WorldReadableFiles")
+    public static String getPrefStringPublic(Context context, String key, String value) {
+        return SystemUtils.getSystemPropertiesString(key,value);
+    }
+
+    private float dpToPx(float dp) {
+        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
+    }
+
+    @Override
+    public void onDirection(int flag) {
+        if (flag == 2) {
+            finish();
+        }
+    }
+
+    @Override
+    public void onDouble() {
+
+    }
+
+    private void registerCloseSystemReceiver(){
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+        registerReceiver(systemReceiver, filter);
+    }
+
+    private  final  BroadcastReceiver  systemReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
+                String reason = intent.getStringExtra("reason");
+                if ("homekey".equals(reason)) {
+                    // 按下HOME健
+                    IcLog.i("QrCodeActivity","Home");
+                    finish();
+                }
+            }
+        }
+    };
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (gesture.onTouchEvent(event)) {
+
+
+
+
+            return true;
+        }
+        return true;
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        if (keyCode == KeyEvent.KEYCODE_BACK) {
+            // 禁用 KEYCODE_BACK 退出功能
+            finish();
+        }
+        return true;
+    }
+
+    @Override
+    public void onClick(View view) {
+        practising=!practising;
+        if(practising){
+            mhandler.sendEmptyMessage(1);
+        }else{
+            mhandler.sendEmptyMessage(0);
+        }
+    }
+}
diff --git a/app/src/main/res/mipmap-mdpi/a9_practice_l02.png b/app/src/main/res/mipmap-mdpi/a9_practice_l02.png
new file mode 100644 (file)
index 0000000..fdaa686
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/a9_practice_l02.png differ
diff --git a/app/src/main/res/mipmap-mdpi/practice.png b/app/src/main/res/mipmap-mdpi/practice.png
new file mode 100644 (file)
index 0000000..6802692
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/practice.png differ
diff --git a/app/src/main/res/mipmap-mdpi/practice_logo.png b/app/src/main/res/mipmap-mdpi/practice_logo.png
new file mode 100644 (file)
index 0000000..fe72793
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/practice_logo.png differ
diff --git a/app/src/main/res/mipmap-mdpi/practising.png b/app/src/main/res/mipmap-mdpi/practising.png
new file mode 100644 (file)
index 0000000..0a57147
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/practising.png differ