|
1 | 1 | package fr.free.nrw.commons.widget;
|
2 | 2 |
|
| 3 | +import android.app.PendingIntent; |
3 | 4 | import android.appwidget.AppWidgetManager;
|
4 | 5 | import android.appwidget.AppWidgetProvider;
|
5 | 6 | import android.content.Context;
|
| 7 | +import android.content.Intent; |
6 | 8 | import android.graphics.Bitmap;
|
7 | 9 | import android.graphics.Canvas;
|
8 | 10 | import android.graphics.Paint;
|
9 | 11 | import android.net.Uri;
|
10 |
| -import androidx.annotation.Nullable; |
11 | 12 | import android.widget.RemoteViews;
|
12 | 13 |
|
13 | 14 | import com.facebook.common.executors.CallerThreadExecutor;
|
|
22 | 23 |
|
23 | 24 | import javax.inject.Inject;
|
24 | 25 |
|
| 26 | +import androidx.annotation.Nullable; |
25 | 27 | import fr.free.nrw.commons.R;
|
26 | 28 | import fr.free.nrw.commons.di.ApplicationlessInjection;
|
27 | 29 | import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
|
30 | 32 | import io.reactivex.schedulers.Schedulers;
|
31 | 33 | import timber.log.Timber;
|
32 | 34 |
|
| 35 | +import static android.content.Intent.ACTION_VIEW; |
| 36 | + |
33 | 37 | /**
|
34 | 38 | * Implementation of App Widget functionality.
|
35 | 39 | */
|
@@ -62,6 +66,14 @@ private void loadPictureOfTheDay(Context context,
|
62 | 66 | response -> {
|
63 | 67 | if (response != null) {
|
64 | 68 | 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 | + |
65 | 77 | loadImageFromUrl(response.getImageUrl(), context, views, appWidgetManager, appWidgetId);
|
66 | 78 | }
|
67 | 79 | },
|
|
0 commit comments