Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
383bjz82bu committed Apr 16, 2022
1 parent 0a6a53d commit 7f7bcc7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.8.6
- fix custom wifi icon failed
- one key lock crash
---------

## 0.1.8.5
- fix no custom wifi icon crash
---------
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId "cn.modificator.launcher"
minSdkVersion 14
targetSdkVersion 31
versionCode 29
versionName "0.1.8.5"
versionCode 30
versionName "0.1.8.6"
signingConfig signingConfigs.config
}
buildTypes {
Expand Down
33 changes: 29 additions & 4 deletions app/src/main/java/cn/modificator/launcher/Launcher.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cn.modificator.launcher;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -415,13 +417,36 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
}

public void lockScreen() {
if (policyManager.isAdminActive(new ComponentName(this, AdminReceiver.class))) {
policyManager.lockNow();
} else {
activeManage();
try {
if (policyManager.isAdminActive(new ComponentName(this, AdminReceiver.class))) {
policyManager.lockNow();
} else {
activeManage();
}
}catch (Exception e){
openDevicePolicyManager();
}
}

private void openDevicePolicyManager() {
new AlertDialog.Builder(this)
.setTitle(R.string.launch_failed)
.setMessage(R.string.launch_devicemanager_failed)
.setPositiveButton(R.string.launch_devicemanager, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
Intent intent = Intent.parseUri("intent:#Intent;component=com.android.settings/.DeviceAdminSettings;end", Intent.URI_INTENT_SCHEME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
})
.setNegativeButton(R.string.dialog_cancel, null).show();
}

private void activeManage() {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, new ComponentName(this, AdminReceiver.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void updateStatus(){
appName.setText(mContext.getString(showNameRes, connectWifiName));
String fileName = showIconRes == R.drawable.wifi_on ? wifiOnResName : wifiOffResName;
int index = iconReplacePkg.indexOf(fileName);
if (Config.showCustomIcon && iconReplacePkg != null && index > 0) {
if (!Config.showCustomIcon && iconReplacePkg != null && index > 0) {
appImage.setImageURI(Uri.fromFile(iconReplaceFile.get(index)));
} else {
appImage.setImageResource(showIconRes);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@
<string name="show_wifi_name">显示WiFi名字</string>
<string name="notification_click_back_launcher">点击这里回到桌面</string>
<string name="app_show_name">App 名字</string>
<string name="launch_failed">启动失败</string>
<string name="launch_devicemanager">打开设备管理器</string>
<string name="launch_devicemanager_failed">请打开设备管理器并启用 E-Ink Launcher</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<string name="wifi_status_disconnecting">WiFi disconnecting</string>

<string name="item_lockscreen">Lock Screen</string>
<string name="launch_failed">Launch failed</string>
<string name="launch_devicemanager_failed">Please open Device Policy Manager and enable E-Ink Launcher</string>
<string name="launch_devicemanager">Open Device Policy Manager</string>

<string-array name="power_menu">
<item>Power off</item>
Expand Down

0 comments on commit 7f7bcc7

Please sign in to comment.