skip config screen at the first widget setup on Simple Phone

This commit is contained in:
tibbi 2022-11-01 23:07:12 +01:00
parent 8b1151fd71
commit 557e84b426
3 changed files with 15 additions and 1 deletions

View File

@ -5,11 +5,13 @@ import android.appwidget.AppWidgetManager
import android.content.Intent import android.content.Intent
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.widget.SeekBar import android.widget.SeekBar
import com.simplemobiletools.clock.R import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.extensions.config import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.helpers.MyDigitalTimeWidgetProvider import com.simplemobiletools.clock.helpers.MyDigitalTimeWidgetProvider
import com.simplemobiletools.clock.helpers.SIMPLE_PHONE
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
@ -31,9 +33,15 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
setContentView(R.layout.widget_config_digital) setContentView(R.layout.widget_config_digital)
initVariables() initVariables()
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
if (!config.wasInitialWidgetSetUp && Build.BRAND.equals(SIMPLE_PHONE, true)) {
saveConfig()
config.wasInitialWidgetSetUp = true
return
}
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !isCustomizingColors) { if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !isCustomizingColors) {
finish() finish()
} }

View File

@ -80,4 +80,8 @@ class Config(context: Context) : BaseConfig(context) {
var stopwatchLapsSort: Int var stopwatchLapsSort: Int
get() = prefs.getInt(STOPWATCH_LAPS_SORT_BY, SORT_BY_LAP or SORT_DESCENDING) get() = prefs.getInt(STOPWATCH_LAPS_SORT_BY, SORT_BY_LAP or SORT_DESCENDING)
set(stopwatchLapsSort) = prefs.edit().putInt(STOPWATCH_LAPS_SORT_BY, stopwatchLapsSort).apply() set(stopwatchLapsSort) = prefs.edit().putInt(STOPWATCH_LAPS_SORT_BY, stopwatchLapsSort).apply()
var wasInitialWidgetSetUp: Boolean
get() = prefs.getBoolean(WAS_INITIAL_WIDGET_SET_UP, false)
set(wasInitialWidgetSetUp) = prefs.edit().putBoolean(WAS_INITIAL_WIDGET_SET_UP, wasInitialWidgetSetUp).apply()
} }

View File

@ -20,6 +20,7 @@ const val TIMER_LAST_CONFIG = "timer_last_config"
const val INCREASE_VOLUME_GRADUALLY = "increase_volume_gradually" const val INCREASE_VOLUME_GRADUALLY = "increase_volume_gradually"
const val ALARMS_SORT_BY = "alarms_sort_by" const val ALARMS_SORT_BY = "alarms_sort_by"
const val STOPWATCH_LAPS_SORT_BY = "stopwatch_laps_sort_by" const val STOPWATCH_LAPS_SORT_BY = "stopwatch_laps_sort_by"
const val WAS_INITIAL_WIDGET_SET_UP = "was_initial_widget_set_up"
const val TABS_COUNT = 4 const val TABS_COUNT = 4
const val EDITED_TIME_ZONE_SEPARATOR = ":" const val EDITED_TIME_ZONE_SEPARATOR = ":"
@ -27,6 +28,7 @@ const val ALARM_ID = "alarm_id"
const val DEFAULT_ALARM_MINUTES = 480 const val DEFAULT_ALARM_MINUTES = 480
const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300 const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300
const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60 const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60
const val SIMPLE_PHONE = "Simple_Phone"
const val PICK_AUDIO_FILE_INTENT_ID = 9994 const val PICK_AUDIO_FILE_INTENT_ID = 9994
const val REMINDER_ACTIVITY_INTENT_ID = 9995 const val REMINDER_ACTIVITY_INTENT_ID = 9995