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;
|
||||||
@ -20,6 +23,9 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
protected SharedPreferences m_prefs;
|
protected SharedPreferences m_prefs;
|
||||||
|
|
||||||
|
private ActionBarDrawerToggle m_drawerToggle;
|
||||||
|
private DrawerLayout m_drawerLayout;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@Override
|
@Override
|
||||||
@ -32,8 +38,34 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.headlines_articles);
|
setContentView(R.layout.headlines_articles);
|
||||||
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
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().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,9 +120,19 @@ 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) {
|
||||||
switch (item.getItemId()) {
|
if (m_drawerToggle != null && m_drawerToggle.onOptionsItemSelected(item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
finish();
|
finish();
|
||||||
overridePendingTransition(0, R.anim.right_slide_out);
|
overridePendingTransition(0, R.anim.right_slide_out);
|
||||||
@ -115,7 +157,11 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
if (m_drawerLayout != null) {
|
||||||
|
m_drawerLayout.closeDrawers();
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||||
|
|
||||||
af.setArticleId(articleId);
|
af.setArticleId(articleId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -66,10 +66,13 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
private OfflineHeadlinesEventListener m_listener;
|
private OfflineHeadlinesEventListener m_listener;
|
||||||
private OfflineActivity m_activity;
|
private OfflineActivity m_activity;
|
||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
|
|
||||||
|
private boolean m_compactLayoutMode = false;
|
||||||
|
|
||||||
public void initialize(int feedId, boolean isCat) {
|
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();
|
||||||
@ -664,7 +670,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
flavorImageHolder.setVisibility(View.GONE);
|
flavorImageHolder.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView ib = (ImageView) v.findViewById(R.id.article_menu_button);
|
ImageView ib = (ImageView) v.findViewById(R.id.article_menu_button);
|
||||||
|
|
||||||
if (ib != null) {
|
if (ib != null) {
|
||||||
//if (m_activity.isDarkTheme())
|
//if (m_activity.isDarkTheme())
|
||||||
@ -678,7 +684,13 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
View headlineFooter = v.findViewById(R.id.headline_footer);
|
||||||
|
|
||||||
|
if (headlineFooter != null && m_compactLayoutMode && m_activity.isSmallScreen()) {
|
||||||
|
headlineFooter.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustTitleTextView(int score, TextView tv, int position) {
|
private void adjustTitleTextView(int score, TextView tv, int position) {
|
||||||
|
Loading…
Reference in New Issue
Block a user