Revamp the Settings page (#1259)

* Revamp the Settings page

* Update License Test
This commit is contained in:
Madhur Gupta 2018-03-11 00:56:05 +05:30 committed by Vivek Maskara
parent de673eb4ca
commit bdd7a86cd5
4 changed files with 68 additions and 58 deletions

View file

@ -5,6 +5,7 @@ import android.preference.PreferenceManager;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.action.ViewActions;
import android.support.test.espresso.assertion.ViewAssertions;
import android.support.test.espresso.matcher.PreferenceMatchers;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
@ -61,7 +62,7 @@ public class SettingsActivityTest {
@Test
public void oneLicenseIsChecked() {
// click "License" (the first item)
Espresso.onData(Matchers.anything())
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
.inAdapterView(ViewMatchers.withId(android.R.id.list))
.atPosition(0)
.perform(ViewActions.click());
@ -74,7 +75,7 @@ public class SettingsActivityTest {
@Test
public void afterClickingCcby4ItWillStay() {
// click "License" (the first item)
Espresso.onData(Matchers.anything())
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
.inAdapterView(ViewMatchers.withId(android.R.id.list))
.atPosition(0)
.perform(ViewActions.click());
@ -85,7 +86,7 @@ public class SettingsActivityTest {
).perform(ViewActions.click());
// click "License" (the first item)
Espresso.onData(Matchers.anything())
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
.inAdapterView(ViewMatchers.withId(android.R.id.list))
.atPosition(0)
.perform(ViewActions.click());
@ -96,4 +97,4 @@ public class SettingsActivityTest {
ViewMatchers.withText(R.string.license_name_cc_by_four)
));
}
}
}

View file

@ -10,7 +10,7 @@ import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.SwitchPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@ -59,7 +59,7 @@ public class SettingsFragment extends PreferenceFragment {
return true;
});
CheckBoxPreference themePreference = (CheckBoxPreference) findPreference("theme");
SwitchPreference themePreference = (SwitchPreference) findPreference("theme");
themePreference.setOnPreferenceChangeListener((preference, newValue) -> {
getActivity().recreate();
return true;

View file

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="preference_category_appearance">Appearance</string>
<string name="preference_category_general">General</string>
<string name="preference_category_feedback">Feedback</string>
<string name="preference_category_location">Location</string>
<string name="app_name">Commons</string>
<string name="bullet">&#8226; </string>
<string name="menu_settings">Settings</string>
@ -94,7 +98,7 @@
<string name="share_license_summary">This image will be licensed under %1$s</string>
<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>
<string name="menu_download">Download</string>
<string name="preference_license">License</string>
<string name="preference_license">Default License</string>
<string name="use_previous">Use previous title/description</string>
<string name="allow_gps">Automatically get current location</string>
<string name="allow_gps_summary">Retrieve current location to offer category suggestions if image is not geotagged</string>
@ -170,8 +174,6 @@
<string name="become_a_tester_title">Become a Beta Tester</string>
<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>
<string name="beta_opt_in_link">https://play.google.com/apps/testing/fr.free.nrw.commons</string>
<string name="use_wikidata">Use Wikidata</string>
<string name="use_wikidata_summary">(Warning: disabling this may cause large mobile data consumption)</string>
<string name="map_theme_light">mapbox://styles/mapbox/traffic-day-v2</string>
<string name="map_theme_dark">mapbox://styles/mapbox/traffic-night-v2</string>
<string name="mapbox_commons_app_token">pk.eyJ1IjoibWFza2FyYXZpdmVrIiwiYSI6ImNqMmxvdzFjMTAwMHYzM283ZWM3eW5tcDAifQ.ib5SZ9EVjwJe6GSKve0bcg</string>

View file

@ -1,61 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
>
xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:key="defaultLicense"
android:title="@string/preference_license"
android:entries="@array/pref_defaultLicense_entries"
android:entryValues="@array/pref_defaultLicense_values"
android:defaultValue="@string/license_pref_cc_by_sa_4_0"
/>
<PreferenceCategory
android:title="@string/preference_category_appearance">
<CheckBoxPreference
android:key="allowGps"
android:title="@string/allow_gps"
android:defaultValue="false"
android:summary="@string/allow_gps_summary"
/>
<SwitchPreference
android:title="@string/preference_theme"
android:defaultValue="false"
android:summary="@string/preference_theme_summary"
android:key="theme" />
<Preference android:title="@string/become_a_tester_title"
android:summary="@string/become_a_tester_description">
<intent android:action="android.intent.action.VIEW"
android:data="@string/beta_opt_in_link" />
</Preference>
</PreferenceCategory>
<CheckBoxPreference
android:title="@string/preference_theme"
android:defaultValue="false"
android:summary="@string/preference_theme_summary"
android:key="theme"
/>
<PreferenceCategory
android:title="@string/preference_category_general">
<CheckBoxPreference
android:key="useWikidata"
android:title="@string/use_wikidata"
android:defaultValue="true"
android:summary="@string/use_wikidata_summary"
/>
<ListPreference
android:key="defaultLicense"
android:title="@string/preference_license"
android:entries="@array/pref_defaultLicense_entries"
android:entryValues="@array/pref_defaultLicense_values"
android:defaultValue="@string/license_pref_cc_by_sa_4_0" />
<EditTextPreference
android:key="uploads"
android:defaultValue="100"
android:title= "@string/set_limit"
android:inputType="numberDecimal"
android:maxLength="3"
/>
<SwitchPreference
android:key="useExternalStorage"
android:title="@string/use_external_storage"
android:defaultValue="true"
android:summary="@string/use_external_storage_summary" />
<CheckBoxPreference
android:key="useExternalStorage"
android:title="@string/use_external_storage"
android:defaultValue="true"
android:summary="@string/use_external_storage_summary"
/>
<EditTextPreference
android:key="uploads"
android:defaultValue="100"
android:title= "@string/set_limit"
android:inputType="numberDecimal"
android:maxLength="3" />
<Preference
android:key="sendLogFile"
android:title="@string/send_log_file"
android:summary="@string/send_log_file_description"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/preference_category_location">
<SwitchPreference
android:key="allowGps"
android:title="@string/allow_gps"
android:defaultValue="false"
android:summary="@string/allow_gps_summary" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/preference_category_feedback">
<Preference android:title="@string/become_a_tester_title"
android:summary="@string/become_a_tester_description">
<intent android:action="android.intent.action.VIEW"
android:data="@string/beta_opt_in_link" />
</Preference>
<Preference
android:key="sendLogFile"
android:title="@string/send_log_file"
android:summary="@string/send_log_file_description"/>
</PreferenceCategory>
</PreferenceScreen>