initial implementation of slidingmenu stuff
This commit is contained in:
parent
b87a1056d7
commit
882f3a370e
@ -39,6 +39,7 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".HeadlinesActivity"
|
||||
android:uiOptions="splitActionBarWhenNarrow"
|
||||
android:label="@string/app_name" >
|
||||
</activity>
|
||||
<activity
|
||||
|
@ -11,3 +11,4 @@
|
||||
target=android-17
|
||||
android.library.reference.1=..\\Android-ViewPagerIndicator\\library
|
||||
android.library.reference.2=..\\ActionBarSherlock\\actionbarsherlock
|
||||
android.library.reference.3=../SlidingMenu/library
|
||||
|
@ -5,22 +5,13 @@
|
||||
android:background="?headlinesBackgroundSolid"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_container"
|
||||
<FrameLayout
|
||||
android:id="@+id/sw600dp_anchor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?loadingBackground"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loading_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/loading_message"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fragment_container"
|
||||
|
@ -1,48 +1,40 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/headlines"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="?headlinesBackgroundSolid"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_container"
|
||||
<FrameLayout
|
||||
android:id="@+id/sw600dp_anchor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?loadingBackground"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible" >
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loading_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/loading_message"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:baselineAligned="false"
|
||||
android:weightSum="1.05"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/feeds_fragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?feedlistBackground" >
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/headlines_fragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"
|
||||
android:background="?feedlistBackground" >
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/article_fragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.6"
|
||||
android:background="?articleBackground" >
|
||||
android:layout_weight="2"
|
||||
android:background="?headlinesBackground" >
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -4,21 +4,6 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loading_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/loading_message" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/feeds_fragment"
|
||||
android:background="?smallScreenBackground"
|
||||
|
@ -4,23 +4,8 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loading_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/loading_message" />
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/headlines_container"
|
||||
android:id="@+id/headlines_fragment"
|
||||
android:background="?smallScreenBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
@ -56,7 +56,7 @@ public class CommonActivity extends SherlockFragmentActivity {
|
||||
tv.setText(status);
|
||||
}
|
||||
|
||||
findViewById(R.id.loading_container).setVisibility(status == R.string.blank ? View.GONE : View.VISIBLE);
|
||||
//findViewById(R.id.loading_container).setVisibility(status == R.string.blank ? View.GONE : View.VISIBLE);
|
||||
|
||||
setProgressBarIndeterminateVisibility(showProgress);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.fox.ttrss.types.FeedCategory;
|
||||
import org.fox.ttrss.util.AppRater;
|
||||
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.animation.LayoutTransition;
|
||||
@ -35,6 +36,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
private boolean m_actionbarUpEnabled = false;
|
||||
private int m_actionbarRevertDepth = 0;
|
||||
private SlidingMenu m_slidingMenu;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
@ -46,18 +48,38 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.feeds);
|
||||
setContentView(R.layout.headlines);
|
||||
|
||||
setSmallScreen(findViewById(R.id.headlines_fragment) == null);
|
||||
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
|
||||
|
||||
GlobalState.getInstance().load(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
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 (m_slidingMenu != null)
|
||||
m_slidingMenu.showMenu();
|
||||
|
||||
if (intent.getParcelableExtra("feed") != null || intent.getParcelableExtra("category") != null ||
|
||||
intent.getParcelableExtra("article") != null) {
|
||||
/* if (intent.getParcelableExtra("article") != null) {
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
m_actionbarUpEnabled = true;
|
||||
@ -79,27 +101,11 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
ap.setSearchQuery(intent.getStringExtra("searchQuery"));
|
||||
|
||||
setTitle(feed.title);
|
||||
} else {
|
||||
if (feed != null) {
|
||||
HeadlinesFragment hf = new HeadlinesFragment();
|
||||
hf.initialize(feed);
|
||||
ft.replace(R.id.feeds_fragment, hf, FRAG_HEADLINES);
|
||||
|
||||
setTitle(feed.title);
|
||||
}
|
||||
|
||||
if (cat != null) {
|
||||
FeedsFragment ff = new FeedsFragment();
|
||||
ff.initialize(cat);
|
||||
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
|
||||
|
||||
setTitle(cat.title);
|
||||
}
|
||||
}
|
||||
|
||||
ft.commit();
|
||||
|
||||
} else {
|
||||
} else { */
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
if (m_prefs.getBoolean("enable_cats", false)) {
|
||||
@ -116,11 +122,14 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
AppRater.appLaunched(this);
|
||||
checkTrial(true);
|
||||
}
|
||||
//}
|
||||
} else { // savedInstanceState != null
|
||||
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
|
||||
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
|
||||
|
||||
if (m_slidingMenu != null && savedInstanceState.getBoolean("slidingMenuVisible"))
|
||||
m_slidingMenu.showMenu();
|
||||
|
||||
if (!isSmallScreen()) {
|
||||
// temporary hack because FeedsActivity doesn't track whether active feed is open
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
||||
@ -146,22 +155,27 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
if (m_menu != null && getSessionId() != null) {
|
||||
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
||||
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||
//ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
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());
|
||||
|
||||
if (isSmallScreen()) {
|
||||
m_menu.findItem(R.id.update_headlines).setVisible(hf != null && hf.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);
|
||||
}
|
||||
|
||||
if (af != null) {
|
||||
/* if (isSmallScreen()) {
|
||||
m_menu.findItem(R.id.update_headlines).setVisible(hf != null && hf.isAdded());
|
||||
} else {
|
||||
m_menu.findItem(R.id.update_headlines).setVisible(false);
|
||||
} */
|
||||
|
||||
/* if (af != null) {
|
||||
if (af.getSelectedArticle() != null && af.getSelectedArticle().attachments != null && af.getSelectedArticle().attachments.size() > 0) {
|
||||
if (!isCompatMode()) {
|
||||
m_menu.findItem(R.id.toggle_attachments).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
@ -173,7 +187,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
}
|
||||
m_menu.findItem(R.id.toggle_attachments).setVisible(false);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
MenuItem item = m_menu.findItem(R.id.show_feeds);
|
||||
|
||||
@ -188,19 +202,13 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
public void onFeedSelected(Feed feed) {
|
||||
GlobalState.getInstance().m_loadedArticles.clear();
|
||||
|
||||
if (isSmallScreen()) {
|
||||
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||
intent.putExtra("feed", feed);
|
||||
|
||||
startActivityForResult(intent, 0);
|
||||
} else {
|
||||
FragmentTransaction ft = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
|
||||
ft.replace(R.id.headlines_fragment, new LoadingFragment(), null);
|
||||
ft.commit();
|
||||
|
||||
if (!isCompatMode()) {
|
||||
if (!isCompatMode() && !isSmallScreen()) {
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
||||
float wSum = container.getWeightSum();
|
||||
if (wSum <= 2.0f) {
|
||||
@ -223,6 +231,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
||||
|
||||
ft.commit();
|
||||
|
||||
if (m_slidingMenu != null) {
|
||||
m_slidingMenu.showContent();
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
m_actionbarUpEnabled = true;
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
|
||||
@ -233,7 +247,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
m_lastRefresh = date.getTime();
|
||||
refresh(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onCatSelected(FeedCategory cat, boolean openAsFeed) {
|
||||
@ -241,7 +254,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
if (!openAsFeed) {
|
||||
|
||||
if (isSmallScreen()) {
|
||||
if (false && isSmallScreen()) {
|
||||
|
||||
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||
intent.putExtra("category", cat);
|
||||
@ -282,6 +295,15 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
onCatSelected(cat, m_prefs.getBoolean("browse_cats_like_feeds", false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
|
||||
m_slidingMenu.showMenu();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
@ -293,6 +315,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
|
||||
|
||||
onBackPressed();
|
||||
} else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
|
||||
m_slidingMenu.showMenu();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
@ -314,7 +338,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
@Override
|
||||
protected void loginSuccess(boolean refresh) {
|
||||
setLoadingStatus(R.string.blank, false);
|
||||
findViewById(R.id.loading_container).setVisibility(View.GONE);
|
||||
//findViewById(R.id.loading_container).setVisibility(View.GONE);
|
||||
initMenu();
|
||||
|
||||
if (refresh) refresh();
|
||||
@ -327,6 +351,9 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
|
||||
out.putInt("actionbarRevertDepth", m_actionbarRevertDepth);
|
||||
|
||||
if (m_slidingMenu != null )
|
||||
out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing());
|
||||
|
||||
GlobalState.getInstance().save(out);
|
||||
}
|
||||
|
||||
@ -342,7 +369,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
}
|
||||
|
||||
public void openFeedArticles(Feed feed) {
|
||||
if (isSmallScreen()) {
|
||||
/* if (isSmallScreen()) {
|
||||
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||
|
||||
GlobalState.getInstance().m_activeFeed = feed;
|
||||
@ -351,7 +378,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
intent.putExtra("feed", feed);
|
||||
intent.putExtra("article", new Article());
|
||||
startActivityForResult(intent, 0);
|
||||
} else {
|
||||
} else { */
|
||||
GlobalState.getInstance().m_loadedArticles.clear();
|
||||
|
||||
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
||||
@ -361,7 +388,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
startActivityForResult(intent, HEADLINES_REQUEST);
|
||||
overridePendingTransition(R.anim.right_slide_in, 0);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public void onArticleSelected(Article article, boolean open) {
|
||||
@ -373,7 +400,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
if (open) {
|
||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
if (isSmallScreen()) {
|
||||
/* if (isSmallScreen()) {
|
||||
|
||||
//GlobalState.getInstance().m_loadedArticles.clear();
|
||||
|
||||
@ -385,7 +412,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
startActivityForResult(intent, 0);
|
||||
|
||||
|
||||
} else {
|
||||
} else { */
|
||||
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
||||
intent.putExtra("feed", hf.getFeed());
|
||||
intent.putExtra("article", article);
|
||||
@ -393,7 +420,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
|
||||
startActivityForResult(intent, HEADLINES_REQUEST);
|
||||
overridePendingTransition(R.anim.right_slide_in, 0);
|
||||
}
|
||||
//}
|
||||
} else {
|
||||
initMenu();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.headlines);
|
||||
setContentView(R.layout.headlines_articles);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@ -142,7 +142,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
|
||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, !isPortrait() && hf != null && hf.isAdded());
|
||||
m_menu.setGroupVisible(R.id.menu_group_headlines, !isPortrait() && hf != null && hf.isAdded() && hf.isVisible());
|
||||
|
||||
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user