summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-06-24 23:52:23 +0400
committerAndrew Dolgov <[email protected]>2012-06-24 23:52:23 +0400
commit099377a665d8901b245a42125ecd8703c73b49af (patch)
tree6452a87504e917f6cd29e3a36f1055e006aa809e
parentff63819a65d47536332655947eeb92013a940f8e (diff)
move some shared activity code to CommonActivity
-rw-r--r--src/org/fox/ttrss/CommonActivity.java71
-rw-r--r--src/org/fox/ttrss/MainActivity.java94
-rw-r--r--src/org/fox/ttrss/offline/OfflineActivity.java98
3 files changed, 120 insertions, 143 deletions
diff --git a/src/org/fox/ttrss/CommonActivity.java b/src/org/fox/ttrss/CommonActivity.java
new file mode 100644
index 00000000..07f18fc9
--- /dev/null
+++ b/src/org/fox/ttrss/CommonActivity.java
@@ -0,0 +1,71 @@
+package org.fox.ttrss;
+
+import org.fox.ttrss.util.DatabaseHelper;
+
+import android.content.res.Configuration;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.util.Log;
+
+public class CommonActivity extends FragmentActivity {
+ private final String TAG = this.getClass().getSimpleName();
+
+ private SQLiteDatabase m_readableDb;
+ private SQLiteDatabase m_writableDb;
+
+ private boolean m_smallScreenMode;
+ private boolean m_compatMode = false;
+
+ private void initDatabase() {
+ DatabaseHelper dh = new DatabaseHelper(getApplicationContext());
+
+ m_writableDb = dh.getWritableDatabase();
+ m_readableDb = dh.getReadableDatabase();
+ }
+
+ public synchronized SQLiteDatabase getReadableDb() {
+ return m_readableDb;
+ }
+
+ public synchronized SQLiteDatabase getWritableDb() {
+ return m_writableDb;
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ m_readableDb.close();
+ m_writableDb.close();
+
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ initDatabase();
+
+ m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
+
+ m_smallScreenMode = m_compatMode || (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) !=
+ Configuration.SCREENLAYOUT_SIZE_XLARGE;
+
+ Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode);
+ Log.d(TAG, "m_compatMode=" + m_compatMode);
+
+ super.onCreate(savedInstanceState);
+ }
+
+ public boolean isSmallScreen() {
+ return m_smallScreenMode;
+ }
+
+ public boolean isCompatMode() {
+ return m_compatMode;
+ }
+
+ public int getOrientation() {
+ return getWindowManager().getDefaultDisplay().getOrientation();
+ }
+
+}
diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java
index 38589338..b1b4da0d 100644
--- a/src/org/fox/ttrss/MainActivity.java
+++ b/src/org/fox/ttrss/MainActivity.java
@@ -19,7 +19,6 @@ import org.fox.ttrss.types.Feed;
import org.fox.ttrss.types.FeedCategory;
import org.fox.ttrss.types.Label;
import org.fox.ttrss.util.AppRater;
-import org.fox.ttrss.util.DatabaseHelper;
import android.animation.LayoutTransition;
import android.annotation.SuppressLint;
@@ -34,15 +33,12 @@ import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.ActionMode;
@@ -66,7 +62,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
-public class MainActivity extends FragmentActivity implements OnlineServices {
+public class MainActivity extends CommonActivity implements OnlineServices {
private final String TAG = this.getClass().getSimpleName();
protected final static String FRAG_HEADLINES = "headlines";
@@ -83,10 +79,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private Timer m_refreshTimer;
private RefreshTask m_refreshTask;
private Menu m_menu;
- private boolean m_smallScreenMode;
private boolean m_unreadOnly = true;
private boolean m_unreadArticlesOnly = true;
- private boolean m_compatMode = false;
private boolean m_enableCats = false;
private int m_apiLevel = 0;
private boolean m_isLoggingIn = false;
@@ -95,9 +89,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private int m_selectedProduct = -1;
private long m_lastRefresh = 0;
- private SQLiteDatabase m_readableDb;
- private SQLiteDatabase m_writableDb;
-
private ActionMode m_headlinesActionMode;
private HeadlinesActionModeCallback m_headlinesActionModeCallback;
private NavigationListener m_navigationListener;
@@ -141,7 +132,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_selectedArticle = null;
m_activeCategory = null;
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
if (m_enableCats) {
ft.replace(R.id.fragment_container, new FeedCategoriesFragment(), FRAG_CATS);
@@ -188,7 +179,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
Fragment hf = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (hf != null) ft.remove(hf);
@@ -238,7 +229,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_selectedArticle = null;
- if (!m_smallScreenMode)
+ if (!isSmallScreen())
findViewById(R.id.article_fragment).setVisibility(View.GONE);
viewFeed(m_feed, false);
@@ -618,24 +609,10 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
}
@Override
- public boolean isSmallScreen() {
- return m_smallScreenMode;
- }
-
- @Override
- public int getOrientation() {
- return getWindowManager().getDefaultDisplay().getOrientation();
- }
-
- @Override
public void onCreate(Bundle savedInstanceState) {
- initDatabase();
-
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
- m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
-
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
@@ -670,9 +647,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_enableCats = m_prefs.getBoolean("enable_cats", false);
- m_smallScreenMode = m_compatMode || (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) !=
- Configuration.SCREENLAYOUT_SIZE_XLARGE;
-
setContentView(R.layout.main);
IntentFilter filter = new IntentFilter();
@@ -687,12 +661,10 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_isOffline = localPrefs.getBoolean("offline_mode_active", false);
Log.d(TAG, "m_isOffline=" + m_isOffline);
- Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode);
- Log.d(TAG, "m_compatMode=" + m_compatMode);
- if (!m_compatMode) {
+ if (!isCompatMode()) {
- if (!m_smallScreenMode) {
+ if (!isSmallScreen()) {
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticle != null && getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(m_selectedArticle != null ? View.VISIBLE : View.GONE);
}
@@ -708,7 +680,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
getActionBar().setListNavigationCallbacks(m_navigationAdapter, m_navigationListener);
}
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (m_selectedArticle != null) {
@@ -742,20 +714,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
}
}
- private void initDatabase() {
- DatabaseHelper dh = new DatabaseHelper(getApplicationContext());
- m_writableDb = dh.getWritableDatabase();
- m_readableDb = dh.getReadableDatabase();
- }
-
- public synchronized SQLiteDatabase getReadableDb() {
- return m_readableDb;
- }
-
- public synchronized SQLiteDatabase getWritableDb() {
- return m_writableDb;
- }
-
private void switchOffline() {
if (m_offlineModeStatus == 2) {
@@ -977,7 +935,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_activeCategory = null;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, new FeedCategoriesFragment(), FRAG_CATS);
} else {
ft.replace(R.id.feeds_fragment, new FeedCategoriesFragment(), FRAG_CATS);
@@ -1003,7 +961,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
}
private void goBack(boolean allowQuit) {
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
if (m_selectedArticle != null) {
closeArticle();
} else if (m_activeFeed != null) {
@@ -1100,7 +1058,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
goBack(false);
return true;
case R.id.search:
- if (hf != null && m_compatMode) {
+ if (hf != null && isCompatMode()) {
Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this);
@@ -1455,7 +1413,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.remove(getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE));
ft.show(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
} else {
@@ -1493,7 +1451,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
numSelected = hf.getSelectedArticles().size();
if (numSelected != 0) {
- if (m_compatMode) {
+ if (isCompatMode()) {
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
} else {
if (m_headlinesActionMode == null)
@@ -1509,7 +1467,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
search.setEnabled(m_apiLevel >= 2);
- if (!m_compatMode) {
+ if (!isCompatMode()) {
SearchView searchView = (SearchView) search.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
private String query = "";
@@ -1552,7 +1510,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_headlinesActionMode.finish();
}
- if (!m_compatMode) {
+ if (!isCompatMode()) {
/* if (m_activeFeed != null) {
getActionBar().setTitle(m_activeFeed.title);
@@ -1564,7 +1522,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_navigationAdapter.clear();
- if (m_activeCategory != null || (m_activeFeed != null && m_smallScreenMode)) {
+ if (m_activeCategory != null || (m_activeFeed != null && isSmallScreen())) {
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
@@ -1587,7 +1545,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
getActionBar().setTitle(R.string.app_name);
}
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null || m_activeFeed != null);
} else {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null);
@@ -1637,10 +1595,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
super.onDestroy();
unregisterReceiver(m_broadcastReceiver);
-
- m_readableDb.close();
- m_writableDb.close();
-
}
private void syncOfflineData() {
@@ -1721,7 +1675,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (m_enableCats) {
FeedCategoriesFragment frag = new FeedCategoriesFragment();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, frag, FRAG_CATS);
} else {
ft.replace(R.id.feeds_fragment, frag, FRAG_CATS);
@@ -1729,7 +1683,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
} else {
FeedsFragment frag = new FeedsFragment();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, frag, FRAG_FEEDS);
} else {
ft.replace(R.id.feeds_fragment, frag, FRAG_FEEDS);
@@ -1820,7 +1774,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search);
- if (search != null && !m_compatMode) {
+ if (search != null && !isCompatMode()) {
SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false);
}
@@ -1831,7 +1785,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
Fragment cats = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
if (cats != null) ft.hide(cats);
@@ -1869,7 +1823,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, frag, FRAG_FEEDS);
} else {
ft.replace(R.id.feeds_fragment, frag, FRAG_FEEDS);
@@ -1882,7 +1836,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search);
- if (search != null && !m_compatMode) {
+ if (search != null && !isCompatMode()) {
SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false);
}
@@ -1910,14 +1864,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
Fragment frag;
- if (m_smallScreenMode || m_prefs.getBoolean("tablet_article_swipe", false)) {
+ if (isSmallScreen() || m_prefs.getBoolean("tablet_article_swipe", false)) {
frag = new ArticlePager(article);
} else {
frag = new ArticleFragment(article);
}
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
ft.add(R.id.fragment_container, frag, FRAG_ARTICLE);
} else {
diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java
index 3a11b87e..e5f4793c 100644
--- a/src/org/fox/ttrss/offline/OfflineActivity.java
+++ b/src/org/fox/ttrss/offline/OfflineActivity.java
@@ -2,13 +2,13 @@ package org.fox.ttrss.offline;
import java.util.ArrayList;
+import org.fox.ttrss.CommonActivity;
import org.fox.ttrss.DummyFragment;
import org.fox.ttrss.MainActivity;
import org.fox.ttrss.OnlineServices;
import org.fox.ttrss.OnlineServices.RelativeArticle;
import org.fox.ttrss.PreferencesActivity;
import org.fox.ttrss.R;
-import org.fox.ttrss.util.DatabaseHelper;
import android.animation.LayoutTransition;
import android.app.ActionBar;
@@ -20,15 +20,12 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.ActionMode;
@@ -45,7 +42,7 @@ import android.widget.SearchView;
import android.widget.ShareActionProvider;
import android.widget.Toast;
-public class OfflineActivity extends FragmentActivity implements
+public class OfflineActivity extends CommonActivity implements
OfflineServices {
private final String TAG = this.getClass().getSimpleName();
@@ -57,10 +54,8 @@ public class OfflineActivity extends FragmentActivity implements
private SharedPreferences m_prefs;
private String m_themeName = "";
private Menu m_menu;
- private boolean m_smallScreenMode;
private boolean m_unreadOnly = true;
private boolean m_unreadArticlesOnly = true;
- private boolean m_compatMode = false;
private boolean m_enableCats = false;
private int m_activeFeedId = 0;
@@ -68,14 +63,6 @@ public class OfflineActivity extends FragmentActivity implements
private int m_activeCatId = -1;
private int m_selectedArticleId = 0;
- private SQLiteDatabase m_readableDb;
- private SQLiteDatabase m_writableDb;
-
- @Override
- public boolean isSmallScreen() {
- return m_smallScreenMode;
- }
-
private ActionMode m_headlinesActionMode;
private HeadlinesActionModeCallback m_headlinesActionModeCallback;
private NavigationListener m_navigationListener;
@@ -96,7 +83,7 @@ public class OfflineActivity extends FragmentActivity implements
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
if (m_enableCats) {
ft.replace(R.id.fragment_container, new OfflineFeedCategoriesFragment(), FRAG_CATS);
@@ -146,7 +133,7 @@ public class OfflineActivity extends FragmentActivity implements
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
Fragment hf = getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (hf != null) ft.remove(hf);
@@ -192,7 +179,7 @@ public class OfflineActivity extends FragmentActivity implements
m_selectedArticleId = 0;
- if (!m_smallScreenMode)
+ if (!isSmallScreen())
findViewById(R.id.article_fragment).setVisibility(View.GONE);
viewFeed(m_feed, false);
@@ -273,13 +260,9 @@ public class OfflineActivity extends FragmentActivity implements
@Override
public void onCreate(Bundle savedInstanceState) {
- initDatabase();
-
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
- m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
-
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
@@ -307,16 +290,10 @@ public class OfflineActivity extends FragmentActivity implements
m_enableCats = m_prefs.getBoolean("enable_cats", false);
- m_smallScreenMode = m_compatMode || (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) !=
- Configuration.SCREENLAYOUT_SIZE_XLARGE;
-
setContentView(R.layout.main);
- Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode);
- Log.d(TAG, "m_compatMode=" + m_compatMode);
-
- if (!m_compatMode) {
- if (!m_smallScreenMode) {
+ if (!isCompatMode()) {
+ if (!isSmallScreen()) {
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticleId != 0 && getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(m_selectedArticleId != 0 ? View.VISIBLE : View.GONE);
}
@@ -353,7 +330,7 @@ public class OfflineActivity extends FragmentActivity implements
tag = FRAG_FEEDS;
}
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, frag, tag);
} else {
ft.replace(R.id.feeds_fragment, frag, tag);
@@ -363,22 +340,6 @@ public class OfflineActivity extends FragmentActivity implements
}
}
- private void initDatabase() {
- DatabaseHelper dh = new DatabaseHelper(getApplicationContext());
- m_writableDb = dh.getWritableDatabase();
- m_readableDb = dh.getReadableDatabase();
- }
-
- @Override
- public synchronized SQLiteDatabase getReadableDb() {
- return m_readableDb;
- }
-
- @Override
- public synchronized SQLiteDatabase getWritableDb() {
- return m_writableDb;
- }
-
private void switchOnline() {
SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = localPrefs.edit();
@@ -477,7 +438,7 @@ public class OfflineActivity extends FragmentActivity implements
}
private void goBack(boolean allowQuit) {
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
if (m_selectedArticleId != 0) {
closeArticle();
} else if (m_activeFeedId != 0) {
@@ -542,8 +503,8 @@ public class OfflineActivity extends FragmentActivity implements
* @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if
* (keyCode == KeyEvent.KEYCODE_BACK) {
*
- * if (m_smallScreenMode) { if (m_selectedArticleId != 0) { closeArticle();
- * } else if (m_activeFeedId != 0) { if (m_compatMode) {
+ * if (isSmallScreen()) { if (m_selectedArticleId != 0) { closeArticle();
+ * } else if (m_activeFeedId != 0) { if (isCompatMode()) {
* findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this,
* R.anim.slide_right)); }
*/
@@ -646,7 +607,7 @@ public class OfflineActivity extends FragmentActivity implements
goBack(false);
return true;
case R.id.search:
- if (ohf != null && m_compatMode) {
+ if (ohf != null && isCompatMode()) {
Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this);
@@ -875,7 +836,7 @@ public class OfflineActivity extends FragmentActivity implements
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.remove(getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE));
ft.show(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
} else {
@@ -912,7 +873,7 @@ public class OfflineActivity extends FragmentActivity implements
m_menu.setGroupVisible(R.id.menu_group_article, false);
if (numSelected != 0) {
- if (m_compatMode) {
+ if (isCompatMode()) {
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
} else {
if (m_headlinesActionMode == null)
@@ -925,7 +886,7 @@ public class OfflineActivity extends FragmentActivity implements
MenuItem search = m_menu.findItem(R.id.search);
- if (!m_compatMode) {
+ if (!isCompatMode()) {
SearchView searchView = (SearchView) search.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
private String query = "";
@@ -968,7 +929,7 @@ public class OfflineActivity extends FragmentActivity implements
m_headlinesActionMode.finish();
}
- if (!m_compatMode) {
+ if (!isCompatMode()) {
/* if (m_activeFeedId != 0) {
if (!m_activeFeedIsCat) {
@@ -997,7 +958,7 @@ public class OfflineActivity extends FragmentActivity implements
m_navigationAdapter.clear();
- if (m_activeCatId != -1 || (m_activeFeedId != 0 && m_smallScreenMode)) {
+ if (m_activeCatId != -1 || (m_activeFeedId != 0 && isSmallScreen())) {
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
@@ -1033,7 +994,7 @@ public class OfflineActivity extends FragmentActivity implements
getActionBar().setTitle(R.string.app_name);
}
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0 || m_activeCatId != -1);
} else {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeCatId != -1);
@@ -1061,10 +1022,6 @@ public class OfflineActivity extends FragmentActivity implements
@Override
public void onDestroy() {
super.onDestroy();
-
- m_readableDb.close();
- m_writableDb.close();
-
}
private void refreshViews() {
@@ -1392,7 +1349,7 @@ public class OfflineActivity extends FragmentActivity implements
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, frag, FRAG_FEEDS);
} else {
ft.replace(R.id.feeds_fragment, frag, FRAG_FEEDS);
@@ -1405,7 +1362,7 @@ public class OfflineActivity extends FragmentActivity implements
if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search);
- if (search != null && !m_compatMode) {
+ if (search != null && !isCompatMode()) {
SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false);
}
@@ -1436,7 +1393,7 @@ public class OfflineActivity extends FragmentActivity implements
if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search);
- if (search != null && !m_compatMode) {
+ if (search != null && !isCompatMode()) {
SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false);
}
@@ -1445,7 +1402,7 @@ public class OfflineActivity extends FragmentActivity implements
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
OfflineHeadlinesFragment frag = new OfflineHeadlinesFragment(feedId, isCat);
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, frag, FRAG_HEADLINES);
} else {
findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE);
@@ -1478,7 +1435,7 @@ public class OfflineActivity extends FragmentActivity implements
Fragment frag;
- if (m_smallScreenMode || m_prefs.getBoolean("tablet_article_swipe", false)) {
+ if (isSmallScreen() || m_prefs.getBoolean("tablet_article_swipe", false)) {
frag = new OfflineArticlePager(articleId);
} else {
frag = new OfflineArticleFragment(articleId);
@@ -1486,7 +1443,7 @@ public class OfflineActivity extends FragmentActivity implements
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
ft.add(R.id.fragment_container, frag, FRAG_ARTICLE);
} else {
@@ -1516,7 +1473,7 @@ public class OfflineActivity extends FragmentActivity implements
m_activeCatId = -1;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- if (m_smallScreenMode) {
+ if (isSmallScreen()) {
ft.replace(R.id.fragment_container, new OfflineFeedCategoriesFragment(), FRAG_CATS);
} else {
ft.replace(R.id.feeds_fragment, new OfflineFeedCategoriesFragment(), FRAG_CATS);
@@ -1532,9 +1489,4 @@ public class OfflineActivity extends FragmentActivity implements
public boolean activeFeedIsCat() {
return m_activeFeedIsCat;
}
-
- @Override
- public int getOrientation() {
- return getWindowManager().getDefaultDisplay().getOrientation();
- }
} \ No newline at end of file