fix disappearing up arrow on actionbar; import cleanup

This commit is contained in:
Andrew Dolgov 2012-12-04 10:52:55 +04:00
parent d5ebce0b53
commit 1b40669cc5
10 changed files with 28 additions and 37 deletions

View File

@ -1,15 +1,13 @@
package org.fox.ttrss; package org.fox.ttrss;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.CharBuffer;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashMap; import java.util.HashMap;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
@ -19,10 +17,6 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import org.apache.http.util.CharArrayBuffer;
import java.security.cert.X509Certificate;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;

View File

@ -2,7 +2,6 @@ package org.fox.ttrss;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -23,8 +22,6 @@ 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.Fragment; import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log; import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ContextMenu; import android.view.ContextMenu;
@ -38,7 +35,6 @@ import android.webkit.WebChromeClient;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.Spinner; import android.widget.Spinner;

View File

@ -6,8 +6,6 @@ import android.annotation.SuppressLint;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.util.FloatMath;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.View; import android.view.View;

View File

@ -25,7 +25,6 @@ import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;

View File

@ -28,6 +28,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
protected SharedPreferences m_prefs; protected SharedPreferences m_prefs;
protected long m_lastRefresh = 0; protected long m_lastRefresh = 0;
private boolean m_actionbarUpEnabled = false;
@SuppressLint("NewApi") @SuppressLint("NewApi")
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -57,6 +59,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (!isCompatMode()) { if (!isCompatMode()) {
getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true);
m_actionbarUpEnabled = true;
} }
Feed feed = (Feed) intent.getParcelableExtra("feed"); Feed feed = (Feed) intent.getParcelableExtra("feed");
@ -105,12 +108,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
AppRater.appLaunched(this); 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) { public void onSaveInstanceState(Bundle out) {
super.onSaveInstanceState(out); super.onSaveInstanceState(out);
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
GlobalState.getInstance().save(out); GlobalState.getInstance().save(out);
} }

View File

@ -7,22 +7,12 @@ import java.io.InputStream;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.Feed;
import org.fox.ttrss.types.FeedCategory; import org.fox.ttrss.types.FeedCategory;
import org.fox.ttrss.types.FeedList; import org.fox.ttrss.types.FeedList;
@ -35,7 +25,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.http.AndroidHttpClient; import android.net.http.AndroidHttpClient;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;

View File

@ -4,7 +4,6 @@ import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.ArticleList; import org.fox.ttrss.types.ArticleList;
import org.fox.ttrss.types.Feed; import org.fox.ttrss.types.Feed;
import android.animation.LayoutTransition;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -16,7 +15,6 @@ import android.support.v4.app.FragmentTransaction;
import android.util.Log; import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventListener { public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventListener {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();

View File

@ -21,16 +21,14 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log; import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebSettings; import android.webkit.WebSettings;

View File

@ -1,7 +1,6 @@
package org.fox.ttrss.offline; package org.fox.ttrss.offline;
import org.fox.ttrss.R; import org.fox.ttrss.R;
import org.fox.ttrss.types.Article;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;

View File

@ -1,5 +1,6 @@
package org.fox.ttrss.offline; package org.fox.ttrss.offline;
import org.fox.ttrss.GlobalState;
import org.fox.ttrss.R; import org.fox.ttrss.R;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
@ -17,6 +18,8 @@ import android.view.View;
public class OfflineFeedsActivity extends OfflineActivity implements OfflineHeadlinesEventListener { public class OfflineFeedsActivity extends OfflineActivity implements OfflineHeadlinesEventListener {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
private boolean m_actionbarUpEnabled = false;
@SuppressLint("NewApi") @SuppressLint("NewApi")
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -35,8 +38,16 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
setSmallScreen(findViewById(R.id.headlines_fragment) == null); setSmallScreen(findViewById(R.id.headlines_fragment) == null);
GlobalState.getInstance().load(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null) {
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
if (!isCompatMode() && m_actionbarUpEnabled) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
} else { } else {
Intent intent = getIntent(); Intent intent = getIntent();
@ -45,6 +56,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
if (!isCompatMode()) { if (!isCompatMode()) {
getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true);
} }
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
@ -115,6 +127,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
public void onSaveInstanceState(Bundle out) { public void onSaveInstanceState(Bundle out) {
super.onSaveInstanceState(out); super.onSaveInstanceState(out);
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
GlobalState.getInstance().save(out);
} }
public void initMenu() { public void initMenu() {