version:1.7
fix:优化接口请求 update:增加锁屏密码
This commit is contained in:
@@ -17,7 +17,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
@@ -31,13 +31,14 @@ import com.fuying.sn.receiver.APKinstallReceiver;
|
||||
import com.fuying.sn.receiver.BootReceiver;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.TimeUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tuo.customview.VerificationCodeView;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
@@ -224,43 +225,14 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
|
||||
});
|
||||
if (null == topView) {
|
||||
topView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.activity_screen_lock, null);
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
// EditText et_password = topView.findViewById(R.id.et_password);
|
||||
// TextView tv_confirm = topView.findViewById(R.id.tv_confirm);
|
||||
// tv_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// String password = (String) SPUtils.get(ManagerService.this, UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
// String pwd = et_password.getText().toString();
|
||||
// if (!TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(password) && password.equals(pwd)) {
|
||||
// hideFloatingWindow();
|
||||
// }else {
|
||||
// ToastUtil.show("密码错误");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
initTopView(topView, name);
|
||||
} else {
|
||||
if ("added".equals(topView.getTag())) {
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
// EditText et_password = topView.findViewById(R.id.et_password);
|
||||
// TextView tv_confirm = topView.findViewById(R.id.tv_confirm);
|
||||
// tv_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// String password = (String) SPUtils.get(ManagerService.this, UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
// String pwd = et_password.getText().toString();
|
||||
// if (!TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(password) && password.equals(pwd)) {
|
||||
// hideFloatingWindow();
|
||||
// }else {
|
||||
// ToastUtil.show("密码错误");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
initTopView(topView, name);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// topView.setAlpha(0.8f);
|
||||
// 设置LayoutParam
|
||||
@@ -291,6 +263,108 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
|
||||
}
|
||||
}
|
||||
|
||||
private void initTopView(View view, String name) {
|
||||
TextView textView = view.findViewById(R.id.textView);
|
||||
TextView tv_hint = view.findViewById(R.id.tv_hint);
|
||||
textView.setText(name);
|
||||
LinearLayout ll_keyboard = view.findViewById(R.id.ll_keyboard);
|
||||
VerificationCodeView codeView = view.findViewById(R.id.icv);
|
||||
codeView.getEditText().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ll_keyboard.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
codeView.setInputCompleteListener(new VerificationCodeView.InputCompleteListener() {
|
||||
@Override
|
||||
public void inputComplete() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteContent() {
|
||||
|
||||
}
|
||||
});
|
||||
Button bt0 = view.findViewById(R.id.bt_0);
|
||||
Button bt1 = view.findViewById(R.id.bt_1);
|
||||
Button bt2 = view.findViewById(R.id.bt_2);
|
||||
Button bt3 = view.findViewById(R.id.bt_3);
|
||||
Button bt4 = view.findViewById(R.id.bt_4);
|
||||
Button bt5 = view.findViewById(R.id.bt_5);
|
||||
Button bt6 = view.findViewById(R.id.bt_6);
|
||||
Button bt7 = view.findViewById(R.id.bt_7);
|
||||
Button bt8 = view.findViewById(R.id.bt_8);
|
||||
Button bt9 = view.findViewById(R.id.bt_9);
|
||||
Button bt_del = view.findViewById(R.id.bt_del);
|
||||
Button bt_confirm = view.findViewById(R.id.bt_confirm);
|
||||
bt0.setOnClickListener(view1 -> add(codeView, "0"));
|
||||
bt1.setOnClickListener(view1 -> add(codeView, "1"));
|
||||
bt2.setOnClickListener(view1 -> add(codeView, "2"));
|
||||
bt3.setOnClickListener(view1 -> add(codeView, "3"));
|
||||
bt4.setOnClickListener(view1 -> add(codeView, "4"));
|
||||
bt5.setOnClickListener(view1 -> add(codeView, "5"));
|
||||
bt6.setOnClickListener(view1 -> add(codeView, "6"));
|
||||
bt7.setOnClickListener(view1 -> add(codeView, "7"));
|
||||
bt8.setOnClickListener(view1 -> add(codeView, "8"));
|
||||
bt9.setOnClickListener(view1 -> add(codeView, "9"));
|
||||
bt_del.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
tv_hint.setText("");
|
||||
codeView.clearInputContent();
|
||||
}
|
||||
});
|
||||
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 = (String) SPUtils.get(ManagerService.this, UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
if (!TextUtils.isEmpty(content) && !TextUtils.isEmpty(password) && password.equals(content)) {
|
||||
hideFloatingWindow();
|
||||
SPUtils.put(ManagerService.this, ManagerService.LOCK_STATE, 0);
|
||||
NetInterfaceManager.getInstance().getUpdateLockScreenObservable()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("getUpdateLockScreenObservable", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// ToastUtil.show("密码错误");
|
||||
tv_hint.setText("密码错误");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void add(VerificationCodeView codeView, String text) {
|
||||
Log.e(TAG, "add: text = " + text);
|
||||
String oldText = codeView.getEditText().getText().toString();
|
||||
Log.e(TAG, "add: " + oldText);
|
||||
codeView.getEditText().setText(text);
|
||||
}
|
||||
|
||||
private void hideFloatingWindow() {
|
||||
if (null == windowManager) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user