mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Merge remote-tracking branch 'refs/remotes/commons-app/master'
This commit is contained in:
commit
9e17405b92
10 changed files with 47 additions and 36 deletions
|
|
@ -84,9 +84,9 @@ public class SettingsActivityTest {
|
|||
.atPosition(0)
|
||||
.perform(ViewActions.click());
|
||||
|
||||
// click "CC BY-4.0"
|
||||
// click "Attribution 4.0"
|
||||
Espresso.onView(
|
||||
ViewMatchers.withText(R.string.license_name_cc_by_4_0)
|
||||
ViewMatchers.withText(R.string.license_name_cc_by_four)
|
||||
).perform(ViewActions.click());
|
||||
|
||||
// click "License" (the first item)
|
||||
|
|
@ -95,10 +95,10 @@ public class SettingsActivityTest {
|
|||
.atPosition(0)
|
||||
.perform(ViewActions.click());
|
||||
|
||||
// test the value remains "CC BY-4.0"
|
||||
// test the value remains "Attribution 4.0"
|
||||
Espresso.onView(ViewMatchers.isChecked())
|
||||
.check(ViewAssertions.matches(
|
||||
ViewMatchers.withText(R.string.license_name_cc_by_4_0)
|
||||
ViewMatchers.withText(R.string.license_name_cc_by_four)
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ public class ContributionsActivity
|
|||
AdapterView.OnItemClickListener,
|
||||
MediaDetailPagerFragment.MediaDetailProvider,
|
||||
FragmentManager.OnBackStackChangedListener,
|
||||
ContributionsListFragment.SourceRefresher
|
||||
{
|
||||
ContributionsListFragment.SourceRefresher {
|
||||
|
||||
private Cursor allContributions;
|
||||
private ContributionsListFragment contributionsList;
|
||||
|
|
@ -92,6 +91,15 @@ public class ContributionsActivity
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean isSettingsChanged =
|
||||
sharedPreferences.getBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,false);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,false);
|
||||
editor.apply();
|
||||
if (isSettingsChanged) {
|
||||
refreshSource();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import android.os.Bundle;
|
|||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import fr.free.nrw.commons.MWApi;
|
||||
import org.mediawiki.api.ApiResult;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -20,6 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.MWApi;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|||
|
||||
private int getLimit() {
|
||||
|
||||
int limit = 100;
|
||||
int limit = 500;
|
||||
Timber.d("Max number of uploads set to %d", limit);
|
||||
return limit; // FIXME: Parameterize!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class Prefs {
|
|||
public static String TRACKING_ENABLED = "eventLogging";
|
||||
public static final String DEFAULT_LICENSE = "defaultLicense";
|
||||
public static final String UPLOADS_SHOWING = "uploadsshowing";
|
||||
public static final String IS_CONTRIBUTION_COUNT_CHANGED = "ccontributionCountChanged";
|
||||
|
||||
public static class Licenses {
|
||||
public static final String CC_BY_SA_3 = "CC BY-SA 3.0";
|
||||
|
|
|
|||
|
|
@ -24,24 +24,10 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
|
||||
// Update spinner to show selected value as summary
|
||||
ListPreference licensePreference = (ListPreference) findPreference(Prefs.DEFAULT_LICENSE);
|
||||
// WARNING: ORDERING NEEDS TO MATCH FOR THE LICENSE NAMES AND DISPLAY VALUES
|
||||
licensePreference.setEntries(new String[]{
|
||||
getString(R.string.license_name_cc0),
|
||||
getString(R.string.license_name_cc_by_3_0),
|
||||
getString(R.string.license_name_cc_by_4_0),
|
||||
getString(R.string.license_name_cc_by_sa_3_0),
|
||||
getString(R.string.license_name_cc_by_sa_4_0)
|
||||
});
|
||||
licensePreference.setEntryValues(new String[]{
|
||||
Prefs.Licenses.CC0,
|
||||
Prefs.Licenses.CC_BY_3,
|
||||
Prefs.Licenses.CC_BY_4,
|
||||
Prefs.Licenses.CC_BY_SA_3,
|
||||
Prefs.Licenses.CC_BY_SA_4
|
||||
});
|
||||
|
||||
licensePreference.setSummary(getString(Utils.licenseNameFor(licensePreference.getValue())));
|
||||
licensePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
|
||||
|
||||
// Keep summary updated when changing value
|
||||
licensePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(getString(Utils.licenseNameFor((String) newValue)));
|
||||
|
|
@ -59,17 +45,16 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
});
|
||||
|
||||
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
||||
SharedPreferences sharedPref = PreferenceManager
|
||||
final SharedPreferences sharedPref = PreferenceManager
|
||||
.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||
uploadLimit.setText(uploads + "");
|
||||
uploadLimit.setSummary(uploads + "");
|
||||
uploadLimit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
int value = Integer.parseInt(newValue.toString());
|
||||
final SharedPreferences sharedPref = PreferenceManager
|
||||
.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
final SharedPreferences.Editor editor = sharedPref.edit();
|
||||
if (value > 500) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
|
|
@ -83,10 +68,12 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
editor.putInt(Prefs.UPLOADS_SHOWING, 500);
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,true);
|
||||
uploadLimit.setSummary(500 + "");
|
||||
uploadLimit.setText(500 + "");
|
||||
} else {
|
||||
editor.putInt(Prefs.UPLOADS_SHOWING, Integer.parseInt(newValue.toString()));
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,true);
|
||||
uploadLimit.setSummary(newValue.toString());
|
||||
}
|
||||
editor.apply();
|
||||
|
|
@ -97,4 +84,4 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,13 @@ public class SingleUploadFragment extends Fragment {
|
|||
licenseSpinner.setAdapter(adapter);
|
||||
|
||||
int position = licenseItems.indexOf(getString(Utils.licenseNameFor(license)));
|
||||
|
||||
// Check position is valid
|
||||
if (position < 0) {
|
||||
Timber.d("Invalid position: %d. Using default license", position);
|
||||
position = 4;
|
||||
}
|
||||
|
||||
Timber.d("Position: %d %s", position, getString(Utils.licenseNameFor(license)));
|
||||
licenseSpinner.setSelection(position);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
<item>@string/license_name_cc_by_sa_four</item>
|
||||
</array>
|
||||
<array name="pref_defaultLicense_values">
|
||||
<item>@string/license_name_cc0</item>
|
||||
<item>@string/license_name_cc_by_3_0</item>
|
||||
<item>@string/license_name_cc_by_4_0</item>
|
||||
<item>@string/license_name_cc_by_sa_3_0</item>
|
||||
<item>@string/license_name_cc_by_sa_4_0</item>
|
||||
<item>@string/license_pref_cc0</item>
|
||||
<item>@string/license_pref_cc_by_3_0</item>
|
||||
<item>@string/license_pref_cc_by_4_0</item>
|
||||
<item>@string/license_pref_cc_by_sa_3_0</item>
|
||||
<item>@string/license_pref_cc_by_sa_4_0</item>
|
||||
</array>
|
||||
</resources>
|
||||
8
app/src/main/res/values/keys.xml
Normal file
8
app/src/main/res/values/keys.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="license_pref_cc0" translatable="false">CC0</string>
|
||||
<string name="license_pref_cc_by_3_0" translatable="false">CC BY 3.0</string>
|
||||
<string name="license_pref_cc_by_sa_3_0" translatable="false">CC BY-SA 3.0</string>
|
||||
<string name="license_pref_cc_by_4_0" translatable="false">CC BY 4.0</string>
|
||||
<string name="license_pref_cc_by_sa_4_0" translatable="false">CC BY-SA 4.0</string>
|
||||
</resources>
|
||||
|
|
@ -175,7 +175,7 @@ Tap this message (or hit back) to skip this step.</string>
|
|||
<string name="mapbox_commons_app_token">pk.eyJ1IjoibWFza2FyYXZpdmVrIiwiYSI6ImNqMmxvdzFjMTAwMHYzM283ZWM3eW5tcDAifQ.ib5SZ9EVjwJe6GSKve0bcg</string>
|
||||
<string name="number_of_uploads">My Recent Upload Limit</string>
|
||||
<string name="maximum_limit">Maximum Limit</string>
|
||||
<string name="maximum_limit_alert">Maximum limit should be 500</string>
|
||||
<string name="maximum_limit_alert">Unable to display more than 500</string>
|
||||
<string name="set_limit">Set Recent Upload Limit</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
android:title="@string/preference_license"
|
||||
android:entries="@array/pref_defaultLicense_entries"
|
||||
android:entryValues="@array/pref_defaultLicense_values"
|
||||
android:defaultValue="@string/license_name_cc_by_sa_4_0"
|
||||
android:defaultValue="@string/license_pref_cc_by_sa_4_0"
|
||||
/>
|
||||
|
||||
<CheckBoxPreference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue