better handle moving back from nested feeds
This commit is contained in:
parent
c59613fe05
commit
858e2c93c9
@ -457,8 +457,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_activity.isSmallScreen())
|
||||
m_selectedCat = cat;
|
||||
//if (!m_activity.isSmallScreen())
|
||||
// m_selectedCat = cat;
|
||||
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
protected long m_lastRefresh = 0;
|
||||
|
||||
private boolean m_actionbarUpEnabled = false;
|
||||
private int m_actionbarRevertDepth = 0;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
@ -118,6 +119,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
}
|
||||
} else { // savedInstanceState != null
|
||||
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
|
||||
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
|
||||
|
||||
if (!isSmallScreen()) {
|
||||
// temporary hack because FeedsActivity doesn't track whether active feed is open
|
||||
@ -235,6 +237,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
}
|
||||
|
||||
public void onCatSelected(FeedCategory cat, boolean openAsFeed) {
|
||||
FeedCategoriesFragment fc = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||
|
||||
if (!openAsFeed) {
|
||||
|
||||
@ -246,6 +249,10 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
} else {
|
||||
if (fc != null) {
|
||||
fc.setSelectedCategory(null);
|
||||
}
|
||||
|
||||
FragmentTransaction ft = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
|
||||
@ -255,8 +262,17 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
ft.addToBackStack(null);
|
||||
ft.commit();
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
m_actionbarUpEnabled = true;
|
||||
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (fc != null) {
|
||||
fc.setSelectedCategory(cat);
|
||||
}
|
||||
|
||||
Feed feed = new Feed(cat.id, cat.title, true);
|
||||
onFeedSelected(feed);
|
||||
}
|
||||
@ -269,6 +285,18 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (m_actionbarRevertDepth > 0) {
|
||||
|
||||
m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
|
||||
m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
|
||||
|
||||
onBackPressed();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
case R.id.show_feeds:
|
||||
setUnreadOnly(!getUnreadOnly());
|
||||
initMenu();
|
||||
@ -297,6 +325,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
|
||||
out.putInt("actionbarRevertDepth", m_actionbarRevertDepth);
|
||||
|
||||
GlobalState.getInstance().save(out);
|
||||
}
|
||||
|
@ -621,9 +621,9 @@ public class OnlineActivity extends CommonActivity {
|
||||
final ArticlePager ap = (ArticlePager)getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
/* case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
return true; */
|
||||
case R.id.subscribe_to_feed:
|
||||
Intent subscribe = new Intent(OnlineActivity.this, SubscribeActivity.class);
|
||||
startActivityForResult(subscribe, 0);
|
||||
|
@ -169,9 +169,9 @@ public class OfflineActivity extends CommonActivity {
|
||||
.findFragmentByTag(FRAG_ARTICLE);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
/* case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
return true; */
|
||||
case R.id.go_online:
|
||||
switchOnline();
|
||||
return true;
|
||||
|
@ -197,8 +197,8 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
||||
m_activity.onCatSelected(feedId);
|
||||
}
|
||||
|
||||
if (!m_activity.isSmallScreen())
|
||||
m_selectedCatId = feedId;
|
||||
/* if (!m_activity.isSmallScreen())
|
||||
m_selectedCatId = feedId; */
|
||||
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
|
||||
private boolean m_actionbarUpEnabled = false;
|
||||
private int m_actionbarRevertDepth = 0;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
@ -44,6 +45,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
if (savedInstanceState != null) {
|
||||
|
||||
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
|
||||
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
|
||||
|
||||
if (m_actionbarUpEnabled) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@ -127,6 +129,18 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (m_actionbarRevertDepth > 0) {
|
||||
|
||||
m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
|
||||
m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
|
||||
|
||||
onBackPressed();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
case R.id.show_feeds:
|
||||
setUnreadOnly(!getUnreadOnly());
|
||||
initMenu();
|
||||
@ -143,6 +157,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
|
||||
out.putInt("actionbarRevertDepth", m_actionbarRevertDepth);
|
||||
|
||||
GlobalState.getInstance().save(out);
|
||||
}
|
||||
@ -179,7 +194,13 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
}
|
||||
|
||||
public void onCatSelected(int catId, boolean openAsFeed) {
|
||||
OfflineFeedCategoriesFragment fc = (OfflineFeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||
|
||||
if (openAsFeed) {
|
||||
if (fc != null) {
|
||||
fc.setSelectedFeedId(catId);
|
||||
}
|
||||
|
||||
onFeedSelected(catId, true, true);
|
||||
} else {
|
||||
if (isSmallScreen()) {
|
||||
@ -188,6 +209,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
|
||||
startActivityForResult(intent, 0);
|
||||
} else {
|
||||
if (fc != null) {
|
||||
fc.setSelectedFeedId(-1);
|
||||
}
|
||||
|
||||
FragmentTransaction ft = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
|
||||
@ -197,6 +222,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
|
||||
ft.addToBackStack(null);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
m_actionbarUpEnabled = true;
|
||||
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
|
||||
|
||||
ft.commit();
|
||||
}
|
||||
}
|
||||
@ -304,6 +333,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
||||
intent.putExtra("article", articleId);
|
||||
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
overridePendingTransition(R.anim.right_slide_in, 0);
|
||||
}
|
||||
} else {
|
||||
refresh();
|
||||
|
@ -3,6 +3,8 @@ package org.fox.ttrss.offline;
|
||||
import org.fox.ttrss.GlobalState;
|
||||
import org.fox.ttrss.R;
|
||||
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -13,6 +15,7 @@ import android.preference.PreferenceManager;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
public class OfflineHeadlinesActivity extends OfflineActivity implements OfflineHeadlinesEventListener {
|
||||
@ -90,6 +93,19 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
||||
initMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
overridePendingTransition(0, R.anim.right_slide_out);
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArticleSelected(int articleId, boolean open) {
|
||||
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||
@ -142,4 +158,10 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
||||
public void onArticleSelected(int articleId) {
|
||||
onArticleSelected(articleId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(0, R.anim.right_slide_out);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user