add ability to display privacy policy link in menu

This commit is contained in:
Daniel Gultsch 2024-02-14 09:11:49 +01:00
parent 617dd76d2f
commit 59c23f5558
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
8 changed files with 65 additions and 22 deletions

View file

@ -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 {

View file

@ -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;
@ -309,7 +311,13 @@ public class ConversationsOverviewFragment extends XmppFragment {
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));
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

View file

@ -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);

View file

@ -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()) {

View file

@ -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.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
try {
context.startActivity(intent);

View file

@ -49,6 +49,11 @@
android:orderInCategory="90"
android:title="@string/action_account"
app:showAsAction="never" />
<item android:id="@+id/action_privacy_policy"
android:visible="false"
android:orderInCategory="98"
android:title="@string/privacy_policy"
app:showAsAction="never"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -10,8 +10,8 @@
app:showAsAction="collapseActionView|always" />
<item
android:id="@+id/action_scan_qr_code"
android:title="@string/scan_qr_code"
android:icon="?attr/icon_scan_qr_code"
android:title="@string/scan_qr_code"
app:showAsAction="always" />
<item
@ -31,6 +31,12 @@
android:orderInCategory="90"
android:title="@string/action_account"
app:showAsAction="never" />
<item
android:id="@+id/action_privacy_policy"
android:orderInCategory="98"
android:title="@string/privacy_policy"
android:visible="false"
app:showAsAction="never" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -1023,4 +1023,5 @@
<string name="unverified_devices">You are using unverified devices. Scan the QR Code on your other devices to perform verification and impede active MITM attacks.</string>
<string name="report_spam">Report spam</string>
<string name="report_spam_and_block">Report spam and block spammer</string>
<string name="privacy_policy">Privacy policy</string>
</resources>