diff --git a/app/build.gradle b/app/build.gradle
index dc8c3b845..68a31f984 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,6 +7,8 @@ apply from: 'quality.gradle'
apply plugin: 'com.getkeepsafe.dexcount'
dependencies {
+ implementation 'com.squareup.picasso:picasso:2.71828'
+ implementation 'com.prof.rssparser:rssparser:1.1'
implementation 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'in.yuvi:http.fluent:1.3'
@@ -19,48 +21,37 @@ dependencies {
implementation 'com.jakewharton.timber:timber:4.5.1'
implementation 'info.debatty:java-string-similarity:0.24'
implementation 'com.borjabravo:readmoretextview:2.1.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.0'
- implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.4.1@aar'){
- transitive=true
+ implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.4.1@aar') {
+ transitive = true
}
-
- implementation "com.github.deano2390:MaterialShowcaseView:1.2.0"
-
+ implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
implementation "com.android.support:design:$SUPPORT_LIB_VERSION"
implementation "com.android.support:customtabs:$SUPPORT_LIB_VERSION"
-
implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION"
-
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
-
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.okio:okio:1.13.0'
-
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'com.android.support:multidex:1.0.3'
-
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
-
implementation 'org.jsoup:jsoup:1.11.3'
-
implementation 'com.facebook.fresco:fresco:1.5.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
-
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
-
- testImplementation "org.robolectric:multidex:3.4.2"
+ testImplementation 'org.robolectric:multidex:3.4.2'
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation 'junit:junit:4.12'
@@ -134,6 +125,7 @@ android {
flavorDimensions 'tier'
productFlavors {
prod {
+ buildConfigField "String", "WIKIMEDIA_API_POTD", "\"https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&feedformat=rss&language=en\""
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.org/w/api.php\""
buildConfigField "String", "WIKIDATA_API_HOST", "\"https://www.wikidata.org/w/api.php\""
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
@@ -151,6 +143,7 @@ android {
beta {
// What values do we need to hit the BETA versions of the site / api ?
+ buildConfigField "String", "WIKIMEDIA_API_POTD", "\"https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&feedformat=rss&language=en\""
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.beta.wmflabs.org/w/api.php\""
buildConfigField "String", "WIKIDATA_API_HOST", "\"https://www.wikidata.org/w/api.php\""
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
diff --git a/app/libs/java-json.jar b/app/libs/java-json.jar
new file mode 100644
index 000000000..2f211e366
Binary files /dev/null and b/app/libs/java-json.jar differ
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 80bc59c27..38fc2e35a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -165,6 +165,16 @@
android:label="@string/provider_categories"
android:syncable="false" />
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/fr/free/nrw/commons/widget/PicOfDayAppWidget.java b/app/src/main/java/fr/free/nrw/commons/widget/PicOfDayAppWidget.java
new file mode 100644
index 000000000..82bad3f09
--- /dev/null
+++ b/app/src/main/java/fr/free/nrw/commons/widget/PicOfDayAppWidget.java
@@ -0,0 +1,80 @@
+package fr.free.nrw.commons.widget;
+
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.Context;
+import android.widget.RemoteViews;
+
+import com.prof.rssparser.Article;
+import com.prof.rssparser.Parser;
+import com.squareup.picasso.Picasso;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import java.util.ArrayList;
+
+import fr.free.nrw.commons.BuildConfig;
+import fr.free.nrw.commons.R;
+
+/**
+ * Implementation of App Widget functionality.
+ */
+public class PicOfDayAppWidget extends AppWidgetProvider {
+
+ static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
+ int appWidgetId) {
+
+ // Construct the RemoteViews object
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.pic_of_day_app_widget);
+
+ String urlString = BuildConfig.WIKIMEDIA_API_POTD;
+ Parser parser = new Parser();
+ parser.execute(urlString);
+ parser.onFinish(new Parser.OnTaskCompleted() {
+ @Override
+ public void onTaskCompleted(ArrayList list) {
+ String desc = list.get(list.size() - 1).getDescription();
+ if (desc != null) {
+ Document document = Jsoup.parse(desc);
+ Elements elements = document.select("img");
+ String imageUrl = elements.get(0).attr("src");
+ if (imageUrl != null && imageUrl.length() > 0) {
+ Picasso.get().load(imageUrl).into(views, R.id.appwidget_image, new int[]{appWidgetId});
+ }
+ }
+
+ }
+
+ @Override
+ public void onError() {
+ }
+ });
+
+ // Instruct the widget manager to update the widget
+ appWidgetManager.updateAppWidget(appWidgetId, views);
+ }
+
+ @Override
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
+ // There may be multiple widgets active, so update all of them
+ for (int appWidgetId : appWidgetIds) {
+ updateAppWidget(context, appWidgetManager, appWidgetId);
+ }
+ }
+
+ @Override
+ public void onEnabled(Context context) {
+ // Enter relevant functionality for when the first widget is created
+ }
+
+ @Override
+ public void onDisabled(Context context) {
+ // Enter relevant functionality for when the last widget is disabled
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/pic_of_day_app_widget.xml b/app/src/main/res/layout/pic_of_day_app_widget.xml
new file mode 100644
index 000000000..6b0559b37
--- /dev/null
+++ b/app/src/main/res/layout/pic_of_day_app_widget.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v14/dimens.xml b/app/src/main/res/values-v14/dimens.xml
new file mode 100644
index 000000000..4db8c5906
--- /dev/null
+++ b/app/src/main/res/values-v14/dimens.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ 0dp
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index ef5000d60..1db51fd8b 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -52,4 +52,6 @@
#424242
#757575
+ #FFFFFF
+ #000000
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 7eaf97880..1697853e8 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -25,4 +25,10 @@
14sp
15dp
25dp
+
+
+ 8dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d2acdb245..1372d5866 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -241,47 +241,49 @@
See webpage for details
View in Browser
- Location has not changed.
- Location not available.
- Permission required to display a list of nearby places
- GET DIRECTIONS
- READ ARTICLE
+ Location has not changed.
+ Location not available.
+ Permission required to display a list of nearby places
+ GET DIRECTIONS
+ READ ARTICLE
- Welcome to Wikimedia Commons, %1$s! We\'re glad you\'re here.
- %1$s left a message on your talk page
- Thank you for making an edit
- %1$s mentioned you on %2$s.
- Toggle view
- DIRECTIONS
- WIKIDATA
- WIKIPEDIA
- COMMONS
- Rate us]]>
- FAQ]]>
- Skip Tutorial
- Internet unavailable
- Internet available
- Error fetching notifications
- No notifications found
- Translate]]>
- Languages
- Select the language that you would like to submit translations for
- Proceed
- Cancel
- Retry
+ Welcome to Wikimedia Commons, %1$s! We\'re glad you\'re here.
+ %1$s left a message on your talk page
+ Thank you for making an edit
+ %1$s mentioned you on %2$s.
+ Toggle view
+ DIRECTIONS
+ WIKIDATA
+ WIKIPEDIA
+ COMMONS
+ Rate us]]>
+ FAQ]]>
+ Skip Tutorial
+ Internet unavailable
+ Internet available
+ Error fetching notifications
+ No notifications found
+ Translate]]>
+ Languages
+ Select the language that you would like to submit translations for
+ Proceed
+ Cancel
+ Retry
- Got it!
- These are the places near you that need pictures to illustrate their Wikipedia articles
- Tapping this button brings up a list of these places
- You can upload a picture for any place from your gallery or camera
+ Got it!
+ These are the places near you that need pictures to illustrate their Wikipedia articles
+ Tapping this button brings up a list of these places
+ You can upload a picture for any place from your gallery or camera
- No images found!
- Error occurred while loading images.
- Uploaded by: %1$s
+ No images found!
+ Error occurred while loading images.
+ Uploaded by: %1$s
- Share App
- Coordinates were not specified during image selection
- Error fetching nearby places.
+ Share App
+ Coordinates were not specified during image selection
+ Error fetching nearby places.
+ Pic of the Day
+ Pic of the Day
Image successfully added to %1$s on Wikidata!
Failed to update corresponding Wikidata entity!
diff --git a/app/src/main/res/xml/pic_of_day_app_widget_info.xml b/app/src/main/res/xml/pic_of_day_app_widget_info.xml
new file mode 100644
index 000000000..5b370e9a1
--- /dev/null
+++ b/app/src/main/res/xml/pic_of_day_app_widget_info.xml
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file