diff options
author | Vishnu Sanal T <50027064+VishnuSanal@users.noreply.github.com> | 2022-10-29 20:56:14 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-29 17:26:14 +0200 |
commit | c171ab6823150d8cba1fe836269881ff5ec9cf2a (patch) | |
tree | e261c57bffe0809cfaf0ccdf6e21a30360e63141 /app | |
parent | fe2195f051e5b9a17281f4a42c54ad803fe6c9ef (diff) | |
download | AntennaPod-c171ab6823150d8cba1fe836269881ff5ec9cf2a.zip |
Remove 'seconds' and 'hours' options from sleep timer (#6148)
Diffstat (limited to 'app')
3 files changed, 13 insertions, 17 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java index 5a4adf6a4..52e6f7807 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java @@ -6,12 +6,10 @@ import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.inputmethod.InputMethodManager; -import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.LinearLayout; -import android.widget.Spinner; import android.widget.TextView; import androidx.annotation.NonNull; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -30,7 +28,6 @@ import org.greenrobot.eventbus.ThreadMode; public class SleepTimerDialog extends DialogFragment { private PlaybackController controller; private EditText etxtTime; - private Spinner spTimeUnit; private LinearLayout timeSetup; private LinearLayout timeDisplay; private TextView time; @@ -70,7 +67,6 @@ public class SleepTimerDialog extends DialogFragment { builder.setPositiveButton(R.string.close_label, null); etxtTime = content.findViewById(R.id.etxtTime); - spTimeUnit = content.findViewById(R.id.spTimeUnit); timeSetup = content.findViewById(R.id.timeSetup); timeDisplay = content.findViewById(R.id.timeDisplay); timeDisplay.setVisibility(View.GONE); @@ -103,16 +99,6 @@ public class SleepTimerDialog extends DialogFragment { imm.showSoftInput(etxtTime, InputMethodManager.SHOW_IMPLICIT); }, 100); - String[] spinnerContent = new String[] { - getString(R.string.time_seconds), - getString(R.string.time_minutes), - getString(R.string.time_hours) }; - ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), - android.R.layout.simple_spinner_item, spinnerContent); - spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - spTimeUnit.setAdapter(spinnerAdapter); - spTimeUnit.setSelection(SleepTimerPreferences.lastTimerTimeUnit()); - CheckBox cbShakeToReset = content.findViewById(R.id.cbShakeToReset); CheckBox cbVibrate = content.findViewById(R.id.cbVibrate); CheckBox chAutoEnable = content.findViewById(R.id.chAutoEnable); @@ -145,7 +131,7 @@ public class SleepTimerDialog extends DialogFragment { if (time == 0) { throw new NumberFormatException("Timer must not be zero"); } - SleepTimerPreferences.setLastTimer(etxtTime.getText().toString(), spTimeUnit.getSelectedItemPosition()); + SleepTimerPreferences.setLastTimer(etxtTime.getText().toString()); if (controller != null) { controller.setSleepTimer(SleepTimerPreferences.timerMillis()); } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java index d2796b5e2..3abd14bac 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java @@ -5,7 +5,10 @@ import android.content.SharedPreferences; import android.view.KeyEvent; import androidx.preference.PreferenceManager; +import java.util.concurrent.TimeUnit; + import de.danoeh.antennapod.BuildConfig; +import de.danoeh.antennapod.core.preferences.SleepTimerPreferences; import de.danoeh.antennapod.error.CrashReportWriter; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -116,6 +119,13 @@ public class PreferenceUpgrader { if (feedCounterSetting.equals("0")) { prefs.edit().putString(UserPreferences.PREF_DRAWER_FEED_COUNTER, "2").apply(); } + + SharedPreferences sleepTimerPreferences = + context.getSharedPreferences(SleepTimerPreferences.PREF_NAME, Context.MODE_PRIVATE); + TimeUnit[] timeUnits = { TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS }; + long value = Long.parseLong(SleepTimerPreferences.lastTimerValue()); + TimeUnit unit = timeUnits[sleepTimerPreferences.getInt("LastTimeUnit", 1)]; + SleepTimerPreferences.setLastTimer(String.valueOf(unit.toMinutes(value))); } } } diff --git a/app/src/main/res/layout/time_dialog.xml b/app/src/main/res/layout/time_dialog.xml index a61fdea4b..50001bf9c 100644 --- a/app/src/main/res/layout/time_dialog.xml +++ b/app/src/main/res/layout/time_dialog.xml @@ -30,10 +30,10 @@ android:inputType="number" android:maxLength="3" /> - <Spinner - android:id="@+id/spTimeUnit" + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="@string/time_minutes" android:layout_marginBottom="8dp" android:layout_marginTop="8dp" /> |