diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java | 13 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java | 19 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java) | 26 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java | 37 |
4 files changed, 64 insertions, 31 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java index 5909970af..912caf32f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java @@ -27,11 +27,14 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +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 HelpAboutFragment extends Fragment { @@ -44,8 +47,14 @@ public class HelpAboutFragment extends Fragment { HtmlTextView aboutTextView = (HtmlTextView) view.findViewById(R.id.help_about_text); - // load html from raw resource (Parsing handled by HtmlTextView library) - aboutTextView.setHtmlFromRawResource(getActivity(), R.raw.help_about, true); + // load mardown from raw resource + try { + String html = new Markdown4jProcessor().process( + getActivity().getResources().openRawResource(R.raw.help_about)); + aboutTextView.setHtmlFromString(html, true); + } catch (IOException e) { + Log.e(Constants.TAG, "IOException", e); + } // no flickering when clicking textview for Android < 4 aboutTextView.setTextColor(getResources().getColor(android.R.color.black)); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java index cd6cdf4d6..24136a4b8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java @@ -64,18 +64,23 @@ public class HelpActivity extends BaseActivity { } Bundle startBundle = new Bundle(); - startBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_start); - mTabsAdapter.addTab(HelpHtmlFragment.class, startBundle, + startBundle.putInt(HelpMarkdownFragment.ARG_MARKDOWN_FILE, R.raw.help_start); + mTabsAdapter.addTab(HelpMarkdownFragment.class, startBundle, getString(R.string.help_tab_start)); - Bundle wotBundle = new Bundle(); - wotBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_certification); - mTabsAdapter.addTab(HelpHtmlFragment.class, wotBundle, + Bundle certificationBundle = new Bundle(); + certificationBundle.putInt(HelpMarkdownFragment.ARG_MARKDOWN_FILE, R.raw.help_certification); + mTabsAdapter.addTab(HelpMarkdownFragment.class, certificationBundle, getString(R.string.help_tab_wot)); + Bundle faqBundle = new Bundle(); + faqBundle.putInt(HelpMarkdownFragment.ARG_MARKDOWN_FILE, R.raw.help_faq); + mTabsAdapter.addTab(HelpMarkdownFragment.class, faqBundle, + getString(R.string.help_tab_faq)); + Bundle changelogBundle = new Bundle(); - changelogBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_changelog); - mTabsAdapter.addTab(HelpHtmlFragment.class, changelogBundle, + changelogBundle.putInt(HelpMarkdownFragment.ARG_MARKDOWN_FILE, R.raw.help_changelog); + mTabsAdapter.addTab(HelpMarkdownFragment.class, changelogBundle, getString(R.string.help_tab_changelog)); mTabsAdapter.addTab(HelpAboutFragment.class, null, diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java index a3f0ef614..69ddf2e99 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpMarkdownFragment.java @@ -26,24 +26,29 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ScrollView; +import org.markdown4j.Markdown4jProcessor; import org.sufficientlysecure.htmltextview.HtmlTextView; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.util.Log; -public class HelpHtmlFragment extends Fragment { +import java.io.IOException; + +public class HelpMarkdownFragment extends Fragment { private Activity mActivity; private int mHtmlFile; - public static final String ARG_HTML_FILE = "htmlFile"; + public static final String ARG_MARKDOWN_FILE = "htmlFile"; /** * Create a new instance of HelpHtmlFragment, providing "htmlFile" as an argument. */ - static HelpHtmlFragment newInstance(int htmlFile) { - HelpHtmlFragment f = new HelpHtmlFragment(); + static HelpMarkdownFragment newInstance(int htmlFile) { + HelpMarkdownFragment f = new HelpMarkdownFragment(); // Supply html raw file input as an argument. Bundle args = new Bundle(); - args.putInt(ARG_HTML_FILE, htmlFile); + args.putInt(ARG_MARKDOWN_FILE, htmlFile); f.setArguments(args); return f; @@ -53,7 +58,7 @@ public class HelpHtmlFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity(); - mHtmlFile = getArguments().getInt(ARG_HTML_FILE); + mHtmlFile = getArguments().getInt(ARG_MARKDOWN_FILE); ScrollView scroller = new ScrollView(mActivity); HtmlTextView text = new HtmlTextView(mActivity); @@ -65,8 +70,13 @@ public class HelpHtmlFragment extends Fragment { scroller.addView(text); - // load html from raw resource (Parsing handled by HtmlTextView library) - text.setHtmlFromRawResource(getActivity(), mHtmlFile, true); + // load mardown from raw resource + try { + String html = new Markdown4jProcessor().process(getActivity().getResources().openRawResource(mHtmlFile)); + text.setHtmlFromString(html, true); + } catch (IOException e) { + Log.e(Constants.TAG, "IOException", e); + } // no flickering when clicking textview for Android < 4 text.setTextColor(getResources().getColor(android.R.color.black)); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java index 3121e02ef..7e07ed818 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java @@ -37,7 +37,28 @@ import org.sufficientlysecure.keychain.util.FabContainer; */ public class Notify { - public static enum Style {OK, WARN, ERROR} + public static enum Style { + OK, WARN, ERROR; + + public void applyToBar(Snackbar bar) { + + switch (this) { + case OK: + // bar.actionColorResource(R.color.android_green_light); + bar.lineColorResource(R.color.android_green_light); + break; + case WARN: + // bar.textColorResource(R.color.android_orange_light); + bar.lineColorResource(R.color.android_orange_light); + break; + case ERROR: + // bar.textColorResource(R.color.android_red_light); + bar.lineColorResource(R.color.android_red_light); + break; + } + + } + } public static final int LENGTH_INDEFINITE = 0; public static final int LENGTH_LONG = 3500; @@ -54,19 +75,7 @@ public class Notify { snackbar.duration(duration); } - switch (style) { - case OK: - snackbar.actionColorResource(R.color.android_green_light); - break; - - case WARN: - snackbar.textColorResource(R.color.android_orange_light); - break; - - case ERROR: - snackbar.textColorResource(R.color.android_red_light); - break; - } + style.applyToBar(snackbar); if (actionListener != null) { snackbar.actionLabel(actionResId) |