mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
* UploadController: Added support for using author names. Fixes #1707. * Minor PR tidy-up * Reword preference item * Null check to pass startUpload test
This commit is contained in:
parent
809c0c32d7
commit
8e967a3698
4 changed files with 34 additions and 0 deletions
|
|
@ -63,6 +63,15 @@ public class SettingsFragment extends PreferenceFragment {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Check if the Author Name switch is enabled and appropriately handle the author name usage
|
||||||
|
SwitchPreference useAuthorName = (SwitchPreference) findPreference("useAuthorName");
|
||||||
|
EditTextPreference authorName = (EditTextPreference) findPreference("authorName");
|
||||||
|
authorName.setEnabled(prefs.getBoolean("useAuthorName", false));
|
||||||
|
useAuthorName.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
authorName.setEnabled((Boolean)newValue);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
||||||
int uploads = prefs.getInt(Prefs.UPLOADS_SHOWING, 100);
|
int uploads = prefs.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||||
uploadLimit.setText(uploads + "");
|
uploadLimit.setText(uploads + "");
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
|
@ -103,6 +104,15 @@ public class UploadController {
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void startUpload(final Contribution contribution, final ContributionUploadProgress onComplete) {
|
private void startUpload(final Contribution contribution, final ContributionUploadProgress onComplete) {
|
||||||
//Set creator, desc, and license
|
//Set creator, desc, and license
|
||||||
|
|
||||||
|
// If author name is enabled and set, use it
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
if(preferences != null && preferences.getBoolean("useAuthorName", false)) {
|
||||||
|
String authorName = preferences.getString("authorName", "");
|
||||||
|
contribution.setCreator(authorName);
|
||||||
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(contribution.getCreator())) {
|
if (TextUtils.isEmpty(contribution.getCreator())) {
|
||||||
Account currentAccount = sessionManager.getCurrentAccount();
|
Account currentAccount = sessionManager.getCurrentAccount();
|
||||||
if (currentAccount == null) {
|
if (currentAccount == null) {
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,10 @@
|
||||||
<string name="error_occurred">Error occurred!</string>
|
<string name="error_occurred">Error occurred!</string>
|
||||||
<string name="notifications_channel_name_all">Commons Notification</string>
|
<string name="notifications_channel_name_all">Commons Notification</string>
|
||||||
|
|
||||||
|
<string name="preference_author_name_toggle">Use custom author name</string>
|
||||||
|
<string name="preference_author_name_toggle_summary">Use a custom author name instead of your username while uploading photos</string>
|
||||||
|
<string name="preference_author_name">Custom author name</string>
|
||||||
|
<string name="preference_author_name_summary">The custom author name to use instead of your username in uploads</string>
|
||||||
<string name="contributions_fragment">Contributions</string>
|
<string name="contributions_fragment">Contributions</string>
|
||||||
<string name="nearby_fragment">Nearby</string>
|
<string name="nearby_fragment">Nearby</string>
|
||||||
<string name="notifications">Notifications</string>
|
<string name="notifications">Notifications</string>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,17 @@
|
||||||
android:inputType="numberDecimal"
|
android:inputType="numberDecimal"
|
||||||
android:maxLength="3" />
|
android:maxLength="3" />
|
||||||
|
|
||||||
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
|
||||||
|
android:key="useAuthorName"
|
||||||
|
android:title="@string/preference_author_name_toggle"
|
||||||
|
android:summary="@string/preference_author_name_toggle_summary"/>
|
||||||
|
|
||||||
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleEditTextPreference
|
||||||
|
android:key="authorName"
|
||||||
|
android:title="@string/preference_author_name"
|
||||||
|
android:summary="@string/preference_author_name_summary"
|
||||||
|
/>
|
||||||
|
|
||||||
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
|
||||||
android:key="displayNearbyCardView"
|
android:key="displayNearbyCardView"
|
||||||
android:title="@string/display_nearby_notification"
|
android:title="@string/display_nearby_notification"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue