Skip to content

Commit 031f334

Browse files
madhurgupta10domdomegg
authored andcommitted
Added Click To View Photo on Home Screen Widget (commons-app#2768)
1 parent 0bf63f5 commit 031f334

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/src/main/java/fr/free/nrw/commons/widget/PicOfDayAppWidget.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package fr.free.nrw.commons.widget;
22

3+
import android.app.PendingIntent;
34
import android.appwidget.AppWidgetManager;
45
import android.appwidget.AppWidgetProvider;
56
import android.content.Context;
7+
import android.content.Intent;
68
import android.graphics.Bitmap;
79
import android.graphics.Canvas;
810
import android.graphics.Paint;
911
import android.net.Uri;
10-
import androidx.annotation.Nullable;
1112
import android.widget.RemoteViews;
1213

1314
import com.facebook.common.executors.CallerThreadExecutor;
@@ -22,6 +23,7 @@
2223

2324
import javax.inject.Inject;
2425

26+
import androidx.annotation.Nullable;
2527
import fr.free.nrw.commons.R;
2628
import fr.free.nrw.commons.di.ApplicationlessInjection;
2729
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
@@ -30,6 +32,8 @@
3032
import io.reactivex.schedulers.Schedulers;
3133
import timber.log.Timber;
3234

35+
import static android.content.Intent.ACTION_VIEW;
36+
3337
/**
3438
* Implementation of App Widget functionality.
3539
*/
@@ -62,6 +66,14 @@ private void loadPictureOfTheDay(Context context,
6266
response -> {
6367
if (response != null) {
6468
views.setTextViewText(R.id.appwidget_title, response.getDisplayTitle());
69+
70+
// View in browser
71+
Intent viewIntent = new Intent();
72+
viewIntent.setAction(ACTION_VIEW);
73+
viewIntent.setData(response.getFilePageTitle().getMobileUri());
74+
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, viewIntent, 0);
75+
views.setOnClickPendingIntent(R.id.appwidget_image, pendingIntent);
76+
6577
loadImageFromUrl(response.getImageUrl(), context, views, appWidgetManager, appWidgetId);
6678
}
6779
},

0 commit comments

Comments
 (0)