-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from FazziCLAY/feature/pin-code
Feature/pin code
- Loading branch information
Showing
43 changed files
with
1,147 additions
and
487 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OwO |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/fazziclay/opentoday/app/ActivitySettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.fazziclay.opentoday.app; | ||
|
||
public class ActivitySettings { | ||
private boolean clockVisible = true; | ||
private boolean notificationsVisible = true; | ||
|
||
|
||
public ActivitySettings setClockVisible(boolean clockVisible) { | ||
this.clockVisible = clockVisible; | ||
return this; | ||
} | ||
|
||
public ActivitySettings invertClockVisible() { | ||
this.clockVisible = !this.clockVisible; | ||
return this; | ||
} | ||
|
||
public ActivitySettings setNotificationsVisible(boolean notificationsVisible) { | ||
this.notificationsVisible = notificationsVisible; | ||
return this; | ||
} | ||
|
||
public ActivitySettings invertNotificationsVisible() { | ||
this.notificationsVisible = !this.notificationsVisible; | ||
return this; | ||
} | ||
|
||
public boolean isClockVisible() { | ||
return clockVisible; | ||
} | ||
|
||
public boolean isNotificationsVisible() { | ||
return notificationsVisible; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/fazziclay/opentoday/app/pincode/PinCodeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.fazziclay.opentoday.app.pincode; | ||
|
||
import static android.content.Context.MODE_PRIVATE; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import com.fazziclay.javaneoutil.FileUtil; | ||
import com.fazziclay.opentoday.app.App; | ||
|
||
import java.io.File; | ||
|
||
public class PinCodeManager { | ||
private final SharedPreferences sharedPreferences; | ||
private final File backupFile; | ||
|
||
|
||
public PinCodeManager(Context context) { | ||
this.sharedPreferences = context.getSharedPreferences(App.SHARED_NAME, MODE_PRIVATE); | ||
this.backupFile = new File(context.getExternalFilesDir(""), "pcb"); | ||
} | ||
|
||
public boolean isPinCodeSet() { | ||
return sharedPreferences.contains(App.SHARED_KEY_PINCODE); | ||
} | ||
|
||
public String getPinCode() { | ||
return sharedPreferences.getString(App.SHARED_KEY_PINCODE, "0000"); | ||
} | ||
|
||
public void disablePinCode() { | ||
sharedPreferences.edit().remove(App.SHARED_KEY_PINCODE).apply(); | ||
if (FileUtil.isExist(backupFile)) { | ||
FileUtil.delete(backupFile); | ||
} | ||
} | ||
|
||
public void enablePinCode(String pin) { | ||
if (pin.isEmpty()) { | ||
throw new ContainNonDigitChars(); | ||
} | ||
for (char c : pin.toCharArray()) { | ||
if (!Character.isDigit(c)) { | ||
throw new ContainNonDigitChars(); | ||
} | ||
} | ||
sharedPreferences.edit().putString(App.SHARED_KEY_PINCODE, pin).apply(); | ||
FileUtil.setText(backupFile, pin); | ||
} | ||
|
||
public static class ContainNonDigitChars extends RuntimeException { | ||
public ContainNonDigitChars() { | ||
super("Contains non-digit chars in pin-code!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.