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

View File

@ -5,7 +5,7 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<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">
<set>
<option value="$PROJECT_DIR$" />

View File

@ -3,6 +3,7 @@ package org.fox.ttrss;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
@ -39,6 +40,10 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
GlobalState.getInstance().load(savedInstanceState);
if (isPortrait() && !isSmallScreen()) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
}
if (savedInstanceState == null) {
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
protected void refresh() {
super.refresh();
@ -223,7 +237,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
}
public void showSidebar(boolean show) {
if (!isSmallScreen()) {
if (!isSmallScreen() && !isPortrait()) {
findViewById(R.id.headlines_fragment).setVisibility(show ? View.VISIBLE : View.GONE);
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,9 +1,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:id="@+id/headlines"
android:fitsSystemWindows="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:orientation="vertical" >
<FrameLayout
android:id="@+id/sw600dp_anchor"
@ -12,25 +12,30 @@
android:visibility="gone" >
</FrameLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/headlines_drawer"
<LinearLayout
android:id="@+id/fragment_container"
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
android:id="@+id/article_fragment"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="?articleBackground">
android:layout_weight="0.6"
android:elevation="4dp"
android:background="?articleBackground" >
</FrameLayout>
<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>