From 8352b872a2190cf4d60859b08370882d289910cf Mon Sep 17 00:00:00 2001 From: Neven Date: Wed, 2 Nov 2022 10:02:07 +0100 Subject: [PATCH] Truncate changelog and add the link to the website --- .../com/orgzly/android/ui/CommonActivity.kt | 10 +- .../android/ui/dialogs/WhatsNewDialog.java | 34 - .../android/ui/dialogs/WhatsNewDialog.kt | 35 + .../orgzly/android/ui/views/WhatsNewChange.kt | 12 +- app/src/main/res/layout/dialog_whats_new.xml | 1266 +---------------- app/src/main/res/layout/text_list_item.xml | 2 +- app/src/main/res/values/whats_new_strings.xml | 6 + 7 files changed, 61 insertions(+), 1304 deletions(-) delete mode 100644 app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.java create mode 100644 app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.kt diff --git a/app/src/main/java/com/orgzly/android/ui/CommonActivity.kt b/app/src/main/java/com/orgzly/android/ui/CommonActivity.kt index 094dea040..2455c4531 100644 --- a/app/src/main/java/com/orgzly/android/ui/CommonActivity.kt +++ b/app/src/main/java/com/orgzly/android/ui/CommonActivity.kt @@ -191,10 +191,12 @@ abstract class CommonActivity : AppCompatActivity() { protected fun displayWhatsNewDialog() { whatsNewDialog?.dismiss() - whatsNewDialog = WhatsNewDialog.create(this) - whatsNewDialog?.let { - it.setOnDismissListener { whatsNewDialog = null } - it.show() + whatsNewDialog = WhatsNewDialog.create(this).apply { + setOnDismissListener { + whatsNewDialog = null + } + + show() } } diff --git a/app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.java b/app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.java deleted file mode 100644 index 1b48dfe3e..000000000 --- a/app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.orgzly.android.ui.dialogs; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.text.method.LinkMovementMethod; -import android.view.View; -import android.widget.TextView; - -import androidx.appcompat.app.AlertDialog; - -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.orgzly.R; -import com.orgzly.android.ui.util.SystemServices; -import com.orgzly.android.util.MiscUtils; - -public class WhatsNewDialog { - /** - * Display dialog with changes. - */ - public static AlertDialog create(Context context) { - @SuppressLint("InflateParams") final View layoutView = - SystemServices.getLayoutInflater(context).inflate(R.layout.dialog_whats_new, null, false); - - TextView view = ((TextView) layoutView.findViewById(R.id.dialog_whats_new_intro)); - view.setText(MiscUtils.fromHtml(context.getString(R.string.whats_new_intro))); - view.setMovementMethod(LinkMovementMethod.getInstance()); - - return new MaterialAlertDialogBuilder(context) - .setTitle(R.string.whats_new_title) - .setPositiveButton(R.string.ok, null) - .setView(layoutView) - .create(); - } -} diff --git a/app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.kt b/app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.kt new file mode 100644 index 000000000..e60a5ef13 --- /dev/null +++ b/app/src/main/java/com/orgzly/android/ui/dialogs/WhatsNewDialog.kt @@ -0,0 +1,35 @@ +package com.orgzly.android.ui.dialogs + +import android.content.Context +import android.text.method.LinkMovementMethod +import android.widget.TextView +import androidx.appcompat.app.AlertDialog +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.orgzly.R +import com.orgzly.android.ui.util.getLayoutInflater +import com.orgzly.android.util.MiscUtils + +object WhatsNewDialog { + /** + * Display dialog with changes. + */ + fun create(context: Context): AlertDialog { + val layoutView = context.getLayoutInflater().inflate(R.layout.dialog_whats_new, null, false) + + layoutView.findViewById(R.id.dialog_whats_new_intro).apply { + text = MiscUtils.fromHtml(context.getString(R.string.whats_new_intro)) + movementMethod = LinkMovementMethod.getInstance() + } + + layoutView.findViewById(R.id.dialog_whats_new_outro).apply { + text = MiscUtils.fromHtml(context.getString(R.string.whats_new_outro)) + movementMethod = LinkMovementMethod.getInstance() + } + + return MaterialAlertDialogBuilder(context) + .setTitle(R.string.whats_new_title) + .setPositiveButton(R.string.ok, null) + .setView(layoutView) + .create() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/orgzly/android/ui/views/WhatsNewChange.kt b/app/src/main/java/com/orgzly/android/ui/views/WhatsNewChange.kt index 0b04f0580..dfb3e124e 100644 --- a/app/src/main/java/com/orgzly/android/ui/views/WhatsNewChange.kt +++ b/app/src/main/java/com/orgzly/android/ui/views/WhatsNewChange.kt @@ -16,11 +16,11 @@ class WhatsNewChange(context: Context, attrs: AttributeSet) : LinearLayout(conte typedArray.getString(R.styleable.WhatsNewChange_text) } - val view = context.getLayoutInflater().inflate(R.layout.text_list_item, this, true) + val layoutView = context.getLayoutInflater().inflate(R.layout.text_list_item, this, true) - val c = view.findViewById(R.id.content) - c.text = MiscUtils.fromHtml(content) - c.movementMethod = LinkMovementMethod.getInstance() + layoutView.findViewById(R.id.content).apply { + text = MiscUtils.fromHtml(content) + movementMethod = LinkMovementMethod.getInstance() + } } -} - +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_whats_new.xml b/app/src/main/res/layout/dialog_whats_new.xml index dba9eb0ef..abe2c5627 100644 --- a/app/src/main/res/layout/dialog_whats_new.xml +++ b/app/src/main/res/layout/dialog_whats_new.xml @@ -17,8 +17,7 @@ + android:layout_height="wrap_content" /> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:id="@+id/dialog_whats_new_outro" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/text_list_item.xml b/app/src/main/res/layout/text_list_item.xml index dcae0a5c2..0836e2e0f 100644 --- a/app/src/main/res/layout/text_list_item.xml +++ b/app/src/main/res/layout/text_list_item.xml @@ -20,6 +20,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" - tools:text="This is some change"/> + tools:text="@string/lorem_ipsum_longer"/> diff --git a/app/src/main/res/values/whats_new_strings.xml b/app/src/main/res/values/whats_new_strings.xml index 88ab69824..8fa494c06 100644 --- a/app/src/main/res/values/whats_new_strings.xml +++ b/app/src/main/res/values/whats_new_strings.xml @@ -25,4 +25,10 @@ translate the app on Crowdin. ]]> + + Changelog + for the full list. + ]]>