|
@@ -0,0 +1,184 @@
|
|
|
+package com.wdkl.launch;
|
|
|
+
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.provider.Settings;
|
|
|
+import android.support.v7.app.AppCompatActivity;
|
|
|
+import android.view.MotionEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.wdkl.launch.anrfcutil.AnrFcExceptionUtil;
|
|
|
+import com.wdkl.launch.runningApp.RunningUtil;
|
|
|
+import com.wdkl.launch.util.EthernetStatus;
|
|
|
+
|
|
|
+public class MainActivity extends AppCompatActivity implements View.OnTouchListener, View.OnClickListener {
|
|
|
+
|
|
|
+ float x1 = 0;
|
|
|
+ float x2 = 0;
|
|
|
+ float y1 = 0;
|
|
|
+ float y2 = 0;
|
|
|
+
|
|
|
+ Button mBtnF;
|
|
|
+ Button mBtnS;
|
|
|
+ Button mBtnT;
|
|
|
+ Button mBtnFo;
|
|
|
+ Button mBtnSi;
|
|
|
+ TextView mTvFo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_main);
|
|
|
+ //ANR奔溃异常处理
|
|
|
+ AnrFcExceptionUtil.getInstance(getApplication()).initFCException();
|
|
|
+ Intent intent = new Intent(this, Launcher.class);
|
|
|
+ startService(intent);
|
|
|
+
|
|
|
+ mBtnF = (Button) findViewById(R.id.activity_main_first_btn);
|
|
|
+ mBtnS = (Button) findViewById(R.id.activity_main_second_btn);
|
|
|
+ mBtnT = (Button) findViewById(R.id.activity_main_third_btn);
|
|
|
+ mBtnFo = (Button) findViewById(R.id.activity_main_four_btn);
|
|
|
+ mBtnSi = (Button) findViewById(R.id.activity_main_six_btn);
|
|
|
+ mTvFo = (TextView) findViewById(R.id.activity_main_first_tv);
|
|
|
+
|
|
|
+ mBtnF.setOnClickListener(this);
|
|
|
+ mBtnS.setOnClickListener(this);
|
|
|
+ mBtnT.setOnClickListener(this);
|
|
|
+ mBtnFo.setOnClickListener(this);
|
|
|
+ mBtnSi.setOnClickListener(this);
|
|
|
+
|
|
|
+ //mBtnF.setOnTouchListener(this);
|
|
|
+ //mBtnS.setOnTouchListener(this);
|
|
|
+ //mBtnT.setOnTouchListener(this);
|
|
|
+ //mBtnFo.setOnTouchListener(this);
|
|
|
+ //mBtnSi.setOnTouchListener(this);
|
|
|
+ //Launcher.checkApkLaunch(this);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ final int TIME_WHAT = 1000;
|
|
|
+ public Handler handler = new Handler() {
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case TIME_WHAT:
|
|
|
+ handler.sendEmptyMessageDelayed(TIME_WHAT, 3000);
|
|
|
+ try {
|
|
|
+ if (!RunningUtil.appIsRunning(MainActivity.this)) {
|
|
|
+ Launcher.checkApkLaunch(MainActivity.this);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ public String mInput = "";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.activity_main_first_btn:
|
|
|
+ mInput = mInput + "1";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_second_btn:
|
|
|
+ mInput = mInput + "2";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_third_btn:
|
|
|
+ mInput = mInput + "3";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_four_btn:
|
|
|
+ mInput = mInput + "4";
|
|
|
+ if (mInput.equals("1234")) {
|
|
|
+ mTvFo.setText("");
|
|
|
+ Intent intent = new Intent(this, ListAppActivity.class);
|
|
|
+ startActivity(intent);
|
|
|
+ } else {
|
|
|
+ mTvFo.setText("密码有误,请重试");
|
|
|
+ }
|
|
|
+ mInput = "";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_six_btn:
|
|
|
+ Launcher.checkApkLaunch(this);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPause() {
|
|
|
+ super.onPause();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ Launcher.checkApkLaunch(this);
|
|
|
+
|
|
|
+ if (Launcher.systemVersionIsO()) {//安卓8.1.0 版用
|
|
|
+
|
|
|
+ } else {
|
|
|
+ handler.sendEmptyMessageDelayed(TIME_WHAT, 3000);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onTouchEvent(MotionEvent event) {
|
|
|
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
+ //当手指按下的时候
|
|
|
+ x1 = event.getX();
|
|
|
+ y1 = event.getY();
|
|
|
+ }
|
|
|
+ if (event.getAction() == MotionEvent.ACTION_UP) {
|
|
|
+ //当手指离开的时候
|
|
|
+ x2 = event.getX();
|
|
|
+ y2 = event.getY();
|
|
|
+ if (y1 - y2 > 400) {
|
|
|
+ startActivity(new Intent(Settings.ACTION_SETTINGS));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return super.onTouchEvent(event);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ if (event.getAction() != MotionEvent.ACTION_UP) return false;
|
|
|
+ switch (v.getId()) {
|
|
|
+ case R.id.activity_main_first_btn:
|
|
|
+ mInput = mInput + "1";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_second_btn:
|
|
|
+ mInput = mInput + "2";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_third_btn:
|
|
|
+ mInput = mInput + "3";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_four_btn:
|
|
|
+ mInput = mInput + "4";
|
|
|
+ if (mInput.equals("1234")) {
|
|
|
+ mTvFo.setText("");
|
|
|
+ Intent intent = new Intent(MainActivity.this, ListAppActivity.class);
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
+ startActivity(intent);
|
|
|
+ } else {
|
|
|
+ mTvFo.setText("密码有误,请重试");
|
|
|
+ }
|
|
|
+ mInput = "";
|
|
|
+ break;
|
|
|
+ case R.id.activity_main_six_btn:
|
|
|
+ Launcher.checkApkLaunch(this);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|