offline: modernize UI

This commit is contained in:
Andrew Dolgov 2013-04-16 22:23:36 +04:00
parent f10c37563a
commit d9563da33d
6 changed files with 41 additions and 26 deletions

View File

@ -51,6 +51,7 @@
</activity> </activity>
<activity <activity
android:name=".offline.OfflineFeedsActivity" android:name=".offline.OfflineFeedsActivity"
android:uiOptions="splitActionBarWhenNarrow"
android:label="@string/app_name" > android:label="@string/app_name" >
</activity> </activity>
<activity <activity

View File

@ -3,7 +3,7 @@
<item <item
android:id="@+id/selection_toggle_unread" android:id="@+id/selection_toggle_unread"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:icon="@drawable/ic_undo_light" android:icon="@drawable/ic_unread_light"
android:title="@string/selection_toggle_unread"/> android:title="@string/selection_toggle_unread"/>
<item <item

View File

@ -23,10 +23,13 @@
android:title="@string/search"/> android:title="@string/search"/>
<item <item
android:id="@+id/headlines_mark_as_read" android:id="@+id/headlines_mark_as_read"
android:icon="@drawable/ic_accept_light"
android:showAsAction="ifRoom"
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"
android:showAsAction="" android:icon="@drawable/ic_select_all_light"
android:showAsAction="ifRoom"
android:title="@string/headlines_select"/> android:title="@string/headlines_select"/>
</group> </group>
<group android:id="@+id/menu_group_headlines_selection" > <group android:id="@+id/menu_group_headlines_selection" >
@ -62,14 +65,13 @@
android:title="@string/article_toggle_published"/> android:title="@string/article_toggle_published"/>
<item <item
android:id="@+id/share_article" android:id="@+id/share_article"
android:actionProviderClass="android.widget.ShareActionProvider"
android:icon="@drawable/ic_share_light" android:icon="@drawable/ic_share_light"
android:showAsAction="" android:showAsAction="ifRoom"
android:title="@string/share_article"/> android:title="@string/share_article"/>
<item <item
android:id="@+id/set_unread" android:id="@+id/set_unread"
android:icon="@drawable/ic_read_light" android:icon="@drawable/ic_read_light"
android:showAsAction="" android:showAsAction="ifRoom"
android:title="@string/article_set_unread"/> android:title="@string/article_set_unread"/>
<item <item
android:id="@+id/catchup_above" android:id="@+id/catchup_above"

View File

@ -27,7 +27,6 @@ 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.SearchView;
import android.widget.ShareActionProvider;
public class OfflineActivity extends CommonActivity { public class OfflineActivity extends CommonActivity {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
@ -269,7 +268,7 @@ public class OfflineActivity extends CommonActivity {
} }
return true; return true;
case R.id.share_article: case R.id.share_article:
if (android.os.Build.VERSION.SDK_INT < 14 && oap != null && android.os.Build.VERSION.SDK_INT < 14) { if (true) {
int articleId = oap.getSelectedArticleId(); int articleId = oap.getSelectedArticleId();
shareArticle(articleId); shareArticle(articleId);
@ -408,20 +407,6 @@ public class OfflineActivity extends CommonActivity {
m_menu.setGroupVisible(R.id.menu_group_article, false); m_menu.setGroupVisible(R.id.menu_group_article, false);
m_menu.setGroupVisible(R.id.menu_group_feeds, false); m_menu.setGroupVisible(R.id.menu_group_feeds, false);
if (android.os.Build.VERSION.SDK_INT >= 14) {
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
if (af != null && af.getSelectedArticleId() > 0) {
shareProvider.setShareIntent(getShareIntent(getArticleById(af.getSelectedArticleId())));
if (!isSmallScreen()) {
m_menu.findItem(R.id.share_article).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
}
}
if (!isCompatMode()) { if (!isCompatMode()) {
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
@ -435,6 +420,31 @@ public class OfflineActivity extends CommonActivity {
} }
} }
OfflineArticlePager ap = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
if (ap != null) {
int articleId = ap.getSelectedArticleId();
Cursor article = getArticleById(articleId);
if (article != null) {
boolean unread = article.getInt(article.getColumnIndex("unread")) == 1;
boolean marked = article.getInt(article.getColumnIndex("marked")) == 1;
boolean published = article.getInt(article.getColumnIndex("published")) == 1;
m_menu.findItem(R.id.toggle_marked).setIcon(marked ? R.drawable.ic_important_light :
R.drawable.ic_unimportant_light);
m_menu.findItem(R.id.toggle_published).setIcon(published ? R.drawable.ic_menu_published_light :
R.drawable.ic_menu_unpublished_light);
m_menu.findItem(R.id.set_unread).setIcon(unread ? R.drawable.ic_unread_light :
R.drawable.ic_read_light);
article.close();
}
}
SearchView searchView = (SearchView) search.getActionView(); SearchView searchView = (SearchView) search.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
private String query = ""; private String query = "";
@ -618,8 +628,10 @@ public class OfflineActivity extends CommonActivity {
.findFragmentByTag(FRAG_HEADLINES); .findFragmentByTag(FRAG_HEADLINES);
if (ohf != null) { if (ohf != null) {
ohf.refresh(); ohf.refresh();
} }
initMenu();
} }
} }

View File

@ -192,11 +192,9 @@ public class OfflineArticlePager extends Fragment {
public void onPageSelected(int position) { public void onPageSelected(int position) {
if (m_cursor.moveToPosition(position)) { if (m_cursor.moveToPosition(position)) {
int articleId = m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID)); int articleId = m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID));
m_listener.onArticleSelected(articleId, false);
m_articleId = articleId; m_articleId = articleId;
m_listener.onArticleSelected(articleId, false);
} }
} }
}); });

View File

@ -272,6 +272,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
stmt.execute(); stmt.execute();
stmt.close(); stmt.close();
initMenu();
if (open) { if (open) {
if (isSmallScreen()) { if (isSmallScreen()) {