From e64ce1da0ef49a56fa904b38c48b76298e1f892a Mon Sep 17 00:00:00 2001 From: YuutaW <17158086+Trumeet@users.noreply.github.com> Date: Sat, 2 Mar 2019 09:59:43 -0800 Subject: feat(app): add about dialog Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com> --- .../main/java/moe/yuuta/workmode/MainActivity.kt | 13 +++++++ .../moe/yuuta/workmode/widgets/HtmlTextView.java | 33 ++++++++++++++++ app/src/main/res/layout/dialog_about.xml | 44 ++++++++++++++++++++++ app/src/main/res/menu/menu_main.xml | 2 + app/src/main/res/values/attrs.xml | 5 +++ app/src/main/res/values/strings.xml | 7 +++- 6 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/moe/yuuta/workmode/widgets/HtmlTextView.java create mode 100644 app/src/main/res/layout/dialog_about.xml (limited to 'app/src/main') diff --git a/app/src/main/java/moe/yuuta/workmode/MainActivity.kt b/app/src/main/java/moe/yuuta/workmode/MainActivity.kt index e2ff1e1..1346f6d 100644 --- a/app/src/main/java/moe/yuuta/workmode/MainActivity.kt +++ b/app/src/main/java/moe/yuuta/workmode/MainActivity.kt @@ -16,6 +16,7 @@ import android.widget.* import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat +import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -288,6 +289,10 @@ class MainActivity : AppCompatActivity(), SwitchBar.OnSwitchChangeListener, View startActivity(Intent.createChooser(intent, getString(R.string.feedback))) return true } + R.id.action_about -> { + AboutFragment().show(supportFragmentManager, "About") + return true + } R.id.action_check_update -> { mCheckUpdateObserver.start() return true @@ -426,4 +431,12 @@ private class Adapter : RecyclerView.Adapter() { fun destroy() { mStoppableGroup.stop() } +} + +class AboutFragment : DialogFragment() { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + val view = inflater.inflate(R.layout.dialog_about, container, false) + view.findViewById(R.id.text_version).text = BuildConfig.VERSION_NAME + return view + } } \ No newline at end of file diff --git a/app/src/main/java/moe/yuuta/workmode/widgets/HtmlTextView.java b/app/src/main/java/moe/yuuta/workmode/widgets/HtmlTextView.java new file mode 100644 index 0000000..1d5ee0e --- /dev/null +++ b/app/src/main/java/moe/yuuta/workmode/widgets/HtmlTextView.java @@ -0,0 +1,33 @@ +package moe.yuuta.workmode.widgets; + +import android.content.Context; +import android.content.res.TypedArray; +import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.util.AttributeSet; + +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatTextView; + +import moe.yuuta.workmode.R; + +public class HtmlTextView extends AppCompatTextView { + + public HtmlTextView(Context context) { + this(context, null); + } + + public HtmlTextView(Context context, @Nullable AttributeSet attrs) { + this(context, attrs, android.R.attr.textViewStyle); + } + + public HtmlTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray a = context.getTheme().obtainStyledAttributes( + attrs, R.styleable.HtmlTextView, defStyleAttr, 0); + + setText(Html.fromHtml(a.getString(R.styleable.HtmlTextView_html))); + if (a.getBoolean(R.styleable.HtmlTextView_enableLinks, false)) setMovementMethod(new LinkMovementMethod()); + } +} diff --git a/app/src/main/res/layout/dialog_about.xml b/app/src/main/res/layout/dialog_about.xml new file mode 100644 index 0000000..98dca7f --- /dev/null +++ b/app/src/main/res/layout/dialog_about.xml @@ -0,0 +1,44 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index df1c7f3..de8cf2e 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -13,6 +13,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 82dae90..8f7ca34 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,7 +16,7 @@ Switch to whitelist These apps will be enabled and others will be disabled when you are working Cannot get applications - Unable to apply settings + Settings are saved but cannot be applied to system Feedback Get logs Check update @@ -26,13 +26,16 @@ %1$s is available for download Tap here to update to the latest version Tap here to update to the latest version and get more features + 小雅 + ]]> Y29tLmFuZHJvaWQudmVuZGluZw== Z2V0SW5zdGFsbGVyUGFja2FnZQ== L2RhdGEvbWlzYy8ud29tby8= L2RhdGEvbWlzYy8ud29tby8uZmMvLmxvZ3Mv - AVA + AVA litu You\'re in the basement now. De -- cgit v1.2.3