/* * Copyright 2012 The Stanford MobiSocial Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mobisocial.widget; import android.app.Activity; import android.appwidget.AppWidgetManager; import android.content.Intent; import android.os.Bundle; import android.widget.RemoteViews; import mobisocial.musubi.PickContactsActivity; import mobisocial.musubi.R; public class ShareConfigurator extends Activity { private static final int PICKER_CODE = 9; private int mAppWidgetId; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(Activity.RESULT_CANCELED); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } Intent picker = new Intent(this, PickContactsActivity.class); startActivityForResult(picker, PICKER_CODE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { finish(); return; } AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this); RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget_message); appWidgetManager.updateAppWidget(mAppWidgetId, views); Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); setResult(RESULT_OK, resultValue); finish(); } }