simplify visible actionbar icons

This commit is contained in:
Andrew Dolgov 2014-10-30 15:17:15 +03:00
parent f62363bc96
commit 3dc5a9668f
4 changed files with 12 additions and 95 deletions

View File

@ -27,7 +27,6 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.widget.EditText; import android.widget.EditText;
import android.widget.SearchView;
import android.widget.TextView; import android.widget.TextView;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -759,7 +758,7 @@ public class OnlineActivity extends CommonActivity {
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
return true; return true;
case R.id.search: case R.id.search:
if (hf != null && isCompatMode()) { if (hf != null) {
Dialog dialog = new Dialog(this); Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this); final EditText edit = new EditText(this);
@ -1582,44 +1581,6 @@ public class OnlineActivity extends CommonActivity {
m_headlinesActionMode.finish(); m_headlinesActionMode.finish();
} }
} }
if (!isCompatMode()) {
SearchView searchView = (SearchView) search.getActionView();
if (searchView != null) {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
private String query = "";
@Override
public boolean onQueryTextSubmit(String query) {
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager()
.findFragmentByTag(FRAG_HEADLINES);
if (frag != null) {
frag.setSearchQuery(query);
this.query = query;
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.equals("") && !newText.equals(this.query)) {
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager()
.findFragmentByTag(FRAG_HEADLINES);
if (frag != null) {
frag.setSearchQuery(newText);
this.query = newText;
}
}
return false;
}
});
}
}
} }
} }

View File

@ -23,7 +23,6 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.widget.EditText; import android.widget.EditText;
import android.widget.SearchView;
import android.widget.TextView; import android.widget.TextView;
import org.fox.ttrss.CommonActivity; import org.fox.ttrss.CommonActivity;
@ -281,7 +280,7 @@ public class OfflineActivity extends CommonActivity {
switchOnline(); switchOnline();
return true; return true;
case R.id.search: case R.id.search:
if (ohf != null && isCompatMode()) { if (ohf != null) {
Dialog dialog = new Dialog(this); Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this); final EditText edit = new EditText(this);
@ -622,46 +621,6 @@ public class OfflineActivity extends CommonActivity {
article.close(); article.close();
} }
} }
if (!isCompatMode()) {
MenuItem search = m_menu.findItem(R.id.search);
SearchView searchView = (SearchView) search.getActionView();
if (searchView != null) {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
private String query = "";
@Override
public boolean onQueryTextSubmit(String query) {
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentByTag(FRAG_HEADLINES);
if (frag != null) {
frag.setSearchQuery(query);
this.query = query;
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.equals("") && !newText.equals(this.query)) {
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentByTag(FRAG_HEADLINES);
if (frag != null) {
frag.setSearchQuery(newText);
this.query = newText;
}
}
return false;
}
});
}
}
} }
} }

View File

@ -14,13 +14,13 @@
<item <item
android:id="@+id/subscribe_to_feed" android:id="@+id/subscribe_to_feed"
android:icon="@drawable/ic_new_light" android:icon="@drawable/ic_new_light"
app:showAsAction="ifRoom" app:showAsAction=""
android:title="@string/subscribe_to_feed"/> android:title="@string/subscribe_to_feed"/>
<item <item
android:id="@+id/show_feeds" android:id="@+id/show_feeds"
android:icon="@drawable/ic_list_light" android:icon="@drawable/ic_list_light"
app:showAsAction="ifRoom" app:showAsAction=""
android:title="@string/menu_all_feeds"/> android:title="@string/menu_all_feeds"/>
<item <item
android:id="@+id/go_offline" android:id="@+id/go_offline"
@ -45,9 +45,8 @@
android:title="@string/update_headlines"/> android:title="@string/update_headlines"/>
<item <item
android:id="@+id/search" android:id="@+id/search"
app:actionViewClass="android.widget.SearchView"
android:icon="@drawable/ic_search_light" android:icon="@drawable/ic_search_light"
app:showAsAction="ifRoom|collapseActionView" app:showAsAction="ifRoom"
android:title="@string/search"/> android:title="@string/search"/>
<item <item
android:id="@+id/headlines_mark_as_read" android:id="@+id/headlines_mark_as_read"
@ -56,7 +55,7 @@
android:title="@string/headlines_mark_as_read"/> android:title="@string/headlines_mark_as_read"/>
<item <item
android:id="@+id/headlines_select" android:id="@+id/headlines_select"
app:showAsAction="ifRoom" app:showAsAction=""
android:icon="@drawable/ic_select_all_light" android:icon="@drawable/ic_select_all_light"
android:title="@string/headlines_select"/> android:title="@string/headlines_select"/>
@ -138,7 +137,7 @@
<item <item
android:id="@+id/set_unread" android:id="@+id/set_unread"
android:icon="@drawable/ic_read_light" android:icon="@drawable/ic_read_light"
app:showAsAction="ifRoom" app:showAsAction=""
android:title="@string/article_set_unread"/> android:title="@string/article_set_unread"/>
</group> </group>

View File

@ -10,15 +10,13 @@
<item <item
android:id="@+id/show_feeds" android:id="@+id/show_feeds"
android:icon="@drawable/ic_list_light" android:icon="@drawable/ic_list_light"
app:showAsAction="ifRoom" app:showAsAction=""
android:title="@string/menu_all_feeds"/> android:title="@string/menu_all_feeds"/>
</group> </group>
<group android:id="@+id/menu_group_headlines" > <group android:id="@+id/menu_group_headlines" >
<item <item
android:id="@+id/search" android:id="@+id/search"
app:actionViewClass="android.widget.SearchView"
android:icon="@drawable/ic_search_light" android:icon="@drawable/ic_search_light"
app:showAsAction="ifRoom|collapseActionView"
android:title="@string/search"/> android:title="@string/search"/>
<item <item
android:id="@+id/headlines_mark_as_read" android:id="@+id/headlines_mark_as_read"
@ -28,7 +26,7 @@
<item <item
android:id="@+id/headlines_select" android:id="@+id/headlines_select"
android:icon="@drawable/ic_select_all_light" android:icon="@drawable/ic_select_all_light"
app:showAsAction="ifRoom" app:showAsAction=""
android:title="@string/headlines_select"/> android:title="@string/headlines_select"/>
<item <item
android:id="@+id/headlines_view_mode" android:id="@+id/headlines_view_mode"
@ -81,7 +79,7 @@
<item <item
android:id="@+id/set_unread" android:id="@+id/set_unread"
android:icon="@drawable/ic_read_light" android:icon="@drawable/ic_read_light"
app:showAsAction="ifRoom" app:showAsAction=""
android:title="@string/article_set_unread"/> android:title="@string/article_set_unread"/>
<item <item
android:id="@+id/catchup_above" android:id="@+id/catchup_above"