From 4e6057171b49b024ccaff251a5c85421b1259764 Mon Sep 17 00:00:00 2001 From: opyale Date: Sat, 9 May 2020 19:07:55 +0000 Subject: [PATCH] Adding deprecation dialog. (#492) Additional improvements. Final improvements. Adding deprecation dialog. Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/492 Reviewed-by: M M Arif --- .../gitnex/helpers/DeprecationDialog.java | 77 +++++++++++++++++++ .../res/layout/layout_deprecation_dialog.xml | 37 +++++++++ app/src/main/res/values/strings.xml | 4 +- 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/mian/gitnex/helpers/DeprecationDialog.java create mode 100644 app/src/main/res/layout/layout_deprecation_dialog.xml diff --git a/app/src/main/java/org/mian/gitnex/helpers/DeprecationDialog.java b/app/src/main/java/org/mian/gitnex/helpers/DeprecationDialog.java new file mode 100644 index 00000000..a493498c --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/helpers/DeprecationDialog.java @@ -0,0 +1,77 @@ +package org.mian.gitnex.helpers; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import org.mian.gitnex.R; + +/** + * Author opyale + */ + +public class DeprecationDialog extends AlertDialog.Builder { + + private Context context; + + private String title; + private String message; + + public DeprecationDialog(@NonNull Context context) { + + super(context); + this.context = context; + setup(); + + } + + public DeprecationDialog(@NonNull Context context, int themeResId) { + + super(context, themeResId); + this.context = context; + setup(); + + } + + @NonNull + @SuppressLint("InflateParams") + @Override + public AlertDialog create() { + + setCancelable(false); + setPositiveButton(context.getResources().getString(R.string.okButton), (dialog, which) -> dialog.dismiss()); + + View view = LayoutInflater.from(context).inflate(R.layout.layout_deprecation_dialog, null); + + TextView customTitle = view.findViewById(R.id.customTitle); + TextView customMessage = view.findViewById(R.id.customMessage); + + customTitle.setText(title); + customMessage.setText(message); + + setView(view); + return super.create(); + + } + + private void setup() { + + this.message = ""; + this.title = context.getResources().getString(R.string.featureDeprecated); + + } + + public void setMessage(String message) { + + this.message = message; + } + + public void setTitle(String title) { + + this.title = title; + } + +} diff --git a/app/src/main/res/layout/layout_deprecation_dialog.xml b/app/src/main/res/layout/layout_deprecation_dialog.xml new file mode 100644 index 00000000..8efcb173 --- /dev/null +++ b/app/src/main/res/layout/layout_deprecation_dialog.xml @@ -0,0 +1,37 @@ + + + + + + + + + + \ 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 9205a06d..ee7f0188 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -197,6 +197,9 @@ Comment posted Something went wrong, please try again + This function will be removed in the future. + 😱 + Avatar GitNex @@ -622,7 +625,6 @@ Once Abort - Issue Subscribed Issue Subscription failed Issue Unsubscribed