Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

Commit 61a609b

Browse files
committed
closes #11,#12,#13,#14,#15,#22.#23
1 parent 4b0469b commit 61a609b

File tree

12 files changed

+55
-36
lines changed

12 files changed

+55
-36
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "io.github.subhamtyagi.privacyapplock"
77
minSdkVersion 15
88
targetSdkVersion 28
9-
versionCode 5
10-
versionName "1.0.5"
9+
versionCode 6
10+
versionName "1.0.6"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {

app/src/main/java/com/lzx/lock/activities/lock/GestureUnlockActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
import java.util.List;
3636

37+
import io.github.subhamtyagi.crashreporter.CrashReporter;
38+
3739
/**
3840
* Created by xian on 2017/2/17.
3941
*/
@@ -130,7 +132,11 @@ public boolean onPreDraw() {
130132
height = size.y;
131133
}
132134
Bitmap bmp = LockUtil.drawableToBitmap(icon, width, height);
133-
LockUtil.blur(GestureUnlockActivity.this, LockUtil.big(bmp), mUnLockLayout);
135+
try {
136+
LockUtil.blur(GestureUnlockActivity.this, LockUtil.big(bmp), mUnLockLayout,width,height);
137+
}catch (IllegalArgumentException ignore){
138+
CrashReporter.logException(ignore);
139+
}
134140
return true;
135141
}
136142
});

app/src/main/java/com/lzx/lock/activities/main/SplashActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ protected void initViews(Bundle savedInstanceState) {
4949

5050
@Override
5151
protected void initData() {
52-
//TODO: pie compatable done
5352
//startService(new Intent(this, LoadAppListService.class));
5453
BackgroundManager.getInstance().init(this).startService(LoadAppListService.class);
5554

app/src/main/java/com/lzx/lock/activities/setting/LockSettingActivity.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,19 @@ protected void initAction() {
110110
@Override
111111
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
112112
SpUtil.getInstance().putBoolean(AppConstants.LOCK_STATE, b);
113-
Intent intent = new Intent(LockSettingActivity.this, LockService.class);
113+
//Intent intent = new Intent(LockSettingActivity.this, LockService.class);
114114
if (b) {
115-
mLockTip.setText("Opened, password is required when the lock application is opened");
116-
115+
mLockTip.setText(R.string.pattern_is_required);
116+
//restart service
117+
BackgroundManager.getInstance().init(LockSettingActivity.this).stopService(LockService.class);
117118
BackgroundManager.getInstance().init(LockSettingActivity.this).startService(LockService.class);
118119

120+
BackgroundManager.getInstance().init(LockSettingActivity.this).startAlarmManager();
121+
119122
} else {
120-
mLockTip.setText("Closed, no password is required when the lock app opens");
123+
mLockTip.setText(R.string.pattern_is_not_required);
121124
BackgroundManager.getInstance().init(LockSettingActivity.this).stopService(LockService.class);
122-
125+
BackgroundManager.getInstance().init(LockSettingActivity.this).stopAlarmManager();
123126
}
124127
}
125128
});
@@ -146,10 +149,12 @@ public void onClick(@NonNull View view) {
146149
boolean ishideline = SpUtil.getInstance().getBoolean(AppConstants.LOCK_IS_HIDE_LINE, false);
147150
if (ishideline) {
148151
SpUtil.getInstance().putBoolean(AppConstants.LOCK_IS_HIDE_LINE, false);
149-
ToastUtil.showToast("Path is displayed");
152+
mIsShowPath.setText(R.string.hide_pattern);
153+
ToastUtil.showToast("Pattern is displayed");
150154
} else {
151155
SpUtil.getInstance().putBoolean(AppConstants.LOCK_IS_HIDE_LINE, true);
152-
ToastUtil.showToast("Path is hidden");
156+
mIsShowPath.setText(R.string.show_pattern);
157+
ToastUtil.showToast("Pattern is hidden");
153158
}
154159
break;
155160
case R.id.lock_screen:

app/src/main/java/com/lzx/lock/receiver/LockRestarterBroadcastReceiver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class LockRestarterBroadcastReceiver extends BroadcastReceiver {
1414

1515
@Override
1616
public void onReceive(Context context, Intent intent) {
17-
if (intent != null) {
17+
boolean lockState=SpUtil.getInstance().getBoolean(AppConstants.LOCK_STATE);
18+
if (intent != null && lockState) {
1819
String type = intent.getStringExtra("type");
1920
if (type.contentEquals("lockservice"))
2021
//context.startService(new Intent(context, LockService.class));

app/src/main/java/com/lzx/lock/services/BackgroundManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ private void checkContext() {
8484

8585
public void stopService(Class<?> serviceClass) {
8686
checkContext();
87-
ctx.stopService(new Intent(ctx, serviceClass));
87+
if (isServiceRunning(LockService.class))
88+
ctx.stopService(new Intent(ctx, serviceClass));
8889
}
8990
}

app/src/main/java/com/lzx/lock/services/LockService.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ public void onDestroy() {
229229
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
230230
NotificationUtil.cancelNotification(this);
231231
}
232-
Intent intent = new Intent(this, LockRestarterBroadcastReceiver.class);
233-
intent.putExtra("type", "lockservice");
234-
sendBroadcast(intent);
232+
lockState = SpUtil.getInstance().getBoolean(AppConstants.LOCK_STATE);
233+
if (lockState) {
234+
Intent intent = new Intent(this, LockRestarterBroadcastReceiver.class);
235+
intent.putExtra("type", "lockservice");
236+
sendBroadcast(intent);
237+
}
235238
unregisterReceiver(mServiceReceiver);
236239
}
237240

@@ -244,14 +247,17 @@ public void onTaskRemoved(Intent rootIntent) {
244247
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
245248
NotificationUtil.cancelNotification(this);
246249
}
247-
Intent restartServiceTask = new Intent(getApplicationContext(), this.getClass());
248-
restartServiceTask.setPackage(getPackageName());
249-
PendingIntent restartPendingIntent = PendingIntent.getService(getApplicationContext(), 1495, restartServiceTask, PendingIntent.FLAG_ONE_SHOT);
250-
AlarmManager myAlarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
251-
myAlarmService.set(
252-
AlarmManager.ELAPSED_REALTIME,
253-
SystemClock.elapsedRealtime() + 1500,
254-
restartPendingIntent);
250+
lockState = SpUtil.getInstance().getBoolean(AppConstants.LOCK_STATE);
251+
if (lockState) {
252+
Intent restartServiceTask = new Intent(getApplicationContext(), this.getClass());
253+
restartServiceTask.setPackage(getPackageName());
254+
PendingIntent restartPendingIntent = PendingIntent.getService(getApplicationContext(), 1495, restartServiceTask, PendingIntent.FLAG_ONE_SHOT);
255+
AlarmManager myAlarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
256+
myAlarmService.set(
257+
AlarmManager.ELAPSED_REALTIME,
258+
SystemClock.elapsedRealtime() + 1500,
259+
restartPendingIntent);
260+
}
255261

256262
}
257263

app/src/main/java/com/lzx/lock/utils/LockUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ public static Bitmap drawableToBitmap(Drawable drawable, int width,int height) {
130130
}
131131

132132
private static final String TAG="LockUtil";
133-
public static void blur(Context mContent, @NonNull Bitmap bkg, View view) {
134-
long startMs = System.currentTimeMillis();
133+
public static void blur(Context mContent, @NonNull Bitmap bkg, View view,int width,int height) {
134+
//long startMs = System.currentTimeMillis();
135135
float radius = 50;
136136
float scaleFactor = 8;
137137
Bitmap overlay = Bitmap.createBitmap(
138-
(int) (view.getMeasuredWidth() / scaleFactor),
139-
(int) (view.getMeasuredHeight() / scaleFactor),
138+
(int) (width / scaleFactor),
139+
(int) (height/ scaleFactor),
140140
Bitmap.Config.ARGB_8888);
141141
Canvas canvas = new Canvas(overlay);
142142
canvas.translate(-view.getLeft() / scaleFactor, -view.getTop() / scaleFactor);

app/src/main/java/com/lzx/lock/utils/NotificationUtil.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class NotificationUtil {
2222

2323
@RequiresApi(api = Build.VERSION_CODES.O)
2424
public static void createNotification(Service mContext,String title, String message) {
25-
26-
2725
Intent resultIntent = new Intent(mContext, MainActivity.class);
2826
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2927
PendingIntent resultPendingIntent = PendingIntent.getActivity(mContext, 112 /* Request code */, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
@@ -47,7 +45,6 @@ public static void createNotification(Service mContext,String title, String mess
4745
mContext.startForeground(145,mBuilder.build());
4846
}
4947

50-
5148
public static void cancelNotification(Service mContext){
5249
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
5350
mNotificationManager.cancel(145);

app/src/main/res/layout/activity_about_me.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
android:layout_marginStart="40dp"
8686
android:autoLink="web"
8787
android:padding="@dimen/activity_horizontal_margin"
88-
android:text="@string/github_https_github_com_lizixian18"
88+
android:text="@string/github_https_github_com_espoir_x"
8989
android:textColorLink="@color/colorPrimary"/>
9090

9191

0 commit comments

Comments
 (0)