update offline to work with new layout system
This commit is contained in:
parent
339f37e5b0
commit
ab4480c6f5
@ -49,7 +49,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.headlines);
|
setContentView(R.layout.headlines);
|
||||||
|
|
||||||
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
|
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
|
||||||
|
|
||||||
GlobalState.getInstance().load(savedInstanceState);
|
GlobalState.getInstance().load(savedInstanceState);
|
||||||
|
@ -4,6 +4,7 @@ import org.fox.ttrss.GlobalState;
|
|||||||
import org.fox.ttrss.R;
|
import org.fox.ttrss.R;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
|
||||||
|
|
||||||
import android.animation.LayoutTransition;
|
import android.animation.LayoutTransition;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
@ -25,6 +26,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
private boolean m_actionbarUpEnabled = false;
|
private boolean m_actionbarUpEnabled = false;
|
||||||
private int m_actionbarRevertDepth = 0;
|
private int m_actionbarRevertDepth = 0;
|
||||||
|
private SlidingMenu m_slidingMenu;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@Override
|
@Override
|
||||||
@ -36,12 +38,32 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.feeds);
|
setContentView(R.layout.headlines);
|
||||||
|
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
|
||||||
setSmallScreen(findViewById(R.id.headlines_fragment) == null);
|
|
||||||
|
|
||||||
GlobalState.getInstance().load(savedInstanceState);
|
GlobalState.getInstance().load(savedInstanceState);
|
||||||
|
|
||||||
|
if (isSmallScreen()) {
|
||||||
|
m_slidingMenu = new SlidingMenu(this);
|
||||||
|
|
||||||
|
m_slidingMenu.setMode(SlidingMenu.LEFT);
|
||||||
|
m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
|
||||||
|
m_slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
|
||||||
|
m_slidingMenu.setSlidingEnabled(true);
|
||||||
|
m_slidingMenu.setMenu(R.layout.feeds);
|
||||||
|
m_slidingMenu.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpened() {
|
||||||
|
if (m_actionbarRevertDepth == 0) {
|
||||||
|
m_actionbarUpEnabled = false;
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
initMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
|
||||||
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
|
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
|
||||||
@ -52,55 +74,22 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent = getIntent();
|
if (m_slidingMenu != null)
|
||||||
|
m_slidingMenu.showMenu();
|
||||||
|
|
||||||
if (intent.getIntExtra("feed", -10000) != -10000 || intent.getIntExtra("category", -10000) != -10000 ||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
intent.getIntExtra("article", -10000) != -10000) {
|
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
if (m_prefs.getBoolean("enable_cats", false)) {
|
||||||
m_actionbarUpEnabled = true;
|
ft.replace(R.id.feeds_fragment, new OfflineFeedCategoriesFragment(), FRAG_CATS);
|
||||||
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
||||||
|
|
||||||
int feedId = intent.getIntExtra("feed", -10000);
|
|
||||||
int catId = intent.getIntExtra("category", -10000);
|
|
||||||
int articleId = intent.getIntExtra("article", -10000);
|
|
||||||
boolean isCat = intent.getBooleanExtra("isCat", false);
|
|
||||||
|
|
||||||
if (articleId != -10000) {
|
|
||||||
OfflineArticlePager oap = new OfflineArticlePager();
|
|
||||||
oap.initialize(articleId, feedId, isCat);
|
|
||||||
ft.replace(R.id.feeds_fragment, oap, FRAG_ARTICLE);
|
|
||||||
} else {
|
|
||||||
if (feedId != -10000) {
|
|
||||||
OfflineHeadlinesFragment ohf = new OfflineHeadlinesFragment();
|
|
||||||
ohf.initialize(feedId, isCat);
|
|
||||||
ft.replace(R.id.feeds_fragment, ohf, FRAG_HEADLINES);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (catId != -10000) {
|
|
||||||
OfflineFeedsFragment off = new OfflineFeedsFragment();
|
|
||||||
off.initialize(catId);
|
|
||||||
ft.replace(R.id.feeds_fragment, off, FRAG_FEEDS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ft.commit();
|
|
||||||
} else {
|
} else {
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
ft.replace(R.id.feeds_fragment, new OfflineFeedsFragment(), FRAG_FEEDS);
|
||||||
|
|
||||||
if (m_prefs.getBoolean("enable_cats", false)) {
|
|
||||||
ft.replace(R.id.feeds_fragment, new OfflineFeedCategoriesFragment(), FRAG_CATS);
|
|
||||||
} else {
|
|
||||||
ft.replace(R.id.feeds_fragment, new OfflineFeedsFragment(), FRAG_FEEDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
ft.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ft.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoadingStatus(R.string.blank, false);
|
setLoadingStatus(R.string.blank, false);
|
||||||
findViewById(R.id.loading_container).setVisibility(View.GONE);
|
//findViewById(R.id.loading_container).setVisibility(View.GONE);
|
||||||
|
|
||||||
initMenu();
|
initMenu();
|
||||||
|
|
||||||
@ -117,7 +106,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
public void openFeedArticles(int feedId, boolean isCat) {
|
public void openFeedArticles(int feedId, boolean isCat) {
|
||||||
if (isSmallScreen()) {
|
if (isSmallScreen()) {
|
||||||
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
|
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineHeadlinesActivity.class);
|
||||||
|
|
||||||
intent.putExtra("feed", feedId);
|
intent.putExtra("feed", feedId);
|
||||||
intent.putExtra("isCat", isCat);
|
intent.putExtra("isCat", isCat);
|
||||||
@ -126,20 +115,27 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (m_actionbarRevertDepth > 0) {
|
||||||
|
|
||||||
|
m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
|
||||||
|
m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
|
||||||
|
|
||||||
|
onBackPressed();
|
||||||
|
} else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
|
||||||
|
m_slidingMenu.showMenu();
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
if (m_actionbarRevertDepth > 0) {
|
onBackPressed();
|
||||||
|
|
||||||
m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
|
|
||||||
m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
|
|
||||||
|
|
||||||
onBackPressed();
|
|
||||||
} else {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.show_feeds:
|
case R.id.show_feeds:
|
||||||
setUnreadOnly(!getUnreadOnly());
|
setUnreadOnly(!getUnreadOnly());
|
||||||
@ -168,14 +164,25 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
if (m_menu != null) {
|
if (m_menu != null) {
|
||||||
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
||||||
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||||
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
//OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||||
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
|
if (m_slidingMenu != null) {
|
||||||
|
m_menu.setGroupVisible(R.id.menu_group_feeds, m_slidingMenu.isMenuShowing());
|
||||||
|
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && !m_slidingMenu.isMenuShowing());
|
||||||
|
} else {
|
||||||
|
m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
|
||||||
|
//m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded());
|
||||||
|
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded());
|
||||||
|
|
||||||
|
m_menu.findItem(R.id.update_headlines).setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
|
||||||
|
|
||||||
m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded());
|
m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded());
|
||||||
|
|
||||||
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded());
|
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded()); */
|
||||||
//m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && getSelectedArticleCount() == 0);
|
//m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && getSelectedArticleCount() == 0);
|
||||||
//m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isAdded() && getSelectedArticleCount() != 0);
|
//m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isAdded() && getSelectedArticleCount() != 0);
|
||||||
|
|
||||||
@ -203,12 +210,12 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
onFeedSelected(catId, true, true);
|
onFeedSelected(catId, true, true);
|
||||||
} else {
|
} else {
|
||||||
if (isSmallScreen()) {
|
/* if (isSmallScreen()) {
|
||||||
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
|
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
|
||||||
intent.putExtra("category", catId);
|
intent.putExtra("category", catId);
|
||||||
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
} else {
|
} else { */
|
||||||
if (fc != null) {
|
if (fc != null) {
|
||||||
fc.setSelectedFeedId(-1);
|
fc.setSelectedFeedId(-1);
|
||||||
}
|
}
|
||||||
@ -227,7 +234,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
|
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
|
||||||
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +245,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
public void onFeedSelected(final int feedId, final boolean isCat, boolean open) {
|
public void onFeedSelected(final int feedId, final boolean isCat, boolean open) {
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
if (isSmallScreen()) {
|
/* if (isSmallScreen()) {
|
||||||
|
|
||||||
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
|
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
|
||||||
intent.putExtra("feed", feedId);
|
intent.putExtra("feed", feedId);
|
||||||
@ -246,7 +253,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
|
|
||||||
} else {
|
} else { */
|
||||||
/* if (!isCompatMode()) {
|
/* if (!isCompatMode()) {
|
||||||
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
||||||
float wSum = container.getWeightSum();
|
float wSum = container.getWeightSum();
|
||||||
@ -259,8 +266,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
// ^ no idea why the animation hangs half the time :(
|
// ^ no idea why the animation hangs half the time :(
|
||||||
|
|
||||||
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
if (!isSmallScreen()) {
|
||||||
container.setWeightSum(3f);
|
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
||||||
|
container.setWeightSum(3f);
|
||||||
|
}
|
||||||
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -273,10 +282,17 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
||||||
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
|
if (m_slidingMenu != null) {
|
||||||
|
m_slidingMenu.showContent();
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
m_actionbarUpEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +328,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
initMenu();
|
initMenu();
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
if (isSmallScreen()) {
|
/* if (isSmallScreen()) {
|
||||||
|
|
||||||
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
@ -323,7 +339,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
|
|
||||||
} else {
|
} else { */
|
||||||
|
|
||||||
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
@ -335,7 +351,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
|
|
||||||
overridePendingTransition(R.anim.right_slide_in, 0);
|
overridePendingTransition(R.anim.right_slide_in, 0);
|
||||||
}
|
//}
|
||||||
} else {
|
} else {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.headlines);
|
setContentView(R.layout.headlines_articles);
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user