add fix for sidebar not showing/hiding properly on tablets because of activity not being recreated on orientation change (this is needed to restore webview/fsview state)

This commit is contained in:
Andrew Dolgov 2015-02-07 16:35:44 +03:00
parent 183079172d
commit df0c03abd8
4 changed files with 37 additions and 54 deletions

2
.idea/gradle.xml generated
View File

@ -5,7 +5,7 @@
<GradleProjectSettings> <GradleProjectSettings>
<option name="distributionType" value="LOCAL" /> <option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:\Users\fox\android-studio\gradle\gradle-2.2.1" /> <option name="gradleHome" value="C:\Users\Andrew\AppData\Local\Android\android-studio1\gradle\gradle-2.2.1" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@ -3,6 +3,7 @@ package org.fox.ttrss;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -39,6 +40,10 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
GlobalState.getInstance().load(savedInstanceState); GlobalState.getInstance().load(savedInstanceState);
if (isPortrait() && !isSmallScreen()) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
}
if (savedInstanceState == null) { if (savedInstanceState == null) {
Intent i = getIntent(); Intent i = getIntent();
@ -99,6 +104,15 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
} }
} }
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (!isSmallScreen()) {
findViewById(R.id.headlines_fragment).setVisibility(isPortrait() ? View.GONE : View.VISIBLE);
}
}
@Override @Override
protected void refresh() { protected void refresh() {
super.refresh(); super.refresh();
@ -223,7 +237,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
} }
public void showSidebar(boolean show) { public void showSidebar(boolean show) {
if (!isSmallScreen()) { if (!isSmallScreen() && !isPortrait()) {
findViewById(R.id.headlines_fragment).setVisibility(show ? View.VISIBLE : View.GONE); findViewById(R.id.headlines_fragment).setVisibility(show ? View.VISIBLE : View.GONE);
invalidateOptionsMenu(); invalidateOptionsMenu();
} }

View File

@ -1,36 +0,0 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/sw600dp_port_anchor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
</FrameLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/headlines_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/headlines_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?headlinesBackground">
</FrameLayout>
<FrameLayout
android:id="@+id/feeds_fragment"
android:layout_width="300dp"
android:layout_gravity="start"
android:background="?feedlistBackground"
android:layout_height="match_parent" >
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
</FrameLayout>

View File

@ -1,5 +1,5 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main" android:id="@+id/headlines"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
@ -12,25 +12,30 @@
android:visibility="gone" > android:visibility="gone" >
</FrameLayout> </FrameLayout>
<android.support.v4.widget.DrawerLayout <LinearLayout
android:id="@+id/headlines_drawer" android:id="@+id/fragment_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<FrameLayout
android:paddingRight="4dp"
android:id="@+id/headlines_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="?headlinesBackground" >
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/article_fragment" android:id="@+id/article_fragment"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.6"
android:elevation="4dp"
android:background="?articleBackground" > android:background="?articleBackground" >
</FrameLayout> </FrameLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/headlines_fragment"
android:layout_height="match_parent"
android:layout_width="500dp"
android:layout_gravity="start"
android:background="?headlinesBackground">
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout> </LinearLayout>