Index: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java |
index 035a48a8bdfe4d65939a4f0edb3b47ef77fa8bf4..8527aedc41c53c31c1372c2b4e95dfb6bd24395a 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java |
@@ -11,14 +11,12 @@ import android.content.ComponentName; |
import android.content.Context; |
import android.content.Intent; |
import android.content.SharedPreferences; |
-import android.graphics.Rect; |
import android.net.Uri; |
import android.os.Bundle; |
import android.support.v4.app.ActivityOptionsCompat; |
import android.text.TextUtils; |
import android.widget.RemoteViews; |
-import org.chromium.base.ApplicationStatus; |
import org.chromium.base.ContextUtils; |
import org.chromium.base.Log; |
import org.chromium.base.ThreadUtils; |
@@ -51,10 +49,6 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
} |
} |
- static final int INVALID_WIDGET_ID = -1; |
- |
- static final boolean ANIMATE_TRANSITION = false; |
- |
private static final String ACTION_START_TEXT_QUERY = |
"org.chromium.chrome.browser.searchwidget.START_TEXT_QUERY"; |
private static final String ACTION_START_VOICE_QUERY = |
@@ -64,11 +58,7 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
static final String EXTRA_START_VOICE_SEARCH = |
"org.chromium.chrome.browser.searchwidget.START_VOICE_SEARCH"; |
- private static final String EXTRA_WIDGET_ID = |
- "org.chromium.chrome.browser.searchwidget.WIDGET_ID"; |
- private static final String PREF_LAUNCHING_WIDGET_ID = |
- "org.chromium.chrome.browser.searchwidget.LAUNCHING_WIDGET_ID"; |
private static final String PREF_SEARCH_ENGINE_SHORTNAME = |
"org.chromium.chrome.browser.searchwidget.SEARCH_ENGINE_SHORTNAME"; |
static final String PREF_USE_HERB_TAB = "org.chromium.chrome.browser.searchwidget.USE_HERB_TAB"; |
@@ -107,10 +97,10 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
public void onReceive(Context context, Intent intent) { |
if (IntentHandler.isIntentChromeOrFirstParty(intent)) { |
if (ACTION_START_TEXT_QUERY.equals(intent.getAction())) { |
- startSearchActivity(context, intent, false); |
+ startSearchActivity(context, false); |
return; |
} else if (ACTION_START_VOICE_QUERY.equals(intent.getAction())) { |
- startSearchActivity(context, intent, true); |
+ startSearchActivity(context, true); |
return; |
} |
} else if (ACTION_UPDATE_ALL_WIDGETS.equals(intent.getAction())) { |
@@ -120,10 +110,8 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
super.onReceive(context, intent); |
} |
- private void startSearchActivity(Context context, Intent intent, boolean startVoiceSearch) { |
- int widgetId = getLaunchingWidgetIdFromIntent(intent); |
- SearchWidgetProvider.setLaunchingWidgetId(widgetId); |
- Log.d(TAG, "Launching SearchActivity: ID=" + widgetId + " VOICE=" + startVoiceSearch); |
+ private void startSearchActivity(Context context, boolean startVoiceSearch) { |
+ Log.d(TAG, "Launching SearchActivity: VOICE=" + startVoiceSearch); |
// Launch the SearchActivity. |
Intent searchIntent = new Intent(); |
@@ -133,16 +121,9 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
searchIntent.putExtra(EXTRA_START_VOICE_SEARCH, startVoiceSearch); |
Bundle optionsBundle; |
- if (ANIMATE_TRANSITION) { |
- // Pass the widget's bounds along to allow moving the box into place. |
- Rect rect = intent.getSourceBounds(); |
- if (rect != null) searchIntent.setSourceBounds(rect); |
- optionsBundle = ActivityOptionsCompat.makeCustomAnimation(context, 0, 0).toBundle(); |
- } else { |
- optionsBundle = ActivityOptionsCompat |
- .makeCustomAnimation(context, R.anim.activity_open_enter, 0) |
- .toBundle(); |
- } |
+ optionsBundle = |
+ ActivityOptionsCompat.makeCustomAnimation(context, R.anim.activity_open_enter, 0) |
+ .toBundle(); |
context.startActivity(searchIntent, optionsBundle); |
} |
@@ -162,12 +143,9 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
} |
private void updateWidget(Context context, int id) { |
- int launchingWidgetId = ANIMATE_TRANSITION ? getLaunchingWidgetId() : INVALID_WIDGET_ID; |
- |
AppWidgetManager manager = AppWidgetManager.getInstance(context); |
- RemoteViews views = new RemoteViews(context.getPackageName(), |
- id == launchingWidgetId ? R.layout.search_widget_template_transparent |
- : R.layout.search_widget_template); |
+ RemoteViews views = |
+ new RemoteViews(context.getPackageName(), R.layout.search_widget_template); |
// Clicking on the widget fires an Intent back at this BroadcastReceiver, allowing control |
// over how the Activity is animated when it starts up. |
@@ -239,38 +217,6 @@ public class SearchWidgetProvider extends AppWidgetProvider { |
ContextUtils.getApplicationContext(), SearchWidgetProvider.class.getName())); |
} |
- private int getLaunchingWidgetId() { |
- int launchingWidgetId = INVALID_WIDGET_ID; |
- |
- // If the SearchActivity isn't in the foreground, the user must have exited it. |
- if (ApplicationStatus.getLastTrackedFocusedActivity() instanceof SearchActivity) { |
- launchingWidgetId = ContextUtils.getAppSharedPreferences().getInt( |
- PREF_LAUNCHING_WIDGET_ID, INVALID_WIDGET_ID); |
- } |
- |
- return launchingWidgetId; |
- } |
- |
- /** Cache the ID of the widget that was used to launch the SearchActivity. */ |
- static void setLaunchingWidgetId(int id) { |
- SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); |
- SharedPreferences.Editor editor = prefs.edit(); |
- editor.putInt(PREF_LAUNCHING_WIDGET_ID, id); |
- editor.apply(); |
- } |
- |
- /** Parse out which widget launched the Activity from the given Intent. */ |
- private static int getLaunchingWidgetIdFromIntent(Intent intent) { |
- String data = intent.getData() == null ? null : intent.getData().toString(); |
- if (data == null) return INVALID_WIDGET_ID; |
- |
- try { |
- return Integer.parseInt(data); |
- } catch (NumberFormatException e) { |
- return INVALID_WIDGET_ID; |
- } |
- } |
- |
/** Creates a trusted Intent that lets the user begin performing queries. */ |
private Intent createStartQueryIntent(Context context, String action, int widgetId) { |
Intent intent = new Intent(action, Uri.parse(String.valueOf(widgetId))); |