mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Enable widget stacks for all users
This commit is contained in:
@@ -54,7 +54,6 @@ open class HabitPickerDialog : Activity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val component = (applicationContext as HabitsApplication).component
|
val component = (applicationContext as HabitsApplication).component
|
||||||
val habitList = component.habitList
|
val habitList = component.habitList
|
||||||
val preferences = component.preferences
|
|
||||||
widgetPreferences = component.widgetPreferences
|
widgetPreferences = component.widgetPreferences
|
||||||
widgetUpdater = component.widgetUpdater
|
widgetUpdater = component.widgetUpdater
|
||||||
widgetId = intent.extras?.getInt(EXTRA_APPWIDGET_ID, INVALID_APPWIDGET_ID) ?: 0
|
widgetId = intent.extras?.getInt(EXTRA_APPWIDGET_ID, INVALID_APPWIDGET_ID) ?: 0
|
||||||
@@ -79,35 +78,21 @@ open class HabitPickerDialog : Activity() {
|
|||||||
val listView = findViewById<ListView>(R.id.listView)
|
val listView = findViewById<ListView>(R.id.listView)
|
||||||
val saveButton = findViewById<Button>(R.id.buttonSave)
|
val saveButton = findViewById<Button>(R.id.buttonSave)
|
||||||
|
|
||||||
if(preferences.isWidgetStackEnabled) {
|
with(listView) {
|
||||||
with(listView) {
|
adapter = ArrayAdapter(context,
|
||||||
adapter = ArrayAdapter(context,
|
android.R.layout.simple_list_item_multiple_choice,
|
||||||
android.R.layout.simple_list_item_multiple_choice,
|
habitNames)
|
||||||
habitNames)
|
choiceMode = CHOICE_MODE_MULTIPLE
|
||||||
choiceMode = CHOICE_MODE_MULTIPLE
|
itemsCanFocus = false
|
||||||
itemsCanFocus = false
|
}
|
||||||
}
|
saveButton.setOnClickListener {
|
||||||
saveButton.setOnClickListener {
|
val selectedIds = mutableListOf<Long>()
|
||||||
val selectedIds = mutableListOf<Long>()
|
for (i in 0..listView.count) {
|
||||||
for (i in 0..listView.count) {
|
if (listView.isItemChecked(i)) {
|
||||||
if (listView.isItemChecked(i)) {
|
selectedIds.add(habitIds[i])
|
||||||
selectedIds.add(habitIds[i])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
confirm(selectedIds)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
saveButton.visibility = GONE
|
|
||||||
with(listView) {
|
|
||||||
adapter = ArrayAdapter(context,
|
|
||||||
android.R.layout.simple_list_item_1,
|
|
||||||
habitNames)
|
|
||||||
choiceMode = CHOICE_MODE_SINGLE
|
|
||||||
itemsCanFocus = false
|
|
||||||
}
|
|
||||||
listView.setOnItemClickListener { _, _, position, _ ->
|
|
||||||
confirm(listOf(habitIds[position]))
|
|
||||||
}
|
}
|
||||||
|
confirm(selectedIds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,12 +222,6 @@
|
|||||||
android:title="Enable developer mode"
|
android:title="Enable developer mode"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="pref_feature_widget_stack"
|
|
||||||
android:title="Enable widget stacks"
|
|
||||||
app:iconSpaceReserved="false" />
|
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="@string/syncBaseURL"
|
android:defaultValue="@string/syncBaseURL"
|
||||||
android:key="pref_sync_base_url"
|
android:key="pref_sync_base_url"
|
||||||
|
|||||||
@@ -226,11 +226,6 @@ public class Preferences
|
|||||||
storage.putBoolean("pref_short_toggle", enabled);
|
storage.putBoolean("pref_short_toggle", enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWidgetStackEnabled()
|
|
||||||
{
|
|
||||||
return storage.getBoolean("pref_feature_widget_stack", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeListener(Listener listener)
|
public void removeListener(Listener listener)
|
||||||
{
|
{
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
|
|||||||
Reference in New Issue
Block a user