add ability to toggle headlines activity sidebar manually in landscape

on tablets
This commit is contained in:
Andrew Dolgov 2013-11-29 00:47:38 +04:00
parent f0a29f9bcb
commit 7bbbadee1e
10 changed files with 49 additions and 6 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss" package="org.fox.ttrss"
android:versionCode="226" android:versionCode="227"
android:versionName="1.30" > android:versionName="1.31" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"

View File

@ -65,6 +65,10 @@
android:showAsAction="" android:showAsAction=""
android:title="@string/headlines_view_mode"/> android:title="@string/headlines_view_mode"/>
<item
android:id="@+id/headlines_toggle_sidebar"
android:showAsAction=""
android:title="@string/toggle_sidebar"/>
<!-- <!--
<item <item

View File

@ -34,6 +34,11 @@
android:id="@+id/headlines_view_mode" android:id="@+id/headlines_view_mode"
android:showAsAction="" android:showAsAction=""
android:title="@string/headlines_view_mode"/> android:title="@string/headlines_view_mode"/>
<item
android:id="@+id/headlines_toggle_sidebar"
android:showAsAction=""
android:title="@string/toggle_sidebar"/>
</group> </group>
<!-- <!--
<group android:id="@+id/menu_group_headlines_selection" > <group android:id="@+id/menu_group_headlines_selection" >

View File

@ -215,4 +215,5 @@
<string name="server_function_not_available">Sorry, this function is not available on your tt-rss version.</string> <string name="server_function_not_available">Sorry, this function is not available on your tt-rss version.</string>
<string name="unsubscribe">Unsubscribe</string> <string name="unsubscribe">Unsubscribe</string>
<string name="unsubscribe_from_prompt">Unsubscribe from %1$s?</string> <string name="unsubscribe_from_prompt">Unsubscribe from %1$s?</string>
<string name="toggle_sidebar">Toggle sidebar</string>
</resources> </resources>

View File

@ -194,6 +194,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
m_menu.findItem(R.id.update_headlines).setVisible(false); m_menu.findItem(R.id.update_headlines).setVisible(false);
} }
m_menu.findItem(R.id.headlines_toggle_sidebar).setVisible(false);
MenuItem item = m_menu.findItem(R.id.show_feeds); MenuItem item = m_menu.findItem(R.id.show_feeds);
if (getUnreadOnly()) { if (getUnreadOnly()) {

View File

@ -39,7 +39,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
GlobalState.getInstance().load(savedInstanceState); GlobalState.getInstance().load(savedInstanceState);
if (isPortrait()) { if (isPortrait() || m_prefs.getBoolean("headlines_hide_sidebar", false)) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE); findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
} }
@ -161,7 +161,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
//HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); //HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
m_menu.setGroupVisible(R.id.menu_group_headlines, !isPortrait() && !isSmallScreen()); m_menu.setGroupVisible(R.id.menu_group_headlines, !isPortrait() && !isSmallScreen());
m_menu.findItem(R.id.headlines_toggle_sidebar).setVisible(!isPortrait() && !isSmallScreen());
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);

View File

@ -18,6 +18,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshAttacher; import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshAttacher;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
@ -36,11 +37,13 @@ import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
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.FrameLayout;
import android.widget.SearchView; import android.widget.SearchView;
import android.widget.TextView; import android.widget.TextView;
@ -641,6 +644,19 @@ public class OnlineActivity extends CommonActivity {
/* case android.R.id.home: /* case android.R.id.home:
finish(); finish();
return true; */ return true; */
case R.id.headlines_toggle_sidebar:
if (true && !isSmallScreen()) {
View v = findViewById(R.id.headlines_fragment);
if (v != null) {
SharedPreferences.Editor editor = m_prefs.edit();
editor.putBoolean("headlines_hide_sidebar", !m_prefs.getBoolean("headlines_hide_sidebar", false));
editor.commit();
v.setVisibility(m_prefs.getBoolean("headlines_hide_sidebar", false) ? View.GONE : View.VISIBLE);
}
}
return true;
case R.id.subscribe_to_feed: case R.id.subscribe_to_feed:
Intent subscribe = new Intent(OnlineActivity.this, SubscribeActivity.class); Intent subscribe = new Intent(OnlineActivity.this, SubscribeActivity.class);
startActivityForResult(subscribe, 0); startActivityForResult(subscribe, 0);

View File

@ -267,6 +267,17 @@ public class OfflineActivity extends CommonActivity {
/* case android.R.id.home: /* case android.R.id.home:
finish(); finish();
return true; */ return true; */
case R.id.headlines_toggle_sidebar:
if (true && !isSmallScreen()) {
SharedPreferences.Editor editor = m_prefs.edit();
editor.putBoolean("headlines_hide_sidebar", !m_prefs.getBoolean("headlines_hide_sidebar", false));
editor.commit();
if (ohf != null && ohf.isAdded()) {
ohf.getView().setVisibility(m_prefs.getBoolean("headlines_hide_sidebar", false) ? View.GONE : View.VISIBLE);
}
}
return true;
case R.id.go_online: case R.id.go_online:
switchOnline(); switchOnline();
return true; return true;

View File

@ -215,6 +215,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded()); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded());
} }
m_menu.findItem(R.id.headlines_toggle_sidebar).setVisible(false);
MenuItem item = m_menu.findItem(R.id.show_feeds); MenuItem item = m_menu.findItem(R.id.show_feeds);
if (getUnreadOnly()) { if (getUnreadOnly()) {

View File

@ -39,7 +39,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null); setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
if (isPortrait()) { if (isPortrait() || m_prefs.getBoolean("headlines_hide_sidebar", false)) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE); findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
} }
@ -143,7 +143,8 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
//OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); //OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
m_menu.setGroupVisible(R.id.menu_group_headlines, !isPortrait() && !isSmallScreen()); m_menu.setGroupVisible(R.id.menu_group_headlines, !isPortrait() && !isSmallScreen());
m_menu.findItem(R.id.headlines_toggle_sidebar).setVisible(!isPortrait() && !isSmallScreen());
Fragment af = getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); Fragment af = getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);