mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Allow sharing download link for Briar from settings actions
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
package org.briarproject.briar.android.settings;
|
package org.briarproject.briar.android.settings;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.mailbox.MailboxActivity;
|
import org.briarproject.briar.android.mailbox.MailboxActivity;
|
||||||
@@ -24,6 +26,9 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
|
|
||||||
|
import static android.content.Intent.ACTION_SEND;
|
||||||
|
import static android.content.Intent.EXTRA_TEXT;
|
||||||
|
import static android.widget.Toast.LENGTH_LONG;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||||
@@ -37,11 +42,14 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||||||
public static final String SETTINGS_NAMESPACE = "android-ui";
|
public static final String SETTINGS_NAMESPACE = "android-ui";
|
||||||
|
|
||||||
private static final String PREF_KEY_AVATAR = "pref_key_avatar";
|
private static final String PREF_KEY_AVATAR = "pref_key_avatar";
|
||||||
|
private static final String PREF_KEY_SHARE_LINK = "pref_key_share_app_link";
|
||||||
private static final String PREF_KEY_FEEDBACK = "pref_key_send_feedback";
|
private static final String PREF_KEY_FEEDBACK = "pref_key_send_feedback";
|
||||||
private static final String PREF_KEY_DEV = "pref_key_dev";
|
private static final String PREF_KEY_DEV = "pref_key_dev";
|
||||||
private static final String PREF_KEY_EXPLODE = "pref_key_explode";
|
private static final String PREF_KEY_EXPLODE = "pref_key_explode";
|
||||||
private static final String PREF_KEY_MAILBOX = "pref_key_mailbox";
|
private static final String PREF_KEY_MAILBOX = "pref_key_mailbox";
|
||||||
|
|
||||||
|
private static final String DOWNLOAD_URL = "https://briarproject.org/download/";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ViewModelProvider.Factory viewModelFactory;
|
ViewModelProvider.Factory viewModelFactory;
|
||||||
|
|
||||||
@@ -86,6 +94,21 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Preference prefShareLink =
|
||||||
|
requireNonNull(findPreference(PREF_KEY_SHARE_LINK));
|
||||||
|
prefShareLink.setOnPreferenceClickListener(preference -> {
|
||||||
|
String text = getString(R.string.share_app_link_text, DOWNLOAD_URL);
|
||||||
|
Intent sendIntent = new Intent(ACTION_SEND);
|
||||||
|
sendIntent.putExtra(EXTRA_TEXT, text);
|
||||||
|
sendIntent.setType("text/plain");
|
||||||
|
try {
|
||||||
|
startActivity(Intent.createChooser(sendIntent, null));
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(requireContext(),
|
||||||
|
R.string.error_start_activity, LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
Preference prefFeedback =
|
Preference prefFeedback =
|
||||||
requireNonNull(findPreference(PREF_KEY_FEEDBACK));
|
requireNonNull(findPreference(PREF_KEY_FEEDBACK));
|
||||||
prefFeedback.setOnPreferenceClickListener(preference -> {
|
prefFeedback.setOnPreferenceClickListener(preference -> {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?android:attr/textColorPrimary"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M21,12L14,5V9C7,10 4,15 3,20C5.5,16.5 9,14.9 14,14.9V19L21,12Z" />
|
||||||
|
</vector>
|
||||||
@@ -733,6 +733,8 @@
|
|||||||
|
|
||||||
<!-- Settings Actions -->
|
<!-- Settings Actions -->
|
||||||
<string name="pref_category_actions">Actions</string>
|
<string name="pref_category_actions">Actions</string>
|
||||||
|
<string name="share_app_link">Share download link</string>
|
||||||
|
<string name="share_app_link_text">Download Briar at %s</string>
|
||||||
<string name="send_feedback">Send feedback</string>
|
<string name="send_feedback">Send feedback</string>
|
||||||
|
|
||||||
<!-- Link Warning -->
|
<!-- Link Warning -->
|
||||||
|
|||||||
@@ -47,6 +47,11 @@
|
|||||||
android:targetClass="org.briarproject.briar.android.hotspot.HotspotActivity"
|
android:targetClass="org.briarproject.briar.android.hotspot.HotspotActivity"
|
||||||
android:targetPackage="@string/app_package" />
|
android:targetPackage="@string/app_package" />
|
||||||
</Preference>
|
</Preference>
|
||||||
|
<Preference
|
||||||
|
android:key="pref_key_share_app_link"
|
||||||
|
android:title="@string/share_app_link"
|
||||||
|
app:icon="@drawable/ic_settings_share_link">
|
||||||
|
</Preference>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="pref_key_send_feedback"
|
android:key="pref_key_send_feedback"
|
||||||
android:title="@string/send_feedback"
|
android:title="@string/send_feedback"
|
||||||
|
|||||||
Reference in New Issue
Block a user