Polishing
This commit is contained in:
parent
8f1167b54d
commit
3ec1208edd
8 changed files with 58 additions and 70 deletions
|
@ -293,19 +293,6 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUnifiedPushBaseUrl(baseUrl: String) {
|
|
||||||
if (baseUrl == "") {
|
|
||||||
sharedPrefs
|
|
||||||
.edit()
|
|
||||||
.remove(SHARED_PREFS_UNIFIED_PUSH_BASE_URL)
|
|
||||||
.apply()
|
|
||||||
} else {
|
|
||||||
sharedPrefs.edit()
|
|
||||||
.putString(SHARED_PREFS_UNIFIED_PUSH_BASE_URL, baseUrl)
|
|
||||||
.apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDefaultBaseUrl(): String? {
|
fun getDefaultBaseUrl(): String? {
|
||||||
return sharedPrefs.getString(SHARED_PREFS_DEFAULT_BASE_URL, null) ?:
|
return sharedPrefs.getString(SHARED_PREFS_DEFAULT_BASE_URL, null) ?:
|
||||||
sharedPrefs.getString(SHARED_PREFS_UNIFIED_PUSH_BASE_URL, null) // Fall back to UP URL, removed when default is set!
|
sharedPrefs.getString(SHARED_PREFS_UNIFIED_PUSH_BASE_URL, null) // Fall back to UP URL, removed when default is set!
|
||||||
|
@ -439,8 +426,7 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas
|
||||||
const val SHARED_PREFS_BROADCAST_ENABLED = "BroadcastEnabled"
|
const val SHARED_PREFS_BROADCAST_ENABLED = "BroadcastEnabled"
|
||||||
const val SHARED_PREFS_RECORD_LOGS_ENABLED = "RecordLogs"
|
const val SHARED_PREFS_RECORD_LOGS_ENABLED = "RecordLogs"
|
||||||
const val SHARED_PREFS_BATTERY_OPTIMIZATIONS_REMIND_TIME = "BatteryOptimizationsRemindTime"
|
const val SHARED_PREFS_BATTERY_OPTIMIZATIONS_REMIND_TIME = "BatteryOptimizationsRemindTime"
|
||||||
const val SHARED_PREFS_UNIFIED_PUSH_ENABLED = "UnifiedPushEnabled"
|
const val SHARED_PREFS_UNIFIED_PUSH_BASE_URL = "UnifiedPushBaseURL" // Legacy key required for migration to DefaultBaseURL
|
||||||
const val SHARED_PREFS_UNIFIED_PUSH_BASE_URL = "UnifiedPushBaseURL"
|
|
||||||
const val SHARED_PREFS_DEFAULT_BASE_URL = "DefaultBaseURL"
|
const val SHARED_PREFS_DEFAULT_BASE_URL = "DefaultBaseURL"
|
||||||
const val SHARED_PREFS_LAST_TOPICS = "LastTopics"
|
const val SHARED_PREFS_LAST_TOPICS = "LastTopics"
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,9 @@ class AddFragment : DialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validateInputLoginView() {
|
private fun validateInputLoginView() {
|
||||||
if (!this::positiveButton.isInitialized) return // As per crash seen in Google Play
|
if (!this::positiveButton.isInitialized || !this::loginUsernameText.isInitialized || !this::loginPasswordText.isInitialized) {
|
||||||
|
return // As per crash seen in Google Play
|
||||||
|
}
|
||||||
if (loginUsernameText.visibility == View.GONE) {
|
if (loginUsernameText.visibility == View.GONE) {
|
||||||
positiveButton.isEnabled = true
|
positiveButton.isEnabled = true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -260,7 +260,7 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dark mode
|
// Dark mode
|
||||||
val darkModePrefId = context?.getString(R.string.settings_appearance_dark_mode_key) ?: return
|
val darkModePrefId = context?.getString(R.string.settings_general_dark_mode_key) ?: return
|
||||||
val darkMode: ListPreference? = findPreference(darkModePrefId)
|
val darkMode: ListPreference? = findPreference(darkModePrefId)
|
||||||
darkMode?.value = repository.getDarkMode().toString()
|
darkMode?.value = repository.getDarkMode().toString()
|
||||||
darkMode?.preferenceDataStore = object : PreferenceDataStore() {
|
darkMode?.preferenceDataStore = object : PreferenceDataStore() {
|
||||||
|
@ -277,15 +277,15 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||||
darkMode?.summaryProvider = Preference.SummaryProvider<ListPreference> { pref ->
|
darkMode?.summaryProvider = Preference.SummaryProvider<ListPreference> { pref ->
|
||||||
val darkModeValue = pref.value.toIntOrNull() ?: repository.getDarkMode()
|
val darkModeValue = pref.value.toIntOrNull() ?: repository.getDarkMode()
|
||||||
when (darkModeValue) {
|
when (darkModeValue) {
|
||||||
AppCompatDelegate.MODE_NIGHT_NO -> getString(R.string.settings_appearance_dark_mode_summary_light)
|
AppCompatDelegate.MODE_NIGHT_NO -> getString(R.string.settings_general_dark_mode_summary_light)
|
||||||
AppCompatDelegate.MODE_NIGHT_YES -> getString(R.string.settings_appearance_dark_mode_summary_dark)
|
AppCompatDelegate.MODE_NIGHT_YES -> getString(R.string.settings_general_dark_mode_summary_dark)
|
||||||
else -> getString(R.string.settings_appearance_dark_mode_summary_system)
|
else -> getString(R.string.settings_general_dark_mode_summary_system)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default Base URL
|
// Default Base URL
|
||||||
val appBaseUrl = getString(R.string.app_base_url)
|
val appBaseUrl = getString(R.string.app_base_url)
|
||||||
val defaultBaseUrlPrefId = context?.getString(R.string.settings_advanced_default_base_url_key) ?: return
|
val defaultBaseUrlPrefId = context?.getString(R.string.settings_general_default_base_url_key) ?: return
|
||||||
val defaultBaseUrl: EditTextPreference? = findPreference(defaultBaseUrlPrefId)
|
val defaultBaseUrl: EditTextPreference? = findPreference(defaultBaseUrlPrefId)
|
||||||
defaultBaseUrl?.text = repository.getDefaultBaseUrl() ?: ""
|
defaultBaseUrl?.text = repository.getDefaultBaseUrl() ?: ""
|
||||||
defaultBaseUrl?.preferenceDataStore = object : PreferenceDataStore() {
|
defaultBaseUrl?.preferenceDataStore = object : PreferenceDataStore() {
|
||||||
|
@ -299,7 +299,7 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||||
}
|
}
|
||||||
defaultBaseUrl?.summaryProvider = Preference.SummaryProvider<EditTextPreference> { pref ->
|
defaultBaseUrl?.summaryProvider = Preference.SummaryProvider<EditTextPreference> { pref ->
|
||||||
if (TextUtils.isEmpty(pref.text)) {
|
if (TextUtils.isEmpty(pref.text)) {
|
||||||
getString(R.string.settings_advanced_default_base_url_default_summary, appBaseUrl)
|
getString(R.string.settings_general_default_base_url_default_summary, appBaseUrl)
|
||||||
} else {
|
} else {
|
||||||
pref.text
|
pref.text
|
||||||
}
|
}
|
||||||
|
@ -586,11 +586,11 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||||
val preference = Preference(preferenceScreen.context)
|
val preference = Preference(preferenceScreen.context)
|
||||||
preference.title = user.user.username
|
preference.title = user.user.username
|
||||||
preference.summary = if (user.topics.isEmpty()) {
|
preference.summary = if (user.topics.isEmpty()) {
|
||||||
getString(R.string.settings_users_prefs_user_not_used)
|
getString(R.string.settings_general_users_prefs_user_not_used)
|
||||||
} else if (user.topics.size == 1) {
|
} else if (user.topics.size == 1) {
|
||||||
getString(R.string.settings_users_prefs_user_used_by_one, user.topics[0])
|
getString(R.string.settings_general_users_prefs_user_used_by_one, user.topics[0])
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.settings_users_prefs_user_used_by_many, user.topics.joinToString(", "))
|
getString(R.string.settings_general_users_prefs_user_used_by_many, user.topics.joinToString(", "))
|
||||||
}
|
}
|
||||||
preference.onPreferenceClickListener = OnPreferenceClickListener { _ ->
|
preference.onPreferenceClickListener = OnPreferenceClickListener { _ ->
|
||||||
activity?.let {
|
activity?.let {
|
||||||
|
@ -606,12 +606,12 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||||
|
|
||||||
// Add user
|
// Add user
|
||||||
val userAddCategory = PreferenceCategory(preferenceScreen.context)
|
val userAddCategory = PreferenceCategory(preferenceScreen.context)
|
||||||
userAddCategory.title = getString(R.string.settings_users_prefs_user_add)
|
userAddCategory.title = getString(R.string.settings_general_users_prefs_user_add)
|
||||||
preferenceScreen.addPreference(userAddCategory)
|
preferenceScreen.addPreference(userAddCategory)
|
||||||
|
|
||||||
val userAddPref = Preference(preferenceScreen.context)
|
val userAddPref = Preference(preferenceScreen.context)
|
||||||
userAddPref.title = getString(R.string.settings_users_prefs_user_add_title)
|
userAddPref.title = getString(R.string.settings_general_users_prefs_user_add_title)
|
||||||
userAddPref.summary = getString(R.string.settings_users_prefs_user_add_summary)
|
userAddPref.summary = getString(R.string.settings_general_users_prefs_user_add_summary)
|
||||||
userAddPref.onPreferenceClickListener = OnPreferenceClickListener { _ ->
|
userAddPref.onPreferenceClickListener = OnPreferenceClickListener { _ ->
|
||||||
activity?.let {
|
activity?.let {
|
||||||
UserFragment
|
UserFragment
|
||||||
|
|
|
@ -317,7 +317,9 @@ class ShareActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validateInput() {
|
private fun validateInput() {
|
||||||
if (!this::sendItem.isInitialized) return // Initialized late in onCreateOptionsMenu
|
if (!this::sendItem.isInitialized || !this::useAnotherServerCheckbox.isInitialized || !this::contentText.isInitialized || !this::topicText.isInitialized) {
|
||||||
|
return // sendItem is initialized late in onCreateOptionsMenu
|
||||||
|
}
|
||||||
val enabled = if (useAnotherServerCheckbox.isChecked) {
|
val enabled = if (useAnotherServerCheckbox.isChecked) {
|
||||||
contentText.text.isNotEmpty() && validTopic(topicText.text.toString()) && validUrl(baseUrlText.text.toString())
|
contentText.text.isNotEmpty() && validTopic(topicText.text.toString()) && validUrl(baseUrlText.text.toString())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -217,7 +217,6 @@
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
<string name="settings_general_header">General</string>
|
|
||||||
<string name="settings_notifications_header">Notifications</string>
|
<string name="settings_notifications_header">Notifications</string>
|
||||||
<string name="settings_notifications_muted_until_key">MutedUntil</string>
|
<string name="settings_notifications_muted_until_key">MutedUntil</string>
|
||||||
<string name="settings_notifications_muted_until_title">Pause notifications</string>
|
<string name="settings_notifications_muted_until_title">Pause notifications</string>
|
||||||
|
@ -261,31 +260,30 @@
|
||||||
<string name="settings_notifications_auto_delete_one_week">After one week</string>
|
<string name="settings_notifications_auto_delete_one_week">After one week</string>
|
||||||
<string name="settings_notifications_auto_delete_one_month">After one month</string>
|
<string name="settings_notifications_auto_delete_one_month">After one month</string>
|
||||||
<string name="settings_notifications_auto_delete_three_months">After 3 months</string>
|
<string name="settings_notifications_auto_delete_three_months">After 3 months</string>
|
||||||
<string name="settings_appearance_header">Appearance</string>
|
<string name="settings_general_header">General</string>
|
||||||
<string name="settings_appearance_dark_mode_key">DarkMode</string>
|
<string name="settings_general_default_base_url_key">DefaultBaseURL</string>
|
||||||
<string name="settings_appearance_dark_mode_title">Dark mode</string>
|
<string name="settings_general_default_base_url_title">Default server</string>
|
||||||
<string name="settings_appearance_dark_mode_summary_system">Use the system default</string>
|
<string name="settings_general_default_base_url_message">To use your own server as a default when subscribing to new topics and/or sharing to topics, enter the server base URL.</string>
|
||||||
<string name="settings_appearance_dark_mode_summary_light">Light mode is enabled</string>
|
<string name="settings_general_default_base_url_default_summary">%1$s (default)</string>
|
||||||
<string name="settings_appearance_dark_mode_summary_dark">Dark mode is enabled. Are you a vampire?</string>
|
<string name="settings_general_users_key">ManageUsers</string>
|
||||||
<string name="settings_appearance_dark_mode_entry_system">Use system default</string>
|
<string name="settings_general_users_title">Manage users</string>
|
||||||
<string name="settings_appearance_dark_mode_entry_light">Light mode</string>
|
<string name="settings_general_users_summary">Add/remove users for protected topics</string>
|
||||||
<string name="settings_appearance_dark_mode_entry_dark">Dark mode</string>
|
<string name="settings_general_users_prefs_title">Users</string>
|
||||||
<string name="settings_users_header">Users</string>
|
<string name="settings_general_users_prefs_user_not_used">Not used by any topics</string>
|
||||||
<string name="settings_users_key">ManageUsers</string>
|
<string name="settings_general_users_prefs_user_used_by_one">Used by topic %1$s</string>
|
||||||
<string name="settings_users_title">Manage users</string>
|
<string name="settings_general_users_prefs_user_used_by_many">Used by topics %1$s</string>
|
||||||
<string name="settings_users_summary">Add/remove users for protected topics</string>
|
<string name="settings_general_users_prefs_user_add">Add users</string>
|
||||||
<string name="settings_users_prefs_title">Users</string>
|
<string name="settings_general_users_prefs_user_add_title">Add new user</string>
|
||||||
<string name="settings_users_prefs_user_not_used">Not used by any topics</string>
|
<string name="settings_general_users_prefs_user_add_summary">Create a new user for a new server</string>
|
||||||
<string name="settings_users_prefs_user_used_by_one">Used by topic %1$s</string>
|
<string name="settings_general_dark_mode_key">DarkMode</string>
|
||||||
<string name="settings_users_prefs_user_used_by_many">Used by topics %1$s</string>
|
<string name="settings_general_dark_mode_title">Dark mode</string>
|
||||||
<string name="settings_users_prefs_user_add">Add users</string>
|
<string name="settings_general_dark_mode_summary_system">Use the system default</string>
|
||||||
<string name="settings_users_prefs_user_add_title">Add new user</string>
|
<string name="settings_general_dark_mode_summary_light">Light mode is enabled</string>
|
||||||
<string name="settings_users_prefs_user_add_summary">Create a new user for a new server</string>
|
<string name="settings_general_dark_mode_summary_dark">Dark mode is enabled. Are you a vampire?</string>
|
||||||
|
<string name="settings_general_dark_mode_entry_system">Use system default</string>
|
||||||
|
<string name="settings_general_dark_mode_entry_light">Light mode</string>
|
||||||
|
<string name="settings_general_dark_mode_entry_dark">Dark mode</string>
|
||||||
<string name="settings_advanced_header">Advanced</string>
|
<string name="settings_advanced_header">Advanced</string>
|
||||||
<string name="settings_advanced_default_base_url_key">DefaultBaseURL</string>
|
|
||||||
<string name="settings_advanced_default_base_url_title">Default server</string>
|
|
||||||
<string name="settings_advanced_default_base_url_message">To use your own server as a default when subscribing to new topics and/or sharing to topics, enter the server base URL.</string>
|
|
||||||
<string name="settings_advanced_default_base_url_default_summary">%1$s (default)</string>
|
|
||||||
<string name="settings_advanced_broadcast_key">BroadcastEnabled</string>
|
<string name="settings_advanced_broadcast_key">BroadcastEnabled</string>
|
||||||
<string name="settings_advanced_broadcast_title">Broadcast messages</string>
|
<string name="settings_advanced_broadcast_title">Broadcast messages</string>
|
||||||
<string name="settings_advanced_broadcast_summary_enabled">Apps can receive incoming notifications as broadcasts</string>
|
<string name="settings_advanced_broadcast_summary_enabled">Apps can receive incoming notifications as broadcasts</string>
|
||||||
|
|
|
@ -89,12 +89,12 @@
|
||||||
<item>upload_original</item>
|
<item>upload_original</item>
|
||||||
<item>upload_scrubbed</item>
|
<item>upload_scrubbed</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="settings_appearance_dark_mode_entries">
|
<string-array name="settings_general_dark_mode_entries">
|
||||||
<item>@string/settings_appearance_dark_mode_entry_system</item>
|
<item>@string/settings_general_dark_mode_entry_system</item>
|
||||||
<item>@string/settings_appearance_dark_mode_entry_light</item>
|
<item>@string/settings_general_dark_mode_entry_light</item>
|
||||||
<item>@string/settings_appearance_dark_mode_entry_dark</item>
|
<item>@string/settings_general_dark_mode_entry_dark</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="settings_appearance_dark_mode_values">
|
<string-array name="settings_general_dark_mode_values">
|
||||||
<!-- Must match values in AppCompatDelegate -->
|
<!-- Must match values in AppCompatDelegate -->
|
||||||
<item>-1</item>
|
<item>-1</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
|
|
|
@ -28,20 +28,20 @@
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory app:title="@string/settings_general_header">
|
<PreferenceCategory app:title="@string/settings_general_header">
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
app:key="@string/settings_advanced_default_base_url_key"
|
app:key="@string/settings_general_default_base_url_key"
|
||||||
app:title="@string/settings_advanced_default_base_url_title"
|
app:title="@string/settings_general_default_base_url_title"
|
||||||
app:dialogLayout="@layout/preference_dialog_edittext_edited"
|
app:dialogLayout="@layout/preference_dialog_edittext_edited"
|
||||||
app:dialogMessage="@string/settings_advanced_default_base_url_message"/>
|
app:dialogMessage="@string/settings_general_default_base_url_message"/>
|
||||||
<Preference
|
<Preference
|
||||||
app:key="@string/settings_users_key"
|
app:key="@string/settings_general_users_key"
|
||||||
app:title="@string/settings_users_title"
|
app:title="@string/settings_general_users_title"
|
||||||
app:summary="@string/settings_users_summary"
|
app:summary="@string/settings_general_users_summary"
|
||||||
app:fragment="io.heckel.ntfy.ui.SettingsActivity$UserSettingsFragment"/>
|
app:fragment="io.heckel.ntfy.ui.SettingsActivity$UserSettingsFragment"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:key="@string/settings_appearance_dark_mode_key"
|
app:key="@string/settings_general_dark_mode_key"
|
||||||
app:title="@string/settings_appearance_dark_mode_title"
|
app:title="@string/settings_general_dark_mode_title"
|
||||||
app:entries="@array/settings_appearance_dark_mode_entries"
|
app:entries="@array/settings_general_dark_mode_entries"
|
||||||
app:entryValues="@array/settings_appearance_dark_mode_values"
|
app:entryValues="@array/settings_general_dark_mode_values"
|
||||||
app:defaultValue="-1"/>
|
app:defaultValue="-1"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory app:title="@string/settings_advanced_header">
|
<PreferenceCategory app:title="@string/settings_advanced_header">
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
app:title="@string/settings_users_prefs_title">
|
app:title="@string/settings_general_users_prefs_title">
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue