remove direct access to sResources 1

This commit is contained in:
AdrianLxM 2018-05-02 13:32:41 +02:00
parent cfaa26d337
commit 81ad2779bc
4 changed files with 23 additions and 23 deletions

View file

@ -131,9 +131,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
switch (v.getId()) { switch (v.getId()) {
case R.id.profileswitch_remove: case R.id.profileswitch_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(profileSwitch.date)); builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(profileSwitch.date));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
final String _id = profileSwitch._id; final String _id = profileSwitch._id;
if (NSUpload.isIdValid(_id)) { if (NSUpload.isIdValid(_id)) {
@ -144,7 +144,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
MainApp.getDbHelper().delete(profileSwitch); MainApp.getDbHelper().delete(profileSwitch);
} }
}); });
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;
case R.id.profileswitch_date: case R.id.profileswitch_date:

View file

@ -140,9 +140,9 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
switch (v.getId()) { switch (v.getId()) {
case R.id.temptargetrange_remove: case R.id.temptargetrange_remove:
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.gs(R.string.confirmation));
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.date)); builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.date));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
final String _id = tempTarget._id; final String _id = tempTarget._id;
if (NSUpload.isIdValid(_id)) { if (NSUpload.isIdValid(_id)) {
@ -153,7 +153,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
MainApp.getDbHelper().delete(tempTarget); MainApp.getDbHelper().delete(tempTarget);
} }
}); });
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
builder.show(); builder.show();
break; break;
} }

View file

@ -25,7 +25,7 @@ public class LogDialog {
String logCat = "no logs"; String logCat = "no logs";
final String processId = Integer.toString(android.os.Process.myPid()); final String processId = Integer.toString(android.os.Process.myPid());
try { try {
Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.sResources.getString(R.string.app_name) + ":D"); Process process = Runtime.getRuntime().exec("logcat -d " + MainApp.gs(R.string.app_name) + ":D");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder log = new StringBuilder(); StringBuilder log = new StringBuilder();
String line; String line;
@ -46,11 +46,11 @@ public class LogDialog {
try { try {
AlertDialog alertDialog = new AlertDialog.Builder(context) AlertDialog alertDialog = new AlertDialog.Builder(context)
.setMessage(msg) .setMessage(msg)
.setPositiveButton(MainApp.sResources.getString(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() { .setPositiveButton(MainApp.gs(R.string.copy_to_clipboard), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setPrimaryClip(ClipData.newPlainText(null, msg)); clipboard.setPrimaryClip(ClipData.newPlainText(null, msg));
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.copied_to_clipboard)); ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.copied_to_clipboard));
} }
}) })
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)

View file

@ -17,7 +17,7 @@ public class SP {
} }
static public String getString(int resourceID, String defaultValue) { static public String getString(int resourceID, String defaultValue) {
return sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue); return sharedPreferences.getString(MainApp.gs(resourceID), defaultValue);
} }
static public String getString(String key, String defaultValue) { static public String getString(String key, String defaultValue) {
@ -26,7 +26,7 @@ public class SP {
static public boolean getBoolean(int resourceID, Boolean defaultValue) { static public boolean getBoolean(int resourceID, Boolean defaultValue) {
try { try {
return sharedPreferences.getBoolean(MainApp.sResources.getString(resourceID), defaultValue); return sharedPreferences.getBoolean(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) { } catch (Exception e) {
return defaultValue; return defaultValue;
} }
@ -41,7 +41,7 @@ public class SP {
} }
static public Double getDouble(int resourceID, Double defaultValue) { static public Double getDouble(int resourceID, Double defaultValue) {
return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString())); return SafeParse.stringToDouble(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
} }
static public Double getDouble(String key, Double defaultValue) { static public Double getDouble(String key, Double defaultValue) {
@ -50,9 +50,9 @@ public class SP {
static public int getInt(int resourceID, Integer defaultValue) { static public int getInt(int resourceID, Integer defaultValue) {
try { try {
return sharedPreferences.getInt(MainApp.sResources.getString(resourceID), defaultValue); return sharedPreferences.getInt(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) { } catch (Exception e) {
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString())); return SafeParse.stringToInt(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
} }
} }
@ -66,9 +66,9 @@ public class SP {
static public long getLong(int resourceID, Long defaultValue) { static public long getLong(int resourceID, Long defaultValue) {
try { try {
return sharedPreferences.getLong(MainApp.sResources.getString(resourceID), defaultValue); return sharedPreferences.getLong(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) { } catch (Exception e) {
return SafeParse.stringToLong(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString())); return SafeParse.stringToLong(sharedPreferences.getString(MainApp.gs(resourceID), defaultValue.toString()));
} }
} }
@ -88,7 +88,7 @@ public class SP {
static public void putBoolean(int resourceID, boolean value) { static public void putBoolean(int resourceID, boolean value) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(MainApp.sResources.getString(resourceID), value); editor.putBoolean(MainApp.gs(resourceID), value);
editor.apply(); editor.apply();
} }
@ -100,7 +100,7 @@ public class SP {
static public void putLong(int resourceID, long value) { static public void putLong(int resourceID, long value) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putLong(MainApp.sResources.getString(resourceID), value); editor.putLong(MainApp.gs(resourceID), value);
editor.apply(); editor.apply();
} }
@ -112,13 +112,13 @@ public class SP {
static public void putInt(int resourceID, int value) { static public void putInt(int resourceID, int value) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt(MainApp.sResources.getString(resourceID), value); editor.putInt(MainApp.gs(resourceID), value);
editor.apply(); editor.apply();
} }
static public void putString(int resourceID, String value) { static public void putString(int resourceID, String value) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(MainApp.sResources.getString(resourceID), value); editor.putString(MainApp.gs(resourceID), value);
editor.apply(); editor.apply();
} }
@ -130,7 +130,7 @@ public class SP {
static public void remove(int resourceID) { static public void remove(int resourceID) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(MainApp.sResources.getString(resourceID)); editor.remove(MainApp.gs(resourceID));
editor.apply(); editor.apply();
} }