mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #421 from maskaravivek/fixLintIssues
Fix lint issues
This commit is contained in:
commit
3a813dd302
12 changed files with 46 additions and 27 deletions
|
|
@ -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,11 +304,11 @@ 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;
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue