diff --git a/briar-android/src/main/java/org/briarproject/briar/android/hotspot/ManualHotspotFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/hotspot/ManualHotspotFragment.java index f049eab18..4f2fa72f7 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/hotspot/ManualHotspotFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/hotspot/ManualHotspotFragment.java @@ -2,6 +2,9 @@ package org.briarproject.briar.android.hotspot; import android.content.Context; import android.os.Bundle; +import android.text.SpannableString; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,7 +20,9 @@ import androidx.annotation.Nullable; import androidx.core.util.Consumer; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; +import androidx.viewpager2.widget.ViewPager2; +import static android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE; import static android.view.View.GONE; import static org.briarproject.briar.android.AppModule.getAndroidComponent; import static org.briarproject.briar.android.hotspot.AbstractTabsFragment.ARG_FOR_WIFI_CONNECT; @@ -66,22 +71,19 @@ public class ManualHotspotFragment extends Fragment { TextView ssidLabelView = v.findViewById(R.id.ssidLabelView); TextView ssidView = v.findViewById(R.id.ssidView); TextView passwordView = v.findViewById(R.id.passwordView); - TextView altView = v.findViewById(R.id.altView); Consumer consumer; if (requireArguments().getBoolean(ARG_FOR_WIFI_CONNECT)) { - manualIntroView.setText(R.string.hotspot_manual_wifi); + linkify(manualIntroView, R.string.hotspot_manual_wifi); ssidLabelView.setText(R.string.hotspot_manual_wifi_ssid); consumer = state -> { ssidView.setText(state.getNetworkConfig().ssid); passwordView.setText(state.getNetworkConfig().password); }; - altView.setText(R.string.hotspot_manual_wifi_alt); } else { - manualIntroView.setText(R.string.hotspot_manual_site); + linkify(manualIntroView, R.string.hotspot_manual_site); ssidLabelView.setText(R.string.hotspot_manual_site_address); consumer = state -> ssidView.setText(state.getWebsiteConfig().url); - altView.setText(R.string.hotspot_manual_site_alt); v.findViewById(R.id.passwordLabelView).setVisibility(GONE); passwordView.setVisibility(GONE); } @@ -92,4 +94,26 @@ public class ManualHotspotFragment extends Fragment { } }); } + + private void linkify(TextView textView, int resPattern) { + String pattern = getString(resPattern); + String replacement = getString(R.string.hotspot_scanning_a_qr_code); + String text = String.format(pattern, replacement); + int start = pattern.indexOf("%s"); + int end = start + replacement.length(); + SpannableString spannable = new SpannableString(text); + ClickableSpan clickable = new ClickableSpan() { + + @Override + public void onClick(View textView) { + ViewPager2 pager = requireActivity().findViewById(R.id.pager); + pager.setCurrentItem(1); + } + + }; + spannable.setSpan(clickable, start, end, SPAN_EXCLUSIVE_EXCLUSIVE); + + textView.setText(spannable); + textView.setMovementMethod(LinkMovementMethod.getInstance()); + } } diff --git a/briar-android/src/main/res/layout/fragment_hotspot_manual.xml b/briar-android/src/main/res/layout/fragment_hotspot_manual.xml index c35087421..5c6dbf048 100644 --- a/briar-android/src/main/res/layout/fragment_hotspot_manual.xml +++ b/briar-android/src/main/res/layout/fragment_hotspot_manual.xml @@ -80,16 +80,6 @@ app:layout_constraintTop_toBottomOf="@+id/passwordLabelView" tools:text="sdfsdgt2334rfw" /> - - diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index c35fb0cbe..c4198032d 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -694,15 +694,14 @@ Share Briar offline - Share this app with someone nearby without internet connection - by using your phone\'s Wi-Fi. - \n\nYour phone will open a local hotspot and provide a small website with a download of this app. - Start sharing - Stop sharing + Share this app with someone nearby without internet connection by using your phone\'s Wi-Fi. + \n\nYour phone will start a Wi-Fi hotspot. People nearby can connect to the hotspot and download the Briar app from your phone. + Start hotspot + Stop hotspot Setting up hotspot… Wi-Fi hotspot Sharing Briar offline - Start app sharing + Next To create a Wi-Fi hotspot, Briar needs permission to access your location.\n\nBriar does not store your location or share it with anyone. You have denied access to your location, but Briar needs this permission to create a Wi-Fi hotspot.\n\nPlease consider granting access. @@ -710,26 +709,22 @@ To create a Wi-Fi hotspot, Briar needs to use Wi-Fi. Please enable it. You have denied to enable Wi-Fi, but Briar needs to use Wi-Fi.\n\nPlease consider enabling it. - Something went wrong while trying to share the app via Wi-Fi: - Device does not support Wi-Fi Direct - Hotspot failed to start: error %s - Hotspot failed to start with an unknown error, reason %d - Hotspot failed to start: no group info - Error starting web server! - Error presenting website.\n\nPlease send feedback (with anonymous data) via the Briar app if the issue persists. - Warning: This app was installed with Android Studio and can NOT be installed on another device. - Manual - To download the app on another phone, please connect to this Wi-Fi network: + scanning a QR code + + + + Your phone is providing a Wi-Fi hotspot. People who want to download Briar can connect to the hotspot by entering the details below or %s. When they have connected to the hotspot, press \'Next\'. Network name (SSID) - Instead of adding the network manually, you can also scan a QR code. + Your phone is providing a Wi-Fi hotspot. People who want to download Briar can connect to the hotspot by scanning this QR code. When they have connected to the hotspot, press \'Next\'. Successfully connected Show download info - After you are connected to the Wi-Fi, carefully enter this address in your browser. + + + + Your phone is providing a Wi-Fi hotspot. People who are connected to the hotspot can download Briar by typing the following link in a web browser or %s. Address (URL) - Instead of typing the address manually, you can also scan a QR code. - To download the app on another phone, please scan this QR code to connect to this Wi-Fi network: - After you are connected to the Wi-Fi, scan this QR code to download the app. + Your phone is providing a Wi-Fi hotspot. People who are connected to the hotspot can download Briar by scanning this QR code. Download %s @@ -753,6 +748,16 @@ \n\nTip: For sharing via Bluetooth, you might need to rename the file to end with .zip first. Save app install file + + Something went wrong while trying to share the app via Wi-Fi: + Device does not support Wi-Fi Direct + Hotspot failed to start: error %s + Hotspot failed to start with an unknown error, reason %d + Hotspot failed to start: no group info + Error starting web server! + Error presenting website.\n\nPlease send feedback (with anonymous data) via the Briar app if the issue persists. + Warning: This app was installed with Android Studio and can NOT be installed on another device. +