From cc917857b00ea8bf6328f351eb051e7e5313e60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 11 Jan 2016 07:42:00 +0100 Subject: Advanced screen, warning fragment --- .../keychain/ui/ViewKeyAdvActivity.java | 25 ++++++---- .../keychain/ui/ViewKeyAdvStartFragment.java | 55 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvStartFragment.java (limited to 'OpenKeychain/src/main/java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index b10e5f8d4..b9a8259c1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -61,10 +61,11 @@ public class ViewKeyAdvActivity extends BaseActivity implements protected Uri mDataUri; public static final String EXTRA_SELECTED_TAB = "selected_tab"; - public static final int TAB_SHARE = 0; - public static final int TAB_IDENTITIES = 1; - public static final int TAB_SUBKEYS = 2; - public static final int TAB_CERTS = 3; + public static final int TAB_START = 0; + public static final int TAB_SHARE = 1; + public static final int TAB_IDENTITIES = 2; + public static final int TAB_SUBKEYS = 3; + public static final int TAB_CERTS = 4; // view private ViewPager mViewPager; @@ -126,31 +127,35 @@ public class ViewKeyAdvActivity extends BaseActivity implements mViewPager.setAdapter(mTabAdapter); // keep track which of these are action mode enabled! - mTabsWithActionMode = new boolean[4]; + mTabsWithActionMode = new boolean[5]; + + mTabAdapter.addTab(ViewKeyAdvStartFragment.class, + null, getString(R.string.key_view_tab_start)); + mTabsWithActionMode[0] = false; Bundle shareBundle = new Bundle(); shareBundle.putParcelable(ViewKeyAdvShareFragment.ARG_DATA_URI, dataUri); mTabAdapter.addTab(ViewKeyAdvShareFragment.class, shareBundle, getString(R.string.key_view_tab_share)); - mTabsWithActionMode[0] = false; + mTabsWithActionMode[1] = false; Bundle userIdsBundle = new Bundle(); userIdsBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri); mTabAdapter.addTab(ViewKeyAdvUserIdsFragment.class, userIdsBundle, getString(R.string.section_user_ids)); - mTabsWithActionMode[1] = true; + mTabsWithActionMode[2] = true; Bundle keysBundle = new Bundle(); keysBundle.putParcelable(ViewKeyAdvSubkeysFragment.ARG_DATA_URI, dataUri); mTabAdapter.addTab(ViewKeyAdvSubkeysFragment.class, keysBundle, getString(R.string.key_view_tab_keys)); - mTabsWithActionMode[2] = true; + mTabsWithActionMode[3] = true; Bundle certsBundle = new Bundle(); certsBundle.putParcelable(ViewKeyAdvCertsFragment.ARG_DATA_URI, dataUri); mTabAdapter.addTab(ViewKeyAdvCertsFragment.class, certsBundle, getString(R.string.key_view_tab_certs)); - mTabsWithActionMode[3] = false; + mTabsWithActionMode[4] = false; // update layout after operations mSlidingTabLayout.setViewPager(mViewPager); @@ -158,7 +163,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements // switch to tab selected by extra Intent intent = getIntent(); - int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, TAB_SHARE); + int switchToTab = intent.getIntExtra(EXTRA_SELECTED_TAB, TAB_START); mViewPager.setCurrentItem(switchToTab); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvStartFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvStartFragment.java new file mode 100644 index 000000000..f7e6f2b9c --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvStartFragment.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import org.markdown4j.Markdown4jProcessor; +import org.sufficientlysecure.htmltextview.HtmlTextView; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; + +import java.io.IOException; + +public class ViewKeyAdvStartFragment extends Fragment { + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.view_key_adv_start_fragment, container, false); + + HtmlTextView textView = (HtmlTextView) + view.findViewById(R.id.view_key_adv_start_text); + + // load markdown from raw resource + try { + String html = new Markdown4jProcessor().process( + getActivity().getResources().openRawResource(R.raw.advanced)); + textView.setHtmlFromString(html, new HtmlTextView.LocalImageGetter()); + } catch (IOException e) { + Log.e(Constants.TAG, "IOException", e); + } + + return view; + } + +} -- cgit v1.2.3