reorganize actionbar

This commit is contained in:
Andrew Dolgov 2011-11-24 19:11:10 +03:00
parent 2c2a032471
commit 1469ff7b8f
4 changed files with 49 additions and 21 deletions

View File

@ -9,7 +9,7 @@
<item android:id="@+id/show_feeds" <item android:id="@+id/show_feeds"
android:visible="false" android:enabled="false"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_rotate"
android:title="@string/menu_all_feeds" android:title="@string/menu_all_feeds"
android:showAsAction=""/> android:showAsAction=""/>
@ -21,22 +21,23 @@
android:showAsAction="ifRoom|withText"/> android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/update" <item android:id="@+id/update_feeds"
android:visible="false"
android:icon="@android:drawable/ic_menu_rotate"
android:title="@string/update"
android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/share"
android:enabled="false" android:enabled="false"
android:icon="@android:drawable/ic_menu_share" android:icon="@android:drawable/ic_menu_rotate"
android:title="@string/share_article" android:title="@string/update_feeds"
android:showAsAction="ifRoom"/> android:showAsAction=""/>
<item android:id="@+id/preferences" <item android:id="@+id/preferences"
android:icon="@android:drawable/ic_menu_preferences" android:icon="@android:drawable/ic_menu_preferences"
android:title="@string/preferences" android:title="@string/preferences"
android:showAsAction="ifRoom|withText"/> android:showAsAction=""/>
<item android:id="@+id/share_article"
android:visible="false"
android:icon="@android:drawable/ic_menu_share"
android:title="@string/share_article"
android:showAsAction="ifRoom"/>
<item android:id="@+id/logout" <item android:id="@+id/logout"
android:visible="false" android:visible="false"

View File

@ -28,7 +28,7 @@
<string name="loading_message">Loading, please wait...</string> <string name="loading_message">Loading, please wait...</string>
<string name="menu_unread_feeds">Show unread feeds</string> <string name="menu_unread_feeds">Show unread feeds</string>
<string name="menu_all_feeds">Show all feeds</string> <string name="menu_all_feeds">Show all feeds</string>
<string name="update">Update</string> <string name="update_feeds">Refresh feeds</string>
<string name="close_article">Close article</string> <string name="close_article">Close article</string>
<string name="share_article">Share article</string> <string name="share_article">Share article</string>
</resources> </resources>

View File

@ -26,6 +26,7 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ToggleButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
@ -214,6 +215,24 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
ar.execute(map); ar.execute(map);
} }
public void setArticleMarked(final Article article) {
ApiRequest ar = new ApiRequest();
ar.setApi(m_prefs.getString("ttrss_url", null));
final String sessionId = ((MainActivity)getActivity()).getSessionId();
HashMap<String,String> map = new HashMap<String,String>() {
{
put("sid", sessionId);
put("op", "updateArticle");
put("article_ids", String.valueOf(article.id));
put("mode", article.marked ? "1" : "0");
put("field", "0");
}
};
ar.execute(map);
}
private class ArticleListAdapter extends ArrayAdapter<Article> { private class ArticleListAdapter extends ArrayAdapter<Article> {
private ArrayList<Article> items; private ArrayList<Article> items;
@ -296,9 +315,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Log.d(TAG, "Marked image clicked " + v + " / " + article.id + "/" + article.marked);
article.marked = !article.marked; article.marked = !article.marked;
m_adapter.notifyDataSetChanged(); m_adapter.notifyDataSetChanged();
setArticleMarked(article);
} }
}); });
} }

View File

@ -182,7 +182,7 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
Intent intent = new Intent(this, PreferencesActivity.class); Intent intent = new Intent(this, PreferencesActivity.class);
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
return true; return true;
case R.id.update: case R.id.update_feeds:
refreshFeeds(); refreshFeeds();
return true; return true;
case R.id.logout: case R.id.logout:
@ -245,9 +245,11 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
ft.commit(); ft.commit();
m_menu.findItem(R.id.login).setVisible(false); m_menu.findItem(R.id.login).setVisible(false);
m_menu.findItem(R.id.logout).setVisible(true); m_menu.findItem(R.id.logout).setVisible(true);
m_menu.findItem(R.id.update).setVisible(true);
m_menu.findItem(R.id.show_feeds).setVisible(true); m_menu.findItem(R.id.update_feeds).setEnabled(true);
m_menu.findItem(R.id.show_feeds).setEnabled(true);
if (m_refreshTask != null) { if (m_refreshTask != null) {
m_refreshTask.cancel(); m_refreshTask.cancel();
@ -329,8 +331,10 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
if (m_menu != null) if (m_menu != null) {
m_menu.findItem(R.id.close_article).setVisible(true); m_menu.findItem(R.id.close_article).setVisible(true);
m_menu.findItem(R.id.share_article).setVisible(true);
}
} }
@ -344,10 +348,13 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
if (m_menu != null) { if (m_menu != null) {
m_menu.findItem(R.id.login).setVisible(true); m_menu.findItem(R.id.login).setVisible(true);
m_menu.findItem(R.id.logout).setVisible(false); m_menu.findItem(R.id.logout).setVisible(false);
m_menu.findItem(R.id.update).setVisible(false);
m_menu.findItem(R.id.show_feeds).setVisible(false);
m_menu.findItem(R.id.close_article).setVisible(false); m_menu.findItem(R.id.close_article).setVisible(false);
m_menu.findItem(R.id.share_article).setVisible(false);
m_menu.findItem(R.id.update_feeds).setEnabled(false);
m_menu.findItem(R.id.show_feeds).setEnabled(false);
} }
if (m_refreshTask != null) { if (m_refreshTask != null) {