From 1b40669cc52fa81c4a66d8591a31d3d864dc5876 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 4 Dec 2012 10:52:55 +0400 Subject: [PATCH] fix disappearing up arrow on actionbar; import cleanup --- src/org/fox/ttrss/ApiRequest.java | 8 +------- src/org/fox/ttrss/ArticleFragment.java | 4 ---- src/org/fox/ttrss/CommonActivity.java | 2 -- src/org/fox/ttrss/FeedCategoriesFragment.java | 1 - src/org/fox/ttrss/FeedsActivity.java | 17 +++++++++++------ src/org/fox/ttrss/FeedsFragment.java | 11 ----------- src/org/fox/ttrss/HeadlinesActivity.java | 2 -- .../ttrss/offline/OfflineArticleFragment.java | 4 +--- .../fox/ttrss/offline/OfflineArticlePager.java | 1 - .../fox/ttrss/offline/OfflineFeedsActivity.java | 15 +++++++++++++++ 10 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/org/fox/ttrss/ApiRequest.java b/src/org/fox/ttrss/ApiRequest.java index bce8c20d..95d72385 100644 --- a/src/org/fox/ttrss/ApiRequest.java +++ b/src/org/fox/ttrss/ApiRequest.java @@ -1,15 +1,13 @@ package org.fox.ttrss; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; -import java.nio.CharBuffer; import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.HashMap; import javax.net.ssl.HostnameVerifier; @@ -19,10 +17,6 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; -import org.apache.http.util.CharArrayBuffer; - -import java.security.cert.X509Certificate; - import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java index 399f0f10..f1846863 100644 --- a/src/org/fox/ttrss/ArticleFragment.java +++ b/src/org/fox/ttrss/ArticleFragment.java @@ -2,7 +2,6 @@ package org.fox.ttrss; import java.net.MalformedURLException; import java.net.URL; -import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -23,8 +22,6 @@ import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; -import android.text.Html; -import android.text.method.LinkMovementMethod; import android.util.Log; import android.util.TypedValue; import android.view.ContextMenu; @@ -38,7 +35,6 @@ import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebView; -import android.webkit.WebViewClient; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; diff --git a/src/org/fox/ttrss/CommonActivity.java b/src/org/fox/ttrss/CommonActivity.java index 4f73b046..5c18f383 100644 --- a/src/org/fox/ttrss/CommonActivity.java +++ b/src/org/fox/ttrss/CommonActivity.java @@ -6,8 +6,6 @@ import android.annotation.SuppressLint; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.support.v4.app.FragmentActivity; -import android.util.DisplayMetrics; -import android.util.FloatMath; import android.util.Log; import android.view.Display; import android.view.View; diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index 0b7922c1..65b3af36 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -25,7 +25,6 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index f499bd98..2480de6a 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -28,6 +28,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe protected SharedPreferences m_prefs; protected long m_lastRefresh = 0; + private boolean m_actionbarUpEnabled = false; + @SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { @@ -57,6 +59,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe if (!isCompatMode()) { getActionBar().setDisplayHomeAsUpEnabled(true); + m_actionbarUpEnabled = true; } Feed feed = (Feed) intent.getParcelableExtra("feed"); @@ -105,12 +108,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe AppRater.appLaunched(this); - if (GlobalState.getInstance().m_activeArticle != null || GlobalState.getInstance().m_activeFeed != null) { - if (!isCompatMode()) { - getActionBar().setDisplayHomeAsUpEnabled(true); - } - } - + } + } else { // savedInstanceState != null + m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); + + if (!isCompatMode() && m_actionbarUpEnabled) { + getActionBar().setDisplayHomeAsUpEnabled(true); } } @@ -255,6 +258,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe public void onSaveInstanceState(Bundle out) { super.onSaveInstanceState(out); + out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); + GlobalState.getInstance().save(out); } diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 1b1cec44..8375d4d9 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -7,22 +7,12 @@ import java.io.InputStream; import java.lang.reflect.Type; import java.net.HttpURLConnection; import java.net.URL; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.fox.ttrss.types.Article; import org.fox.ttrss.types.Feed; import org.fox.ttrss.types.FeedCategory; import org.fox.ttrss.types.FeedList; @@ -35,7 +25,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.http.AndroidHttpClient; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; diff --git a/src/org/fox/ttrss/HeadlinesActivity.java b/src/org/fox/ttrss/HeadlinesActivity.java index 97f06b6f..9b5d8a1f 100644 --- a/src/org/fox/ttrss/HeadlinesActivity.java +++ b/src/org/fox/ttrss/HeadlinesActivity.java @@ -4,7 +4,6 @@ import org.fox.ttrss.types.Article; import org.fox.ttrss.types.ArticleList; import org.fox.ttrss.types.Feed; -import android.animation.LayoutTransition; import android.annotation.SuppressLint; import android.content.Intent; import android.content.SharedPreferences; @@ -16,7 +15,6 @@ import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventListener { private final String TAG = this.getClass().getSimpleName(); diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index a1b22094..56df22b4 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -21,16 +21,14 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.BaseColumns; import android.support.v4.app.Fragment; -import android.text.Html; -import android.text.method.LinkMovementMethod; import android.util.Log; import android.util.TypedValue; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; -import android.view.View.OnClickListener; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.webkit.WebChromeClient; import android.webkit.WebSettings; diff --git a/src/org/fox/ttrss/offline/OfflineArticlePager.java b/src/org/fox/ttrss/offline/OfflineArticlePager.java index bc138bb0..74eb8ca9 100644 --- a/src/org/fox/ttrss/offline/OfflineArticlePager.java +++ b/src/org/fox/ttrss/offline/OfflineArticlePager.java @@ -1,7 +1,6 @@ package org.fox.ttrss.offline; import org.fox.ttrss.R; -import org.fox.ttrss.types.Article; import android.app.Activity; import android.content.SharedPreferences; diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index 5abf8b12..99351849 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -1,5 +1,6 @@ package org.fox.ttrss.offline; +import org.fox.ttrss.GlobalState; import org.fox.ttrss.R; import android.annotation.SuppressLint; @@ -17,6 +18,8 @@ import android.view.View; public class OfflineFeedsActivity extends OfflineActivity implements OfflineHeadlinesEventListener { private final String TAG = this.getClass().getSimpleName(); + private boolean m_actionbarUpEnabled = false; + @SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { @@ -35,8 +38,16 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead setSmallScreen(findViewById(R.id.headlines_fragment) == null); + GlobalState.getInstance().load(savedInstanceState); + if (savedInstanceState != null) { + m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); + + if (!isCompatMode() && m_actionbarUpEnabled) { + getActionBar().setDisplayHomeAsUpEnabled(true); + } + } else { Intent intent = getIntent(); @@ -45,6 +56,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead if (!isCompatMode()) { getActionBar().setDisplayHomeAsUpEnabled(true); + } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); @@ -115,6 +127,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead public void onSaveInstanceState(Bundle out) { super.onSaveInstanceState(out); + out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); + + GlobalState.getInstance().save(out); } public void initMenu() {