From bdd7a86cd5bf9f53c0fec4e1b044934d226c6ab5 Mon Sep 17 00:00:00 2001 From: Madhur Gupta <30932899+madhurgupta10@users.noreply.github.com> Date: Sun, 11 Mar 2018 00:56:05 +0530 Subject: [PATCH] Revamp the Settings page (#1259) * Revamp the Settings page * Update License Test --- .../nrw/commons/SettingsActivityTest.java | 9 +- .../commons/settings/SettingsFragment.java | 4 +- app/src/main/res/values/strings.xml | 8 +- app/src/main/res/xml/preferences.xml | 105 ++++++++++-------- 4 files changed, 68 insertions(+), 58 deletions(-) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java b/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java index 5be309252..80caf0010 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java +++ b/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java @@ -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) )); } -} \ No newline at end of file +} diff --git a/app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java b/app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java index 66be88e3f..c7ee3df48 100644 --- a/app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java @@ -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; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e7da11672..2aa47bcfd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,9 @@ + Appearance + General + Feedback + Location Commons Settings @@ -94,7 +98,7 @@ This image will be licensed under %1$s 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 <a href=\"https://commons.wikimedia.org/wiki/Commons:Policies_and_guidelines\">Wikimedia Commons policies</a>. Download - License + Default License Use previous title/description Automatically get current location Retrieve current location to offer category suggestions if image is not geotagged @@ -170,8 +174,6 @@ Become a Beta Tester Opt-in to our beta channel on Google Play and get early access to new features and bug fixes https://play.google.com/apps/testing/fr.free.nrw.commons - Use Wikidata - (Warning: disabling this may cause large mobile data consumption) mapbox://styles/mapbox/traffic-day-v2 mapbox://styles/mapbox/traffic-night-v2 pk.eyJ1IjoibWFza2FyYXZpdmVrIiwiYSI6ImNqMmxvdzFjMTAwMHYzM283ZWM3eW5tcDAifQ.ib5SZ9EVjwJe6GSKve0bcg diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index b7b63d39c..70ab2736f 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,61 +1,68 @@ + xmlns:android="http://schemas.android.com/apk/res/android"> - + - + - - - + - + - + - + - + - + + + + + + + + + + + + + + + + + \ No newline at end of file