add drawer stuff to offline headlines activity
This commit is contained in:
parent
acdcf759a0
commit
04366e58f1
@ -240,7 +240,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
.beginTransaction();
|
.beginTransaction();
|
||||||
|
|
||||||
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
|
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
|
||||||
hf.initialize(feedId, isCat);
|
hf.initialize(feedId, isCat, false);
|
||||||
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
||||||
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
@ -10,8 +10,11 @@ import android.preference.PreferenceManager;
|
|||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import org.fox.ttrss.GlobalState;
|
import org.fox.ttrss.GlobalState;
|
||||||
import org.fox.ttrss.R;
|
import org.fox.ttrss.R;
|
||||||
@ -21,6 +24,9 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
|
|
||||||
protected SharedPreferences m_prefs;
|
protected SharedPreferences m_prefs;
|
||||||
|
|
||||||
|
private ActionBarDrawerToggle m_drawerToggle;
|
||||||
|
private DrawerLayout m_drawerLayout;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -33,7 +39,33 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
|
|
||||||
setContentView(R.layout.headlines_articles);
|
setContentView(R.layout.headlines_articles);
|
||||||
|
|
||||||
|
m_drawerLayout = (DrawerLayout) findViewById(R.id.headlines_drawer);
|
||||||
|
|
||||||
|
if (m_drawerLayout != null) {
|
||||||
|
|
||||||
|
m_drawerToggle = new ActionBarDrawerToggle(this, m_drawerLayout, R.string.blank, R.string.blank) {
|
||||||
|
@Override
|
||||||
|
public void onDrawerOpened(View drawerView) {
|
||||||
|
super.onDrawerOpened(drawerView);
|
||||||
|
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerClosed(View drawerView) {
|
||||||
|
super.onDrawerClosed(drawerView);
|
||||||
|
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
m_drawerLayout.setDrawerListener(m_drawerToggle);
|
||||||
|
m_drawerToggle.setDrawerIndicatorEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
|
|
||||||
setStatusBarTint();
|
setStatusBarTint();
|
||||||
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
|
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null);
|
||||||
@ -52,7 +84,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
String searchQuery = i.getStringExtra("searchQuery");
|
String searchQuery = i.getStringExtra("searchQuery");
|
||||||
|
|
||||||
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
|
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
|
||||||
hf.initialize(feedId, isCat);
|
hf.initialize(feedId, isCat, true);
|
||||||
|
|
||||||
OfflineArticlePager af = new OfflineArticlePager();
|
OfflineArticlePager af = new OfflineArticlePager();
|
||||||
af.initialize(articleId, feedId, isCat);
|
af.initialize(articleId, feedId, isCat);
|
||||||
@ -88,8 +120,18 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
initMenu();
|
initMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
|
super.onPostCreate(savedInstanceState);
|
||||||
|
// Sync the toggle state after onRestoreInstanceState has occurred.
|
||||||
|
if (m_drawerToggle != null) m_drawerToggle.syncState();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (m_drawerToggle != null && m_drawerToggle.onOptionsItemSelected(item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
finish();
|
finish();
|
||||||
@ -115,6 +157,10 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
|
if (m_drawerLayout != null) {
|
||||||
|
m_drawerLayout.closeDrawers();
|
||||||
|
}
|
||||||
|
|
||||||
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||||
|
|
||||||
af.setArticleId(articleId);
|
af.setArticleId(articleId);
|
||||||
|
@ -67,9 +67,12 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
private OfflineActivity m_activity;
|
private OfflineActivity m_activity;
|
||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
|
|
||||||
public void initialize(int feedId, boolean isCat) {
|
private boolean m_compactLayoutMode = false;
|
||||||
|
|
||||||
|
public void initialize(int feedId, boolean isCat, boolean compactMode) {
|
||||||
m_feedId = feedId;
|
m_feedId = feedId;
|
||||||
m_feedIsCat = isCat;
|
m_feedIsCat = isCat;
|
||||||
|
m_compactLayoutMode = compactMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -276,6 +279,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
//m_selectedArticles = savedInstanceState.getParcelableArrayList("selectedArticles");
|
//m_selectedArticles = savedInstanceState.getParcelableArrayList("selectedArticles");
|
||||||
m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery");
|
m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery");
|
||||||
m_feedIsCat = savedInstanceState.getBoolean("feedIsCat");
|
m_feedIsCat = savedInstanceState.getBoolean("feedIsCat");
|
||||||
|
m_compactLayoutMode = savedInstanceState.getBoolean("compactLayoutMode");
|
||||||
} else {
|
} else {
|
||||||
m_activity.getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
|
m_activity.getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
|
||||||
}
|
}
|
||||||
@ -405,6 +409,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
//out.putParcelableArrayList("selectedArticles", m_selectedArticles);
|
//out.putParcelableArrayList("selectedArticles", m_selectedArticles);
|
||||||
out.putCharSequence("searchQuery", m_searchQuery);
|
out.putCharSequence("searchQuery", m_searchQuery);
|
||||||
out.putBoolean("feedIsCat", m_feedIsCat);
|
out.putBoolean("feedIsCat", m_feedIsCat);
|
||||||
|
|
||||||
|
out.putBoolean("compactLayoutMode", m_compactLayoutMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public void setLoadingStatus(int status, boolean showProgress) {
|
/* public void setLoadingStatus(int status, boolean showProgress) {
|
||||||
@ -586,7 +592,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
TextView te = (TextView)v.findViewById(R.id.excerpt);
|
TextView te = (TextView)v.findViewById(R.id.excerpt);
|
||||||
|
|
||||||
if (te != null) {
|
if (te != null) {
|
||||||
if (!m_prefs.getBoolean("headlines_show_content", true)) {
|
if ((m_compactLayoutMode && m_activity.isSmallScreen()) || !m_prefs.getBoolean("headlines_show_content", true)) {
|
||||||
te.setVisibility(View.GONE);
|
te.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
String excerpt = Jsoup.parse(article.getString(article.getColumnIndex("content"))).text();
|
String excerpt = Jsoup.parse(article.getString(article.getColumnIndex("content"))).text();
|
||||||
@ -678,6 +684,12 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View headlineFooter = v.findViewById(R.id.headline_footer);
|
||||||
|
|
||||||
|
if (headlineFooter != null && m_compactLayoutMode && m_activity.isSmallScreen()) {
|
||||||
|
headlineFooter.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user