|
@@ -154,18 +154,8 @@ public class ApexDriverApplication extends Application {
|
|
|
this.password = password;
|
|
this.password = password;
|
|
|
|
|
|
|
|
|
|
|
|
|
- SharedPreferences pref=null;
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
|
- {
|
|
|
|
|
- Context c= this.createDeviceProtectedStorageContext();
|
|
|
|
|
- pref = c.getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- pref = getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ SharedPreferences pref = sharedPreferences();
|
|
|
|
|
|
|
|
-// SharedPreferences pref = ApexDriverApplication.sharedApplication().getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
@@ -182,7 +172,7 @@ public class ApexDriverApplication extends Application {
|
|
|
|
|
|
|
|
public void updatePassword(String password) {
|
|
public void updatePassword(String password) {
|
|
|
this.password = password;
|
|
this.password = password;
|
|
|
- SharedPreferences pref = ApexDriverApplication.sharedApplication().getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
|
|
+ SharedPreferences pref = sharedPreferences();
|
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
@@ -198,18 +188,8 @@ public class ApexDriverApplication extends Application {
|
|
|
public String savedUser() {
|
|
public String savedUser() {
|
|
|
|
|
|
|
|
|
|
|
|
|
- SharedPreferences pref=null;
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
|
- {
|
|
|
|
|
- Context c= this.createDeviceProtectedStorageContext();
|
|
|
|
|
- pref = c.getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- pref = getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ SharedPreferences pref=sharedPreferences();
|
|
|
|
|
|
|
|
-// SharedPreferences
|
|
|
|
|
String user = pref.getString("user", null);
|
|
String user = pref.getString("user", null);
|
|
|
if (user != null) {
|
|
if (user != null) {
|
|
|
user = decryptString(user);
|
|
user = decryptString(user);
|
|
@@ -220,17 +200,8 @@ public class ApexDriverApplication extends Application {
|
|
|
public String savedPassword() {
|
|
public String savedPassword() {
|
|
|
|
|
|
|
|
|
|
|
|
|
- SharedPreferences pref=null;
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
|
- {
|
|
|
|
|
- Context c= this.createDeviceProtectedStorageContext();
|
|
|
|
|
- pref = c.getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- pref = getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
- }
|
|
|
|
|
-// SharedPreferences pref = getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
|
|
+ SharedPreferences pref=sharedPreferences();
|
|
|
|
|
+
|
|
|
String p = pref.getString("password", null);
|
|
String p = pref.getString("password", null);
|
|
|
if (p != null) {
|
|
if (p != null) {
|
|
|
p = decryptString(p);
|
|
p = decryptString(p);
|
|
@@ -266,9 +237,8 @@ public class ApexDriverApplication extends Application {
|
|
|
return AESUtil.decrypt256(secretKey, string);
|
|
return AESUtil.decrypt256(secretKey, string);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void logout() {
|
|
|
|
|
- user = null;
|
|
|
|
|
- password = null;
|
|
|
|
|
|
|
+ private SharedPreferences sharedPreferences() {
|
|
|
|
|
+
|
|
|
SharedPreferences pref=null;
|
|
SharedPreferences pref=null;
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
{
|
|
{
|
|
@@ -279,7 +249,14 @@ public class ApexDriverApplication extends Application {
|
|
|
{
|
|
{
|
|
|
pref = getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
pref = getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
}
|
|
}
|
|
|
-// SharedPreferences pref = ApexDriverApplication.sharedApplication().getSharedPreferences(ApexDriverApplication.preferencesKey, 0);
|
|
|
|
|
|
|
+ return pref;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void logout() {
|
|
|
|
|
+ user = null;
|
|
|
|
|
+ password = null;
|
|
|
|
|
+ SharedPreferences pref = sharedPreferences();
|
|
|
|
|
+
|
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
|
editor.remove("user");
|
|
editor.remove("user");
|
|
|
editor.remove("password");
|
|
editor.remove("password");
|