version:1.3.9
fix: update:优化退出界面
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
package com.uiui.zyos.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.SoundPool;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -30,29 +32,29 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
private static final String TAG = ScreenLockActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.bt_0)
|
||||
Button bt0;
|
||||
TextView bt0;
|
||||
@BindView(R.id.bt_1)
|
||||
Button bt1;
|
||||
TextView bt1;
|
||||
@BindView(R.id.bt_2)
|
||||
Button bt2;
|
||||
TextView bt2;
|
||||
@BindView(R.id.bt_3)
|
||||
Button bt3;
|
||||
TextView bt3;
|
||||
@BindView(R.id.bt_4)
|
||||
Button bt4;
|
||||
TextView bt4;
|
||||
@BindView(R.id.bt_5)
|
||||
Button bt5;
|
||||
TextView bt5;
|
||||
@BindView(R.id.bt_6)
|
||||
Button bt6;
|
||||
TextView bt6;
|
||||
@BindView(R.id.bt_7)
|
||||
Button bt7;
|
||||
TextView bt7;
|
||||
@BindView(R.id.bt_8)
|
||||
Button bt8;
|
||||
TextView bt8;
|
||||
@BindView(R.id.bt_9)
|
||||
Button bt9;
|
||||
TextView bt9;
|
||||
@BindView(R.id.bt_del)
|
||||
Button bt_del;
|
||||
TextView bt_del;
|
||||
@BindView(R.id.bt_confirm)
|
||||
Button bt_confirm;
|
||||
TextView bt_confirm;
|
||||
|
||||
@BindView(R.id.textView)
|
||||
TextView textView;
|
||||
@@ -63,10 +65,21 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
@BindView(R.id.icv)
|
||||
VerificationCodeView codeView;
|
||||
|
||||
private SoundPool soundPool;
|
||||
private int soundId;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
AudioAttributes attr = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME) // 设置音效使用场景
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build(); // 设置音效的类型
|
||||
soundPool = new SoundPool.Builder().setAudioAttributes(attr) // 设置音效池的属性
|
||||
.setMaxStreams(1) // 设置最多可容纳10个音频流
|
||||
.build(); // ①
|
||||
// load方法加载指定音频文件,并返回所加载的音效ID
|
||||
// 此处使用HashMap来管理这些音频流
|
||||
soundId = soundPool.load(this, R.raw.click, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +101,7 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
codeView.setInputCompleteListener(new VerificationCodeView.InputCompleteListener() {
|
||||
@Override
|
||||
public void inputComplete() {
|
||||
|
||||
checkPasswd();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,24 +120,7 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
bt_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String content = codeView.getInputContent();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "inputComplete: " + content);
|
||||
String password = Settings.Global.getString(getContentResolver(), CommonConfig.DEFAULT_PASSWORD);
|
||||
if ((!TextUtils.isEmpty(content) && !TextUtils.isEmpty(password))) {
|
||||
if (password.equals(content)) {
|
||||
exitDesktop();
|
||||
} else {
|
||||
tv_hint.setText("密码错误");
|
||||
}
|
||||
} else if (CommonConfig.DEFAULT_PASSWORD.equals(content)) {
|
||||
exitDesktop();
|
||||
} else {
|
||||
// ToastUtil.show("密码错误");
|
||||
tv_hint.setText("密码错误");
|
||||
}
|
||||
checkPasswd();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -140,6 +136,38 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
bt9.setOnClickListener(view1 -> add(codeView, "9"));
|
||||
}
|
||||
|
||||
private void checkPasswd() {
|
||||
String content = codeView.getInputContent();
|
||||
if (TextUtils.isEmpty(content) || content.length() != 6) {
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "inputComplete: " + content);
|
||||
String password = Settings.Global.getString(getContentResolver(), CommonConfig.DEFAULT_PASSWORD);
|
||||
if ((!TextUtils.isEmpty(content) && !TextUtils.isEmpty(password))) {
|
||||
if (password.equals(content)) {
|
||||
exitDesktop();
|
||||
} else {
|
||||
setEmpty();
|
||||
tv_hint.setText("密码错误");
|
||||
}
|
||||
} else if (CommonConfig.DEFAULT_PASSWORD.equals(content)) {
|
||||
exitDesktop();
|
||||
} else {
|
||||
setEmpty();
|
||||
tv_hint.setText("密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
private void setEmpty() {
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
codeView.clearInputContent();
|
||||
tv_hint.setText("");
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
@@ -150,15 +178,16 @@ public class ScreenLockActivity extends BaseActivity {
|
||||
String oldText = codeView.getEditText().getText().toString();
|
||||
Log.e(TAG, "add: " + oldText);
|
||||
codeView.getEditText().setText(text);
|
||||
soundPool.play(soundId, 1, 1, 0, 0, 1);
|
||||
}
|
||||
|
||||
private void exitDesktop() {
|
||||
RemoteManager.getInstance().setDefaultDesktop(ApkUtils.ANDROID_LAUNCHER3_PACKAGE_NAME);
|
||||
if (Build.VERSION.SDK_INT> Build.VERSION_CODES.Q) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||
if (!ApkUtils.openPackage(this, ApkUtils.ANDROID_LAUNCHER3_PACKAGE_NAME, ApkUtils.ANDROID_LAUNCHER3_Quickstep_CLASS_NAME)) {
|
||||
ApkUtils.gotoLauncher(this);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (!ApkUtils.openPackage(this, ApkUtils.ANDROID_LAUNCHER3_PACKAGE_NAME, ApkUtils.ANDROID_LAUNCHER3_CLASS_NAME)) {
|
||||
ApkUtils.gotoLauncher(this);
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
}
|
||||
|
||||
private void startJxwLauncher() {
|
||||
ComponentName cn = new ComponentName(JxwPackageConfig.JXW_LAUNCHER_PACKAGE_NAME, JxwPackageConfig.JXW_LAUNCHER_CLASS_NAME);
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(cn);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
// ComponentName cn = new ComponentName(JxwPackageConfig.JXW_LAUNCHER_PACKAGE_NAME, JxwPackageConfig.JXW_LAUNCHER_CLASS_NAME);
|
||||
// Intent intent = new Intent();
|
||||
// intent.setComponent(cn);
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// startForegroundService(intent);
|
||||
// } else {
|
||||
// startService(intent);
|
||||
// }
|
||||
}
|
||||
|
||||
private void unregisterReceiver() {
|
||||
|
||||
Reference in New Issue
Block a user