diff --git a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java index 613499ac..34050373 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java @@ -130,7 +130,7 @@ public class MainActivity extends AppCompatActivity { if (prefs.getBoolean("firstStart", true)) { Intent intent = new Intent(this, UserSettingsActivity.class); - intent.putExtra("mode", UserSettingsActivity.ADD_USER_REQUEST); + intent.putExtra(UserSettingsActivity.EXTRA_MODE, UserSettingsActivity.ADD_USER_REQUEST); startActivity(intent); prefs.edit().putBoolean("firstStart", false).commit(); @@ -252,7 +252,7 @@ public class MainActivity extends AppCompatActivity { break; case R.id.nav_settings: Intent settingsIntent = new Intent(this, SettingsActivity.class); - settingsIntent.putExtra("tintColor", navDrawer.getItemTextColor().getDefaultColor()); + settingsIntent.putExtra(SettingsActivity.EXTRA_TINT_COLOR, navDrawer.getItemTextColor().getDefaultColor()); startActivityForResult(settingsIntent, 1); return; default: diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java index cd1e5ddd..64a1ff12 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java @@ -59,6 +59,8 @@ import java.util.Date; import lecho.lib.hellocharts.util.ChartUtils; public class DataEntryActivity extends Activity { + public static String EXTRA_ID = "id"; + private ArrayList dataEntryMeasurements; private TableLayout tableLayoutDataEntry; @@ -168,8 +170,8 @@ public class DataEntryActivity extends Activity { } int id = 0; - if (getIntent().hasExtra("id")) { - id = getIntent().getExtras().getInt("id"); + if (getIntent().hasExtra(EXTRA_ID)) { + id = getIntent().getExtras().getInt(EXTRA_ID); } if (scaleMeasurement == null || scaleMeasurement.getId() != id) { @@ -289,7 +291,7 @@ public class DataEntryActivity extends Activity { private boolean moveLeft() { if (previousMeasurement != null) { saveScaleData(); - getIntent().putExtra("id", previousMeasurement.getId()); + getIntent().putExtra(EXTRA_ID, previousMeasurement.getId()); updateOnView(); return true; } @@ -300,7 +302,7 @@ public class DataEntryActivity extends Activity { private boolean moveRight() { if (nextMeasurement != null) { saveScaleData(); - getIntent().putExtra("id", nextMeasurement.getId()); + getIntent().putExtra(EXTRA_ID, nextMeasurement.getId()); updateOnView(); return true; } diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/SettingsActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/SettingsActivity.java index 05159197..7b523b89 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/SettingsActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/SettingsActivity.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.List; public class SettingsActivity extends PreferenceActivity { + public static String EXTRA_TINT_COLOR = "tintColor"; private static List fragments = new ArrayList(); @Override @@ -44,7 +45,7 @@ public class SettingsActivity extends PreferenceActivity { public void onBuildHeaders(List
target) { loadHeadersFromResource(R.xml.header_preferences, target); - int tintColor = getIntent().getIntExtra("tintColor", 0); + int tintColor = getIntent().getIntExtra(EXTRA_TINT_COLOR, 0); fragments.clear(); for (Header header : target) { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/UserSettingsActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/UserSettingsActivity.java index 0ead2bc0..7592a53e 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/UserSettingsActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/UserSettingsActivity.java @@ -40,6 +40,8 @@ import java.util.Date; import java.util.List; public class UserSettingsActivity extends Activity { + public static String EXTRA_ID = "id"; + public static String EXTRA_MODE = "mode"; public static final int ADD_USER_REQUEST = 0; public static final int EDIT_USER_REQUEST = 1; @@ -126,11 +128,10 @@ public class UserSettingsActivity extends Activity { }); - if (getIntent().getExtras().getInt("mode") == EDIT_USER_REQUEST) - { + if (getIntent().getExtras().getInt(EXTRA_MODE) == EDIT_USER_REQUEST) { editMode(); - } else - { + } + else { btnOk.setText(getResources().getString(R.string.label_add)); btnDelete.setVisibility(View.GONE); } @@ -138,7 +139,7 @@ public class UserSettingsActivity extends Activity { private void editMode() { - int id = getIntent().getExtras().getInt("id"); + int id = getIntent().getExtras().getInt(EXTRA_ID); OpenScale openScale = OpenScale.getInstance(getApplicationContext()); @@ -240,7 +241,7 @@ public class UserSettingsActivity extends Activity { deleteAllDialog.setPositiveButton(getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { - int userId = getIntent().getExtras().getInt("id"); + int userId = getIntent().getExtras().getInt(EXTRA_ID); OpenScale openScale = OpenScale.getInstance(getApplicationContext()); openScale.clearScaleData(userId); @@ -324,8 +325,8 @@ public class UserSettingsActivity extends Activity { scaleUser.setGoalWeight(goal_weight); scaleUser.setGoalDate(goal_date); - if (getIntent().getExtras().getInt("mode") == EDIT_USER_REQUEST) { - int id = getIntent().getExtras().getInt("id"); + if (getIntent().getExtras().getInt(EXTRA_MODE) == EDIT_USER_REQUEST) { + int id = getIntent().getExtras().getInt(EXTRA_ID); scaleUser.setId(id); openScale.updateScaleUser(scaleUser); } else { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java index c4d7f935..5a6be8ba 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java @@ -608,7 +608,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { int id = scaleMeasurement.getId(); Intent intent = new Intent(graphView.getContext(), DataEntryActivity.class); - intent.putExtra("id", id); + intent.putExtra(DataEntryActivity.EXTRA_ID, id); startActivityForResult(intent, 1); } diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java index e4cf2631..7e368dc0 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/TableFragment.java @@ -270,7 +270,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener { int id = Integer.parseInt(idTextView.getText().toString()); Intent intent = new Intent(tableView.getContext(), DataEntryActivity.class); - intent.putExtra("id", id); + intent.putExtra(DataEntryActivity.EXTRA_ID, id); startActivityForResult(intent, 1); } } diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/UsersPreferences.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/UsersPreferences.java index 1fdfa944..0b37fbdf 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/UsersPreferences.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/UsersPreferences.java @@ -97,8 +97,8 @@ public class UsersPreferences extends PreferenceFragment { @Override public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class); - intent.putExtra("mode", UserSettingsActivity.EDIT_USER_REQUEST); - intent.putExtra("id", Integer.parseInt(preference.getKey())); + intent.putExtra(UserSettingsActivity.EXTRA_MODE, UserSettingsActivity.EDIT_USER_REQUEST); + intent.putExtra(UserSettingsActivity.EXTRA_ID, Integer.parseInt(preference.getKey())); startActivityForResult(intent, UserSettingsActivity.EDIT_USER_REQUEST); return false; @@ -109,7 +109,7 @@ public class UsersPreferences extends PreferenceFragment { @Override public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class); - intent.putExtra("mode", UserSettingsActivity.ADD_USER_REQUEST); + intent.putExtra(UserSettingsActivity.EXTRA_MODE, UserSettingsActivity.ADD_USER_REQUEST); startActivityForResult(intent, UserSettingsActivity.ADD_USER_REQUEST); return false;