summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-01-18 11:43:21 +0300
committerAndrew Dolgov <[email protected]>2012-01-18 12:46:54 +0400
commit3fd2afa44b414f859784a191cc4b0ddf3b91b9c9 (patch)
tree8cd33a454bdde6825a32174b1644a2f34b2bfd0d
parentb2cf227a249e1edd625f70e661b2a1c7e7e5b2a8 (diff)
properly handle home button on actionbar in small screen mode
-rw-r--r--src/org/fox/ttrss/MainActivity.java67
-rw-r--r--src/org/fox/ttrss/OfflineActivity.java21
2 files changed, 51 insertions, 37 deletions
diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java
index 51c40e67..c60e7e66 100644
--- a/src/org/fox/ttrss/MainActivity.java
+++ b/src/org/fox/ttrss/MainActivity.java
@@ -754,6 +754,35 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
@Override
public void onBackPressed() {
+ goBack(true);
+ }
+
+ private void closeCategory() {
+
+ findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
+ findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
+
+ m_activeCategory = null;
+
+ initMainMenu();
+ refreshCategories();
+ }
+
+ private void deselectAllArticles() {
+ HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.headlines_fragment);
+
+ if (hf != null) {
+ ArticleList selected = hf.getSelectedArticles();
+ if (selected.size() > 0) {
+ selected.clear();
+ initMainMenu();
+ hf.notifyUpdated();
+ }
+ }
+ }
+
+ private void goBack(boolean allowQuit) {
if (m_smallScreenMode) {
if (m_selectedArticle != null) {
closeArticle();
@@ -792,7 +821,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
closeCategory();
- } else {
+ } else if (allowQuit) {
finish();
}
} else {
@@ -800,37 +829,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
closeArticle();
} else if (m_activeCategory != null) {
closeCategory();
- } else {
+ } else if (allowQuit) {
finish();
}
}
}
-
- private void closeCategory() {
-
- findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
- findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
-
- m_activeCategory = null;
-
- initMainMenu();
- refreshCategories();
- }
-
- private void deselectAllArticles() {
- HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager()
- .findFragmentById(R.id.headlines_fragment);
-
- if (hf != null) {
- ArticleList selected = hf.getSelectedArticles();
- if (selected.size() > 0) {
- selected.clear();
- initMainMenu();
- hf.notifyUpdated();
- }
- }
- }
-
@SuppressWarnings("unchecked")
@Override
@@ -840,7 +843,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
switch (item.getItemId()) {
case android.R.id.home:
- closeArticle();
+ goBack(false);
return true;
case R.id.preferences:
Intent intent = new Intent(MainActivity.this,
@@ -1199,7 +1202,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
}
if (!m_compatMode) {
- getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null);
+ if (!m_smallScreenMode) {
+ getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null);
+ } else {
+ getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeFeed != null || m_activeCategory != null);
+ }
}
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
diff --git a/src/org/fox/ttrss/OfflineActivity.java b/src/org/fox/ttrss/OfflineActivity.java
index ca69623c..730c6a3e 100644
--- a/src/org/fox/ttrss/OfflineActivity.java
+++ b/src/org/fox/ttrss/OfflineActivity.java
@@ -305,8 +305,7 @@ public class OfflineActivity extends FragmentActivity implements
}
}
- @Override
- public void onBackPressed() {
+ private void goBack(boolean allowQuit) {
if (m_smallScreenMode) {
if (m_selectedArticleId != 0) {
closeArticle();
@@ -332,17 +331,21 @@ public class OfflineActivity extends FragmentActivity implements
refreshViews();
initMainMenu();
- } else {
+ } else if (allowQuit) {
finish();
}
} else {
if (m_selectedArticleId != 0) {
closeArticle();
- } else {
+ } else if (allowQuit) {
finish();
}
}
-
+ }
+
+ @Override
+ public void onBackPressed() {
+ goBack(true);
}
/*
@@ -426,7 +429,7 @@ public class OfflineActivity extends FragmentActivity implements
switch (item.getItemId()) {
case android.R.id.home:
- closeArticle();
+ goBack(false);
return true;
case R.id.preferences:
Intent intent = new Intent(this, PreferencesActivity.class);
@@ -668,7 +671,11 @@ public class OfflineActivity extends FragmentActivity implements
}
if (!m_compatMode) {
- getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0);
+ if (!m_smallScreenMode) {
+ getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0);
+ } else {
+ getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0);
+ }
}
}
}