Commit 30509f7b authored by Michael Merg's avatar Michael Merg
Browse files

UI: add separate search activity

parent 596a81a8
......@@ -17,12 +17,16 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
</activity>
<activity
android:name="SearchActivity"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
android:resource="@xml/searchable"/>
</activity>
<activity
android:name="AboutActivity"
android:theme="@android:style/Theme.NoTitleBar"/>
......
......@@ -4,74 +4,42 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:background="@drawable/header"
android:layout_width="fill_parent"
android:layout_height="48dip">
<LinearLayout
android:id="@+id/ml_search_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="5dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:visibility="invisible">
<ImageView
android:layout_width="35dip"
android:layout_height="35dip"
android:src="@drawable/header_icon_loupe"
android:scaleType="fitXY"
android:paddingTop="2dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="7dip" />
<EditText
android:id="@+id/ml_search_text"
android:layout_width="0px"
android:layout_weight="1"
android:singleLine="true"
android:layout_height="42dp"
android:hint="Search..."
android:inputType="textNoSuggestions"
android:imeOptions="actionSearch"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ml_header_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:src="@drawable/header_logo"
android:layout_width="wrap_content"
android:layout_height="48dip"
android:scaleType="fitStart"
android:paddingLeft="12dip"/>
<View
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<ProgressBar
android:id="@+id/ml_progress_bar"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_margin="13dip"
android:visibility="invisible"/>
<ImageButton
android:id="@+id/ml_header_button_view"
android:background="@drawable/header_button_browser"
android:layout_width="48dip"
android:layout_height="48dip"
android:onClick="changeView"/>
<ImageButton
android:layout_width="48dip"
android:layout_height="48dip"
android:background="@drawable/header_button"
android:src="@drawable/header_icon_loupe"
android:scaleType="fitXY"
android:padding="10dip"
android:onClick="search"/>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dip"
android:orientation="horizontal"
android:background="@drawable/header" >
<ImageView
android:src="@drawable/header_logo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="fitStart"
android:paddingLeft="12dip"/>
<View
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<ProgressBar
android:id="@+id/ml_progress_bar"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_margin="13dip"
android:visibility="invisible"/>
<ImageButton
android:id="@+id/ml_header_button_view"
android:background="@drawable/header_button_browser"
android:layout_width="48dip"
android:layout_height="48dip"
android:onClick="changeTabClick"/>
<ImageButton
android:layout_width="48dip"
android:layout_height="48dip"
android:background="@drawable/header_button"
android:src="@drawable/header_icon_loupe"
android:scaleType="fitXY"
android:padding="10dip"
android:onClick="searchClick"/>
</LinearLayout>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
......@@ -99,7 +67,4 @@
</FrameLayout>
</LinearLayout>
</TabHost>
<EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="match_parent">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dip"
android:orientation="horizontal"
android:paddingTop="5dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:background="@drawable/header">
<ImageView
android:layout_width="35dip"
android:layout_height="35dip"
android:src="@drawable/header_icon_loupe"
android:scaleType="fitXY"
android:paddingTop="2dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="7dip" />
<EditText
android:id="@+id/search_text"
android:layout_width="0px"
android:layout_weight="1"
android:singleLine="true"
android:layout_height="42dp"
android:hint="Search..."
android:inputType="textNoSuggestions"
android:imeOptions="actionSearch"/>
</LinearLayout>
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fastScrollEnabled="true"/>
</LinearLayout>
......@@ -12,4 +12,6 @@
<string name="sortby">Sort By...</string>
<string name="sortby_name">Name</string>
<string name="sortby_length">Length</string>
<string name="searchable_hint">Search...</string>
<string name="searchable_label">VLC media player</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="blub" android:label="VLC">
android:hint="@string/searchable_hint"
android:label="@string/app_name"
android:includeInGlobalSearch="true">
</searchable>
\ No newline at end of file
......@@ -11,7 +11,6 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
......@@ -20,19 +19,12 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TabHost;
public class MediaLibraryActivity extends TabActivity {
public final static String TAG = "VLC/MediaLibraryActivity";
/**
* TODO:
* + onClick events for header buttons
* + search functionality
*/
protected static final int HIDE_PROGRESSBAR = 0;
protected static final int SHOW_PROGRESSBAR = 1;
private static final int VIDEO_TAB = 0;
......@@ -49,9 +41,6 @@ public class MediaLibraryActivity extends TabActivity {
private TabHost mTabHost;
private int mCurrentState = 0;
private LinearLayout mHeaderBar;
private LinearLayout mSearchBar;
private EditText mSearchText;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -62,9 +51,6 @@ public class MediaLibraryActivity extends TabActivity {
mInstance = this;
mDBManager = DatabaseManager.getInstance();
mProgressBar = (ProgressBar)findViewById(R.id.ml_progress_bar);
mHeaderBar = (LinearLayout)findViewById(R.id.ml_header_bar);
mSearchBar = (LinearLayout)findViewById(R.id.ml_search_bar);
mSearchText = (EditText)findViewById(R.id.ml_search_text);
/* Initialize the TabView */
mTabHost = getTabHost();
......@@ -82,7 +68,6 @@ public class MediaLibraryActivity extends TabActivity {
/* Load media items from database and storage */
loadMediaItems();
}
/** Create menu from XML
......@@ -94,8 +79,15 @@ public class MediaLibraryActivity extends TabActivity {
inflater.inflate(R.menu.media_library, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onSearchRequested() {
Intent intent = new Intent(this, SearchActivity.class);
startActivity(intent);
return false;
}
/**
* Handle onClick form menu buttons
*/
......@@ -140,7 +132,7 @@ public class MediaLibraryActivity extends TabActivity {
* onClick event from xml
* @param view
*/
public void changeView(View view) {
public void changeTabClick(View view) {
// TODO: change the icon
if (mCurrentState == VIDEO_TAB) {
......@@ -157,16 +149,10 @@ public class MediaLibraryActivity extends TabActivity {
* onClick event from xml
* @param view
*/
public void search(View view) {
mHeaderBar.setVisibility(LinearLayout.INVISIBLE);
mSearchBar.setVisibility(LinearLayout.VISIBLE);
mSearchText.requestFocus();
// Show soft keyboard
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(mSearchText, InputMethodManager.SHOW_IMPLICIT);
public void searchClick(View view) {
onSearchRequested();
}
/**
* Get instance e.g. for Context or Handler
* @return this ;)
......@@ -175,6 +161,8 @@ public class MediaLibraryActivity extends TabActivity {
return mInstance;
}
protected Handler mHandler = new Handler() {
@Override
......
package org.videolan.vlc.android;
import android.app.ListActivity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
public class SearchActivity extends ListActivity {
public final static String TAG = "VLC/SearchActivit";
private EditText mSearchText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
mSearchText = (EditText)findViewById(R.id.search_text);
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
mSearchText.setText(queryIntent.getStringExtra(SearchManager.QUERY));
mSearchText.requestFocus();
}
}
}
......@@ -57,6 +57,13 @@ public class VideoListActivity extends ListActivity {
return mInstance;
}
@Override
public boolean onSearchRequested() {
Intent intent = new Intent(this, SearchActivity.class);
startActivity(intent);
return false;
}
/**
* Handle changes on the list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment