Skip to content

Commit

Permalink
issue j4velin#158
Browse files Browse the repository at this point in the history
issue j4velin#158 Implemented so that the meta field is an editText with a number value.
  • Loading branch information
saraiva1989 committed Oct 27, 2021
1 parent e4b07bd commit 3ba48c0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/de/j4velin/pedometer/ui/Fragment_Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -157,18 +158,17 @@ public boolean onPreferenceClick(final Preference preference) {
switch (preference.getTitleRes()) {
case R.string.goal:
builder = new AlertDialog.Builder(getActivity());
final NumberPicker np = new NumberPicker(getActivity());
np.setMinValue(1);
np.setMaxValue(100000);
np.setValue(prefs.getInt("goal", 10000));
builder.setView(np);
final EditText ed = new EditText(getActivity());
ed.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER);
ed.setText(String.valueOf(prefs.getInt("goal", 10000)));
builder.setView(ed);
builder.setTitle(R.string.set_goal);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
np.clearFocus();
prefs.edit().putInt("goal", np.getValue()).commit();
preference.setSummary(getString(R.string.goal_summary, np.getValue()));
ed.clearFocus();
prefs.edit().putInt("goal", Integer.parseInt(ed.getText().toString())).commit();
preference.setSummary(getString(R.string.goal_summary, Integer.parseInt(ed.getText().toString())));
dialog.dismiss();
getActivity().startService(new Intent(getActivity(), SensorListener.class)
.putExtra("updateNotificationState", true));
Expand Down

0 comments on commit 3ba48c0

Please sign in to comment.