mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge remote-tracking branch 'refs/remotes/commons-app/master'
This commit is contained in:
commit
3a22579bbd
21 changed files with 78 additions and 44 deletions
6
app/src/debug/res/values/placeholder_strings.xml
Normal file
6
app/src/debug/res/values/placeholder_strings.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="placeholder_place_distance">Overlay</string>
|
||||
<string name="placeholder_place_name">Name</string>
|
||||
<string name="placeholder_place_description">Description</string>
|
||||
</resources>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="fr.free.nrw.commons"
|
||||
android:versionCode="65"
|
||||
android:versionName="2.0.2" >
|
||||
|
|
@ -85,7 +86,7 @@
|
|||
<activity
|
||||
android:name=".nearby.NearbyActivity"
|
||||
android:label="@string/title_activity_nearby"
|
||||
android:parentActivityName=".contributions.ContributionsActivity"/>
|
||||
android:parentActivityName=".contributions.ContributionsActivity" />
|
||||
|
||||
<service android:name=".upload.UploadService" >
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public class LicenseList {
|
|||
public String nameIdForTemplate(String template) {
|
||||
// hack :D (converts dashes and periods to underscores)
|
||||
// cc-by-sa-3.0 -> cc_by_sa_3_0
|
||||
return "license_name_" + template.toLowerCase().replace("-", "_").replace(".", "_");
|
||||
return "license_name_" + template.toLowerCase(Locale.ENGLISH).replace("-", "_").replace(".", "_");
|
||||
}
|
||||
|
||||
private int stringIdByName(String stringId) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -81,7 +82,7 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static Date parseMWDate(String mwDate) {
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // Assuming MW always gives me UTC
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH); // Assuming MW always gives me UTC
|
||||
try {
|
||||
return isoFormat.parse(mwDate);
|
||||
} catch (ParseException e) {
|
||||
|
|
@ -90,7 +91,7 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static String toMWDate(Date date) {
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // Assuming MW always gives me UTC
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH); // Assuming MW always gives me UTC
|
||||
isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
return isoFormat.format(date);
|
||||
}
|
||||
|
|
@ -201,7 +202,7 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static String capitalize(String string) {
|
||||
return string.substring(0,1).toUpperCase() + string.substring(1);
|
||||
return string.substring(0,1).toUpperCase(Locale.getDefault()) + string.substring(1);
|
||||
}
|
||||
|
||||
public static String licenseTemplateFor(String license) {
|
||||
|
|
@ -303,13 +304,17 @@ public class Utils {
|
|||
Pattern jpegPattern = Pattern.compile("\\.jpeg$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
// People are used to ".jpg" more than ".jpeg" which the system gives us.
|
||||
if (extension != null && extension.toLowerCase().equals("jpeg")) {
|
||||
if (extension != null && extension.toLowerCase(Locale.ENGLISH).equals("jpeg")) {
|
||||
extension = "jpg";
|
||||
}
|
||||
title = jpegPattern.matcher(title).replaceFirst(".jpg");
|
||||
if (extension != null && !title.toLowerCase().endsWith("." + extension.toLowerCase())) {
|
||||
if (extension != null && !title.toLowerCase(Locale.getDefault()).endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
|
||||
title += "." + extension;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
public static boolean isNullOrWhiteSpace(String value) {
|
||||
return value == null || value.trim().isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package fr.free.nrw.commons.auth;
|
||||
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -20,23 +24,24 @@ public abstract class AuthenticatedActivity extends AppCompatActivity {
|
|||
CommonsApplication app;
|
||||
|
||||
private String authCookie;
|
||||
|
||||
|
||||
public AuthenticatedActivity(String accountType) {
|
||||
this.accountType = accountType;
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
|
||||
private class GetAuthCookieTask extends AsyncTask<Void, String, String> {
|
||||
private Account account;
|
||||
private AccountManager accountManager;
|
||||
|
||||
public GetAuthCookieTask(Account account, AccountManager accountManager) {
|
||||
this.account = account;
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
if(result != null) {
|
||||
if (result != null) {
|
||||
authCookie = result;
|
||||
onAuthCookieAcquired(result);
|
||||
} else {
|
||||
|
|
@ -60,19 +65,19 @@ public abstract class AuthenticatedActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class AddAccountTask extends AsyncTask<Void, String, String> {
|
||||
private AccountManager accountManager;
|
||||
|
||||
public AddAccountTask(AccountManager accountManager) {
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
if(result != null) {
|
||||
Account[] allAccounts =accountManager.getAccountsByType(accountType);
|
||||
Account curAccount = allAccounts[0];
|
||||
if (result != null) {
|
||||
Account curAccount = getCurrentAccount();
|
||||
GetAuthCookieTask getCookieTask = new GetAuthCookieTask(curAccount, accountManager);
|
||||
getCookieTask.execute();
|
||||
} else {
|
||||
|
|
@ -80,6 +85,18 @@ public abstract class AuthenticatedActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Account getCurrentAccount() {
|
||||
if (ActivityCompat.checkSelfPermission(AuthenticatedActivity.this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
|
||||
return null;
|
||||
}
|
||||
Account[] allAccounts = accountManager.getAccountsByType(accountType);
|
||||
if (allAccounts == null) {
|
||||
return null;
|
||||
}
|
||||
return allAccounts[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
AccountManagerFuture<Bundle> resultFuture = accountManager.addAccount(accountType, null, null, null, AuthenticatedActivity.this, null, null);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.EventLog;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.WelcomeActivity;
|
||||
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
||||
import fr.free.nrw.commons.contributions.ContributionsContentProvider;
|
||||
|
|
@ -220,7 +222,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
private void performLogin() {
|
||||
String username = usernameEdit.getText().toString();
|
||||
// Because Mediawiki is upercase-first-char-then-case-sensitive :)
|
||||
String canonicalUsername = username.substring(0,1).toUpperCase() + username.substring(1);
|
||||
String canonicalUsername = Utils.capitalize(username.substring(0,1)) + username.substring(1);
|
||||
|
||||
String password = passwordEdit.getText().toString();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import android.text.TextUtils;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.EventLog;
|
||||
|
|
@ -131,7 +132,7 @@ public class Contribution extends Media {
|
|||
|
||||
public String getPageContents() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
|
||||
|
||||
buffer
|
||||
.append("== {{int:filedesc}} ==\n")
|
||||
|
|
|
|||
|
|
@ -49,13 +49,16 @@ public class ModificationsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|||
String authCookie;
|
||||
try {
|
||||
authCookie = AccountManager.get(getContext()).blockingGetAuthToken(account, "", false);
|
||||
} catch (OperationCanceledException e) {
|
||||
} catch (OperationCanceledException | AuthenticatorException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
Log.d("Commons", "Could not authenticate :(");
|
||||
return;
|
||||
} catch (AuthenticatorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if(Utils.isNullOrWhiteSpace(authCookie)) {
|
||||
Log.d("Commons", "Could not authenticate :(");
|
||||
return;
|
||||
}
|
||||
|
||||
MWApi api = CommonsApplication.createMWApi();
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public class SingleUploadFragment extends Fragment {
|
|||
setLicenseSummary(license);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(Prefs.DEFAULT_LICENSE, license);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@
|
|||
android:textStyle="bold"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@android:color/white"
|
||||
android:singleLine="false"/>
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="120dp"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/contributionsFragmentContainer"
|
||||
android:background="#000000"
|
||||
>
|
||||
|
||||
<fragment
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="16dp"
|
||||
android:gravity="center"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:hint="@string/categories_search_text_hint"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<!-- Placeholder. Height gets set at runtime based on container size; the initial value is a hack to keep
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="Title"
|
||||
android:text="@string/media_detail_title"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:paddingBottom="6dp"
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Title of the media"
|
||||
android:text="@string/media_detail_media_title"
|
||||
android:id="@+id/mediaDetailTitle"
|
||||
android:layout_gravity="left|start"
|
||||
android:textColor="@android:color/white"
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Description"
|
||||
android:text="@string/media_detail_description"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Description of the media goes here. This can potentially be fairly long, and will need to wrap across multiple lines. We hope it looks nice though."
|
||||
android:text="@string/media_detail_description_explanation"
|
||||
android:background="#20ffffff"
|
||||
android:id="@+id/mediaDetailDesc"
|
||||
android:textColor="@android:color/white"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollHorizontally="false"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"
|
||||
android:hint="@string/share_title_hint"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
style="?android:textAppearanceSmallInverse"
|
||||
android:textColor="#ffffff"
|
||||
android:background="@color/text_background"
|
||||
tools:text="Overlay"
|
||||
tools:text="@string/placeholder_place_distance"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
android:maxLines="1"
|
||||
android:ellipsize="none"
|
||||
style="?android:textAppearanceMedium"
|
||||
tools:text="Name"
|
||||
tools:text="@string/placeholder_place_name"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
android:ellipsize="none"
|
||||
android:maxLines="4"
|
||||
style="?android:textAppearanceSmall"
|
||||
tools:text="Description"
|
||||
tools:text="@string/placeholder_place_description"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
android:id="@+id/proprietary_x"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/selfie_x"
|
||||
/>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
android:layout_height="120dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_toRightOf="@+id/welcome_wikipedia"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -44,7 +43,6 @@
|
|||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@android:color/white"
|
||||
android:singleLine="false"
|
||||
/>
|
||||
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ Wikimedia Commons an det Wikimedia-Commons-Logo san markintiaken faan\'t Wikimed
|
|||
<string name="no_uploads_yet">Dü heest noch nian bilen huuchschüürd.</string>
|
||||
<string name="menu_retry_upload">Noch ans ferschük</string>
|
||||
<string name="menu_cancel_upload">Ufbreeg</string>
|
||||
<string name="share_license_summary">Detdiar bil feit det lisens %$1 .</string>
|
||||
<string name="share_license_summary">Detdiar bil feit det lisens %1$s</string>
|
||||
<string name="menu_download">Deelloose</string>
|
||||
<string name="preference_license">Lisens</string>
|
||||
<string name="use_previous">Ual tiitel/beskriiwang brük</string>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<string name="upload_completed_notification_title">Ua hoʻouka ʻia ʻo %1$s</string>
|
||||
<string name="upload_completed_notification_text">Kīkē no ka ʻike ʻana o kāu hoʻouka</string>
|
||||
<string name="upload_progress_notification_title_start">Hoʻomaka nei i ka hoʻouka ʻana o %1$s</string>
|
||||
<string name="upload_progress_notification_title_in_progress">Hoʻouka nei ʻo</string>
|
||||
<string name="upload_progress_notification_title_in_progress">Hoʻouka nei ʻo %1$s</string>
|
||||
<string name="upload_progress_notification_title_finishing">Hele a pau ka hoʻouka ʻana o %1$s</string>
|
||||
<string name="upload_failed_notification_title">Ua hāʻule ʻo %1$s i ka hoʻouka ʻana</string>
|
||||
<string name="upload_failed_notification_subtitle">Kīkē no ka ʻike ʻana</string>
|
||||
|
|
|
|||
|
|
@ -154,4 +154,8 @@ Tap this message (or hit back) to skip this step.</string>
|
|||
<string name="file_exists">This file already exists on Commons. Are you sure you want to proceed?</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
<string name="media_detail_title">Title</string>
|
||||
<string name="media_detail_media_title">Title of the media</string>
|
||||
<string name="media_detail_description">Description</string>
|
||||
<string name="media_detail_description_explanation">Description of the media goes here. This can potentially be fairly long, and will need to wrap across multiple lines. We hope it looks nice though.</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue