mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
ui: use SlidingTabLayout in help activity
This commit is contained in:
parent
40793935ac
commit
12f1162a1e
@ -24,7 +24,9 @@ import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter;
|
||||
import org.sufficientlysecure.keychain.util.SlidingTabLayout;
|
||||
|
||||
public class HelpActivity extends ActionBarActivity {
|
||||
public static final String EXTRA_SELECTED_TAB = "selected_tab";
|
||||
@ -37,25 +39,27 @@ public class HelpActivity extends ActionBarActivity {
|
||||
public static final int TAB_ABOUT = 5;
|
||||
|
||||
ViewPager mViewPager;
|
||||
TabsAdapter mTabsAdapter;
|
||||
private PagerTabStripAdapter mTabsAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.help_activity);
|
||||
|
||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||
|
||||
mTabsAdapter = new TabsAdapter(this, mViewPager);
|
||||
setContentView(R.layout.help_activity);
|
||||
|
||||
int selectedTab = 0;
|
||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||
SlidingTabLayout slidingTabLayout =
|
||||
(SlidingTabLayout) findViewById(R.id.sliding_tab_layout);
|
||||
|
||||
mTabsAdapter = new PagerTabStripAdapter(this);
|
||||
mViewPager.setAdapter(mTabsAdapter);
|
||||
|
||||
int selectedTab = TAB_START;
|
||||
Intent intent = getIntent();
|
||||
if (intent.getExtras() != null && intent.getExtras().containsKey(EXTRA_SELECTED_TAB)) {
|
||||
selectedTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB);
|
||||
@ -63,30 +67,36 @@ public class HelpActivity extends ActionBarActivity {
|
||||
|
||||
Bundle startBundle = new Bundle();
|
||||
startBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_start);
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_start)),
|
||||
HelpHtmlFragment.class, startBundle, (selectedTab == TAB_START));
|
||||
mTabsAdapter.addTab(HelpHtmlFragment.class, startBundle,
|
||||
getString(R.string.help_tab_start));
|
||||
|
||||
Bundle faqBundle = new Bundle();
|
||||
faqBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_faq);
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_faq)),
|
||||
HelpHtmlFragment.class, faqBundle, (selectedTab == TAB_FAQ));
|
||||
mTabsAdapter.addTab(HelpHtmlFragment.class, faqBundle,
|
||||
getString(R.string.help_tab_faq));
|
||||
|
||||
Bundle wotBundle = new Bundle();
|
||||
wotBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_wot);
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_wot)),
|
||||
HelpHtmlFragment.class, wotBundle, (selectedTab == TAB_WOT));
|
||||
mTabsAdapter.addTab(HelpHtmlFragment.class, wotBundle,
|
||||
getString(R.string.help_tab_wot));
|
||||
|
||||
Bundle nfcBundle = new Bundle();
|
||||
nfcBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_nfc_beam);
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_nfc_beam)),
|
||||
HelpHtmlFragment.class, nfcBundle, (selectedTab == TAB_NFC));
|
||||
mTabsAdapter.addTab(HelpHtmlFragment.class, nfcBundle,
|
||||
getString(R.string.help_tab_nfc_beam));
|
||||
|
||||
Bundle changelogBundle = new Bundle();
|
||||
changelogBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_changelog);
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_changelog)),
|
||||
HelpHtmlFragment.class, changelogBundle, (selectedTab == TAB_CHANGELOG));
|
||||
mTabsAdapter.addTab(HelpHtmlFragment.class, changelogBundle,
|
||||
getString(R.string.help_tab_changelog));
|
||||
|
||||
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_about)),
|
||||
HelpAboutFragment.class, null, (selectedTab == TAB_ABOUT));
|
||||
mTabsAdapter.addTab(HelpAboutFragment.class, null,
|
||||
getString(R.string.help_tab_about));
|
||||
|
||||
// NOTE: must be after adding the tabs!
|
||||
slidingTabLayout.setViewPager(mViewPager);
|
||||
|
||||
// switch to tab selected by extra
|
||||
mViewPager.setCurrentItem(selectedTab);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<org.sufficientlysecure.keychain.util.SlidingTabLayout
|
||||
android:id="@+id/sliding_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user