properly handle home button on actionbar in small screen mode
This commit is contained in:
parent
b2cf227a24
commit
3fd2afa44b
@ -754,6 +754,35 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
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_smallScreenMode) {
|
||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
@ -792,7 +821,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
|
|
||||||
closeCategory();
|
closeCategory();
|
||||||
|
|
||||||
} else {
|
} else if (allowQuit) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -800,38 +829,12 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
closeArticle();
|
closeArticle();
|
||||||
} else if (m_activeCategory != null) {
|
} else if (m_activeCategory != null) {
|
||||||
closeCategory();
|
closeCategory();
|
||||||
} else {
|
} else if (allowQuit) {
|
||||||
finish();
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
@ -840,7 +843,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
closeArticle();
|
goBack(false);
|
||||||
return true;
|
return true;
|
||||||
case R.id.preferences:
|
case R.id.preferences:
|
||||||
Intent intent = new Intent(MainActivity.this,
|
Intent intent = new Intent(MainActivity.this,
|
||||||
@ -1199,7 +1202,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_compatMode) {
|
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);
|
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
|
||||||
|
@ -305,8 +305,7 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void goBack(boolean allowQuit) {
|
||||||
public void onBackPressed() {
|
|
||||||
if (m_smallScreenMode) {
|
if (m_smallScreenMode) {
|
||||||
if (m_selectedArticleId != 0) {
|
if (m_selectedArticleId != 0) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
@ -332,17 +331,21 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
refreshViews();
|
refreshViews();
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
|
|
||||||
} else {
|
} else if (allowQuit) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_selectedArticleId != 0) {
|
if (m_selectedArticleId != 0) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
} else {
|
} else if (allowQuit) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
goBack(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -426,7 +429,7 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
closeArticle();
|
goBack(false);
|
||||||
return true;
|
return true;
|
||||||
case R.id.preferences:
|
case R.id.preferences:
|
||||||
Intent intent = new Intent(this, PreferencesActivity.class);
|
Intent intent = new Intent(this, PreferencesActivity.class);
|
||||||
@ -668,7 +671,11 @@ public class OfflineActivity extends FragmentActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_compatMode) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user