use custom dialog with display name preference
This commit is contained in:
parent
bbc7549d7a
commit
f18285a170
3 changed files with 14 additions and 4 deletions
|
@ -4,6 +4,7 @@ import android.content.ContentResolver
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
@ -298,8 +299,15 @@ class DetailSettingsActivity : AppCompatActivity() {
|
||||||
return subscription.displayName ?: ""
|
return subscription.displayName ?: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pref?.summaryProvider = Preference.SummaryProvider<EditTextPreference> { _ ->
|
pref?.summaryProvider = Preference.SummaryProvider<EditTextPreference> { provider ->
|
||||||
getString(R.string.detail_settings_appearance_display_name_summary, displayName(subscription), topicShortUrl(subscription.baseUrl, subscription.topic))
|
if (TextUtils.isEmpty(provider.text)) {
|
||||||
|
getString(
|
||||||
|
R.string.detail_settings_appearance_display_name_default_summary,
|
||||||
|
displayName(subscription)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
provider.text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,8 @@
|
||||||
<string name="detail_settings_appearance_icon_remove_summary">Icon displayed in notifications for this topic</string>
|
<string name="detail_settings_appearance_icon_remove_summary">Icon displayed in notifications for this topic</string>
|
||||||
<string name="detail_settings_appearance_icon_error_saving">Unable to save icon: %1$s</string>
|
<string name="detail_settings_appearance_icon_error_saving">Unable to save icon: %1$s</string>
|
||||||
<string name="detail_settings_appearance_display_name_title">Display name</string>
|
<string name="detail_settings_appearance_display_name_title">Display name</string>
|
||||||
<string name="detail_settings_appearance_display_name_summary">Set a custom display name for this subscription. Leave empty for default\nCurrent: %1$s\nDefault: %2$s</string>
|
<string name="detail_settings_appearance_display_name_message">Set a custom display name for this subscription. Leave empty for default</string>
|
||||||
|
<string name="detail_settings_appearance_display_name_default_summary">%1$s (default)</string>
|
||||||
<string name="detail_settings_global_setting_title">Use global setting</string>
|
<string name="detail_settings_global_setting_title">Use global setting</string>
|
||||||
<string name="detail_settings_global_setting_suffix">using global setting</string>
|
<string name="detail_settings_global_setting_suffix">using global setting</string>
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
app:key="@string/detail_settings_appearance_display_name_key"
|
app:key="@string/detail_settings_appearance_display_name_key"
|
||||||
app:title="@string/detail_settings_appearance_display_name_title"
|
app:title="@string/detail_settings_appearance_display_name_title"
|
||||||
app:summary="@string/detail_settings_appearance_display_name_summary"
|
app:dialogLayout="@layout/preference_dialog_edittext_edited"
|
||||||
|
app:dialogMessage="@string/detail_settings_appearance_display_name_message"
|
||||||
app:isPreferenceVisible="false"/>
|
app:isPreferenceVisible="false"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue