Skip to content

Commit 7ee6691

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c547c42 + 3e5a663 commit 7ee6691

File tree

166 files changed

+8254
-375
lines changed

Some content is hidden

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

166 files changed

+8254
-375
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ The body should provide a meaningful commit message.
3232
1. Write tests for your code (if possible)
3333

3434
1. Make sure the Wiki pages don't become stale by updating them (if needed)
35+
36+
### Further reading
37+
38+
* [Importance of good commit messages](https://blog.oozou.com/commit-messages-matter-60309983c227?gi=c550a10d0f67)

app/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ dependencies {
2121
implementation 'com.jakewharton.timber:timber:4.5.1'
2222
implementation 'info.debatty:java-string-similarity:0.24'
2323
implementation 'com.borjabravo:readmoretextview:2.1.0'
24-
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
24+
25+
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
2526
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') {
2627
transitive = true
2728
}
2829
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
30+
//noinspection GradleCompatible
2931
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
3032
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
3133
implementation "com.android.support:design:$SUPPORT_LIB_VERSION"
@@ -58,6 +60,7 @@ dependencies {
5860
testImplementation 'org.robolectric:robolectric:3.7.1'
5961
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
6062
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
63+
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
6164

6265
implementation 'com.caverock:androidsvg:1.2.1'
6366
implementation 'com.github.bumptech.glide:glide:4.7.1'
@@ -73,6 +76,9 @@ dependencies {
7376
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY"
7477
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
7578
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
79+
80+
implementation 'com.borjabravo:readmoretextview:2.1.0'
81+
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
7682
}
7783

7884
android {

app/src/main/AndroidManifest.xml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
23
package="fr.free.nrw.commons">
34

@@ -17,6 +18,7 @@
1718
<uses-permission android:name="android.permission.READ_LOGS"/>
1819
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
1920

21+
2022
<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
2123
<uses-feature android:name="android.hardware.location.gps" />
2224

@@ -35,6 +37,7 @@
3537
<activity android:name=".auth.LoginActivity">
3638
<intent-filter>
3739
<category android:name="android.intent.category.LAUNCHER" />
40+
3841
<action android:name="android.intent.action.MAIN" />
3942
</intent-filter>
4043
</activity>
@@ -45,7 +48,7 @@
4548
android:name=".upload.ShareActivity"
4649
android:icon="@drawable/ic_launcher"
4750
android:label="@string/app_name">
48-
<intent-filter>
51+
<intent-filter android:label="@string/intent_share_upload_label">
4952
<action android:name="android.intent.action.SEND" />
5053
<category android:name="android.intent.category.DEFAULT" />
5154
<data android:mimeType="image/*" />
@@ -57,7 +60,7 @@
5760
android:name=".upload.MultipleShareActivity"
5861
android:icon="@drawable/ic_launcher"
5962
android:label="@string/app_name">
60-
<intent-filter>
63+
<intent-filter android:label="@string/intent_share_upload_label">
6164
<action android:name="android.intent.action.SEND_MULTIPLE" />
6265
<category android:name="android.intent.category.DEFAULT" />
6366
<data android:mimeType="image/*" />
@@ -92,21 +95,40 @@
9295
android:name=".notification.NotificationActivity"
9396
android:label="@string/navigation_item_notification" />
9497

98+
<activity android:name=".quiz.QuizActivity"
99+
android:label="@string/quiz"/>
100+
101+
<activity android:name=".quiz.QuizResultActivity"
102+
android:label="@string/result"/>
103+
95104
<activity
96105
android:name=".category.CategoryImagesActivity"
97106
android:label="@string/title_activity_featured_images"
98107
android:parentActivityName=".contributions.ContributionsActivity" />
99108

100-
<service android:name=".upload.UploadService" />
109+
<activity
110+
android:name=".category.CategoryDetailsActivity"
111+
android:label="@string/title_activity_featured_images"
112+
android:parentActivityName=".contributions.ContributionsActivity" />
101113

114+
<activity
115+
android:name=".explore.SearchActivity"
116+
android:label="@string/title_activity_search"
117+
android:parentActivityName=".contributions.ContributionsActivity"
118+
/>
119+
120+
<activity
121+
android:name=".achievements.AchievementsActivity"
122+
android:label="@string/Achievements" />
123+
124+
<service android:name=".upload.UploadService" />
102125
<service
103126
android:name=".auth.WikiAccountAuthenticatorService"
104127
android:exported="true"
105128
android:process=":auth">
106129
<intent-filter>
107130
<action android:name="android.accounts.AccountAuthenticator" />
108131
</intent-filter>
109-
110132
<meta-data
111133
android:name="android.accounts.AccountAuthenticator"
112134
android:resource="@xml/authenticator" />
@@ -165,6 +187,13 @@
165187
android:label="@string/provider_categories"
166188
android:syncable="false" />
167189

190+
<provider
191+
android:name=".explore.recentsearches.RecentSearchesContentProvider"
192+
android:authorities="fr.free.nrw.commons.explore.recentsearches.contentprovider"
193+
android:exported="false"
194+
android:label="@string/provider_searches"
195+
android:syncable="false" />
196+
168197
<receiver android:name=".widget.PicOfDayAppWidget">
169198
<intent-filter>
170199
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@@ -177,4 +206,4 @@
177206

178207
</application>
179208

180-
</manifest>
209+
</manifest>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import android.net.Uri;
44
import android.os.Parcel;
55
import android.os.Parcelable;
6+
import android.support.annotation.NonNull;
67
import android.support.annotation.Nullable;
78

89
import java.util.ArrayList;
10+
import java.util.Collection;
911
import java.util.Date;
1012
import java.util.HashMap;
13+
import java.util.Iterator;
1114
import java.util.List;
1215
import java.util.Map;
16+
import java.util.Set;
1317
import java.util.regex.Matcher;
1418
import java.util.regex.Pattern;
1519

@@ -356,12 +360,8 @@ public void setCategories(List<String> categories) {
356360
* @param descriptions Media descriptions
357361
*/
358362
void setDescriptions(Map<String, String> descriptions) {
359-
for (String key : this.descriptions.keySet()) {
360-
this.descriptions.remove(key);
361-
}
362-
for (String key : descriptions.keySet()) {
363-
this.descriptions.put(key, descriptions.get(key));
364-
}
363+
this.descriptions.clear();
364+
this.descriptions.putAll(descriptions);
365365
}
366366

367367
/**

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ public void setMedia(Media media) {
5151
return;
5252
}
5353

54-
if (thumbnailUrlCache.get(media.getFilename()) != null) {
55-
setImageUrl(thumbnailUrlCache.get(media.getFilename()));
56-
} else {
57-
setImageUrl(null);
54+
if(media.getFilename() != null) {
55+
if (thumbnailUrlCache.get(media.getFilename()) != null) {
56+
setImageUrl(thumbnailUrlCache.get(media.getFilename()));
57+
} else {
58+
setImageUrl(null);
59+
currentThumbnailTask = new ThumbnailFetchTask(media, mwApi);
60+
currentThumbnailTask.execute(media.getFilename());
61+
}
62+
} else { // local image
63+
setImageUrl(media.getLocalUri().toString());
5864
currentThumbnailTask = new ThumbnailFetchTask(media, mwApi);
5965
currentThumbnailTask.execute(media.getFilename());
6066
}

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import android.content.Context;
44
import android.content.Intent;
5+
import android.graphics.Bitmap;
56
import android.net.Uri;
67
import android.preference.PreferenceManager;
78
import android.support.annotation.NonNull;
89
import android.support.customtabs.CustomTabsIntent;
910
import android.support.v4.content.ContextCompat;
11+
import android.view.View;
1012
import android.widget.Toast;
1113

1214
import org.apache.commons.codec.binary.Hex;
@@ -76,7 +78,11 @@ public static String urlEncode(String url) {
7678
* @return string with capitalized first character
7779
*/
7880
public static String capitalize(String string) {
79-
return string.substring(0, 1).toUpperCase(Locale.getDefault()) + string.substring(1);
81+
if(string.length() > 0) {
82+
return string.substring(0, 1).toUpperCase(Locale.getDefault()) + string.substring(1);
83+
} else {
84+
return string;
85+
}
8086
}
8187

8288
/**
@@ -146,7 +152,7 @@ public static String getAppLogs() {
146152
StringBuilder stringBuilder = new StringBuilder();
147153

148154
try {
149-
String[] command = new String[] {"logcat","-d","-v","threadtime"};
155+
String[] command = new String[]{"logcat","-d","-v","threadtime"};
150156

151157
Process process = Runtime.getRuntime().exec(command);
152158

@@ -195,4 +201,18 @@ public static void handleWebUrl(Context context, Uri url) {
195201
customTabsIntent.launchUrl(context, url);
196202
}
197203

204+
/**
205+
* To take screenshot of the screen and return it in Bitmap format
206+
*
207+
* @param view
208+
* @return
209+
*/
210+
public static Bitmap getScreenShot(View view) {
211+
View screenView = view.getRootView();
212+
screenView.setDrawingCacheEnabled(true);
213+
Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
214+
screenView.setDrawingCacheEnabled(false);
215+
return bitmap;
216+
}
217+
198218
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import butterknife.BindView;
1111
import butterknife.ButterKnife;
12+
import fr.free.nrw.commons.quiz.QuizActivity;
1213
import fr.free.nrw.commons.theme.BaseActivity;
1314

1415
public class WelcomeActivity extends BaseActivity {
@@ -17,6 +18,7 @@ public class WelcomeActivity extends BaseActivity {
1718
@BindView(R.id.welcomePagerIndicator) CirclePageIndicator indicator;
1819

1920
private WelcomePagerAdapter adapter = new WelcomePagerAdapter();
21+
private boolean isQuiz;
2022

2123
/**
2224
* Initialises exiting fields and dependencies
@@ -28,6 +30,15 @@ public void onCreate(Bundle savedInstanceState) {
2830
super.onCreate(savedInstanceState);
2931
setContentView(R.layout.activity_welcome);
3032

33+
if(getIntent() != null) {
34+
Bundle bundle = getIntent().getExtras();
35+
if (bundle != null) {
36+
isQuiz = bundle.getBoolean("isQuiz");
37+
}
38+
} else{
39+
isQuiz = false;
40+
}
41+
3142
ButterKnife.bind(this);
3243

3344
pager.setAdapter(adapter);
@@ -40,6 +51,10 @@ public void onCreate(Bundle savedInstanceState) {
4051
*/
4152
@Override
4253
public void onDestroy() {
54+
if(isQuiz){
55+
Intent i = new Intent(WelcomeActivity.this, QuizActivity.class);
56+
startActivity(i);
57+
}
4358
adapter.setCallback(null);
4459
super.onDestroy();
4560
}

0 commit comments

Comments
 (0)