Skip to content

Commit cb6d859

Browse files
committed
Merge remote-tracking branch 'refs/remotes/commons-app/master'
2 parents 89245a6 + bbf159b commit cb6d859

File tree

202 files changed

+5329
-1473
lines changed

Some content is hidden

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

202 files changed

+5329
-1473
lines changed

ISSUE_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ You can find this information by going to the navigation drawer in the app and t
3333
**Screen-shots:**
3434

3535
Can be created by pressing the Volume Down and Power Button at the same time on Android 4.0 and higher.
36+
37+
**Would you like to work on the issue?**
38+
39+
Please let us know whether you want to fix the issue by yourself. If not, anyone can get the issue assigned to them.

PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Fixes #{GitHub issue number}
44

55
{Describe the changes made and why they were made.}
66

7+
## Tests performed
8+
9+
Tested on {API level & name of device/emulator}, with {build variant, e.g. ProdDebug}.
10+
11+
{Please test your PR at least once before submitting.}
12+
713
## Screenshots showing what changed
814

915
{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: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,10 @@ dependencies {
3939
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
4040
// Because RxAndroid releases are few and far between, it is recommended you also
4141
// 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'
42+
implementation 'com.android.support:multidex:1.0.3'
43+
44+
testImplementation "org.robolectric:multidex:3.4.2"
45+
6246
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
6347
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
6448
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
@@ -94,6 +78,9 @@ dependencies {
9478
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
9579
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
9680
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
81+
82+
implementation 'com.borjabravo:readmoretextview:2.1.0'
83+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
9784
}
9885

9986
android {
@@ -116,6 +103,12 @@ android {
116103
multiDexEnabled true
117104
}
118105

106+
testOptions {
107+
unitTests.all {
108+
jvmArgs '-noverify'
109+
}
110+
}
111+
119112
sourceSets {
120113
// use kotlin only in tests (for now)
121114
test.java.srcDirs += 'src/test/kotlin'
@@ -144,11 +137,13 @@ android {
144137
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
145138
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.wikimedia.org/wikipedia/commons\""
146139
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.org/wiki/\""
140+
buildConfigField "String", "COMMONS_URL", "\"https://commons.wikimedia.org\""
147141
buildConfigField "String", "MOBILE_HOME_URL", "\"https://commons.m.wikimedia.org/wiki/\""
148142
buildConfigField "String", "EVENTLOG_URL", "\"https://www.wikimedia.org/beacon/event\""
149143
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
150144
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
151145
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\""
146+
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.org/wiki/Special:PasswordReset\""
152147
dimension 'tier'
153148
}
154149

@@ -158,11 +153,13 @@ android {
158153
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
159154
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.beta.wmflabs.org/wikipedia/commons\""
160155
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/\""
156+
buildConfigField "String", "COMMONS_URL", "\"https://commons.wikimedia.beta.wmflabs.org\""
161157
buildConfigField "String", "MOBILE_HOME_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/wiki/\""
162158
buildConfigField "String", "EVENTLOG_URL", "\"https://commons.wikimedia.beta.wmflabs.org/beacon/event\""
163159
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
164160
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
165161
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\""
162+
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/Special:PasswordReset\""
166163
dimension 'tier'
167164
}
168165
}

app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.support.test.espresso.Espresso;
66
import android.support.test.espresso.action.ViewActions;
77
import android.support.test.espresso.assertion.ViewAssertions;
8+
import android.support.test.espresso.matcher.PreferenceMatchers;
89
import android.support.test.espresso.matcher.ViewMatchers;
910
import android.support.test.filters.LargeTest;
1011
import android.support.test.rule.ActivityTestRule;
@@ -61,7 +62,7 @@ protected void afterActivityFinished() {
6162
@Test
6263
public void oneLicenseIsChecked() {
6364
// click "License" (the first item)
64-
Espresso.onData(Matchers.anything())
65+
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
6566
.inAdapterView(ViewMatchers.withId(android.R.id.list))
6667
.atPosition(0)
6768
.perform(ViewActions.click());
@@ -74,7 +75,7 @@ public void oneLicenseIsChecked() {
7475
@Test
7576
public void afterClickingCcby4ItWillStay() {
7677
// click "License" (the first item)
77-
Espresso.onData(Matchers.anything())
78+
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
7879
.inAdapterView(ViewMatchers.withId(android.R.id.list))
7980
.atPosition(0)
8081
.perform(ViewActions.click());
@@ -85,7 +86,7 @@ public void afterClickingCcby4ItWillStay() {
8586
).perform(ViewActions.click());
8687

8788
// click "License" (the first item)
88-
Espresso.onData(Matchers.anything())
89+
Espresso.onData(PreferenceMatchers.withKey("defaultLicense"))
8990
.inAdapterView(ViewMatchers.withId(android.R.id.list))
9091
.atPosition(0)
9192
.perform(ViewActions.click());
@@ -96,4 +97,4 @@ public void afterClickingCcby4ItWillStay() {
9697
ViewMatchers.withText(R.string.license_name_cc_by_four)
9798
));
9899
}
99-
}
100+
}

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

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,72 @@
11
package fr.free.nrw.commons;
22

3+
import android.annotation.SuppressLint;
4+
import android.app.AlertDialog;
5+
import android.content.DialogInterface;
36
import android.content.Intent;
47
import android.net.Uri;
58
import android.os.Bundle;
9+
import android.text.SpannableString;
10+
import android.text.style.UnderlineSpan;
11+
import android.util.Log;
612
import android.support.customtabs.CustomTabsIntent;
713
import android.support.v4.content.ContextCompat;
814
import android.view.View;
15+
import android.widget.ArrayAdapter;
16+
import android.widget.LinearLayout;
17+
import android.widget.Spinner;
918
import android.widget.TextView;
19+
import android.widget.Toast;
1020

1121
import butterknife.BindView;
1222
import butterknife.ButterKnife;
1323
import butterknife.OnClick;
1424
import fr.free.nrw.commons.theme.NavigationBaseActivity;
1525
import fr.free.nrw.commons.ui.widget.HtmlTextView;
1626

27+
import static android.widget.Toast.LENGTH_SHORT;
28+
1729
/**
1830
* Represents about screen of this app
1931
*/
2032
public class AboutActivity extends NavigationBaseActivity {
2133
@BindView(R.id.about_version) TextView versionText;
2234
@BindView(R.id.about_license) HtmlTextView aboutLicenseText;
35+
@BindView(R.id.about_faq) TextView faqText;
36+
37+
String language[] = { "Kazakh", "Afrikaans", "Arabic", "Bengali", "Asturianu", "azərbaycanca", "Bikol Central",
38+
"Bulgarain", "বাংলা", "Bosanski", "Brezhoneg","català","کوردی", " čeština", " kaszëbsczi", "Cymraeg", "dansk", "Deutsch"
39+
,"Zazaki", "डोटेली","Ελληνικά","euskara","español","فارسی","suomi", "français" ,"Nordfriisk", "galego", "Hawaiʻi"
40+
,"हिन्दी","Hunsrik","עברית","hornjoserbsce","magyar","interlingua","Bahasa Indonesia", "íslenska","Italian","japanese",
41+
"Basa Jawa", "ქართული", " ភាសាខ្មែរ","ಕನ್ನಡ", "한국어","къарачай-малкъар","Кыргызча", "latina", "Lëtzebuergesch", "lietuvių",
42+
"latviešu", "Malagasy", "македонски"," മലയാളം","монгол","मराठी","Bahasa Melayu","Malti", "नेपाली", "norsk bokmål",
43+
" Nederlands","occitan","ଓଡ଼ିଆ","ਪੰਜਾਬੀ","polsk","Piemontèis","پښتو","português","română","русский"," سنڌي", " සිංහල",
44+
"slovenčina"," سرائیکی", "svenska", "தமிழ்", "ತುಳು"," తెలుగు"," ไทย", "Türkçe","українська", "اردو", "Tiếng Việt",
45+
" მარგალური","ייִדיש",};
2346

2447
/**
2548
* This method helps in the creation About screen
2649
*
2750
* @param savedInstanceState Data bundle
2851
*/
2952
@Override
53+
@SuppressLint("StringFormatInvalid")
3054
public void onCreate(Bundle savedInstanceState) {
3155
super.onCreate(savedInstanceState);
3256
setContentView(R.layout.activity_about);
3357

3458
ButterKnife.bind(this);
35-
3659
String aboutText = getString(R.string.about_license);
3760
aboutLicenseText.setHtmlText(aboutText);
38-
61+
SpannableString content = new SpannableString(getString(R.string.about_faq));
62+
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
63+
faqText.setText(content);
3964
versionText.setText(BuildConfig.VERSION_NAME);
4065
initDrawer();
4166
}
4267

4368
@OnClick(R.id.facebook_launch_icon)
4469
public void launchFacebook(View view) {
45-
4670
Intent intent;
4771
try {
4872
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + "1921335171459985"));
@@ -55,14 +79,19 @@ public void launchFacebook(View view) {
5579

5680
@OnClick(R.id.github_launch_icon)
5781
public void launchGithub(View view) {
58-
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
82+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons\\"));
5983
}
6084

6185
@OnClick(R.id.website_launch_icon)
6286
public void launchWebsite(View view) {
6387
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
6488
}
6589

90+
@OnClick(R.id.about_rate_us)
91+
public void launchRatings(View view){
92+
Utils.rateApp(this);
93+
}
94+
6695
@OnClick(R.id.about_credits)
6796
public void launchCredits(View view) {
6897
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\"));
@@ -73,4 +102,43 @@ public void launchPrivacyPolicy(View view) {
73102
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\"));
74103
}
75104

76-
}
105+
106+
@OnClick(R.id.about_faq)
107+
public void launchFrequentlyAskedQuesions(View view) {
108+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions\\"));
109+
}
110+
111+
@OnClick(R.id.about_translate)
112+
public void launchTranslate(View view) {
113+
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<String>(AboutActivity.this,
114+
android.R.layout.simple_spinner_item, language);
115+
final Spinner spinner = new Spinner(AboutActivity.this);
116+
spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
117+
spinner.setAdapter(languageAdapter);
118+
spinner.setGravity(17);
119+
120+
AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this);
121+
builder.setView(spinner);
122+
builder.setTitle(R.string.about_translate_title)
123+
.setMessage(R.string.about_translate_message)
124+
.setPositiveButton(R.string.about_translate_proceed, new DialogInterface.OnClickListener() {
125+
@Override
126+
public void onClick(DialogInterface dialog, int which) {
127+
String languageSelected = spinner.getSelectedItem().toString();
128+
TokensTranslations tokensTranslations = new TokensTranslations();
129+
tokensTranslations.initailize();
130+
String token = tokensTranslations.getTranslationToken(languageSelected);
131+
Utils.handleWebUrl(AboutActivity.this,Uri.parse("https://translatewiki.net/w/i.php?title=Special:Translate&language="+token+"&group=commons-android-strings&filter=%21translated&action=translate ?"));
132+
}
133+
});
134+
builder.setNegativeButton(R.string.about_translate_cancel, new DialogInterface.OnClickListener() {
135+
@Override
136+
public void onClick(DialogInterface dialog, int which) {
137+
finish();
138+
}
139+
});
140+
builder.create().show();
141+
142+
}
143+
144+
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import android.content.Context;
55
import android.content.SharedPreferences;
66
import android.database.sqlite.SQLiteDatabase;
7+
import android.support.multidex.MultiDexApplication;
78

89
import com.facebook.drawee.backends.pipeline.Fresco;
10+
import com.facebook.imagepipeline.core.ImagePipelineConfig;
911
import com.facebook.stetho.Stetho;
1012
import com.squareup.leakcanary.LeakCanary;
1113
import com.squareup.leakcanary.RefWatcher;
@@ -24,7 +26,6 @@
2426
import fr.free.nrw.commons.contributions.ContributionDao;
2527
import fr.free.nrw.commons.data.DBOpenHelper;
2628
import fr.free.nrw.commons.di.ApplicationlessInjection;
27-
import fr.free.nrw.commons.di.CommonsApplicationComponent;
2829
import fr.free.nrw.commons.modifications.ModifierSequenceDao;
2930
import fr.free.nrw.commons.utils.FileUtils;
3031
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -40,7 +41,7 @@
4041
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
4142
resDialogOkToast = R.string.crash_dialog_ok_toast
4243
)
43-
public class CommonsApplication extends Application {
44+
public class CommonsApplication extends MultiDexApplication {
4445

4546
@Inject SessionManager sessionManager;
4647
@Inject DBOpenHelper dbOpenHelper;
@@ -71,8 +72,11 @@ public void onCreate() {
7172
.getInstance(this)
7273
.getCommonsApplicationComponent()
7374
.inject(this);
74-
75-
Fresco.initialize(this);
75+
// Set DownsampleEnabled to True to downsample the image in case it's heavy
76+
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
77+
.setDownsampleEnabled(true)
78+
.build();
79+
Fresco.initialize(this,config);
7680
if (setupLeakCanary() == RefWatcher.DISABLED) {
7781
return;
7882
}

0 commit comments

Comments
 (0)