Merge change I2bbe9af6 into eclair
* changes: Update the search widget to be vertically centered within it's footprint.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 5.4 KiB |
@@ -19,25 +19,25 @@
|
|||||||
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2"
|
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2"
|
||||||
android:id="@+id/widget_search"
|
android:id="@+id/widget_search"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="top">
|
android:gravity="center">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/search_plate"
|
android:id="@+id/search_plate"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="12dip"
|
android:paddingLeft="14dip"
|
||||||
android:paddingRight="12dip"
|
android:paddingRight="14dip"
|
||||||
android:paddingTop="7dip"
|
android:paddingTop="13dip"
|
||||||
android:paddingBottom="13dip"
|
android:paddingBottom="12dip"
|
||||||
android:background="@drawable/search_floater" >
|
android:background="@drawable/search_floater" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_src_text"
|
android:id="@+id/search_src_text"
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="42dip"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
android:editable="false"
|
android:editable="false"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/search_voice_btn"
|
android:id="@+id/search_voice_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="42dip"
|
||||||
android:layout_marginLeft="8dip"
|
android:layout_marginLeft="4dip"
|
||||||
android:background="@*android:drawable/btn_search_dialog_voice"
|
android:background="@*android:drawable/btn_search_dialog_voice"
|
||||||
android:src="@*android:drawable/ic_btn_speak_now"
|
android:src="@*android:drawable/ic_btn_speak_now"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -16,20 +16,15 @@
|
|||||||
|
|
||||||
package com.android.launcher2;
|
package com.android.launcher2;
|
||||||
|
|
||||||
import android.app.SearchManager;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.server.search.SearchableInfo;
|
|
||||||
import android.server.search.Searchables;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -76,8 +71,6 @@ public class Search extends LinearLayout
|
|||||||
// For voice searching
|
// For voice searching
|
||||||
private Intent mVoiceSearchIntent;
|
private Intent mVoiceSearchIntent;
|
||||||
|
|
||||||
private SearchManager mSearchManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to inflate the Workspace from XML.
|
* Used to inflate the Workspace from XML.
|
||||||
*
|
*
|
||||||
@@ -138,8 +131,6 @@ public class Search extends LinearLayout
|
|||||||
mVoiceSearchIntent = new Intent(android.speech.RecognizerIntent.ACTION_WEB_SEARCH);
|
mVoiceSearchIntent = new Intent(android.speech.RecognizerIntent.ACTION_WEB_SEARCH);
|
||||||
mVoiceSearchIntent.putExtra(android.speech.RecognizerIntent.EXTRA_LANGUAGE_MODEL,
|
mVoiceSearchIntent.putExtra(android.speech.RecognizerIntent.EXTRA_LANGUAGE_MODEL,
|
||||||
android.speech.RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
|
android.speech.RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
|
||||||
|
|
||||||
mSearchManager = (SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,7 +165,7 @@ public class Search extends LinearLayout
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Morph the search gadget to the search dialog.
|
* Morph the search gadget to the search dialog.
|
||||||
* See {@link Activity.startSearch()} for the arguments.
|
* See {@link Activity#startSearch()} for the arguments.
|
||||||
*/
|
*/
|
||||||
public void startSearch(String initialQuery, boolean selectInitialQuery,
|
public void startSearch(String initialQuery, boolean selectInitialQuery,
|
||||||
Bundle appSearchData, boolean globalSearch) {
|
Bundle appSearchData, boolean globalSearch) {
|
||||||
@@ -233,11 +224,11 @@ public class Search extends LinearLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAtTop() {
|
private boolean isAtTop() {
|
||||||
return getTop() == 0;
|
return getWidgetTop() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getAnimationDuration() {
|
private int getAnimationDuration() {
|
||||||
return (int) (getTop() / ANIMATION_VELOCITY);
|
return (int) (getWidgetTop() / ANIMATION_VELOCITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -351,7 +342,7 @@ public class Search extends LinearLayout
|
|||||||
@Override
|
@Override
|
||||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
float dx = -getLeft() * interpolatedTime;
|
float dx = -getLeft() * interpolatedTime;
|
||||||
float dy = -getTop() * interpolatedTime;
|
float dy = -getWidgetTop() * interpolatedTime;
|
||||||
t.getMatrix().setTranslate(dx, dy);
|
t.getMatrix().setTranslate(dx, dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,9 +354,17 @@ public class Search extends LinearLayout
|
|||||||
@Override
|
@Override
|
||||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
float dx = -getLeft() * (1.0f - interpolatedTime);
|
float dx = -getLeft() * (1.0f - interpolatedTime);
|
||||||
float dy = -getTop() * (1.0f - interpolatedTime);
|
float dy = -getWidgetTop() * (1.0f - interpolatedTime);
|
||||||
t.getMatrix().setTranslate(dx, dy);
|
t.getMatrix().setTranslate(dx, dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The widget is centered vertically within it's 4x1 slot. This is accomplished by nesting
|
||||||
|
* the actual widget inside another view. For animation purposes, we care about the top of the
|
||||||
|
* actual widget rather than it's container. This method return the top of the actual widget.
|
||||||
|
*/
|
||||||
|
private int getWidgetTop() {
|
||||||
|
return getTop() + getChildAt(0).getTop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user