gecko/mobile/android/base/GeckoAppWidgetProvider.java.in
Sriram Ramasubramanian fcfb1d38d7 Bug 708707: Fennec home screen widget. [r=mfinkle]
--HG--
extra : rebase_source : 63871fd8412c45931e8739b1550ebf537638549f
2012-10-19 11:15:06 -07:00

46 lines
1.9 KiB
Java

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#filter substitution
package @ANDROID_PACKAGE_NAME@;
import org.mozilla.gecko.GeckoApp;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.app.PendingIntent;
import android.widget.RemoteViews;
import org.mozilla.gecko.R;
public class GeckoAppWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int i=0; i < appWidgetIds.length; i++) {
int appWidgetId = appWidgetIds[i];
// Launch the AwesomeScreen on tapping the URL bar.
Intent awesomeBarIntent = new Intent();
awesomeBarIntent.setComponent(new ComponentName("@ANDROID_PACKAGE_NAME@", "@ANDROID_PACKAGE_NAME@.App"));
awesomeBarIntent.setAction(GeckoApp.ACTION_WIDGET);
PendingIntent pendingAwesomeBarIntent = PendingIntent.getActivity(context, 0, awesomeBarIntent, 0);
// Launch the App on tapping the icon.
Intent iconIntent = new Intent();
iconIntent.setComponent(new ComponentName("@ANDROID_PACKAGE_NAME@", "@ANDROID_PACKAGE_NAME@.App"));
PendingIntent pendingIconIntent = PendingIntent.getActivity(context, 0, iconIntent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.gecko_appwidget);
views.setOnClickPendingIntent(R.id.awesome_bar, pendingAwesomeBarIntent);
views.setOnClickPendingIntent(R.id.icon, pendingIconIntent);
// Update the view.
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
}