Skip to content

Commit bdd7a86

Browse files
madhurgupta10Vivek Maskara
authored andcommitted
Revamp the Settings page (commons-app#1259)
* Revamp the Settings page * Update License Test
1 parent de673eb commit bdd7a86

File tree

4 files changed

+76
-66
lines changed

4 files changed

+76
-66
lines changed

app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.support.test.espresso.Espresso;
66
import android.support.test.espresso.action.ViewActions;
77
import android.support.test.espresso.assertion.ViewAssertions;
8+
import android.support.test.espresso.matcher.PreferenceMatchers;
89
import android.support.test.espresso.matcher.ViewMatchers;
910
import android.support.test.filters.LargeTest;
1011
import android.support.test.rule.ActivityTestRule;
@@ -61,7 +62,7 @@ protected void afterActivityFinished() {
6162
@Test
6263
public void oneLicenseIsChecked() {
6364
// click "License" (the first item)
64-
Espresso.onData(Matchers.anything())
65+
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
6566
.inAdapterView(ViewMatchers.withId(android.R.id.list))
6667
.atPosition(0)
6768
.perform(ViewActions.click());
@@ -74,7 +75,7 @@ public void oneLicenseIsChecked() {
7475
@Test
7576
public void afterClickingCcby4ItWillStay() {
7677
// click "License" (the first item)
77-
Espresso.onData(Matchers.anything())
78+
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
7879
.inAdapterView(ViewMatchers.withId(android.R.id.list))
7980
.atPosition(0)
8081
.perform(ViewActions.click());
@@ -85,7 +86,7 @@ public void afterClickingCcby4ItWillStay() {
8586
).perform(ViewActions.click());
8687

8788
// click "License" (the first item)
88-
Espresso.onData(Matchers.anything())
89+
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
8990
.inAdapterView(ViewMatchers.withId(android.R.id.list))
9091
.atPosition(0)
9192
.perform(ViewActions.click());
@@ -96,4 +97,4 @@ public void afterClickingCcby4ItWillStay() {
9697
ViewMatchers.withText(R.string.license_name_cc_by_four)
9798
));
9899
}
99-
}
100+
}

app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import android.net.Uri;
1111
import android.os.Build;
1212
import android.os.Bundle;
13-
import android.preference.CheckBoxPreference;
13+
import android.preference.SwitchPreference;
1414
import android.preference.EditTextPreference;
1515
import android.preference.ListPreference;
1616
import android.preference.Preference;
@@ -59,7 +59,7 @@ public void onCreate(Bundle savedInstanceState) {
5959
return true;
6060
});
6161

62-
CheckBoxPreference themePreference = (CheckBoxPreference) findPreference("theme");
62+
SwitchPreference themePreference = (SwitchPreference) findPreference("theme");
6363
themePreference.setOnPreferenceChangeListener((preference, newValue) -> {
6464
getActivity().recreate();
6565
return true;

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<string name="preference_category_appearance">Appearance</string>
4+
<string name="preference_category_general">General</string>
5+
<string name="preference_category_feedback">Feedback</string>
6+
<string name="preference_category_location">Location</string>
37
<string name="app_name">Commons</string>
48
<string name="bullet">&#8226; </string>
59
<string name="menu_settings">Settings</string>
@@ -94,7 +98,7 @@
9498
<string name="share_license_summary">This image will be licensed under %1$s</string>
9599
<string name="media_upload_policy">By submitting this picture, I declare that this is my own work, that it does not contain copyrighted material or selfies, and otherwise adheres to &lt;a href=\"https://commons.wikimedia.org/wiki/Commons:Policies_and_guidelines\"&gt;Wikimedia Commons policies&lt;/a&gt;.</string>
96100
<string name="menu_download">Download</string>
97-
<string name="preference_license">License</string>
101+
<string name="preference_license">Default License</string>
98102
<string name="use_previous">Use previous title/description</string>
99103
<string name="allow_gps">Automatically get current location</string>
100104
<string name="allow_gps_summary">Retrieve current location to offer category suggestions if image is not geotagged</string>
@@ -170,8 +174,6 @@
170174
<string name="become_a_tester_title">Become a Beta Tester</string>
171175
<string name="become_a_tester_description">Opt-in to our beta channel on Google Play and get early access to new features and bug fixes</string>
172176
<string name="beta_opt_in_link">https://play.google.com/apps/testing/fr.free.nrw.commons</string>
173-
<string name="use_wikidata">Use Wikidata</string>
174-
<string name="use_wikidata_summary">(Warning: disabling this may cause large mobile data consumption)</string>
175177
<string name="map_theme_light">mapbox://styles/mapbox/traffic-day-v2</string>
176178
<string name="map_theme_dark">mapbox://styles/mapbox/traffic-night-v2</string>
177179
<string name="mapbox_commons_app_token">pk.eyJ1IjoibWFza2FyYXZpdmVrIiwiYSI6ImNqMmxvdzFjMTAwMHYzM283ZWM3eW5tcDAifQ.ib5SZ9EVjwJe6GSKve0bcg</string>

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

Lines changed: 64 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,68 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PreferenceScreen
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
>
5-
6-
<ListPreference
7-
android:key="defaultLicense"
8-
android:title="@string/preference_license"
9-
android:entries="@array/pref_defaultLicense_entries"
10-
android:entryValues="@array/pref_defaultLicense_values"
11-
android:defaultValue="@string/license_pref_cc_by_sa_4_0"
12-
/>
13-
14-
<CheckBoxPreference
15-
android:key="allowGps"
16-
android:title="@string/allow_gps"
17-
android:defaultValue="false"
18-
android:summary="@string/allow_gps_summary"
19-
/>
20-
21-
<Preference android:title="@string/become_a_tester_title"
22-
android:summary="@string/become_a_tester_description">
23-
<intent android:action="android.intent.action.VIEW"
24-
android:data="@string/beta_opt_in_link" />
25-
</Preference>
26-
27-
<CheckBoxPreference
28-
android:title="@string/preference_theme"
29-
android:defaultValue="false"
30-
android:summary="@string/preference_theme_summary"
31-
android:key="theme"
32-
/>
33-
34-
<CheckBoxPreference
35-
android:key="useWikidata"
36-
android:title="@string/use_wikidata"
37-
android:defaultValue="true"
38-
android:summary="@string/use_wikidata_summary"
39-
/>
40-
41-
<EditTextPreference
42-
android:key="uploads"
43-
android:defaultValue="100"
44-
android:title= "@string/set_limit"
45-
android:inputType="numberDecimal"
46-
android:maxLength="3"
47-
/>
48-
49-
<CheckBoxPreference
50-
android:key="useExternalStorage"
51-
android:title="@string/use_external_storage"
52-
android:defaultValue="true"
53-
android:summary="@string/use_external_storage_summary"
54-
/>
55-
56-
<Preference
57-
android:key="sendLogFile"
58-
android:title="@string/send_log_file"
59-
android:summary="@string/send_log_file_description"/>
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
5+
<PreferenceCategory
6+
android:title="@string/preference_category_appearance">
7+
8+
<SwitchPreference
9+
android:title="@string/preference_theme"
10+
android:defaultValue="false"
11+
android:summary="@string/preference_theme_summary"
12+
android:key="theme" />
13+
14+
</PreferenceCategory>
15+
16+
<PreferenceCategory
17+
android:title="@string/preference_category_general">
18+
19+
<ListPreference
20+
android:key="defaultLicense"
21+
android:title="@string/preference_license"
22+
android:entries="@array/pref_defaultLicense_entries"
23+
android:entryValues="@array/pref_defaultLicense_values"
24+
android:defaultValue="@string/license_pref_cc_by_sa_4_0" />
25+
26+
<SwitchPreference
27+
android:key="useExternalStorage"
28+
android:title="@string/use_external_storage"
29+
android:defaultValue="true"
30+
android:summary="@string/use_external_storage_summary" />
31+
32+
<EditTextPreference
33+
android:key="uploads"
34+
android:defaultValue="100"
35+
android:title= "@string/set_limit"
36+
android:inputType="numberDecimal"
37+
android:maxLength="3" />
38+
39+
</PreferenceCategory>
40+
41+
<PreferenceCategory
42+
android:title="@string/preference_category_location">
43+
44+
<SwitchPreference
45+
android:key="allowGps"
46+
android:title="@string/allow_gps"
47+
android:defaultValue="false"
48+
android:summary="@string/allow_gps_summary" />
49+
50+
</PreferenceCategory>
51+
52+
<PreferenceCategory
53+
android:title="@string/preference_category_feedback">
54+
55+
<Preference android:title="@string/become_a_tester_title"
56+
android:summary="@string/become_a_tester_description">
57+
<intent android:action="android.intent.action.VIEW"
58+
android:data="@string/beta_opt_in_link" />
59+
</Preference>
60+
61+
<Preference
62+
android:key="sendLogFile"
63+
android:title="@string/send_log_file"
64+
android:summary="@string/send_log_file_description"/>
65+
66+
</PreferenceCategory>
6067

6168
</PreferenceScreen>

0 commit comments

Comments
 (0)