diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-03-02 09:59:43 -0800 |
---|---|---|
committer | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-03-02 09:59:43 -0800 |
commit | e64ce1da0ef49a56fa904b38c48b76298e1f892a (patch) | |
tree | 82bffbfca5f1e3ee48ccc3002e06d9513ebac713 | |
parent | e7be393b842d8445ae47bc59e88980a99b6e468e (diff) | |
download | WorkMode-e64ce1da0ef49a56fa904b38c48b76298e1f892a.tar WorkMode-e64ce1da0ef49a56fa904b38c48b76298e1f892a.tar.gz WorkMode-e64ce1da0ef49a56fa904b38c48b76298e1f892a.tar.bz2 WorkMode-e64ce1da0ef49a56fa904b38c48b76298e1f892a.zip |
feat(app): add about dialog
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
-rw-r--r-- | app/src/main/java/moe/yuuta/workmode/MainActivity.kt | 13 | ||||
-rw-r--r-- | app/src/main/java/moe/yuuta/workmode/widgets/HtmlTextView.java | 33 | ||||
-rw-r--r-- | app/src/main/res/layout/dialog_about.xml | 44 | ||||
-rw-r--r-- | app/src/main/res/menu/menu_main.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/values/attrs.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 7 |
6 files changed, 102 insertions, 2 deletions
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<Adapter.VH>() { 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<TextView>(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 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="24dp"> + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@mipmap/ic_launcher" + android:layout_marginEnd="16dp"/> + <LinearLayout + android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/app_name" + android:textAppearance="@style/TextAppearance.AppCompat.Title"/> + <TextView + android:id="@+id/text_version" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + <moe.yuuta.workmode.widgets.HtmlTextView + android:id="@+id/text_copyright" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:html="@string/about_icon_copyright" + app:enableLinks="true" + android:textSize="12sp" + android:textColor="@android:color/black" /> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Copyright © 2019 - 2019 Trumeet" + android:textSize="12sp" + android:textColor="@android:color/black" + tools:ignore="HardcodedText" /> + </LinearLayout> +</LinearLayout>
\ 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 @@ <item android:title="@string/about"> <menu> <group> + <item android:id="@+id/action_about" + android:title="@string/about" /> <item android:id="@+id/action_check_update" android:title="@string/check_update" /> <item android:id="@+id/action_oss" diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 9e90cdd..9185e25 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -5,4 +5,9 @@ <attr name="switchBarMarginEnd" format="dimension" /> <attr name="switchBarBackgroundColor" format="color" /> <attr name="switchBarBackgroundActivatedColor" format="color" /> + + <declare-styleable name="HtmlTextView"> + <attr name="html" format="string|reference" /> + <attr name="enableLinks" format="boolean|reference" /> + </declare-styleable> </resources>
\ 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 @@ <string name="whitelist_toggle_title">Switch to whitelist</string> <string name="whitelist_toggle_information">These apps will be enabled and others will be disabled when you are working</string> <string name="error_load_applications">Cannot get applications</string> - <string name="error_apply">Unable to apply settings</string> + <string name="error_apply">Settings are saved but cannot be applied to system</string> <string name="feedback">Feedback</string> <string name="get_logs">Get logs</string> <string name="check_update">Check update</string> @@ -26,13 +26,16 @@ <string name="notification_title_update">%1$s is available for download</string> <string name="notification_text_update_summary">Tap here to update to the latest version</string> <string name="notification_text_update">Tap here to update to the latest version and get more features</string> + <string name="about_icon_copyright"><![CDATA[ +The icon is designed by <a href="https://twitter.com/xiaoya_er">小雅</a> + ]]></string> <!-- #Anti-Crack --> <string name="sys_id" translatable="false">Y29tLmFuZHJvaWQudmVuZGluZw==</string> <string name="app_id" translatable="false">Z2V0SW5zdGFsbGVyUGFja2FnZQ==</string> <string name="fol_id_orig" translatable="false">L2RhdGEvbWlzYy8ud29tby8=</string> <string name="fol_id" translatable="false">L2RhdGEvbWlzYy8ud29tby8uZmMvLmxvZ3Mv</string> - <string name="b6_k" translatable="true">AVA</string> + <string name="b6_k" translatable="false">AVA</string> <string name="b7_a" translatable="false">litu</string> <string name="b90_key" translatable="false">You\'re in the basement now.</string> <string name="b99_a" translatable="false">De</string> |