mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Added Click To View Photo on Home Screen Widget (#2768)
This commit is contained in:
parent
0bf63f50b3
commit
031f334c0f
1 changed files with 13 additions and 1 deletions
|
|
@ -1,13 +1,14 @@
|
|||
package fr.free.nrw.commons.widget;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.facebook.common.executors.CallerThreadExecutor;
|
||||
|
|
@ -22,6 +23,7 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
||||
|
|
@ -30,6 +32,8 @@ import io.reactivex.disposables.CompositeDisposable;
|
|||
import io.reactivex.schedulers.Schedulers;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.content.Intent.ACTION_VIEW;
|
||||
|
||||
/**
|
||||
* Implementation of App Widget functionality.
|
||||
*/
|
||||
|
|
@ -62,6 +66,14 @@ public class PicOfDayAppWidget extends AppWidgetProvider {
|
|||
response -> {
|
||||
if (response != null) {
|
||||
views.setTextViewText(R.id.appwidget_title, response.getDisplayTitle());
|
||||
|
||||
// View in browser
|
||||
Intent viewIntent = new Intent();
|
||||
viewIntent.setAction(ACTION_VIEW);
|
||||
viewIntent.setData(response.getFilePageTitle().getMobileUri());
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, viewIntent, 0);
|
||||
views.setOnClickPendingIntent(R.id.appwidget_image, pendingIntent);
|
||||
|
||||
loadImageFromUrl(response.getImageUrl(), context, views, appWidgetManager, appWidgetId);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue