Skip to content

Commit ad97401

Browse files
author
Suchit Kar
committed
Merge branch 'master' of https://github.com/commons-app/apps-android-commons into category-alignment
2 parents 26fc6cf + 5c51e2e commit ad97401

File tree

117 files changed

+1999
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1999
-630
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ app/gradle/wrapper/gradle-wrapper.jar
2727
app/gradlew
2828
app/gradlew.bat
2929
app/gradle/wrapper/gradle-wrapper.properties
30+
31+
#related to OpenCV
32+
/libraries/opencv/build
33+
app/src/main/jniLibs
34+
#Below removes all the HTML files related to OpenCV documentation. The documentation can be otherwise found at:
35+
#https://docs.opencv.org/3.3.0/
36+
/libraries/opencv/javadoc/

PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Description
2+
3+
Fixes #{GitHub issue number}
4+
5+
{Describe the changes made and why they were made.}
6+
7+
## Screenshots showing what changed
8+
9+
{Only for user interface changes, otherwise remove this section. See [how to take a screenshot](https://android.stackexchange.com/questions/1759/how-to-take-a-screenshot-with-an-android-device)}

app/build.gradle

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ dependencies {
1818
implementation 'com.google.code.gson:gson:2.8.1'
1919
implementation 'com.jakewharton.timber:timber:4.5.1'
2020
implementation 'info.debatty:java-string-similarity:0.24'
21-
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.1@aar'){
21+
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.4.1@aar'){
2222
transitive=true
2323
}
2424

2525

2626
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
2727
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
2828
implementation "com.android.support:design:$SUPPORT_LIB_VERSION"
29+
implementation "com.android.support:customtabs:$SUPPORT_LIB_VERSION"
2930

3031
implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION"
3132

@@ -38,6 +39,26 @@ dependencies {
3839
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
3940
// Because RxAndroid releases are few and far between, it is recommended you also
4041
// explicitly depend on RxJava's latest version for bug fixes and new features.
42+
compile 'io.reactivex.rxjava2:rxjava:2.1.2'
43+
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
44+
compile 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
45+
compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
46+
compile 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
47+
48+
compile 'com.facebook.fresco:fresco:1.3.0'
49+
compile 'com.facebook.stetho:stetho:1.5.0'
50+
51+
testCompile 'junit:junit:4.12'
52+
testCompile 'org.robolectric:robolectric:3.7.1'
53+
54+
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
55+
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
56+
androidTestCompile "com.android.support:support-annotations:${project.SUPPORT_LIB_VERSION}"
57+
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
58+
59+
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
60+
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
61+
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
4162
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
4263
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
4364
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
@@ -57,7 +78,7 @@ dependencies {
5778
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
5879

5980
testImplementation 'junit:junit:4.12'
60-
testImplementation 'org.robolectric:robolectric:3.4'
81+
testImplementation 'org.robolectric:robolectric:3.7.1'
6182
testImplementation 'org.mockito:mockito-all:1.10.19'
6283

6384
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
@@ -91,6 +112,8 @@ android {
91112
targetSdkVersion project.targetSdkVersion
92113
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
93114
vectorDrawables.useSupportLibrary = true
115+
116+
multiDexEnabled true
94117
}
95118

96119
sourceSets {

app/src/main/java/fr/free/nrw/commons/AboutActivity.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.content.Intent;
44
import android.net.Uri;
55
import android.os.Bundle;
6+
import android.support.customtabs.CustomTabsIntent;
7+
import android.support.v4.content.ContextCompat;
68
import android.view.View;
79
import android.widget.TextView;
810

@@ -31,7 +33,7 @@ public void onCreate(Bundle savedInstanceState) {
3133

3234
ButterKnife.bind(this);
3335

34-
String aboutText = getString(R.string.about_license, getString(R.string.trademarked_name));
36+
String aboutText = getString(R.string.about_license);
3537
aboutLicenseText.setHtmlText(aboutText);
3638

3739
versionText.setText(BuildConfig.VERSION_NAME);
@@ -47,22 +49,29 @@ public void launchFacebook(View view) {
4749
intent.setPackage("com.facebook.katana");
4850
startActivity(intent);
4951
} catch (Exception e) {
50-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + "1921335171459985")));
52+
Utils.handleWebUrl(this,Uri.parse("https://www.facebook.com/" + "1921335171459985"));
5153
}
52-
5354
}
5455

5556
@OnClick(R.id.github_launch_icon)
5657
public void launchGithub(View view) {
57-
58-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/commons-app/apps-android-commons\\"));
59-
startActivity(browserIntent);
58+
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
6059
}
6160

6261
@OnClick(R.id.website_launch_icon)
6362
public void launchWebsite(View view) {
63+
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
64+
}
6465

65-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://commons-app.github.io/\\"));
66-
startActivity(browserIntent);
66+
@OnClick(R.id.about_credits)
67+
public void launchCredits(View view) {
68+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\"));
6769
}
70+
71+
@OnClick(R.id.about_privacy_policy)
72+
public void launchPrivacyPolicy(View view) {
73+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\"));
74+
}
75+
76+
6877
}

app/src/main/java/fr/free/nrw/commons/MediaDataExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private Map<String, String> getMultilingualText(Node parentNode) throws IOExcept
283283
/**
284284
* Take our metadata and inject it into a live Media object.
285285
* Media object might contain stale or cached data, or emptiness.
286-
* @param media
286+
* @param media Media object to inject into
287287
*/
288288
public void fill(Media media) {
289289
if (!fetched) {

app/src/main/java/fr/free/nrw/commons/Utils.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package fr.free.nrw.commons;
22

33
import android.content.Context;
4+
import android.content.Intent;
5+
import android.net.Uri;
46
import android.preference.PreferenceManager;
57
import android.support.annotation.NonNull;
8+
import android.support.customtabs.CustomTabsIntent;
9+
import android.support.v4.content.ContextCompat;
610

711
import org.apache.commons.codec.binary.Hex;
812
import org.apache.commons.codec.digest.DigestUtils;
@@ -11,6 +15,7 @@
1115
import java.io.IOException;
1216
import java.io.InputStreamReader;
1317
import java.io.UnsupportedEncodingException;
18+
import java.net.URL;
1419
import java.net.URLEncoder;
1520
import java.util.Locale;
1621
import java.util.regex.Matcher;
@@ -65,7 +70,7 @@ public static String urlEncode(String url) {
6570
/**
6671
* Capitalizes the first character of a string.
6772
*
68-
* @param string
73+
* @param string String to alter
6974
* @return string with capitalized first character
7075
*/
7176
public static String capitalize(String string) {
@@ -159,4 +164,15 @@ public static String getAppLogs() {
159164

160165
return stringBuilder.toString();
161166
}
167+
168+
public static void handleWebUrl(Context context,Uri url){
169+
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
170+
builder.setToolbarColor(ContextCompat.getColor(context, R.color.primaryColor));
171+
builder.setSecondaryToolbarColor(ContextCompat.getColor(context, R.color.primaryDarkColor));
172+
builder.setExitAnimations(context, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
173+
CustomTabsIntent customTabsIntent = builder.build();
174+
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
175+
customTabsIntent.launchUrl(context, url);
176+
}
177+
162178
}

app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.accounts.AccountAuthenticatorActivity;
55
import android.accounts.AccountAuthenticatorResponse;
66
import android.accounts.AccountManager;
7+
import android.app.Activity;
78
import android.app.ProgressDialog;
89
import android.content.Intent;
910
import android.content.SharedPreferences;
@@ -17,10 +18,12 @@
1718
import android.support.v7.app.AppCompatDelegate;
1819
import android.text.Editable;
1920
import android.text.TextWatcher;
21+
import android.util.Log;
2022
import android.view.MenuInflater;
2123
import android.view.MenuItem;
2224
import android.view.View;
2325
import android.view.ViewGroup;
26+
import android.view.inputmethod.InputMethodManager;
2427
import android.widget.Button;
2528
import android.widget.EditText;
2629
import android.widget.TextView;
@@ -32,7 +35,6 @@
3235

3336
import butterknife.BindView;
3437
import butterknife.ButterKnife;
35-
import dagger.android.AndroidInjection;
3638
import fr.free.nrw.commons.BuildConfig;
3739
import fr.free.nrw.commons.PageTitle;
3840
import fr.free.nrw.commons.R;
@@ -70,6 +72,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
7072
@BindView(R.id.loginTwoFactor) EditText twoFactorEdit;
7173
@BindView(R.id.error_message_container) ViewGroup errorMessageContainer;
7274
@BindView(R.id.error_message) TextView errorMessage;
75+
@BindView(R.id.login_credentials) TextView loginCredentials;
7376
@BindView(R.id.two_factor_container)TextInputLayout twoFactorContainer;
7477
ProgressDialog progressDialog;
7578
private AppCompatDelegate delegate;
@@ -92,14 +95,39 @@ public void onCreate(Bundle savedInstanceState) {
9295
ButterKnife.bind(this);
9396

9497
usernameEdit.addTextChangedListener(textWatcher);
98+
usernameEdit.setOnFocusChangeListener((v, hasFocus) -> {
99+
if (!hasFocus) {
100+
hideKeyboard(v);
101+
}
102+
});
103+
95104
passwordEdit.addTextChangedListener(textWatcher);
105+
passwordEdit.setOnFocusChangeListener((v, hasFocus) -> {
106+
if (!hasFocus) {
107+
hideKeyboard(v);
108+
}
109+
});
110+
96111
twoFactorEdit.addTextChangedListener(textWatcher);
97112
passwordEdit.setOnEditorActionListener(newLoginInputActionListener());
98113

99114
loginButton.setOnClickListener(view -> performLogin());
100115
signupButton.setOnClickListener(view -> signUp());
116+
117+
if(BuildConfig.FLAVOR == "beta"){
118+
loginCredentials.setText(getString(R.string.login_credential));
119+
} else {
120+
loginCredentials.setVisibility(View.GONE);
121+
}
101122
}
102123

124+
125+
public void hideKeyboard(View view) {
126+
InputMethodManager inputMethodManager =(InputMethodManager)this.getSystemService(Activity.INPUT_METHOD_SERVICE);
127+
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
128+
}
129+
130+
103131
@Override
104132
protected void onPostCreate(Bundle savedInstanceState) {
105133
super.onPostCreate(savedInstanceState);

app/src/main/java/fr/free/nrw/commons/auth/LoginTask.java

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)