Don't show the search box in the selector by default
This commit is contained in:
parent
adee2c36aa
commit
d0a88387af
8
res/drawable/search_background.xml
Normal file
8
res/drawable/search_background.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:endColor="#ff555555"
|
||||
android:startColor="#ff333333"
|
||||
android:angle="90" />
|
||||
</shape>
|
@ -1,56 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/selector_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
<TabHost
|
||||
android:id="@android:id/tabhost"
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout
|
||||
android:id="@+id/selector_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
<TabHost
|
||||
android:id="@android:id/tabhost"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<ListView
|
||||
android:id="@+id/artist_list"
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:fastScrollEnabled="true" />
|
||||
<ListView
|
||||
android:id="@+id/album_list"
|
||||
android:layout_height="wrap_content" />
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:fastScrollEnabled="true" />
|
||||
<ListView
|
||||
android:id="@+id/song_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:fastScrollEnabled="true" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
<LinearLayout
|
||||
android:id="@+id/limiter_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|left" />
|
||||
android:layout_height="fill_parent">
|
||||
<ListView
|
||||
android:id="@+id/artist_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:fastScrollEnabled="true" />
|
||||
<ListView
|
||||
android:id="@+id/album_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:fastScrollEnabled="true" />
|
||||
<ListView
|
||||
android:id="@+id/song_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:divider="@null"
|
||||
android:fastScrollEnabled="true" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
<LinearLayout
|
||||
android:id="@+id/limiter_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|left" />
|
||||
<ViewStub
|
||||
android:id="@+id/status_stub"
|
||||
android:layout="@layout/song_status"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/search_box"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:paddingTop="4dip"
|
||||
android:paddingLeft="4dip"
|
||||
android:paddingRight="4dip"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/search_background">
|
||||
<EditText
|
||||
android:id="@+id/filter_text"
|
||||
android:layout_width="fill_parent"
|
||||
@ -62,9 +75,4 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:src="@android:drawable/ic_menu_close_clear_cancel" />
|
||||
</RelativeLayout>
|
||||
<ViewStub
|
||||
android:id="@+id/status_stub"
|
||||
android:layout="@layout/song_status"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</merge>
|
@ -25,6 +25,7 @@
|
||||
<string name="play">Play</string>
|
||||
<string name="expand">Expand</string>
|
||||
<string name="playback_view">Now Playing</string>
|
||||
<string name="search">Search</string>
|
||||
|
||||
<string name="enqueued">Enqueued %s</string>
|
||||
<string name="playing">Playing %s</string>
|
||||
|
@ -68,6 +68,7 @@ public class FullPlaybackActivity extends PlaybackActivity implements View.OnCli
|
||||
private static final int MENU_SHUFFLE = 4;
|
||||
private static final int MENU_PLAYBACK = 5;
|
||||
private static final int MENU_REPEAT = 6;
|
||||
public static final int MENU_SEARCH = 7;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle)
|
||||
@ -177,6 +178,7 @@ public class FullPlaybackActivity extends PlaybackActivity implements View.OnCli
|
||||
{
|
||||
if (fromDialog) {
|
||||
menu.add(0, MENU_PLAYBACK, 0, R.string.playback_view).setIcon(android.R.drawable.ic_menu_gallery);
|
||||
menu.add(0, MENU_SEARCH, 0, R.string.search).setIcon(android.R.drawable.ic_menu_search);
|
||||
} else {
|
||||
menu.add(0, MENU_LIBRARY, 0, R.string.library).setIcon(android.R.drawable.ic_menu_add);
|
||||
menu.add(0, MENU_DISPLAY, 0, R.string.display_mode).setIcon(android.R.drawable.ic_menu_gallery);
|
||||
|
@ -62,11 +62,16 @@ public class SongSelector extends Dialog implements AdapterView.OnItemClickListe
|
||||
private Handler mHandler = new Handler(this);
|
||||
|
||||
private TabHost mTabHost;
|
||||
|
||||
private View mSearchBox;
|
||||
private boolean mSearchBoxVisible;
|
||||
private TextView mTextFilter;
|
||||
private View mClearButton;
|
||||
|
||||
private View mStatus;
|
||||
private TextView mStatusText;
|
||||
private ControlButton mPlayPauseButton;
|
||||
|
||||
private ViewGroup mLimiterViews;
|
||||
|
||||
private boolean mOnStartUp;
|
||||
@ -108,6 +113,8 @@ public class SongSelector extends Dialog implements AdapterView.OnItemClickListe
|
||||
mTabHost.addTab(mTabHost.newTabSpec("tab_albums").setIndicator(res.getText(R.string.albums), res.getDrawable(R.drawable.tab_albums)).setContent(R.id.album_list));
|
||||
mTabHost.addTab(mTabHost.newTabSpec("tab_songs").setIndicator(res.getText(R.string.songs), res.getDrawable(R.drawable.tab_songs)).setContent(R.id.song_list));
|
||||
|
||||
mSearchBox = findViewById(R.id.search_box);
|
||||
|
||||
mTextFilter = (TextView)findViewById(R.id.filter_text);
|
||||
mTextFilter.addTextChangedListener(this);
|
||||
|
||||
@ -167,21 +174,32 @@ public class SongSelector extends Dialog implements AdapterView.OnItemClickListe
|
||||
{
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
if (mOnStartUp)
|
||||
if (mSearchBoxVisible) {
|
||||
mTextFilter.setText("");
|
||||
setSearchBoxVisible(false);
|
||||
} else if (mOnStartUp) {
|
||||
getOwnerActivity().finish();
|
||||
else
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_SEARCH:
|
||||
dismiss();
|
||||
setSearchBoxVisible(!mSearchBoxVisible);
|
||||
return true;
|
||||
default:
|
||||
if (super.onKeyDown(keyCode, event))
|
||||
return true;
|
||||
|
||||
mTextFilter.requestFocus();
|
||||
return mTextFilter.onKeyDown(keyCode, event);
|
||||
if (mTextFilter.onKeyDown(keyCode, event)) {
|
||||
if (!mSearchBoxVisible)
|
||||
setSearchBoxVisible(true);
|
||||
else
|
||||
mTextFilter.requestFocus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendSongIntent(MediaAdapter.MediaView view, int action)
|
||||
@ -283,7 +301,10 @@ public class SongSelector extends Dialog implements AdapterView.OnItemClickListe
|
||||
{
|
||||
int id = view.getId();
|
||||
if (view == mClearButton) {
|
||||
mTextFilter.setText("");
|
||||
if (mTextFilter.getText().length() == 0)
|
||||
setSearchBoxVisible(false);
|
||||
else
|
||||
mTextFilter.setText("");
|
||||
} else if (id == R.id.play_pause) {
|
||||
try {
|
||||
((FullPlaybackActivity)getOwnerActivity()).mCoverView.go(0);
|
||||
@ -369,6 +390,11 @@ public class SongSelector extends Dialog implements AdapterView.OnItemClickListe
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
if (item.getItemId() == FullPlaybackActivity.MENU_SEARCH) {
|
||||
setSearchBoxVisible(!mSearchBoxVisible);
|
||||
return true;
|
||||
}
|
||||
|
||||
return ((FullPlaybackActivity)getOwnerActivity()).onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@ -452,4 +478,12 @@ public class SongSelector extends Dialog implements AdapterView.OnItemClickListe
|
||||
updateState(intent.getIntExtra("state", 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setSearchBoxVisible(boolean visible)
|
||||
{
|
||||
mSearchBoxVisible = visible;
|
||||
mSearchBox.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
if (visible)
|
||||
mSearchBox.requestFocus();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user