Skip to content

Commit 4f04d31

Browse files
committed
[WIP] Fixes commons-app#3465 Use AndroidX Pref
1 parent 668b589 commit 4f04d31

File tree

2 files changed

+89
-84
lines changed

2 files changed

+89
-84
lines changed

app/build.gradle

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ dependencies {
110110
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
111111
implementation "androidx.room:room-rxjava2:$room_version"
112112
testImplementation "androidx.arch.core:core-testing:2.1.0"
113+
114+
// Pref
115+
def preference_version = "1.1.0"
116+
// Java language implementation
117+
implementation "androidx.preference:preference:$preference_version"
118+
// Kotlin
119+
implementation "androidx.preference:preference-ktx:$preference_version"
113120
}
114121

115122
android {

app/src/main/res/xml/preferences.xml

+82-84
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,97 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<PreferenceScreen
3-
xmlns:android="http://schemas.android.com/apk/res/android">
2+
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:android="http://schemas.android.com/apk/res/android">
44

5-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
6-
android:title="@string/preference_category_appearance">
5+
<PreferenceCategory
6+
android:title="@string/preference_category_appearance">
77

8-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleListPreference
8+
<ListPreference
99
android:key="appThemePref"
1010
android:title= "@string/preference_theme"
1111
android:entries="@array/pref_theme_entries"
1212
android:entryValues="@array/pref_theme_entries_values"
13-
android:defaultValue="0"
14-
android:summary="@string/theme_default_name" />
15-
16-
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
17-
18-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
19-
android:title="@string/preference_category_general">
20-
21-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
22-
android:key="useExternalStorage"
23-
android:title="@string/use_external_storage"
24-
android:defaultValue="true"
25-
android:summary="@string/use_external_storage_summary" />
26-
27-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleEditTextPreference
28-
android:key="uploads"
29-
android:defaultValue="100"
30-
android:title= "@string/set_limit"
31-
android:inputType="number"
32-
android:maxLength="3" />
33-
34-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleListPreference
35-
android:key="descriptionDefaultLanguagePref"
36-
android:title= "@string/default_description_language"
37-
android:summary="English" />
38-
39-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
40-
android:key="useAuthorName"
41-
android:title="@string/preference_author_name_toggle"
42-
android:summary="@string/preference_author_name_toggle_summary"/>
43-
44-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleEditTextPreference
45-
android:key="authorName"
46-
android:title="@string/preference_author_name"
47-
android:summary="@string/preference_author_name_summary"
48-
/>
49-
50-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
51-
android:key="displayNearbyCardView"
52-
android:title="@string/display_nearby_notification"
53-
android:defaultValue="true"
54-
android:summary="@string/display_nearby_notification_summary" />
55-
56-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
57-
android:key="displayLocationPermissionForCardView"
58-
android:title="@string/display_location_permission_title"
59-
android:defaultValue="true"
60-
android:summary="@string/display_location_permission_explanation" />
61-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
62-
android:key="displayCampaignsCardView"
63-
android:title="@string/display_campaigns"
64-
android:defaultValue="true"
65-
android:summary="@string/display_campaigns_explanation" />
66-
67-
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
68-
69-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
70-
android:title="@string/preference_category_privacy">
71-
72-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleMultiSelectListPreference
73-
android:entries="@array/pref_exifTag_entries"
74-
android:entryValues="@array/pref_exifTag_values"
75-
android:key="managed_exif_tags"
76-
android:title="@string/manage_exif_tags"
77-
android:summary="@string/manage_exif_tags_summary"/>
78-
79-
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
13+
app:useSimpleSummaryProvider="true"
14+
android:defaultValue="0" />
15+
16+
</PreferenceCategory>
17+
18+
<PreferenceCategory
19+
android:title="@string/preference_category_general">
20+
21+
<SwitchPreference
22+
android:defaultValue="true"
23+
android:key="useExternalStorage"
24+
android:summary="@string/use_external_storage_summary"
25+
android:title="@string/use_external_storage" />
26+
27+
<EditTextPreference
28+
android:defaultValue="100"
29+
android:inputType="number"
30+
android:key="uploads"
31+
android:maxLength="3"
32+
android:title="@string/set_limit" />
33+
34+
<ListPreference
35+
android:key="descriptionDefaultLanguagePref"
36+
android:summary="English"
37+
android:title="@string/default_description_language" />
38+
39+
<SwitchPreference
40+
android:key="useAuthorName"
41+
android:summary="@string/preference_author_name_toggle_summary"
42+
android:title="@string/preference_author_name_toggle" />
43+
44+
<EditTextPreference
45+
android:key="authorName"
46+
android:summary="@string/preference_author_name_summary"
47+
android:title="@string/preference_author_name" />
48+
49+
<SwitchPreference
50+
android:defaultValue="true"
51+
android:key="displayNearbyCardView"
52+
android:summary="@string/display_nearby_notification_summary"
53+
android:title="@string/display_nearby_notification" />
54+
55+
<SwitchPreference
56+
android:defaultValue="true"
57+
android:key="displayLocationPermissionForCardView"
58+
android:summary="@string/display_location_permission_explanation"
59+
android:title="@string/display_location_permission_title" />
60+
<SwitchPreference
61+
android:defaultValue="true"
62+
android:key="displayCampaignsCardView"
63+
android:summary="@string/display_campaigns_explanation"
64+
android:title="@string/display_campaigns" />
65+
66+
</PreferenceCategory>
67+
68+
<PreferenceCategory
69+
android:title="@string/preference_category_privacy">
70+
71+
<MultiSelectListPreference
72+
android:entries="@array/pref_exifTag_entries"
73+
android:entryValues="@array/pref_exifTag_values"
74+
android:key="managed_exif_tags"
75+
android:summary="@string/manage_exif_tags_summary"
76+
android:title="@string/manage_exif_tags" />
77+
78+
</PreferenceCategory>
8079

8180
<!-- The key 'allowGps' was used before and has since been removed based on the discussion at #1599.
8281
Do not reuse this key unless you revive the same feature with the changes mentioned at #1599.-->
8382

84-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
85-
android:title="@string/preference_category_feedback">
83+
<PreferenceCategory
84+
android:title="@string/preference_category_feedback">
8685

87-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreference
88-
android:key="becomeBetaTester"
89-
android:title="@string/become_a_tester_title"
90-
android:summary="@string/become_a_tester_description">
91-
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreference>
86+
<Preference
87+
android:key="becomeBetaTester"
88+
android:summary="@string/become_a_tester_description"
89+
android:title="@string/become_a_tester_title"/>
9290

93-
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreference
94-
android:key="sendLogFile"
95-
android:title="@string/send_log_file"
96-
android:summary="@string/send_log_file_description"/>
91+
<Preference
92+
android:key="sendLogFile"
93+
android:summary="@string/send_log_file_description"
94+
android:title="@string/send_log_file" />
9795

98-
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
96+
</PreferenceCategory>
9997
</PreferenceScreen>

0 commit comments

Comments
 (0)