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.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
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_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
|
||||
private IntentFilter mCloseDialogsFilter;
|
||||
private IntentFilter mPackageFilter;
|
||||
|
||||
// views & widgets
|
||||
private TextView mBadgeLabel;
|
||||
private ImageView mAppIcon;
|
||||
private SearchAutoComplete mSearchAutoComplete;
|
||||
private Button mGoButton;
|
||||
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);
|
||||
mSearchAutoComplete = (SearchAutoComplete)
|
||||
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);
|
||||
mVoiceButton = (ImageButton) findViewById(com.android.internal.R.id.search_voice_btn);
|
||||
mSearchPlate = findViewById(com.android.internal.R.id.search_plate);
|
||||
@@ -417,6 +423,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
if (isShowing()) {
|
||||
// Redraw (resources may have changed)
|
||||
updateSearchButton();
|
||||
updateSearchAppIcon();
|
||||
updateSearchBadge();
|
||||
updateQueryHint();
|
||||
}
|
||||
@@ -429,6 +436,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
if (mSearchable != null) {
|
||||
updateSearchAutoComplete();
|
||||
updateSearchButton();
|
||||
updateSearchAppIcon();
|
||||
updateSearchBadge();
|
||||
updateQueryHint();
|
||||
updateVoiceButton();
|
||||
@@ -499,6 +507,34 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
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.
|
||||
*/
|
||||
@@ -517,18 +553,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
text = mActivityContext.getResources().getText(mSearchable.getLabelId()).toString();
|
||||
visibility = View.VISIBLE;
|
||||
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);
|
||||
|
||||
@@ -50,13 +50,21 @@
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorPrimaryInverse" />
|
||||
|
||||
<!-- Inner layout contains the button(s) and EditText -->
|
||||
<!-- Inner layout contains the app icon, button(s) and EditText -->
|
||||
<LinearLayout
|
||||
android:id="@+id/search_edit_frame"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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"
|
||||
android:id="@+id/search_src_text"
|
||||
android:background="@drawable/textfield_search"
|
||||
@@ -71,7 +79,7 @@
|
||||
android:dropDownAnchor="@id/search_plate"
|
||||
android:dropDownVerticalOffset="-9dip"
|
||||
android:popupBackground="@android:drawable/search_dropdown_background"
|
||||
/>
|
||||
/>
|
||||
|
||||
<!-- This button can switch between text and icon "modes" -->
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user