Merge change 629 into donut
* changes: Display the app icon to the left of the search field for search within apps.
This commit is contained in:
@@ -57,6 +57,7 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
@@ -89,12 +90,16 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
private static final int INSTANCE_SELECTED_BUTTON = -2;
|
private static final int INSTANCE_SELECTED_BUTTON = -2;
|
||||||
private static final int INSTANCE_SELECTED_QUERY = -1;
|
private static final int INSTANCE_SELECTED_QUERY = -1;
|
||||||
|
|
||||||
|
private static final int SEARCH_PLATE_LEFT_PADDING_GLOBAL = 12;
|
||||||
|
private static final int SEARCH_PLATE_LEFT_PADDING_NON_GLOBAL = 7;
|
||||||
|
|
||||||
// interaction with runtime
|
// interaction with runtime
|
||||||
private IntentFilter mCloseDialogsFilter;
|
private IntentFilter mCloseDialogsFilter;
|
||||||
private IntentFilter mPackageFilter;
|
private IntentFilter mPackageFilter;
|
||||||
|
|
||||||
// views & widgets
|
// views & widgets
|
||||||
private TextView mBadgeLabel;
|
private TextView mBadgeLabel;
|
||||||
|
private ImageView mAppIcon;
|
||||||
private SearchAutoComplete mSearchAutoComplete;
|
private SearchAutoComplete mSearchAutoComplete;
|
||||||
private Button mGoButton;
|
private Button mGoButton;
|
||||||
private ImageButton mVoiceButton;
|
private ImageButton mVoiceButton;
|
||||||
@@ -167,6 +172,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
mBadgeLabel = (TextView) findViewById(com.android.internal.R.id.search_badge);
|
mBadgeLabel = (TextView) findViewById(com.android.internal.R.id.search_badge);
|
||||||
mSearchAutoComplete = (SearchAutoComplete)
|
mSearchAutoComplete = (SearchAutoComplete)
|
||||||
findViewById(com.android.internal.R.id.search_src_text);
|
findViewById(com.android.internal.R.id.search_src_text);
|
||||||
|
mAppIcon = (ImageView) findViewById(com.android.internal.R.id.search_app_icon);
|
||||||
mGoButton = (Button) findViewById(com.android.internal.R.id.search_go_btn);
|
mGoButton = (Button) findViewById(com.android.internal.R.id.search_go_btn);
|
||||||
mVoiceButton = (ImageButton) findViewById(com.android.internal.R.id.search_voice_btn);
|
mVoiceButton = (ImageButton) findViewById(com.android.internal.R.id.search_voice_btn);
|
||||||
mSearchPlate = findViewById(com.android.internal.R.id.search_plate);
|
mSearchPlate = findViewById(com.android.internal.R.id.search_plate);
|
||||||
@@ -417,6 +423,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
if (isShowing()) {
|
if (isShowing()) {
|
||||||
// Redraw (resources may have changed)
|
// Redraw (resources may have changed)
|
||||||
updateSearchButton();
|
updateSearchButton();
|
||||||
|
updateSearchAppIcon();
|
||||||
updateSearchBadge();
|
updateSearchBadge();
|
||||||
updateQueryHint();
|
updateQueryHint();
|
||||||
}
|
}
|
||||||
@@ -429,6 +436,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
if (mSearchable != null) {
|
if (mSearchable != null) {
|
||||||
updateSearchAutoComplete();
|
updateSearchAutoComplete();
|
||||||
updateSearchButton();
|
updateSearchButton();
|
||||||
|
updateSearchAppIcon();
|
||||||
updateSearchBadge();
|
updateSearchBadge();
|
||||||
updateQueryHint();
|
updateQueryHint();
|
||||||
updateVoiceButton();
|
updateVoiceButton();
|
||||||
@@ -499,6 +507,34 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
mGoButton.setCompoundDrawablesWithIntrinsicBounds(iconLabel, null, null, null);
|
mGoButton.setCompoundDrawablesWithIntrinsicBounds(iconLabel, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSearchAppIcon() {
|
||||||
|
if (mGlobalSearchMode) {
|
||||||
|
mAppIcon.setImageResource(0);
|
||||||
|
mAppIcon.setVisibility(View.GONE);
|
||||||
|
mSearchPlate.setPadding(SEARCH_PLATE_LEFT_PADDING_GLOBAL,
|
||||||
|
mSearchPlate.getPaddingTop(),
|
||||||
|
mSearchPlate.getPaddingRight(),
|
||||||
|
mSearchPlate.getPaddingBottom());
|
||||||
|
} else {
|
||||||
|
PackageManager pm = getContext().getPackageManager();
|
||||||
|
Drawable icon = null;
|
||||||
|
try {
|
||||||
|
ActivityInfo info = pm.getActivityInfo(mLaunchComponent, 0);
|
||||||
|
icon = pm.getApplicationIcon(info.applicationInfo);
|
||||||
|
if (DBG) Log.d(LOG_TAG, "Using app-specific icon");
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
icon = pm.getDefaultActivityIcon();
|
||||||
|
Log.w(LOG_TAG, mLaunchComponent + " not found, using generic app icon");
|
||||||
|
}
|
||||||
|
mAppIcon.setImageDrawable(icon);
|
||||||
|
mAppIcon.setVisibility(View.VISIBLE);
|
||||||
|
mSearchPlate.setPadding(SEARCH_PLATE_LEFT_PADDING_NON_GLOBAL,
|
||||||
|
mSearchPlate.getPaddingTop(),
|
||||||
|
mSearchPlate.getPaddingRight(),
|
||||||
|
mSearchPlate.getPaddingBottom());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the search "Badge" if requested by mode flags.
|
* Setup the search "Badge" if requested by mode flags.
|
||||||
*/
|
*/
|
||||||
@@ -517,18 +553,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
|||||||
text = mActivityContext.getResources().getText(mSearchable.getLabelId()).toString();
|
text = mActivityContext.getResources().getText(mSearchable.getLabelId()).toString();
|
||||||
visibility = View.VISIBLE;
|
visibility = View.VISIBLE;
|
||||||
if (DBG) Log.d(LOG_TAG, "Using badge label: " + mSearchable.getLabelId());
|
if (DBG) Log.d(LOG_TAG, "Using badge label: " + mSearchable.getLabelId());
|
||||||
} else if (!mGlobalSearchMode) {
|
|
||||||
// Get the localized name of the application which we are doing search in.
|
|
||||||
try {
|
|
||||||
PackageManager pm = getContext().getPackageManager();
|
|
||||||
ActivityInfo info = pm.getActivityInfo(mLaunchComponent, 0);
|
|
||||||
text = pm.getApplicationLabel(info.applicationInfo);
|
|
||||||
visibility = View.VISIBLE;
|
|
||||||
if (DBG) Log.d(LOG_TAG, "Using application label: " + text);
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
// app not found, fine, don't use its name for the label
|
|
||||||
Log.w(LOG_TAG, mLaunchComponent + " not found.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mBadgeLabel.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
mBadgeLabel.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||||
|
|||||||
@@ -50,13 +50,21 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textColor="?android:attr/textColorPrimaryInverse" />
|
android:textColor="?android:attr/textColorPrimaryInverse" />
|
||||||
|
|
||||||
<!-- Inner layout contains the button(s) and EditText -->
|
<!-- Inner layout contains the app icon, button(s) and EditText -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/search_edit_frame"
|
android:id="@+id/search_edit_frame"
|
||||||
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">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/search_app_icon"
|
||||||
|
android:layout_height="36dip"
|
||||||
|
android:layout_width="36dip"
|
||||||
|
android:layout_marginRight="7dip"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
/>
|
||||||
|
|
||||||
<view class="android.app.SearchDialog$SearchAutoComplete"
|
<view class="android.app.SearchDialog$SearchAutoComplete"
|
||||||
android:id="@+id/search_src_text"
|
android:id="@+id/search_src_text"
|
||||||
android:background="@drawable/textfield_search"
|
android:background="@drawable/textfield_search"
|
||||||
@@ -71,7 +79,7 @@
|
|||||||
android:dropDownAnchor="@id/search_plate"
|
android:dropDownAnchor="@id/search_plate"
|
||||||
android:dropDownVerticalOffset="-9dip"
|
android:dropDownVerticalOffset="-9dip"
|
||||||
android:popupBackground="@android:drawable/search_dropdown_background"
|
android:popupBackground="@android:drawable/search_dropdown_background"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- This button can switch between text and icon "modes" -->
|
<!-- This button can switch between text and icon "modes" -->
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user