version:beta

fix:
update:接口优化
This commit is contained in:
2022-11-04 09:33:43 +08:00
parent 86429b92f8
commit b1645f0fae
6 changed files with 212 additions and 126 deletions

View File

@@ -608,7 +608,7 @@ public class NetInterfaceManager {
public void getSnInfo(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
ConnectMode connectMode = ConnectMode.SIX_HOUR;
if (refresh) {
connectMode = ConnectMode.ONE_MINUTE;
connectMode = ConnectMode.ONE_HOUR;
}
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SNINFO, connectMode)) {
getSnInfo(lifecycle, callback);
@@ -1360,36 +1360,76 @@ public class NetInterfaceManager {
});
}
public void getBrowserWhiteList(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
ConnectMode connectMode = ConnectMode.SIX_HOUR;
if (refresh) {
connectMode = ConnectMode.ONE_HOUR;
}
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_URL, connectMode)) {
getBrowserWhiteList(lifecycle, callback);
} else {
String jsonString = mCacheHelper.getAsString(UrlAddress.SET_BROWSER_URL);
//为 "" 是已经请求成功的
if (jsonString == null) {
getBrowserWhiteList(lifecycle, callback);
} else {
Gson gson = new Gson();
Type type = new TypeToken<String>() {
}.getType();
callback.onComplete();
}
}
}
public void getBrowserWhiteList(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
getBrowserControl()
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
.subscribe(getBrowserWhiteListObserver(callback));
}
public void getBrowserWhiteList(CompleteCallback callback) {
getBrowserControl()
.subscribe(getBrowserWhiteListObserver(callback));
}
/**
* 获取浏览器黑白名单
*/
public void getBrowserWhiteList() {
getBrowserControl()
.subscribe(new Observer<BaseResponse<BrowserApiData>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getBrowserWhiteList", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<BrowserApiData> response) {
setBrowserResponse(response);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getBrowserWhiteList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBrowserWhiteList", "onComplete: ");
new URLUtils(mContext).setBrowserList();
}
});
.subscribe(getBrowserWhiteListObserver(null));
}
public Observer<BaseResponse<BrowserApiData>> getBrowserWhiteListObserver(CompleteCallback callback) {
return new Observer<BaseResponse<BrowserApiData>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getBrowserWhiteList", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<BrowserApiData> response) {
setBrowserResponse(response);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getBrowserWhiteList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBrowserWhiteList", "onComplete: ");
if (callback != null) {
callback.onComplete();
}
new URLUtils(mContext).setBrowserList();
}
};
}
private void setBrowserResponse(BaseResponse<BrowserApiData> response) {
if (response.code == 200) {
//白名单
@@ -1416,31 +1456,73 @@ public class NetInterfaceManager {
}
}
public void getBrowserLabel(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
ConnectMode connectMode = ConnectMode.SIX_HOUR;
if (refresh) {
connectMode = ConnectMode.ONE_HOUR;
}
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_LABEL, connectMode)) {
getBrowserLabel(lifecycle, callback);
} else {
String jsonString = mCacheHelper.getAsString(UrlAddress.SET_BROWSER_LABEL);
//为 "" 是已经请求成功的
if (jsonString == null) {
getBrowserLabel(lifecycle, callback);
} else {
Gson gson = new Gson();
Type type = new TypeToken<String>() {
}.getType();
callback.onComplete();
}
}
}
public void getBrowserLabel(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
getLabelControl()
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
.subscribe(getBrowserLabelObserver(callback));
}
public void getBrowserLabel(CompleteCallback callback) {
getLabelControl()
.subscribe(getBrowserLabelObserver(callback));
}
public void getBrowserLabel() {
getLabelControl()
.subscribe(new Observer<BaseResponse<Label>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getBrowserLabel", "onSubscribe: ");
}
.subscribe(getBrowserLabelObserver(null));
@Override
public void onNext(@NonNull BaseResponse<Label> response) {
setLabelResponse(response);
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getBrowserLabel", "onError: " + e.getMessage());
onComplete();
}
public Observer<BaseResponse<Label>> getBrowserLabelObserver(CompleteCallback callback) {
return new Observer<BaseResponse<Label>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getBrowserLabel", "onSubscribe: ");
}
@Override
public void onComplete() {
Log.e("getBrowserLabel", "onComplete: ");
new URLUtils(mContext).setBrowserList();
}
});
@Override
public void onNext(@NonNull BaseResponse<Label> response) {
setLabelResponse(response);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getBrowserLabel", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBrowserLabel", "onComplete: ");
if (callback != null) {
callback.onComplete();
}
new URLUtils(mContext).setBrowserList();
}
};
}
private void setLabelResponse(BaseResponse<Label> response) {
@@ -2142,8 +2224,11 @@ public class NetInterfaceManager {
public void sendRunningApp() {
String packageName = AppUsedTimeUtils.getInstance().getApp_package();
if (TextUtils.isEmpty(packageName))
Log.e(TAG, "sendRunningApp: packageName = " + packageName);
if (TextUtils.isEmpty(packageName)) {
Log.e(TAG, "sendRunningApp: packageName is empty");
return;
}
long time = AppUsedTimeUtils.getInstance().getStart_time();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("app_package", packageName);

View File

@@ -226,38 +226,38 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
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("密码错误");
}
}
});
// 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("密码错误");
// }
// }
// });
} 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("密码错误");
}
}
});
// 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("密码错误");
// }
// }
// });
} else {
return;
}

View File

@@ -394,7 +394,8 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
}
switch (action) {
case Intent.ACTION_USER_PRESENT:
mPresenter.getAppTimeControl();
// TODO: 2022/11/3 暂时屏蔽获取
// mPresenter.getAppTimeControl();
break;
case Intent.ACTION_SCREEN_ON:

View File

@@ -17,30 +17,30 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_password"
android:layout_width="@dimen/dp_200"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_16"
android:background="@drawable/edit_background"
android:gravity="center"
android:hint="请输入密码解锁"
android:maxEms="20"
android:maxLines="1"
android:singleLine="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<!-- <EditText-->
<!-- android:id="@+id/et_password"-->
<!-- android:layout_width="@dimen/dp_200"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:background="@drawable/edit_background"-->
<!-- android:gravity="center"-->
<!-- android:hint="请输入密码解锁"-->
<!-- android:maxEms="20"-->
<!-- android:maxLines="1"-->
<!-- android:singleLine="true"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/textView" />-->
<TextView
android:id="@+id/tv_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_16"
android:text="确定"
android:textColor="@color/white"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="@+id/et_password"
app:layout_constraintStart_toStartOf="@+id/et_password"
app:layout_constraintTop_toBottomOf="@+id/et_password" />
<!-- <TextView-->
<!-- android:id="@+id/tv_confirm"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:text="确定"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="24sp"-->
<!-- app:layout_constraintEnd_toEndOf="@+id/et_password"-->
<!-- app:layout_constraintStart_toStartOf="@+id/et_password"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/et_password" />-->
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -17,30 +17,30 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_password"
android:layout_width="@dimen/dp_200"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_16"
android:background="@drawable/edit_background"
android:gravity="center"
android:hint="请输入密码解锁"
android:maxEms="20"
android:maxLines="1"
android:singleLine="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<!-- <EditText-->
<!-- android:id="@+id/et_password"-->
<!-- android:layout_width="@dimen/dp_200"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:background="@drawable/edit_background"-->
<!-- android:gravity="center"-->
<!-- android:hint="请输入密码解锁"-->
<!-- android:maxEms="20"-->
<!-- android:maxLines="1"-->
<!-- android:singleLine="true"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/textView" />-->
<TextView
android:id="@+id/tv_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_16"
android:text="确定"
android:textColor="@color/white"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="@+id/et_password"
app:layout_constraintStart_toStartOf="@+id/et_password"
app:layout_constraintTop_toBottomOf="@+id/et_password" />
<!-- <TextView-->
<!-- android:id="@+id/tv_confirm"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:text="确定"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="24sp"-->
<!-- app:layout_constraintEnd_toEndOf="@+id/et_password"-->
<!-- app:layout_constraintStart_toStartOf="@+id/et_password"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/et_password" />-->
</androidx.constraintlayout.widget.ConstraintLayout>