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 /app/src/main/java | |
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>
Diffstat (limited to 'app/src/main/java')
-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 |
2 files changed, 46 insertions, 0 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()); + } +} |