/* * Copyright (C) 2009 The Android Open Source Project * * 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 com.android.quicksearchbox; import com.android.common.Search; import com.android.common.speech.Recognition; import com.android.quicksearchbox.util.Util; import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.app.SearchManager; import android.appwidget.AppWidgetManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; import android.speech.RecognizerIntent; import android.text.Annotation; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.style.StyleSpan; import android.util.Log; import android.view.View; import android.widget.RemoteViews; import java.util.ArrayList; import java.util.Random; /** * Search widget provider. * */ public class SearchWidgetProvider extends BroadcastReceiver { private static final boolean DBG = false; private static final String TAG = "QSB.SearchWidgetProvider"; /** * The {@link Search#SOURCE} value used when starting searches from the search widget. */ private static final String WIDGET_SEARCH_SOURCE = "launcher-widget"; @Override public void onReceive(Context context, Intent intent) { if (DBG) Log.d(TAG, "onReceive(" + intent.toUri(0) + ")"); String action = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) { // nothing needs doing } else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) { updateSearchWidgets(context); } else { if (DBG) Log.d(TAG, "Unhandled intent action=" + action); } } private static SearchWidgetState[] getSearchWidgetStates(Context context) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(myComponentName(context)); SearchWidgetState[] states = new SearchWidgetState[appWidgetIds.length]; for (int i = 0; i