Added Quick Launch Icon to the Home Screen Widget #1296 (#2862)

This commit is contained in:
Madhur Gupta 2019-04-11 14:02:11 +05:30 committed by Josephine Lim
parent 6bde4f97cf
commit a838962f49
2 changed files with 30 additions and 7 deletions

View file

@ -25,6 +25,7 @@ import javax.inject.Inject;
import androidx.annotation.Nullable;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.MainActivity;
import fr.free.nrw.commons.di.ApplicationlessInjection;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import io.reactivex.android.schedulers.AndroidSchedulers;
@ -45,6 +46,13 @@ public class PicOfDayAppWidget extends AppWidgetProvider {
void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.pic_of_day_app_widget);
// Launch App on Button Click
Intent viewIntent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, viewIntent, 0);
views.setOnClickPendingIntent(R.id.camera_button, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
loadPictureOfTheDay(context, views, appWidgetManager, appWidgetId);
}