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

Commit c72cbec

Browse files
committed
setting ui updates
1 parent 61a609b commit c72cbec

File tree

5 files changed

+161
-163
lines changed

5 files changed

+161
-163
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 6
10-
versionName "1.0.6"
9+
versionCode 7
10+
versionName "1.0.7"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {

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

Lines changed: 70 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import android.content.Intent;
77
import android.content.IntentFilter;
88
import android.os.Bundle;
9-
import android.provider.Settings;
109
import android.support.annotation.NonNull;
1110
import android.view.View;
1211
import android.widget.CheckBox;
1312
import android.widget.CompoundButton;
1413
import android.widget.RelativeLayout;
1514
import android.widget.TextView;
15+
import android.widget.Toast;
1616

1717
import com.lzx.lock.R;
1818
import com.lzx.lock.activities.about.AboutMeActivity;
@@ -21,7 +21,6 @@
2121
import com.lzx.lock.base.BaseActivity;
2222
import com.lzx.lock.model.LockAutoTime;
2323
import com.lzx.lock.services.BackgroundManager;
24-
import com.lzx.lock.services.LockAccessibilityService;
2524
import com.lzx.lock.services.LockService;
2625
import com.lzx.lock.utils.SpUtil;
2726
import com.lzx.lock.utils.SystemBarHelper;
@@ -34,16 +33,21 @@
3433
*/
3534

3635
public class LockSettingActivity extends BaseActivity implements View.OnClickListener
37-
, DialogInterface.OnDismissListener {
36+
, DialogInterface.OnDismissListener, CompoundButton.OnCheckedChangeListener {
3837

3938
public static final String ON_ITEM_CLICK_ACTION = "on_item_click_action";
4039
private static final int REQUEST_CHANGE_PWD = 3;
41-
private TextView mBtnAbout,
42-
mLockTime,
43-
//mLockTypeSwitch,
44-
mBtnChangePwd, mIsShowPath, mLockTip, mLockScreenSwitch, mLockTakePicSwitch;
45-
private CheckBox mLockSwitch;
46-
private RelativeLayout mLockWhen, mLockScreen, mLockTakePic;// mLockType,
40+
41+
private CheckBox cbLockSwitch;
42+
private CheckBox cbLockScreen;
43+
private CheckBox cbIntruderSelfie;
44+
private CheckBox cbHidePattern;
45+
private CheckBox cbVibration;
46+
47+
private TextView tvAbout,
48+
tvLockTime,
49+
tvChangePwd;
50+
4751
private LockSettingReceiver mLockSettingReceiver;
4852
private SelectLockTimeDialog dialog;
4953
private RelativeLayout mTopLayout;
@@ -55,19 +59,17 @@ public int getLayoutId() {
5559

5660
@Override
5761
protected void initViews(Bundle savedInstanceState) {
58-
mBtnChangePwd = findViewById(R.id.btn_change_pwd);
59-
mLockTime = findViewById(R.id.lock_time);
60-
mBtnAbout = findViewById(R.id.about_me);
61-
mLockSwitch = findViewById(R.id.switch_compat);
62-
mLockWhen = findViewById(R.id.lock_when);
63-
// mLockType = findViewById(R.id.lock_type);
64-
//mLockTypeSwitch = findViewById(R.id.lock_type_switch);
65-
mLockScreen = findViewById(R.id.lock_screen);
66-
mLockTakePic = findViewById(R.id.lock_take_pic);
67-
mIsShowPath = findViewById(R.id.is_show_path);
68-
mLockTip = findViewById(R.id.lock_tip);
69-
mLockScreenSwitch = findViewById(R.id.lock_screen_switch);
70-
mLockTakePicSwitch = findViewById(R.id.lock_take_pic_switch);
62+
cbLockSwitch=findViewById(R.id.checkbox_app_lock_on_off);
63+
cbLockScreen=findViewById(R.id.checkbox_lock_screen_switch_on_phone_lock);
64+
cbIntruderSelfie=findViewById(R.id.checkbox_intruder_selfie);
65+
cbHidePattern=findViewById(R.id.checkbox_show_hide_pattern);
66+
cbVibration=findViewById(R.id.checkbox_vibrate);
67+
68+
tvChangePwd = findViewById(R.id.btn_change_pwd);
69+
tvLockTime = findViewById(R.id.lock_time);
70+
tvAbout = findViewById(R.id.about_me);
71+
72+
//
7173
mTopLayout = findViewById(R.id.top_layout);
7274
mTopLayout.setPadding(0, SystemBarHelper.getStatusBarHeight(this), 0, 0);
7375
}
@@ -81,51 +83,29 @@ protected void initData() {
8183
dialog = new SelectLockTimeDialog(this, "");
8284
dialog.setOnDismissListener(this);
8385
boolean isLockOpen = SpUtil.getInstance().getBoolean(AppConstants.LOCK_STATE);
84-
mLockSwitch.setChecked(isLockOpen);
86+
cbLockSwitch.setChecked(isLockOpen);
8587

8688
boolean isLockAutoScreen = SpUtil.getInstance().getBoolean(AppConstants.LOCK_AUTO_SCREEN, false);
87-
mLockScreenSwitch.setText(isLockAutoScreen ? "on" : "off");
88-
89-
// boolean isLockAccessibilityOn = SpUtil.getInstance().getBoolean(AppConstants.LOCK_TYPE, false);
90-
// mLockTypeSwitch.setText(isLockAccessibilityOn ? "Accessibility" : "Usages Stats");
89+
cbLockScreen.setChecked(isLockAutoScreen);
9190

9291
boolean isTakePic = SpUtil.getInstance().getBoolean(AppConstants.LOCK_AUTO_RECORD_PIC, false);
93-
mLockTakePicSwitch.setText(isTakePic ? "on" : "off");
94-
95-
mLockTime.setText(SpUtil.getInstance().getString(AppConstants.LOCK_APART_TITLE, "immediately"));
92+
cbIntruderSelfie.setChecked(isTakePic);
93+
tvLockTime.setText(SpUtil.getInstance().getString(AppConstants.LOCK_APART_TITLE, "immediately"));
9694
}
9795

9896
@Override
9997
protected void initAction() {
100-
mBtnChangePwd.setOnClickListener(this);
101-
mBtnAbout.setOnClickListener(this);
102-
mLockWhen.setOnClickListener(this);
103-
// mLockType.setOnClickListener(this);
104-
mLockScreen.setOnClickListener(this);
105-
mIsShowPath.setOnClickListener(this);
106-
mLockScreenSwitch.setOnClickListener(this);
107-
// mLockTypeSwitch.setOnClickListener(this);
108-
mLockTakePic.setOnClickListener(this);
109-
mLockSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
110-
@Override
111-
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
112-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_STATE, b);
113-
//Intent intent = new Intent(LockSettingActivity.this, LockService.class);
114-
if (b) {
115-
mLockTip.setText(R.string.pattern_is_required);
116-
//restart service
117-
BackgroundManager.getInstance().init(LockSettingActivity.this).stopService(LockService.class);
118-
BackgroundManager.getInstance().init(LockSettingActivity.this).startService(LockService.class);
11998

120-
BackgroundManager.getInstance().init(LockSettingActivity.this).startAlarmManager();
99+
cbLockSwitch.setOnCheckedChangeListener(this);
100+
cbLockScreen.setOnCheckedChangeListener(this);
101+
cbIntruderSelfie.setOnCheckedChangeListener(this);
102+
cbHidePattern.setOnCheckedChangeListener(this);
103+
cbVibration.setOnCheckedChangeListener(this);
104+
105+
tvLockTime.setOnClickListener(this);
106+
tvChangePwd.setOnClickListener(this);
107+
tvAbout.setOnClickListener(this);
121108

122-
} else {
123-
mLockTip.setText(R.string.pattern_is_not_required);
124-
BackgroundManager.getInstance().init(LockSettingActivity.this).stopService(LockService.class);
125-
BackgroundManager.getInstance().init(LockSettingActivity.this).stopAlarmManager();
126-
}
127-
}
128-
});
129109
}
130110

131111
@Override
@@ -145,57 +125,43 @@ public void onClick(@NonNull View view) {
145125
dialog.setTitle(title);
146126
dialog.show();
147127
break;
148-
case R.id.is_show_path:
149-
boolean ishideline = SpUtil.getInstance().getBoolean(AppConstants.LOCK_IS_HIDE_LINE, false);
150-
if (ishideline) {
151-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_IS_HIDE_LINE, false);
152-
mIsShowPath.setText(R.string.hide_pattern);
153-
ToastUtil.showToast("Pattern is displayed");
128+
}
129+
}
130+
131+
132+
@Override
133+
public void onCheckedChanged(CompoundButton buttonView, boolean b) {
134+
switch (buttonView.getId()) {
135+
case R.id.checkbox_app_lock_on_off:
136+
SpUtil.getInstance().putBoolean(AppConstants.LOCK_STATE, b);
137+
if (b) {
138+
BackgroundManager.getInstance().init(LockSettingActivity.this).stopService(LockService.class);
139+
BackgroundManager.getInstance().init(LockSettingActivity.this).startService(LockService.class);
140+
141+
BackgroundManager.getInstance().init(LockSettingActivity.this).startAlarmManager();
142+
154143
} else {
155-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_IS_HIDE_LINE, true);
156-
mIsShowPath.setText(R.string.show_pattern);
157-
ToastUtil.showToast("Pattern is hidden");
144+
BackgroundManager.getInstance().init(LockSettingActivity.this).stopService(LockService.class);
145+
BackgroundManager.getInstance().init(LockSettingActivity.this).stopAlarmManager();
158146
}
159147
break;
160-
case R.id.lock_screen:
161-
boolean isLockAutoScreen = SpUtil.getInstance().getBoolean(AppConstants.LOCK_AUTO_SCREEN, false);
162-
if (isLockAutoScreen) {
163-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_SCREEN, false);
164-
mLockScreenSwitch.setText("off");
165-
} else {
166-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_SCREEN, true);
167-
mLockScreenSwitch.setText("on");
168-
}
148+
case R.id.checkbox_lock_screen_switch_on_phone_lock:
149+
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_SCREEN, b);
169150
break;
170-
/*case R.id.lock_type:
171-
boolean isLockTypeAccessibility = SpUtil.getInstance().getBoolean(AppConstants.LOCK_TYPE, false);
172-
if (!isLockTypeAccessibility) {
173-
if (!LockAccessibilityService.isAccessibilitySettingsOn(getApplicationContext())) {
174-
Intent intentForAccessbility = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
175-
intentForAccessbility.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
176-
getApplicationContext().startActivity(intentForAccessbility);
177-
}else {
178-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_TYPE,true);
179-
180-
mLockTypeSwitch.setText("Accessibility");
181-
}
182-
} else {
183-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_TYPE, false);
184-
185-
mLockTypeSwitch.setText("Usage state");
186-
}
187-
break;*/
188-
case R.id.lock_take_pic:
189-
boolean isTakePic = SpUtil.getInstance().getBoolean(AppConstants.LOCK_AUTO_RECORD_PIC, false);
190-
if (isTakePic) {
191-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_RECORD_PIC, false);
192-
mLockTakePicSwitch.setText("off");
193-
} else {
194-
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_RECORD_PIC, true);
195-
mLockTakePicSwitch.setText("on");
196-
}
151+
case R.id.checkbox_intruder_selfie:
152+
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_RECORD_PIC, b);
153+
Toast.makeText(LockSettingActivity.this, "Not implemented yet", Toast.LENGTH_SHORT).show();
154+
break;
155+
case R.id.checkbox_show_hide_pattern:
156+
SpUtil.getInstance().putBoolean(AppConstants.LOCK_IS_HIDE_LINE, b);
157+
break;
158+
case R.id.checkbox_vibrate:
159+
SpUtil.getInstance().putBoolean(AppConstants.PATTERN_VIBRATION,b);
160+
Toast.makeText(LockSettingActivity.this, "Not implemented yet", Toast.LENGTH_SHORT).show();
197161
break;
162+
198163
}
164+
199165
}
200166

201167
@Override
@@ -231,12 +197,12 @@ public void onReceive(Context context, @NonNull Intent intent) {
231197
LockAutoTime info = intent.getParcelableExtra("info");
232198
boolean isLast = intent.getBooleanExtra("isLast", true);
233199
if (isLast) {
234-
mLockTime.setText(info.getTitle());
200+
tvLockTime.setText(info.getTitle());
235201
SpUtil.getInstance().putString(AppConstants.LOCK_APART_TITLE, info.getTitle());
236202
SpUtil.getInstance().putLong(AppConstants.LOCK_APART_MILLISECONDS, 0L);
237203
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_SCREEN_TIME, false);
238204
} else {
239-
mLockTime.setText(info.getTitle());
205+
tvLockTime.setText(info.getTitle());
240206
SpUtil.getInstance().putString(AppConstants.LOCK_APART_TITLE, info.getTitle());
241207
SpUtil.getInstance().putLong(AppConstants.LOCK_APART_MILLISECONDS, info.getTime());
242208
SpUtil.getInstance().putBoolean(AppConstants.LOCK_AUTO_SCREEN_TIME, true);

app/src/main/java/com/lzx/lock/base/AppConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ public class AppConstants {
3434
public static final String LOCK_APART_TITLE = "lock_apart_title";//string
3535
public static final String LOCK_LAST_LOAD_PKG_NAME = "last_load_package_name";//string
3636
public static final String LOCK_AUTO_RECORD_PIC = "AutoRecordPic";//boolean
37+
public static final String PATTERN_VIBRATION="pattern_vibration";
3738
// public static final String LOCK_TYPE = "lock_type";//boolean ACCESSIBILITY OR USAGES STATE
3839
}

0 commit comments

Comments
 (0)