remove smalltablet code as unnecessary, store showunreadfeeds in

globalstate
This commit is contained in:
Andrew Dolgov 2012-09-19 13:44:35 +04:00
parent 797dbe2080
commit 41630980df
6 changed files with 23 additions and 51 deletions

View File

@ -26,13 +26,28 @@ public class CommonActivity extends FragmentActivity {
private boolean m_smallScreenMode = true; private boolean m_smallScreenMode = true;
private boolean m_compatMode = false; private boolean m_compatMode = false;
private boolean m_smallTablet = false;
protected void setSmallScreen(boolean smallScreen) { protected void setSmallScreen(boolean smallScreen) {
Log.d(TAG, "m_smallScreenMode=" + smallScreen); Log.d(TAG, "m_smallScreenMode=" + smallScreen);
m_smallScreenMode = smallScreen; m_smallScreenMode = smallScreen;
} }
public boolean getUnreadArticlesOnly() {
return GlobalState.getInstance().m_unreadArticlesOnly;
}
public boolean getUnreadOnly() {
return GlobalState.getInstance().m_unreadOnly;
}
public void setUnreadOnly(boolean unread) {
GlobalState.getInstance().m_unreadOnly = unread;
}
public void setUnreadArticlesOnly(boolean unread) {
GlobalState.getInstance().m_unreadArticlesOnly = unread;
}
public void setLoadingStatus(int status, boolean showProgress) { public void setLoadingStatus(int status, boolean showProgress) {
TextView tv = (TextView) findViewById(R.id.loading_message); TextView tv = (TextView) findViewById(R.id.loading_message);
@ -53,23 +68,6 @@ public class CommonActivity extends FragmentActivity {
toast.show(); toast.show();
} }
protected void detectSmallTablet() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
float inHeight = displayMetrics.heightPixels / displayMetrics.ydpi;
float inWidth = displayMetrics.widthPixels / displayMetrics.xdpi;
float inDiag = FloatMath.sqrt(inHeight * inHeight + inWidth * inWidth);
if (inDiag < 9) {
m_smallTablet = true;
}
Log.d(TAG, "m_smallTabletMode=" + m_smallTablet + " " + inDiag);
}
private void initDatabase() { private void initDatabase() {
DatabaseHelper dh = new DatabaseHelper(getApplicationContext()); DatabaseHelper dh = new DatabaseHelper(getApplicationContext());
@ -91,7 +89,6 @@ public class CommonActivity extends FragmentActivity {
m_readableDb.close(); m_readableDb.close();
m_writableDb.close(); m_writableDb.close();
} }
@Override @Override
@ -102,8 +99,6 @@ public class CommonActivity extends FragmentActivity {
Log.d(TAG, "m_compatMode=" + m_compatMode); Log.d(TAG, "m_compatMode=" + m_compatMode);
detectSmallTablet();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -111,10 +106,6 @@ public class CommonActivity extends FragmentActivity {
return m_smallScreenMode; return m_smallScreenMode;
} }
public boolean isSmallTablet() {
return m_smallTablet;
}
public boolean isCompatMode() { public boolean isCompatMode() {
return m_compatMode; return m_compatMode;
} }

View File

@ -207,7 +207,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.show_feeds: case R.id.show_feeds:
m_unreadOnly = !m_unreadOnly; setUnreadOnly(!getUnreadOnly());
initMenu(); initMenu();
refresh(); refresh();
return true; return true;

View File

@ -13,6 +13,8 @@ public class GlobalState extends Application {
public Feed m_activeFeed; public Feed m_activeFeed;
public Article m_activeArticle; public Article m_activeArticle;
public int m_selectedArticleId; public int m_selectedArticleId;
public boolean m_unreadOnly = true;
public boolean m_unreadArticlesOnly = true;
public static GlobalState getInstance(){ public static GlobalState getInstance(){
return m_singleton; return m_singleton;

View File

@ -50,8 +50,6 @@ public class OnlineActivity extends CommonActivity {
protected int m_apiLevel = 0; protected int m_apiLevel = 0;
protected Menu m_menu; protected Menu m_menu;
protected boolean m_unreadOnly = true;
protected boolean m_unreadArticlesOnly = true;
protected int m_offlineModeStatus = 0; protected int m_offlineModeStatus = 0;
private ActionMode m_headlinesActionMode; private ActionMode m_headlinesActionMode;
@ -156,8 +154,6 @@ public class OnlineActivity extends CommonActivity {
if (savedInstanceState != null) { if (savedInstanceState != null) {
m_sessionId = savedInstanceState.getString("sessionId"); m_sessionId = savedInstanceState.getString("sessionId");
m_apiLevel = savedInstanceState.getInt("apiLevel"); m_apiLevel = savedInstanceState.getInt("apiLevel");
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
m_unreadArticlesOnly = savedInstanceState.getBoolean("unreadArticlesOnly");
m_offlineModeStatus = savedInstanceState.getInt("offlineModeStatus"); m_offlineModeStatus = savedInstanceState.getInt("offlineModeStatus");
} }
@ -814,22 +810,12 @@ public class OnlineActivity extends CommonActivity {
} }
} }
public boolean getUnreadArticlesOnly() {
return m_unreadArticlesOnly;
}
public boolean getUnreadOnly() {
return m_unreadOnly;
}
@Override @Override
public void onSaveInstanceState(Bundle out) { public void onSaveInstanceState(Bundle out) {
super.onSaveInstanceState(out); super.onSaveInstanceState(out);
out.putString("sessionId", m_sessionId); out.putString("sessionId", m_sessionId);
out.putInt("apiLevel", m_apiLevel); out.putInt("apiLevel", m_apiLevel);
out.putBoolean("unreadOnly", m_unreadOnly);
out.putBoolean("unreadArticlesOnly", m_unreadArticlesOnly);
out.putInt("offlineModeStatus", m_offlineModeStatus); out.putInt("offlineModeStatus", m_offlineModeStatus);
} }

View File

@ -32,7 +32,6 @@ public class OfflineActivity extends CommonActivity {
protected SharedPreferences m_prefs; protected SharedPreferences m_prefs;
protected Menu m_menu; protected Menu m_menu;
protected boolean m_unreadOnly = true;
private ActionMode m_headlinesActionMode; private ActionMode m_headlinesActionMode;
private HeadlinesActionModeCallback m_headlinesActionModeCallback; private HeadlinesActionModeCallback m_headlinesActionModeCallback;
@ -100,9 +99,9 @@ public class OfflineActivity extends CommonActivity {
} }
} }
if (savedInstanceState != null) { /* if (savedInstanceState != null) {
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
} } */
if (!isCompatMode()) { if (!isCompatMode()) {
m_headlinesActionModeCallback = new HeadlinesActionModeCallback(); m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
@ -113,8 +112,6 @@ public class OfflineActivity extends CommonActivity {
@Override @Override
public void onSaveInstanceState(Bundle out) { public void onSaveInstanceState(Bundle out) {
super.onSaveInstanceState(out); super.onSaveInstanceState(out);
out.putBoolean("unreadOnly", m_unreadOnly);
} }
protected void selectArticles(int feedId, boolean isCat, int mode) { protected void selectArticles(int feedId, boolean isCat, int mode) {
@ -401,10 +398,6 @@ public class OfflineActivity extends CommonActivity {
return true; return true;
} }
public boolean getUnreadOnly() {
return m_unreadOnly;
}
@SuppressLint("NewApi") @SuppressLint("NewApi")
protected void initMenu() { protected void initMenu() {
if (m_menu != null) { if (m_menu != null) {

View File

@ -90,7 +90,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.show_feeds: case R.id.show_feeds:
m_unreadOnly = !m_unreadOnly; setUnreadOnly(!getUnreadOnly());
initMenu(); initMenu();
refresh(); refresh();
return true; return true;