Skip to content

Commit ff54d03

Browse files
author
Vivek Maskara
authored
Merge branch 'master' into Fixes-commons-app#1198
2 parents 01ad0c8 + e412c9a commit ff54d03

Some content is hidden

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

54 files changed

+1625
-587
lines changed

ISSUE_TEMPLATE.md

+4
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

+6
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

+8
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ dependencies {
4848
compile 'com.facebook.fresco:fresco:1.3.0'
4949
compile 'com.facebook.stetho:stetho:1.5.0'
5050

51+
compile 'com.android.support:multidex:1.0.3'
52+
5153
testCompile 'junit:junit:4.12'
5254
testCompile 'org.robolectric:robolectric:3.7.1'
55+
testCompile "org.robolectric:multidex:3.4.2"
5356

5457
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
5558
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
@@ -94,6 +97,9 @@ dependencies {
9497
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
9598
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
9699
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
100+
101+
compile 'com.borjabravo:readmoretextview:2.1.0'
102+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
97103
}
98104

99105
android {
@@ -149,6 +155,7 @@ android {
149155
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
150156
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
151157
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\""
158+
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.org/wiki/Special:PasswordReset\""
152159
dimension 'tier'
153160
}
154161

@@ -163,6 +170,7 @@ android {
163170
buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\""
164171
buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\""
165172
buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\""
173+
buildConfigField "String", "FORGOT_PASSWORD_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/Special:PasswordReset\""
166174
dimension 'tier'
167175
}
168176
}

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

+5-4
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

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,57 @@
11
package fr.free.nrw.commons;
22

3+
import android.annotation.SuppressLint;
34
import android.content.Intent;
45
import android.net.Uri;
56
import android.os.Bundle;
7+
import android.text.SpannableString;
8+
import android.text.style.UnderlineSpan;
9+
import android.util.Log;
610
import android.support.customtabs.CustomTabsIntent;
711
import android.support.v4.content.ContextCompat;
812
import android.view.View;
913
import android.widget.TextView;
14+
import android.widget.Toast;
1015

1116
import butterknife.BindView;
1217
import butterknife.ButterKnife;
1318
import butterknife.OnClick;
1419
import fr.free.nrw.commons.theme.NavigationBaseActivity;
1520
import fr.free.nrw.commons.ui.widget.HtmlTextView;
1621

22+
import static android.widget.Toast.LENGTH_SHORT;
23+
1724
/**
1825
* Represents about screen of this app
1926
*/
2027
public class AboutActivity extends NavigationBaseActivity {
2128
@BindView(R.id.about_version) TextView versionText;
2229
@BindView(R.id.about_license) HtmlTextView aboutLicenseText;
30+
@BindView(R.id.about_faq) TextView faqText;
2331

2432
/**
2533
* This method helps in the creation About screen
2634
*
2735
* @param savedInstanceState Data bundle
2836
*/
2937
@Override
38+
@SuppressLint("StringFormatInvalid")
3039
public void onCreate(Bundle savedInstanceState) {
3140
super.onCreate(savedInstanceState);
3241
setContentView(R.layout.activity_about);
3342

3443
ButterKnife.bind(this);
35-
3644
String aboutText = getString(R.string.about_license);
3745
aboutLicenseText.setHtmlText(aboutText);
38-
46+
SpannableString content = new SpannableString(getString(R.string.about_faq));
47+
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
48+
faqText.setText(content);
3949
versionText.setText(BuildConfig.VERSION_NAME);
4050
initDrawer();
4151
}
4252

4353
@OnClick(R.id.facebook_launch_icon)
4454
public void launchFacebook(View view) {
45-
4655
Intent intent;
4756
try {
4857
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + "1921335171459985"));
@@ -55,14 +64,19 @@ public void launchFacebook(View view) {
5564

5665
@OnClick(R.id.github_launch_icon)
5766
public void launchGithub(View view) {
58-
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
67+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons\\"));
5968
}
6069

6170
@OnClick(R.id.website_launch_icon)
6271
public void launchWebsite(View view) {
6372
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
6473
}
6574

75+
@OnClick(R.id.about_rate_us)
76+
public void launchRatings(View view){
77+
Utils.rateApp(this);
78+
}
79+
6680
@OnClick(R.id.about_credits)
6781
public void launchCredits(View view) {
6882
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\"));
@@ -73,5 +87,8 @@ public void launchPrivacyPolicy(View view) {
7387
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\"));
7488
}
7589

76-
77-
}
90+
@OnClick(R.id.about_faq)
91+
public void launchFrequentlyAskedQuesions(View view) {
92+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions\\"));
93+
}
94+
}

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

+9-5
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;
@@ -49,7 +50,7 @@ public class CommonsApplication extends Application {
4950
@Inject @Named("application_preferences") SharedPreferences applicationPrefs;
5051
@Inject @Named("prefs") SharedPreferences otherPrefs;
5152

52-
public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using Android Commons app";
53+
public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using [[COM:MOA|Commons Mobile App]]";
5354

5455
public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com";
5556

@@ -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
}

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

+20-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.support.annotation.NonNull;
88
import android.support.customtabs.CustomTabsIntent;
99
import android.support.v4.content.ContextCompat;
10+
import android.widget.Toast;
1011

1112
import org.apache.commons.codec.binary.Hex;
1213
import org.apache.commons.codec.digest.DigestUtils;
@@ -15,7 +16,6 @@
1516
import java.io.IOException;
1617
import java.io.InputStreamReader;
1718
import java.io.UnsupportedEncodingException;
18-
import java.net.URL;
1919
import java.net.URLEncoder;
2020
import java.util.Locale;
2121
import java.util.regex.Matcher;
@@ -24,6 +24,8 @@
2424
import fr.free.nrw.commons.settings.Prefs;
2525
import timber.log.Timber;
2626

27+
import static android.widget.Toast.LENGTH_SHORT;
28+
2729
public class Utils {
2830

2931
/**
@@ -165,7 +167,24 @@ public static String getAppLogs() {
165167
return stringBuilder.toString();
166168
}
167169

170+
public static void rateApp(Context context) {
171+
final String appPackageName = BuildConfig.class.getPackage().getName();
172+
try {
173+
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
174+
}
175+
catch (android.content.ActivityNotFoundException anfe) {
176+
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
177+
}
178+
}
179+
168180
public static void handleWebUrl(Context context,Uri url){
181+
Intent browserIntent = new Intent(Intent.ACTION_VIEW, url);
182+
if (browserIntent.resolveActivity(context.getPackageManager()) == null) {
183+
Toast toast = Toast.makeText(context, context.getString(R.string.no_web_browser), LENGTH_SHORT);
184+
toast.show();
185+
return;
186+
}
187+
169188
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
170189
builder.setToolbarColor(ContextCompat.getColor(context, R.color.primaryColor));
171190
builder.setSecondaryToolbarColor(ContextCompat.getColor(context, R.color.primaryDarkColor));

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.view.LayoutInflater;
66
import android.view.View;
77
import android.view.ViewGroup;
8+
import android.widget.TextView;
89

910
import butterknife.ButterKnife;
1011
import butterknife.OnClick;
@@ -54,10 +55,18 @@ public boolean isViewFromObject(View view, Object object) {
5455
public Object instantiateItem(ViewGroup container, int position) {
5556
LayoutInflater inflater = LayoutInflater.from(container.getContext());
5657
ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false);
57-
58-
if (position == PAGE_FINAL) {
58+
if( BuildConfig.FLAVOR == "beta"){
59+
TextView textView = (TextView) layout.findViewById(R.id.welcomeYesButton);
60+
if( textView.getVisibility() != View.VISIBLE){
61+
textView.setVisibility(View.VISIBLE);
62+
}
5963
ViewHolder holder = new ViewHolder(layout);
6064
layout.setTag(holder);
65+
} else {
66+
if (position == PAGE_FINAL) {
67+
ViewHolder holder = new ViewHolder(layout);
68+
layout.setTag(holder);
69+
}
6170
}
6271
container.addView(layout);
6372
return layout;
@@ -92,5 +101,6 @@ void onClicked() {
92101
callback.onYesClicked();
93102
}
94103
}
104+
95105
}
96106
}

0 commit comments

Comments
 (0)