From ce1a4a2a1c0a85872714441a1eb4651f65af5603 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 30 Jul 2020 09:36:12 +1000 Subject: [PATCH] Add learn more button --- res/menu/menu_pn_mode.xml | 11 ++++++++ .../loki/activities/PNModeActivity.kt | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 res/menu/menu_pn_mode.xml diff --git a/res/menu/menu_pn_mode.xml b/res/menu/menu_pn_mode.xml new file mode 100644 index 000000000..9fd06956f --- /dev/null +++ b/res/menu/menu_pn_mode.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt index 763c3cf6b..c128e0a80 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt @@ -3,10 +3,14 @@ package org.thoughtcrime.securesms.loki.activities import android.app.AlertDialog import android.content.Intent import android.graphics.drawable.TransitionDrawable +import android.net.Uri import android.os.Bundle import android.support.annotation.DrawableRes +import android.view.Menu +import android.view.MenuItem import android.view.View import android.widget.LinearLayout +import android.widget.Toast import kotlinx.android.synthetic.main.activity_display_name.registerButton import kotlinx.android.synthetic.main.activity_pn_mode.* import network.loki.messenger.R @@ -28,6 +32,11 @@ class PNModeActivity : BaseActionBarActivity() { backgroundPollingOptionView.setOnClickListener { toggleBackgroundPolling() } registerButton.setOnClickListener { register() } } + + override fun onCreateOptionsMenu(menu: Menu?): Boolean { + menuInflater.inflate(R.menu.menu_pn_mode, menu) + return true + } // endregion // region Animation @@ -39,6 +48,25 @@ class PNModeActivity : BaseActionBarActivity() { // endregion // region Interaction + override fun onOptionsItemSelected(item: MenuItem): Boolean { + val id = item.itemId + when(id) { + R.id.learnMoreButton -> learnMore() + else -> { /* Do nothing */ } + } + return super.onOptionsItemSelected(item) + } + + private fun learnMore() { + try { + val url = "https://getsession.org/faq/#privacy" + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(intent) + } catch (e: Exception) { + Toast.makeText(this, R.string.invalid_url, Toast.LENGTH_SHORT).show() + } + } + private fun toggleFCM() { when (selectedOptionView) { null -> {