From 59c23f5558cbd2c7240a669f5b1f7ae2638c2496 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 14 Feb 2024 09:11:49 +0100 Subject: [PATCH] add ability to display privacy policy link in menu --- build.gradle | 4 +++- .../ui/ConversationsOverviewFragment.java | 22 +++++++++++++------ .../ui/StartConversationActivity.java | 11 +++++++--- .../siacs/conversations/ui/XmppActivity.java | 18 +++++++++++++++ .../conversations/ui/text/FixedURLSpan.java | 4 +--- .../menu/fragment_conversations_overview.xml | 5 +++++ src/main/res/menu/start_conversation.xml | 22 ++++++++++++------- src/main/res/values/strings.xml | 1 + 8 files changed, 65 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index 51e51fc85..60ba30519 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ android { defaultConfig { minSdkVersion 21 targetSdkVersion 34 - versionCode 42090 + versionCode 42091 versionName "2.13.2" archivesBaseName += "-$versionName" applicationId "eu.siacs.conversations" @@ -105,6 +105,7 @@ android { def appName = "Conversations" resValue "string", "app_name", appName buildConfigField "String", "APP_NAME", "\"$appName\"" + buildConfigField "String", "PRIVACY_POLICY", "null" } splits { @@ -144,6 +145,7 @@ android { def appName = "Quicksy" resValue "string", "app_name", appName buildConfigField "String", "APP_NAME", "\"$appName\"" + buildConfigField "String", "PRIVACY_POLICY", "\"https://quicksy.im/privacy.htm\"" } conversations { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java index eebd94df5..b673260ad 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java @@ -57,12 +57,14 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; +import eu.siacs.conversations.BuildConfig; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.FragmentConversationsOverviewBinding; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversational; +import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.ui.adapter.ConversationAdapter; import eu.siacs.conversations.ui.interfaces.OnConversationArchived; import eu.siacs.conversations.ui.interfaces.OnConversationSelected; @@ -304,13 +306,19 @@ public class ConversationsOverviewFragment extends XmppFragment { return binding.getRoot(); } - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { - menuInflater.inflate(R.menu.fragment_conversations_overview, menu); - AccountUtils.showHideMenuItems(menu); - final MenuItem easyOnboardInvite = menu.findItem(R.id.action_easy_invite); - easyOnboardInvite.setVisible(EasyOnboardingInvite.anyHasSupport(activity == null ? null : activity.xmppConnectionService)); - } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { + menuInflater.inflate(R.menu.fragment_conversations_overview, menu); + AccountUtils.showHideMenuItems(menu); + final MenuItem easyOnboardInvite = menu.findItem(R.id.action_easy_invite); + easyOnboardInvite.setVisible( + EasyOnboardingInvite.anyHasSupport( + activity == null ? null : activity.xmppConnectionService)); + final MenuItem privacyPolicyMenuItem = menu.findItem(R.id.action_privacy_policy); + privacyPolicyMenuItem.setVisible( + BuildConfig.PRIVACY_POLICY != null + && QuickConversationsService.isPlayStoreFlavor()); + } @Override public void onBackendConnected() { diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index e3850e527..dfdc8be19 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -62,6 +62,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import eu.siacs.conversations.BuildConfig; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.ActivityStartConversationBinding; @@ -658,11 +659,15 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.start_conversation, menu); AccountUtils.showHideMenuItems(menu); - MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline); - MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); + final MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline); + final MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); + final MenuItem privacyPolicyMenuItem = menu.findItem(R.id.action_privacy_policy); + privacyPolicyMenuItem.setVisible( + BuildConfig.PRIVACY_POLICY != null + && QuickConversationsService.isPlayStoreFlavor()); qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); if (QuickConversationsService.isQuicksy()) { menuHideOffline.setVisible(false); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 8b555f1b9..9190697a8 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -56,6 +56,7 @@ import androidx.databinding.DataBindingUtil; import com.google.common.base.Strings; +import eu.siacs.conversations.BuildConfig; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.PgpEngine; @@ -422,6 +423,9 @@ public abstract class XmppActivity extends ActionBarActivity { case R.id.action_settings: startActivity(new Intent(this, SettingsActivity.class)); break; + case R.id.action_privacy_policy: + openPrivacyPolicy(); + break; case R.id.action_accounts: AccountUtils.launchManageAccounts(this); break; @@ -438,6 +442,20 @@ public abstract class XmppActivity extends ActionBarActivity { return super.onOptionsItemSelected(item); } + private void openPrivacyPolicy() { + if (BuildConfig.PRIVACY_POLICY == null) { + return; + } + final var viewPolicyIntent = new Intent(Intent.ACTION_VIEW); + viewPolicyIntent.setData(Uri.parse(BuildConfig.PRIVACY_POLICY)); + try { + startActivity(viewPolicyIntent); + } catch (final ActivityNotFoundException e) { + Toast.makeText(this, R.string.no_application_found_to_open_link, Toast.LENGTH_SHORT) + .show(); + } + } + public void selectPresence(final Conversation conversation, final PresenceSelector.OnPresenceSelected listener) { final Contact contact = conversation.getContact(); if (contact.showInRoster() || contact.isSelf()) { diff --git a/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java b/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java index 684fd8094..a5fba62a7 100644 --- a/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java +++ b/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java @@ -75,9 +75,7 @@ public class FixedURLSpan extends URLSpan { } } final Intent intent = new Intent(Intent.ACTION_VIEW, uri); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); - } + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); //intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); try { context.startActivity(intent); diff --git a/src/main/res/menu/fragment_conversations_overview.xml b/src/main/res/menu/fragment_conversations_overview.xml index 38c83df8f..431e25bbd 100644 --- a/src/main/res/menu/fragment_conversations_overview.xml +++ b/src/main/res/menu/fragment_conversations_overview.xml @@ -49,6 +49,11 @@ android:orderInCategory="90" android:title="@string/action_account" app:showAsAction="never" /> + + xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="collapseActionView|always" /> + android:title="@string/scan_qr_code" + app:showAsAction="always" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + + app:showAsAction="never" /> \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 18a29610a..b644fbdd4 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1023,4 +1023,5 @@ You are using unverified devices. Scan the QR Code on your other devices to perform verification and impede active MITM attacks. Report spam Report spam and block spammer + Privacy policy