mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Revise share-offline screen wording; always show connected peers counter
This commit is contained in:
@@ -9,6 +9,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.google.android.material.tabs.TabLayoutMediator;
|
import com.google.android.material.tabs.TabLayoutMediator;
|
||||||
@@ -43,6 +44,7 @@ public abstract class AbstractTabsFragment extends Fragment {
|
|||||||
|
|
||||||
protected Button stopButton;
|
protected Button stopButton;
|
||||||
protected Button connectedButton;
|
protected Button connectedButton;
|
||||||
|
protected TextView connectedView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
@@ -85,6 +87,9 @@ public abstract class AbstractTabsFragment extends Fragment {
|
|||||||
finishAfterTransition(requireActivity());
|
finishAfterTransition(requireActivity());
|
||||||
});
|
});
|
||||||
connectedButton = view.findViewById(R.id.connectedButton);
|
connectedButton = view.findViewById(R.id.connectedButton);
|
||||||
|
connectedView = view.findViewById(R.id.connectedView);
|
||||||
|
viewModel.getPeersConnectedEvent()
|
||||||
|
.observe(getViewLifecycleOwner(), this::onPeerConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -126,4 +131,13 @@ public abstract class AbstractTabsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onPeerConnected(int peers) {
|
||||||
|
if (peers == 0) {
|
||||||
|
connectedView.setText(R.string.hotspot_no_peers_connected);
|
||||||
|
} else {
|
||||||
|
connectedView.setText(getResources().getQuantityString(
|
||||||
|
R.plurals.hotspot_peers_connected, peers, peers));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package org.briarproject.briar.android.hotspot;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.briar.R;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -23,8 +21,6 @@ public class HotspotFragment extends AbstractTabsFragment {
|
|||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
connectedButton.setOnClickListener(v -> showNextFragment());
|
connectedButton.setOnClickListener(v -> showNextFragment());
|
||||||
viewModel.getPeerConnectedEvent().observeEvent(getViewLifecycleOwner(),
|
|
||||||
this::onPeerConnected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,12 +33,6 @@ public class HotspotFragment extends AbstractTabsFragment {
|
|||||||
return QrHotspotFragment.newInstance(true);
|
return QrHotspotFragment.newInstance(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPeerConnected(boolean connected) {
|
|
||||||
if (!connected) return;
|
|
||||||
Toast.makeText(requireContext(), R.string.hotspot_peer_connected,
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showNextFragment() {
|
private void showNextFragment() {
|
||||||
Fragment f = new WebsiteFragment();
|
Fragment f = new WebsiteFragment();
|
||||||
String tag = WebsiteFragment.TAG;
|
String tag = WebsiteFragment.TAG;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class HotspotManager {
|
|||||||
void onHotspotStarted(NetworkConfig networkConfig);
|
void onHotspotStarted(NetworkConfig networkConfig);
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
void onDeviceConnected();
|
void onPeersUpdated(int peers);
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
void onHotspotError(String error);
|
void onHotspotError(String error);
|
||||||
@@ -377,12 +377,11 @@ class HotspotManager {
|
|||||||
private void requestGroupInfoForConnection() {
|
private void requestGroupInfoForConnection() {
|
||||||
LOG.info("requestGroupInfo for connection");
|
LOG.info("requestGroupInfo for connection");
|
||||||
GroupInfoListener groupListener = group -> {
|
GroupInfoListener groupListener = group -> {
|
||||||
if (group == null || group.getClientList().isEmpty()) {
|
if (group != null) {
|
||||||
handler.postDelayed(this::requestGroupInfoForConnection,
|
listener.onPeersUpdated(group.getClientList().size());
|
||||||
RETRY_DELAY_MILLIS);
|
|
||||||
} else {
|
|
||||||
listener.onDeviceConnected();
|
|
||||||
}
|
}
|
||||||
|
handler.postDelayed(this::requestGroupInfoForConnection,
|
||||||
|
RETRY_DELAY_MILLIS);
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
if (channel == null) return;
|
if (channel == null) return;
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ class HotspotViewModel extends DbViewModel
|
|||||||
|
|
||||||
private final MutableLiveData<HotspotState> state =
|
private final MutableLiveData<HotspotState> state =
|
||||||
new MutableLiveData<>();
|
new MutableLiveData<>();
|
||||||
private final MutableLiveEvent<Boolean> peerConnected =
|
private final MutableLiveData<Integer> peersConnected =
|
||||||
new MutableLiveEvent<>();
|
new MutableLiveData<>();
|
||||||
private final MutableLiveEvent<Uri> savedApkToUri =
|
private final MutableLiveEvent<Uri> savedApkToUri =
|
||||||
new MutableLiveEvent<>();
|
new MutableLiveEvent<>();
|
||||||
|
|
||||||
@@ -137,8 +137,8 @@ class HotspotViewModel extends DbViewModel
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@Override
|
@Override
|
||||||
public void onDeviceConnected() {
|
public void onPeersUpdated(int peers) {
|
||||||
peerConnected.setEvent(true);
|
peersConnected.setValue(peers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -213,8 +213,8 @@ class HotspotViewModel extends DbViewModel
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveEvent<Boolean> getPeerConnectedEvent() {
|
LiveData<Integer> getPeersConnectedEvent() {
|
||||||
return peerConnected;
|
return peersConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveEvent<Uri> getSavedApkToUri() {
|
LiveEvent<Uri> getSavedApkToUri() {
|
||||||
|
|||||||
@@ -6,9 +6,10 @@
|
|||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:id="@+id/coordinatorLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/connectedButton"
|
app:layout_constraintBottom_toTopOf="@+id/connectedView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
@@ -51,14 +52,22 @@
|
|||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
app:layout_constraintBottom_toTopOf="@+id/connectedButton"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tabLayout" />
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/connectedView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/hotspot_no_peers_connected"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/coordinatorLayout"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/connectedButton"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/connectedButton"
|
android:id="@+id/connectedButton"
|
||||||
style="@style/BriarButton"
|
style="@style/BriarButton"
|
||||||
|
|||||||
@@ -693,7 +693,7 @@
|
|||||||
<string name="transports_help_text">Briar can connect to your contacts via the Internet, Wi-Fi or Bluetooth.\n\nAll Internet connections go through the Tor network for privacy.\n\nIf a contact can be reached by multiple methods, Briar uses them in parallel.</string>
|
<string name="transports_help_text">Briar can connect to your contacts via the Internet, Wi-Fi or Bluetooth.\n\nAll Internet connections go through the Tor network for privacy.\n\nIf a contact can be reached by multiple methods, Briar uses them in parallel.</string>
|
||||||
|
|
||||||
<!-- Share app offline -->
|
<!-- Share app offline -->
|
||||||
<string name="hotspot_title">Share Briar offline</string>
|
<string name="hotspot_title">Share this app offline</string>
|
||||||
<string name="hotspot_intro">Share this app with someone nearby without Internet connection by using your phone\'s Wi-Fi.
|
<string name="hotspot_intro">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.</string>
|
\n\nYour phone will start a Wi-Fi hotspot. People nearby can connect to the hotspot and download the Briar app from your phone.</string>
|
||||||
<string name="hotspot_button_start_sharing">Start hotspot</string>
|
<string name="hotspot_button_start_sharing">Start hotspot</string>
|
||||||
@@ -715,10 +715,14 @@
|
|||||||
|
|
||||||
<!-- Wi-Fi setup -->
|
<!-- Wi-Fi setup -->
|
||||||
<!-- The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code' -->
|
<!-- The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code' -->
|
||||||
<string name="hotspot_manual_wifi">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\'.</string>
|
<string name="hotspot_manual_wifi">Your phone is providing a Wi-Fi hotspot. People who want to download Briar can connect to the hotspot by adding it in their device\'s Wi-Fi settings using the details below or by %s. When they have connected to the hotspot, press \'Next\'.</string>
|
||||||
<string name="hotspot_manual_wifi_ssid">Network name (SSID)</string>
|
<string name="hotspot_manual_wifi_ssid">Network name</string>
|
||||||
<string name="hotspot_qr_wifi">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\'.</string>
|
<string name="hotspot_qr_wifi">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\'.</string>
|
||||||
<string name="hotspot_peer_connected">Successfully connected</string>
|
<string name="hotspot_no_peers_connected">No devices connected</string>
|
||||||
|
<plurals name="hotspot_peers_connected">
|
||||||
|
<item quantity="one">%s device connected</item>
|
||||||
|
<item quantity="other">%s devices connected</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
<!-- Download link -->
|
<!-- Download link -->
|
||||||
<!-- The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code' -->
|
<!-- The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code' -->
|
||||||
|
|||||||
Reference in New Issue
Block a user