From d58a047ac8505eb2666dcc5fe59d728923e79894 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 16 Nov 2026 16:19:43 -0600 Subject: [PATCH 1/3] K2GO-577 feat(hotspot): one Hotspot / Wi-Fi rule for Connect, Clone and Share HotspotMode holds a screen's choice: Hotspot takes its hold on the shared hotspot, Wi-Fi gives it back. Share no longer starts the hotspot on its own. Connect warns before Wi-Fi drops joined devices. WifiQr and QrSection.setWifiJoin build the escaped join QR in one place. --- .../org/appdevforall/k2go/QrActivity.java | 23 +-- .../presentation/ContentManagerFragment.java | 44 +--- .../presentation/ContentShareFragment.java | 188 +++++++++++------- .../presentation/ContentShareService.java | 25 +-- .../presentation/ShareSession.java | 16 ++ .../k2go/hotspot/HotspotMode.java | 110 ++++++++++ .../k2go/hotspot/LocalHotspotManager.java | 34 +++- .../hotspot/WifiDirectHotspotManager.java | 9 +- .../k2go/hotspot/domain/WifiQr.java | 41 ++++ .../k2go/redesign/CloneFragment.java | 68 +++---- .../k2go/redesign/ConnectFragment.java | 70 ++++--- .../appdevforall/k2go/redesign/QrSection.java | 15 ++ .../layout/fragment_k2go_content_share.xml | 7 +- .../app/src/main/res/values-ar/strings.xml | 1 - .../app/src/main/res/values-az/strings.xml | 1 - .../app/src/main/res/values-bg/strings.xml | 1 - .../app/src/main/res/values-bn/strings.xml | 1 - .../app/src/main/res/values-cs/strings.xml | 1 - .../app/src/main/res/values-de/strings.xml | 1 - .../app/src/main/res/values-el/strings.xml | 1 - .../app/src/main/res/values-es/strings.xml | 1 - .../app/src/main/res/values-fa/strings.xml | 1 - .../app/src/main/res/values-fr/strings.xml | 1 - .../app/src/main/res/values-gu/strings.xml | 1 - .../app/src/main/res/values-hi/strings.xml | 1 - .../app/src/main/res/values-hu/strings.xml | 1 - .../app/src/main/res/values-in/strings.xml | 1 - .../app/src/main/res/values-it/strings.xml | 1 - .../app/src/main/res/values-ja/strings.xml | 1 - .../app/src/main/res/values-ko/strings.xml | 1 - .../app/src/main/res/values-lt/strings.xml | 1 - .../app/src/main/res/values-nl/strings.xml | 1 - .../app/src/main/res/values-no/strings.xml | 1 - .../app/src/main/res/values-pl/strings.xml | 1 - .../app/src/main/res/values-pt/strings.xml | 1 - .../app/src/main/res/values-ro/strings.xml | 1 - .../src/main/res/values-ru-rRU/strings.xml | 1 - .../app/src/main/res/values-sk/strings.xml | 1 - .../app/src/main/res/values-sr/strings.xml | 1 - .../app/src/main/res/values-sw/strings.xml | 1 - .../app/src/main/res/values-ta/strings.xml | 1 - .../app/src/main/res/values-tr/strings.xml | 1 - .../app/src/main/res/values-uk/strings.xml | 1 - .../app/src/main/res/values-vi/strings.xml | 1 - .../app/src/main/res/values-yo/strings.xml | 1 - .../src/main/res/values-zh-rCN/strings.xml | 1 - .../app/src/main/res/values/strings.xml | 1 - .../main/res/values/strings_untranslated.xml | 3 +- .../k2go/hotspot/HotspotModeTest.java | 79 ++++++++ .../k2go/hotspot/domain/WifiQrTest.java | 25 +++ 50 files changed, 512 insertions(+), 279 deletions(-) create mode 100644 controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java create mode 100644 controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/WifiQr.java create mode 100644 controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java create mode 100644 controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/WifiQrTest.java diff --git a/controller/app/src/main/java/org/appdevforall/k2go/QrActivity.java b/controller/app/src/main/java/org/appdevforall/k2go/QrActivity.java index cc90e75ea..bb8b8c828 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/QrActivity.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/QrActivity.java @@ -25,6 +25,8 @@ import java.util.List; +import org.appdevforall.k2go.hotspot.domain.WifiQr; + public class QrActivity extends AppCompatActivity { private TextView titleText; @@ -164,12 +166,7 @@ private void fetchNetworkInterfaces() { * SSID/password are auto-generated by the OS and cannot be chosen in advance. */ private void showWifiJoin(String ssid, String pass) { - String payload; - if (pass != null && !pass.isEmpty()) { - payload = "WIFI:T:WPA;S:" + escapeWifi(ssid) + ";P:" + escapeWifi(pass) + ";;"; - } else { - payload = "WIFI:T:nopass;S:" + escapeWifi(ssid) + ";;"; - } + String payload = WifiQr.payload(ssid, pass); titleText.setText(getString(R.string.qr_title_join_wifi)); String creds = getString(R.string.qr_wifi_ssid, ssid); if (pass != null && !pass.isEmpty()) { @@ -182,20 +179,6 @@ private void showWifiJoin(String ssid, String pass) { } } - /** Escapes the WIFI: QR reserved characters: backslash, semicolon, comma, colon, quote. */ - private static String escapeWifi(String v) { - if (v == null) return ""; - StringBuilder sb = new StringBuilder(v.length()); - for (int i = 0; i < v.length(); i++) { - char c = v.charAt(i); - if (c == '\\' || c == ';' || c == ',' || c == ':' || c == '"') { - sb.append('\\'); - } - sb.append(c); - } - return sb.toString(); - } - /** * Generates a pure Black & White Bitmap using ZXing. */ diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java index 6053b5516..1edc2cb5b 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java @@ -39,14 +39,11 @@ import org.appdevforall.k2go.contentexchange.domain.ItemRef; import org.appdevforall.k2go.contentexchange.domain.ManagedContent; import org.appdevforall.k2go.contentexchange.domain.StorageStatus; -import org.appdevforall.k2go.hotspot.HotspotPermissions; import org.appdevforall.k2go.hotspot.LocalHotspotManager; import org.appdevforall.k2go.storage.StorageProbe; import org.appdevforall.k2go.ui.dialog.BrandDialog; import org.appdevforall.k2go.util.ByteFormatter; -import org.appdevforall.k2go.util.SnackbarDuration; -import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import java.util.List; @@ -73,11 +70,6 @@ public class ContentManagerFragment extends Fragment { private Button deleteButton; private Button shareButton; - /** The selection captured when Share was tapped, held across the hotspot-permission round-trip. */ - private List pendingShare; - /** Runtime hotspot permission (NEARBY_WIFI_DEVICES / ACCESS_FINE_LOCATION), requested before the - * share foreground service brings the hotspot up (it cannot prompt from a service). */ - private ActivityResultLauncher hotspotPerm; /** Set when a delete run is launched, so the manager reloads the list (and reclaimed space) when * it next resumes. Cleared once the reload runs and the run has settled. */ @@ -106,8 +98,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c openTree = registerForActivityResult(new ActivityResultContracts.OpenDocumentTree(), this::onTreePicked); openImportTree = registerForActivityResult( new ActivityResultContracts.OpenDocumentTree(), this::onImportTreePicked); - hotspotPerm = registerForActivityResult( - new ActivityResultContracts.RequestMultiplePermissions(), result -> onHotspotPermissionResult()); exportButton.setEnabled(true); exportButton.setOnClickListener(v -> onExportClicked()); importButton.setOnClickListener(v -> onImportClicked()); @@ -433,41 +423,16 @@ private void showProgress() { // ---- share --------------------------------------------------------------------------------- - /** Share: if a run is still live, just show it; otherwise capture the selection and make sure the - * hotspot permission is granted (the service cannot prompt) before starting. */ + /** Share: if a run is still live, just show it; otherwise start one over the selection. The share + * screen picks Hotspot or Wi-Fi and asks the hotspot permission itself (K2GO-577). */ private void onShareClicked() { if (ContentShareService.session().hasSession()) { showShareProgress(); return; } List selected = viewModel.selectedItems(); - if (selected.isEmpty()) { - return; - } - pendingShare = selected; - if (!LocalHotspotManager.isSupported()) { - String msg = getString(R.string.k2go_cx_share_hotspot_unsupported); - Snackbar.make(requireView(), msg, SnackbarDuration.millisForText(msg)).show(); - return; - } - if (HotspotPermissions.granted(requireContext())) { - startShare(pendingShare); - } else { - hotspotPerm.launch(HotspotPermissions.required()); - } - } - - /** The hotspot-permission request returned: start when granted, otherwise say why we cannot. */ - private void onHotspotPermissionResult() { - if (!isAdded()) { - return; - } - if (pendingShare != null && HotspotPermissions.granted(requireContext())) { - startShare(pendingShare); - } else { - pendingShare = null; // the request was declined; drop the held selection - String msg = getString(R.string.k2go_cx_share_need_permission); - Snackbar.make(requireView(), msg, SnackbarDuration.millisForText(msg)).show(); + if (!selected.isEmpty()) { + startShare(selected); } } @@ -479,7 +444,6 @@ private void startShare(List selected) { bytes += selected.get(i).bytes(); } ContentShareService.start(requireContext(), refs, bytes); - pendingShare = null; viewModel.clearSelection(); showShareProgress(); } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java index 9aff9926f..8a1066679 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java @@ -4,9 +4,10 @@ * Author : AppDevForAll * Copyright : Copyright (c) 2026 AppDevForAll * Description : K2GO-376. Shows the Share invite: two stacked QR sections (join the hotspot, then - * scan to receive) once the sender foreground service has opened the share session and - * the hotspot is up. Reads state only (the ShareSession + the shared LocalHotspotManager - * state); all work is the service's. Done or Back closes the gate + the hotspot via the service. + * scan to receive) once the sender foreground service has opened the share session. + * The Hotspot / Wi-Fi strip is the one place that takes or gives back the share's hold + * on the hotspot (HotspotMode, K2GO-577). Done or Back closes the gate and the hold + * via the service. * ============================================================================ */ package org.appdevforall.k2go.contentexchange.presentation; @@ -19,6 +20,8 @@ import android.widget.TextView; import androidx.activity.OnBackPressedCallback; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; @@ -26,6 +29,7 @@ import org.appdevforall.k2go.R; import org.appdevforall.k2go.contentexchange.data.ShareHandshake; import org.appdevforall.k2go.contentexchange.domain.ShareTransport; +import org.appdevforall.k2go.hotspot.HotspotMode; import org.appdevforall.k2go.hotspot.HotspotPermissions; import org.appdevforall.k2go.hotspot.LocalHotspotManager; import org.appdevforall.k2go.hotspot.data.ApAddressResolver; @@ -61,10 +65,24 @@ public class ContentShareFragment extends Fragment { /** One-shot guard so a re-entrant render() does not schedule the back-pop twice (K2GO-427). */ private boolean leaving; - /** K2GO-376 transport selector: which address the receive QR carries when both exist. false = - * the hotspot AP IP (the default, fast + direct); true = the station Wi-Fi IP (both phones on - * the same network). Ignored when only one address is available. */ - private boolean useWifiAddress; + private ActivityResultLauncher hotspotPerm; + + @Override + public void onCreate(@Nullable Bundle s) { + super.onCreate(s); + // The answer re-applies the choice; it never asks again (HotspotMode keeps that latch). + hotspotPerm = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), r -> { + if (isAdded() && session.hasSession()) { + mode().resume(); + render(); + } + }); + } + + /** This run's Hotspot / Wi-Fi choice; it lives in the session so it outlasts this view. */ + private HotspotMode mode() { + return session.hotspotMode(requireContext()); + } @Nullable @Override @@ -92,8 +110,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c transportRow = root.findViewById(R.id.k2go_cxs_transport); transportHotspot = root.findViewById(R.id.k2go_cxs_transport_hotspot); transportWifi = root.findViewById(R.id.k2go_cxs_transport_wifi); - transportHotspot.setOnClickListener(v -> selectTransport(false)); - transportWifi.setOnClickListener(v -> selectTransport(true)); + transportHotspot.setOnClickListener(v -> requestMode(HotspotMode.Mode.HOTSPOT)); + transportWifi.setOnClickListener(v -> requestMode(HotspotMode.Mode.WIFI)); done.setOnClickListener(v -> stopAndLeave()); // Back ends the share like Done (a share left running would make the next Share reopen it @@ -135,6 +153,11 @@ public void onResume() { render(); } }); + // Apply the choice on entry and on every return: Hotspot holds the hotspot (asks the + // permission once), Wi-Fi keeps it released. + if (session.hasSession() && mode().ensure()) { + hotspotPerm.launch(HotspotPermissions.required()); + } render(); } @@ -184,65 +207,51 @@ private void render() { } private void renderInvite() { + boolean hotspot = mode().isHotspot(); LocalHotspotManager.State st = hs.state().getValue(); LocalHotspotManager.Phase phase = st != null ? st.phase : LocalHotspotManager.Phase.OFF; - - if (!LocalHotspotManager.isSupported()) { - showStatus(getString(R.string.k2go_cx_share_hotspot_unsupported)); - return; - } - if (phase == LocalHotspotManager.Phase.FAILED - || (phase != LocalHotspotManager.Phase.ON && !HotspotPermissions.granted(requireContext()))) { - showStatus(getString(R.string.k2go_cx_share_hotspot_failed)); - return; - } - - // OFF / STARTING / ON: show the two sections; only ON has scannable codes. - showSections(); - boolean on = phase == LocalHotspotManager.Phase.ON; - if (!on) { - String starting = getString(R.string.k2go_cx_share_starting_hotspot); - for (QrSection sec : new QrSection[]{secJoin, secReceive}) { - sec.setQrPending(requireContext(), starting); - sec.caption.setText(""); - sec.subCaption.setText(""); - sec.setFallback(requireContext(), null); + String ip; + if (hotspot) { + if (!LocalHotspotManager.isSupported()) { + showModeStatus(R.string.k2go_cx_share_hotspot_unsupported, R.string.k2go_connect_try_wifi); + return; + } + if (phase == LocalHotspotManager.Phase.FAILED) { + showModeStatus(R.string.k2go_cx_share_hotspot_failed, R.string.k2go_connect_try_wifi); + return; + } + if (phase != LocalHotspotManager.Phase.ON && !HotspotPermissions.granted(requireContext())) { + // Denied: a tap on Hotspot asks once more (HotspotMode.choose). + showModeStatus(R.string.k2go_cx_share_hotspot_failed, R.string.k2go_connect_enable_location); + return; + } + if (phase != LocalHotspotManager.Phase.ON) { + // OFF / STARTING: hold both slots until the hotspot is up. + showSections(true); + String starting = getString(R.string.k2go_cx_share_starting_hotspot); + for (QrSection sec : new QrSection[]{secJoin, secReceive}) { + sec.setQrPending(requireContext(), starting); + sec.caption.setText(""); + sec.subCaption.setText(""); + sec.setFallback(requireContext(), null); + } + waiting.setVisibility(View.GONE); + showInviteText(null); + return; + } + ip = st.hotspotIp; + } else { + // Wi-Fi: both phones on the same network, so there is nothing to join and no hotspot. + ip = ApAddressResolver.resolveStationWifiIp(requireContext()); + if (ip == null) { + showModeStatus(R.string.k2go_connect_no_wifi, 0); + return; } - transportRow.setVisibility(View.GONE); - waiting.setVisibility(View.GONE); - showInviteText(null); - return; } - - String ssid = st != null && st.ssid != null ? st.ssid : ""; - String pass = st != null && st.passphrase != null ? st.passphrase : ""; - String hotspotIp = st != null ? st.hotspotIp : null; - String wifiIp = ApAddressResolver.resolveStationWifiIp(requireContext()); - - // Transport selector: a choice only when BOTH addresses exist and differ. With one, use it and - // hide the strip (the common case). The hotspot is the default (fast, direct); Wi-Fi lets two - // phones already on the same network pull over it, avoiding the Wi-Fi Direct link. When Wi-Fi is - // chosen there is nothing to join, so the join-hotspot section is hidden too. - boolean both = hotspotIp != null && wifiIp != null && !hotspotIp.equals(wifiIp); - transportRow.setVisibility(both ? View.VISIBLE : View.GONE); - // The selection persists across a Wi-Fi blip: on Wi-Fi loss the strip just hides and the QR - // falls back to whatever address is left; when Wi-Fi returns (a new DHCP IP), the choice is - // still Wi-Fi and the QR redraws at the fresh address, instead of silently reverting to hotspot. - if (both) { - SegmentedTabs.paint(transportHotspot, !useWifiAddress); - SegmentedTabs.paint(transportWifi, useWifiAddress); + showSections(hotspot); + if (hotspot) { + secJoin.setWifiJoin(requireContext(), st.ssid, st.passphrase, R.string.k2go_cx_share_join_caption); } - joinRoot.setVisibility(both && useWifiAddress ? View.GONE : View.VISIBLE); - numberSteps(); - String ip = both ? (useWifiAddress ? wifiIp : hotspotIp) - : (hotspotIp != null ? hotspotIp : wifiIp); - - // Section 1: join the hotspot (standard Wi-Fi auto-join QR + the credentials as fallback). - secJoin.setQr(requireContext(), "WIFI:S:" + ssid + ";T:WPA;P:" + pass + ";;", null); - secJoin.caption.setText(R.string.k2go_cx_share_join_caption); - secJoin.subCaption.setText(""); - secJoin.setFallback(requireContext(), new String[]{ - getString(R.string.k2go_fallback_wifi, ssid), getString(R.string.k2go_fallback_pass, pass)}); // Section 2: the share invite QR. Needs the AP IPv4, which resolves a beat after ON. secReceive.subCaption.setText(""); @@ -275,13 +284,35 @@ private void showInviteText(@Nullable String invite) { codeBlock.setVisibility(vis); } - /** Pick the address the receive QR carries and repaint the strip (Connect/Clone mode pattern). */ - private void selectTransport(boolean wifi) { - if (wifi == useWifiAddress) { - return; // already selected; no re-encode + /** + * A tab tap. Leaving Hotspot gives the hotspot back, which drops a receiver joined to it, so warn + * first when someone may be connected. A tap on the current tab re-applies it (the retry path + * after a denied permission). + */ + private void requestMode(HotspotMode.Mode target) { + LocalHotspotManager.State st = hs.state().getValue(); + boolean dropsClients = mode().isHotspot() && target == HotspotMode.Mode.WIFI + && st != null && st.mayHaveClients(); + if (!dropsClients) { + setMode(target); + return; + } + new BrandDialog(requireContext()) + .setTitle(getString(R.string.k2go_clone_switch_title, getString(R.string.k2go_cx_share_transport_wifi))) + .setMessage(R.string.k2go_clone_switch_msg) + .setNegative(R.string.k2go_cancel, null) + .setPositive(R.string.k2go_clone_switch_confirm, () -> setMode(target)) + .show(); + } + + private void setMode(HotspotMode.Mode target) { + if (!isAdded() || !session.hasSession()) { + return; + } + if (mode().choose(target)) { + hotspotPerm.launch(HotspotPermissions.required()); } - useWifiAddress = wifi; - renderInvite(); // re-encode the receive QR at the chosen address and repaint the strip + render(); } /** Show a single status line (preparing / hotspot / error) instead of the two QR cards. */ @@ -297,10 +328,25 @@ private void showStatus(String text) { showInviteText(null); } - private void showSections() { + /** A status under the strip: the chosen transport cannot carry the share yet. [hint] 0 = none. */ + private void showModeStatus(int message, int hint) { + showStatus(hint != 0 ? getString(message) + "\n" + getString(hint) : getString(message)); + paintTabs(); + } + + private void paintTabs() { + transportRow.setVisibility(View.VISIBLE); + boolean hotspot = mode().isHotspot(); + SegmentedTabs.paint(transportHotspot, hotspot); + SegmentedTabs.paint(transportWifi, !hotspot); + } + + /** The QR cards; the join card only on Hotspot (on Wi-Fi there is nothing to join). */ + private void showSections(boolean join) { status.setVisibility(View.GONE); - joinRoot.setVisibility(View.VISIBLE); + joinRoot.setVisibility(join ? View.VISIBLE : View.GONE); receiveRoot.setVisibility(View.VISIBLE); + paintTabs(); numberSteps(); } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java index f42e2a189..bc7fcbf3a 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java @@ -5,10 +5,10 @@ * Copyright : Copyright (c) 2026 AppDevForAll * Description : K2GO-376. Sender foreground service for granular wireless Share. Over the current * content-manager selection it opens a scoped share session on the LOCAL conex-core - * (loopback), brings the hotspot up (only if it was off), holds both the hotspot and - * the gate open with CPU + Wi-Fi locks, and on teardown closes the gate (DELETE) and - * stops the hotspot only if it started it. It copies NO bytes: conex-core streams to the - * receiver that pulls over the hotspot. The invite/QR fragment observes SESSION. + * (loopback), holds the gate open with CPU + Wi-Fi locks, and on teardown closes the + * gate (DELETE) and gives back the share's hold on the hotspot. The share screen takes + * that hold only when the user picks Hotspot (K2GO-577). It copies NO bytes: the + * receiver pulls from conex-core. The invite/QR fragment observes SESSION. * ============================================================================ */ package org.appdevforall.k2go.contentexchange.presentation; @@ -32,7 +32,6 @@ import org.appdevforall.k2go.R; import org.appdevforall.k2go.contentexchange.data.ConexCoreDataSource; import org.appdevforall.k2go.contentexchange.domain.ItemRef; -import org.appdevforall.k2go.hotspot.HotspotPermissions; import org.appdevforall.k2go.hotspot.LocalHotspotManager; import org.appdevforall.k2go.hotspot.domain.HotspotHolders; import org.appdevforall.k2go.notifications.NotificationIds; @@ -142,7 +141,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { SESSION.beginPreparing(refs.length, intent.getLongExtra(EXTRA_TOTAL_BYTES, 0L)); startForeground(NOTIFICATION_ID, buildNotification()); acquireHardwareLocks(); - ensureHotspot(); + // No hotspot here: the share screen holds it only while the user picks Hotspot (K2GO-577). worker.execute(() -> openSession(refs)); // START_STICKY (like CloneShareService): keep the process at foreground priority so the // process-bound hotspot and the live stream survive backgrounding and Doze. @@ -172,20 +171,6 @@ private void openSession(ItemRef[] refs) { } } - /** - * Hold the shared hotspot for this share (starts it if off). The runtime hotspot permission is - * gated by the fragment before start; without it the hotspot stays off and the fragment surfaces - * the failure from LocalHotspotManager's state. - */ - private void ensureHotspot() { - if (!LocalHotspotManager.isSupported()) { - return; - } - if (HotspotPermissions.granted(this)) { - LocalHotspotManager.get().acquire(getApplicationContext(), HotspotHolders.Holder.CONTENT_SHARE); - } - } - private void acquireHardwareLocks() { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (pm != null && wakeLock == null) { diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ShareSession.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ShareSession.java index 5255f36f3..41dc280b5 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ShareSession.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ShareSession.java @@ -11,9 +11,13 @@ */ package org.appdevforall.k2go.contentexchange.presentation; +import android.content.Context; import android.os.Handler; import android.os.Looper; +import org.appdevforall.k2go.hotspot.HotspotMode; +import org.appdevforall.k2go.hotspot.domain.HotspotHolders; + final class ShareSession { /** Pinged on the main thread whenever the run state changes. */ @@ -36,6 +40,8 @@ enum Phase { PREPARING, READY, ERROR } private String token; private String manifestUrl; private String errorMessage; + /** The sender's Hotspot / Wi-Fi choice for this run (K2GO-577); fresh per run, Hotspot first. */ + private HotspotMode hotspotMode; void setListener(Listener l) { this.listener = l; @@ -52,6 +58,7 @@ void beginPreparing(int itemCount, long totalBytes) { this.token = null; this.manifestUrl = null; this.errorMessage = null; + this.hotspotMode = null; this.phase = Phase.PREPARING; this.active = true; publish(); @@ -81,6 +88,7 @@ void clear() { token = null; manifestUrl = null; errorMessage = null; + hotspotMode = null; publish(); } @@ -133,4 +141,12 @@ String manifestUrl() { String errorMessage() { return errorMessage; } + + /** This run's Hotspot / Wi-Fi rule, made on first use. The service releases the hold on exit. */ + HotspotMode hotspotMode(Context context) { + if (hotspotMode == null) { + hotspotMode = HotspotMode.of(context, HotspotHolders.Holder.CONTENT_SHARE, HotspotMode.Mode.HOTSPOT); + } + return hotspotMode; + } } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java new file mode 100644 index 000000000..301dee296 --- /dev/null +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java @@ -0,0 +1,110 @@ +/* + * ============================================================================ + * Name : HotspotMode.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : K2GO-577. The one rule for a screen's Hotspot / Wi-Fi choice, shared by Connect, + * Clone and Content Exchange Share. Hotspot takes this screen's hold on the shared + * hotspot (LocalHotspotManager); Wi-Fi gives it back, so a Wi-Fi Direct group left up + * cannot slow the radio (K2GO-561). The hotspot permission is asked at most once per + * choice. Each screen still decides when it lets go on exit (release()). + * ============================================================================ + */ +package org.appdevforall.k2go.hotspot; + +import android.content.Context; + +import org.appdevforall.k2go.hotspot.domain.HotspotHolders; + +/** A screen's Hotspot / Wi-Fi choice and its hold on the shared hotspot. */ +public final class HotspotMode { + + public enum Mode { HOTSPOT, WIFI } + + /** What the rule needs from the hotspot; a seam so the rule runs on a plain JVM in tests. */ + public interface Port { + boolean supported(); + boolean permitted(); + boolean isOn(); + void acquire(); + void release(); + } + + private final Port port; + private Mode mode; + /** The permission was asked for the current choice: a re-render must not ask again. Some OEMs + * deny synchronously, so a re-ask from the result's re-render recursed until overflow (ADFA-5146). */ + private boolean asked; + + public HotspotMode(Port port, Mode initial) { + this.port = port; + this.mode = initial; + } + + /** The rule on the shared LocalHotspotManager for [holder]. */ + public static HotspotMode of(Context context, HotspotHolders.Holder holder, Mode initial) { + final Context app = context.getApplicationContext(); + final LocalHotspotManager hs = LocalHotspotManager.get(); + return new HotspotMode(new Port() { + @Override public boolean supported() { return LocalHotspotManager.isSupported(); } + @Override public boolean permitted() { return HotspotPermissions.granted(app); } + @Override public boolean isOn() { return hs.isOn(); } + @Override public void acquire() { hs.acquire(app, holder); } + @Override public void release() { hs.release(holder); } + }, initial); + } + + public Mode mode() { + return mode; + } + + public boolean isHotspot() { + return mode == Mode.HOTSPOT; + } + + /** + * The user picked [m]: a fresh attempt, so the permission may be asked once more. Returns true + * when the caller must launch the hotspot permission request. + */ + public boolean choose(Mode m) { + mode = m; + asked = false; + return ensure(); + } + + /** + * Apply the current choice. Hotspot holds the hotspot (also when another holder already started + * it, so their release cannot drop it), or returns true once when the permission is missing; + * Wi-Fi releases this screen's hold. + */ + public boolean ensure() { + if (mode == Mode.WIFI) { + port.release(); + return false; + } + if (!port.supported()) { + return false; + } + if (port.permitted()) { + port.acquire(); + return false; + } + if (!port.isOn() && !asked) { + asked = true; + return true; + } + return false; + } + + /** Re-apply on a return to the screen or after the permission answer; never asks again. */ + public void resume() { + if (mode == Mode.WIFI || port.permitted()) { + ensure(); + } + } + + /** This screen no longer needs the hotspot (it left, or its transfer ended). */ + public void release() { + port.release(); + } +} diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java index 940b6f754..318a1ef56 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java @@ -56,19 +56,28 @@ public static final class State { // interface has been assigned its address: ON is first emitted with this null (the reservation // reports started before the interface has an IP), then re-emitted with the resolved value. public final String hotspotIp; + // K2GO-577: devices joined to the hotspot, so a screen can warn before it turns the hotspot off. + // Known only for the Wi-Fi Direct group; CLIENTS_UNKNOWN for a LocalOnlyHotspot (no public API). + public final int clients; - State(Phase phase, String ssid, String passphrase, int failureReason, String hotspotIp) { + State(Phase phase, String ssid, String passphrase, int failureReason, String hotspotIp, int clients) { this.phase = phase; this.ssid = ssid; this.passphrase = passphrase; this.failureReason = failureReason; this.hotspotIp = hotspotIp; + this.clients = clients; } - static State off() { return new State(Phase.OFF, null, null, 0, null); } - static State starting() { return new State(Phase.STARTING, null, null, 0, null); } - static State on(String ssid, String pass, String ip) { return new State(Phase.ON, ssid, pass, 0, ip); } - static State failed(int reason) { return new State(Phase.FAILED, null, null, reason, null); } + /** True when someone is, or may be, joined to the hotspot. */ + public boolean mayHaveClients() { return phase == Phase.ON && clients != 0; } + + static State off() { return new State(Phase.OFF, null, null, 0, null, 0); } + static State starting() { return new State(Phase.STARTING, null, null, 0, null, 0); } + static State on(String ssid, String pass, String ip, int clients) { + return new State(Phase.ON, ssid, pass, 0, ip, clients); + } + static State failed(int reason) { return new State(Phase.FAILED, null, null, reason, null, 0); } } private static final LocalHotspotManager INSTANCE = new LocalHotspotManager(); @@ -94,6 +103,9 @@ public static final class State { // and offer a retry instead of the "couldn't start the hotspot" / enable-location hint. public static final int REASON_ADDRESS_UNRESOLVED = 1001; + /** {@link State#clients} when the hotspot cannot report its clients (LocalOnlyHotspot). */ + public static final int CLIENTS_UNKNOWN = -1; + // Object type kept generic so this file compiles on API < 26; cast at use sites. private Object reservation; // WifiManager.LocalOnlyHotspotReservation @@ -225,7 +237,13 @@ private void launchWifiDirect(final Context app, @Override public void onUp(String ssid, String pass, String ip) { if (gen != generation) { m.stop(); return; } // superseded by a newer start/stop Log.d(TAG, "Wi-Fi Direct up, ssid=" + ssid); - publish(State.on(ssid, pass, ip)); + publish(State.on(ssid, pass, ip, 0)); + } + @Override public void onClients(int count) { + State cur = state.getValue(); + if (gen != generation || cur == null || cur.phase != Phase.ON + || cur.clients == count) return; + publish(State.on(cur.ssid, cur.passphrase, cur.hotspotIp, count)); } @Override public void onFailed(String reason) { Log.w(TAG, "Wi-Fi Direct unavailable, falling back to LocalOnlyHotspot: " + reason); @@ -275,7 +293,7 @@ public void onStarted(WifiManager.LocalOnlyHotspotReservation res) { pass = unquote(pass); Log.d(TAG, "LocalOnlyHotspot started, ssid=" + ssid); // ON is emitted with no IP yet; the poll re-emits once the AP interface has one. - publish(State.on(ssid, pass, null)); + publish(State.on(ssid, pass, null, CLIENTS_UNKNOWN)); beginHotspotIpPoll(context.getApplicationContext(), ssid, pass); } @@ -378,7 +396,7 @@ private void beginHotspotIpPoll(final Context ctx, final String ssid, final Stri if (cur.hotspotIp != null) return; // already resolved String ip = ApAddressResolver.resolveOnce(ctx, null); if (ip != null) { - publish(State.on(ssid, pass, ip)); // resolved: re-emit through the one path + publish(State.on(ssid, pass, ip, CLIENTS_UNKNOWN)); // resolved: re-emit through the one path return; } if (++tries >= AP_IP_MAX_POLLS) { // K2GO-471: terminal, not a silent stop diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/WifiDirectHotspotManager.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/WifiDirectHotspotManager.java index 9c9869066..7af98d85d 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/WifiDirectHotspotManager.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/WifiDirectHotspotManager.java @@ -65,6 +65,8 @@ public interface Callbacks { void onFailed(String reason); /** A running group died on its own (e.g. Wi-Fi switched off). */ void onLost(String reason); + /** The number of devices joined to the running group changed (K2GO-577). */ + default void onClients(int count) { } } // The one owner of this manager's liveness; every async callback checks it before touching mgr/channel. @@ -224,7 +226,12 @@ private void recheck(final boolean confirming) { if (runState != RunState.UP || mgr == null || channel == null) return; try { mgr.requestGroupInfo(channel, group -> { - if (group != null || runState != RunState.UP) return; + if (runState != RunState.UP) return; + if (group != null) { + // The same recheck that guards the group also reports who is joined (K2GO-577). + if (cb != null) cb.onClients(group.getClientList().size()); + return; + } if (confirming) lost("the Wi-Fi Direct group stopped"); else main.postDelayed(() -> recheck(true), 1000); }); diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/WifiQr.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/WifiQr.java new file mode 100644 index 000000000..2e3f15027 --- /dev/null +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/WifiQr.java @@ -0,0 +1,41 @@ +/* + * ============================================================================ + * Name : WifiQr.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : K2GO-577. The one builder of the Wi-Fi auto-join QR payload, for Connect, Clone, + * Content Exchange Share and the QR screen. Escapes the reserved characters, so a + * name or password with ';' or ':' still joins. Pure JVM (no Android). + * ============================================================================ + */ +package org.appdevforall.k2go.hotspot.domain; + +/** The "WIFI:" join payload (ZXing Wi-Fi network config format). */ +public final class WifiQr { + + private WifiQr() { + } + + /** WPA network [ssid] with [pass]; an empty or null [pass] makes an open network. */ + public static String payload(String ssid, String pass) { + if (pass == null || pass.isEmpty()) { + return "WIFI:T:nopass;S:" + escape(ssid) + ";;"; + } + return "WIFI:T:WPA;S:" + escape(ssid) + ";P:" + escape(pass) + ";;"; + } + + static String escape(String v) { + if (v == null) { + return ""; + } + StringBuilder sb = new StringBuilder(v.length()); + for (int i = 0; i < v.length(); i++) { + char c = v.charAt(i); + if (c == '\\' || c == ';' || c == ',' || c == ':' || c == '"') { + sb.append('\\'); + } + sb.append(c); + } + return sb.toString(); + } +} diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/CloneFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/CloneFragment.java index 1435fa139..7ac3f2295 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/CloneFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/CloneFragment.java @@ -40,6 +40,8 @@ import org.appdevforall.k2go.env.EnvironmentLock; import org.appdevforall.k2go.sync.data.ApkAbiReader; import org.appdevforall.k2go.sync.domain.ApkShareName; +import org.appdevforall.k2go.hotspot.HotspotMode; +import org.appdevforall.k2go.hotspot.HotspotMode.Mode; import org.appdevforall.k2go.hotspot.HotspotPermissions; import org.appdevforall.k2go.hotspot.LocalHotspotManager; import org.appdevforall.k2go.hotspot.domain.HotspotHolders; @@ -61,14 +63,14 @@ public class CloneFragment extends Fragment { private enum Side { SEND, RECEIVE } - private enum Mode { HOTSPOT, WIFI } // ADFA-5154: the 3-step Send wizard (Join / Get app / Copy) becomes 2 pages. PREPARE shows Join ① // and Get app ② stacked (both QRs at once); COPY shows the transfer QR. The "Installed? Copy the // library ›" gate advances PREPARE -> COPY (a real prerequisite: the app must be on the other phone). private enum Page { PREPARE, COPY } private Side side = Side.SEND; - private Mode mode = Mode.HOTSPOT; + // K2GO-577: the shared Hotspot / Wi-Fi rule (also used by Share): the choice and Clone's hold. + private HotspotMode hsMode; private Page page = Page.PREPARE; private boolean startedStep = false; @@ -110,12 +112,6 @@ private enum Page { PREPARE, COPY } private String apkFileName; private ActivityResultLauncher hotspotPerm; - // ADFA-5146: request the location permission at most once per attempt. ensureHotspot() runs on every - // render, and the permission callback re-renders; on OEMs that return a denied permission result - // synchronously that becomes unbounded recursion (render -> ensureHotspot -> launch -> sync-deny -> - // callback -> render …), overflowing the stack. This latch breaks the loop; setMode() clears it so a - // Hotspot/Wi-Fi switch is a natural retry path. - private boolean locationAsked = false; private TextView tabSend, tabReceive, tabHotspot, tabWifi, caption, subCaption, footer; // ADFA-5346: the "Installed? copy the library" advance CTA is a MaterialButton (shape/size from the @@ -169,10 +165,11 @@ private enum RStage { JOIN, START } @Override public void onCreate(@Nullable Bundle s) { super.onCreate(s); + hsMode = HotspotMode.of(requireContext(), HotspotHolders.Holder.CLONE, Mode.HOTSPOT); hotspotPerm = registerForActivityResult( new ActivityResultContracts.RequestMultiplePermissions(), result -> { - if (HotspotPermissions.granted(requireContext())) acquireHotspot(); + hsMode.resume(); // never asks again: a synchronous deny cannot recurse (ADFA-5146) render(); }); barcodeLauncher = registerForActivityResult(new ScanContract(), r -> onScan(r.getContents())); @@ -350,7 +347,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c // guard skip a re-start. if (CloneSendSession.isActive()) { atFork = false; side = Side.SEND; page = Page.COPY; - mode = CloneSendSession.isHotspot() ? Mode.HOTSPOT : Mode.WIFI; + hsMode = HotspotMode.of(requireContext(), HotspotHolders.Holder.CLONE, + CloneSendSession.isHotspot() ? Mode.HOTSPOT : Mode.WIFI); tempPass = CloneSendSession.tempPass(); hostHasRootfs = CloneSendSession.hostHasRootfs(); shareAnyway = CloneSendSession.shareAnyway(); @@ -407,7 +405,7 @@ private void setSide(Side sd) { // copy in progress. Warn first; elsewhere (or when the mode is unchanged) switch directly. private void requestMode(Mode target) { boolean sharing = (side == Side.SEND && page == Page.COPY && daemonStarted); - if (target == mode || !sharing) { setMode(target); return; } + if (target == hsMode.mode() || !sharing) { setMode(target); return; } String label = (target == Mode.HOTSPOT) ? "Hotspot" : "Wi-Fi"; new BrandDialog(requireContext()) .setTitle(getString(R.string.k2go_clone_switch_title, label)) @@ -418,9 +416,8 @@ private void requestMode(Mode target) { } private void setMode(Mode m) { - mode = m; - locationAsked = false; // ADFA-5146: a mode switch is a fresh attempt — allow one more perm prompt - if (m == Mode.HOTSPOT) ensureHotspot(); else releaseHotspot(); + // A switch is a fresh attempt: one more permission prompt; Wi-Fi gives the hotspot back. + if (hsMode.choose(m)) hotspotPerm.launch(HotspotPermissions.required()); render(); // ADFA-4785: keep the current step; switching Hotspot/Wi-Fi no longer resets to step 1 // ADFA-5154: Hotspot ① has a QR, Wi-Fi ① doesn't, so the two tabs differ in height — switching // mid-scroll would leave the view offset. Snap back to the top (Connect avoids this: single QR @@ -428,26 +425,15 @@ private void setMode(Mode m) { if (contentScroll != null) contentScroll.post(() -> contentScroll.smoothScrollTo(0, 0)); } + // Runs on every render (ADFA-5158: start() ignores a call while a start is in flight). Asks the + // permission at most once per choice (ADFA-5146), so a later render never re-launches it. private void ensureHotspot() { - if (!LocalHotspotManager.isSupported()) return; - if (HotspotPermissions.granted(requireContext())) { - acquireHotspot(); // also when already up: Clone holds it, so another holder's release cannot drop it - } else if (!hs.isOn() && !locationAsked) { - // ADFA-5146: launch the request exactly once. Do NOT re-launch on later renders (incl. the one - // the permission callback triggers): a synchronous deny would otherwise recurse into overflow. - locationAsked = true; - hotspotPerm.launch(HotspotPermissions.required()); - } - } - - // ADFA-5158: renderPrepare runs on every render; start() ignores a call while a start is in flight. - private void acquireHotspot() { - hs.acquire(requireContext().getApplicationContext(), HotspotHolders.Holder.CLONE); + if (hsMode.ensure()) hotspotPerm.launch(HotspotPermissions.required()); } /** K2GO-561: the Wi-Fi Direct group outlives the screen and slows Wi-Fi, so Clone lets go of it. */ private void releaseHotspot() { - hs.release(HotspotHolders.Holder.CLONE); + hsMode.release(); } /** Start the rsync share daemon once we have a LAN IP (off the main thread). */ @@ -479,7 +465,7 @@ private void ensureDaemon(String ip) { act.runOnUiThread(() -> { if (!isAdded()) return; daemonStarting = false; daemonStarted = ok; librarySplit = split; - if (ok) CloneSendSession.begin(mode == Mode.HOTSPOT, tempPass, hostHasRootfs, shareAnyway, split); // ADFA-4960: app-scope the live share so a recreated Fragment re-binds + if (ok) CloneSendSession.begin(hsMode.isHotspot(), tempPass, hostHasRootfs, shareAnyway, split); // ADFA-4960: app-scope the live share so a recreated Fragment re-binds else releaseCloneEnv(); // couldn't serve — boot the server back, drop the lock render(); }); @@ -634,8 +620,8 @@ private void render() { // ADFA-5154: Send is two pages. Common chrome, then the page. actionFooter.setVisibility(View.GONE); // ADFA-5154: default hidden; only Copy's states re-show it netRow.setVisibility(View.VISIBLE); - SegmentedTabs.paint(tabHotspot, mode == Mode.HOTSPOT); - SegmentedTabs.paint(tabWifi, mode == Mode.WIFI); + SegmentedTabs.paint(tabHotspot, hsMode.isHotspot()); + SegmentedTabs.paint(tabWifi, !hsMode.isHotspot()); steps.setVisibility(View.VISIBLE); buildSteps(); advance.setVisibility(View.VISIBLE); @@ -713,7 +699,7 @@ private void renderBusySend() { */ private void renderPrepare() { // ---- Section ① : Join the network ---- - if (mode == Mode.HOTSPOT) { + if (hsMode.isHotspot()) { secJoinTitle.setText(getString(R.string.k2go_clone_join_hotspot_title)); shareWifi.setVisibility(View.GONE); LocalHotspotManager.State st = hs.state().getValue(); @@ -746,14 +732,8 @@ private void renderPrepare() { secJoin.caption.setText(getString(R.string.k2go_connect_starting_hotspot)); secJoin.subCaption.setText(""); } else { - String ssid = (st.ssid != null) ? st.ssid : ""; - String pass = (st.passphrase != null) ? st.passphrase : ""; secJoin.frame.setVisibility(View.VISIBLE); - secJoin.setQr(requireContext(), "WIFI:S:" + ssid + ";T:WPA;P:" + pass + ";;", null); - secJoin.caption.setText(getString(R.string.k2go_clone_point_camera_join)); - secJoin.subCaption.setText(""); - secJoin.setFallback(requireContext(), new String[]{ - getString(R.string.k2go_fallback_wifi, ssid), getString(R.string.k2go_fallback_pass, pass)}); + secJoin.setWifiJoin(requireContext(), st.ssid, st.passphrase, R.string.k2go_clone_point_camera_join); } } else { // Wi-Fi: "join this Wi-Fi" isn't a QR the other camera can act on — instruct + Share secJoinTitle.setText(getString(R.string.k2go_clone_join_wifi_title)); @@ -770,7 +750,7 @@ private void renderPrepare() { } private void renderGetAppSection() { - if (mode == Mode.HOTSPOT) ensureHotspot(); + if (hsMode.isHotspot()) ensureHotspot(); startApkServer(); String appIp = peerReachableIp(); if (appIp == null || apkServer == null) { @@ -799,12 +779,12 @@ private void renderCopy() { // hasn't been assigned yet; wait instead of guessing a fixed address that isn't universal // across OEMs. K2GO-375: the hotspot owner reruns render() when the AP IP lands, so no local // poll is needed here anymore. - if (mode == Mode.HOTSPOT) simpleState(getString(R.string.k2go_clone_starting_service), ""); + if (hsMode.isHotspot()) simpleState(getString(R.string.k2go_clone_starting_service), ""); else simpleState(getString(R.string.k2go_connect_no_wifi), getString(R.string.k2go_connect_join_wifi)); return; } ensureDaemon(ip); - renderStartState(ip, mode == Mode.HOTSPOT); + renderStartState(ip, hsMode.isHotspot()); } /** @@ -819,7 +799,7 @@ private void renderCopy() { * already reruns render() when its IP appears. */ private String peerReachableIp() { - if (mode == Mode.HOTSPOT) { + if (hsMode.isHotspot()) { LocalHotspotManager.State st = hs.state().getValue(); return (st != null) ? st.hotspotIp : null; } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java index d1083483e..ce7321e98 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java @@ -17,11 +17,14 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import org.appdevforall.k2go.R; +import org.appdevforall.k2go.hotspot.HotspotMode; +import org.appdevforall.k2go.hotspot.HotspotMode.Mode; import org.appdevforall.k2go.hotspot.HotspotPermissions; import org.appdevforall.k2go.hotspot.LocalHotspotManager; import org.appdevforall.k2go.hotspot.domain.HotspotHolders; import org.appdevforall.k2go.sync.transport.NetworkInterfaces; import org.appdevforall.k2go.sync.transport.NetworkStateLiveData; +import org.appdevforall.k2go.ui.dialog.BrandDialog; /** * Connect tab (ADFA-4776; redesigned ADFA-5154). Let a nearby device browse the library. @@ -40,13 +43,13 @@ */ public class ConnectFragment extends Fragment { - private enum Mode { HOTSPOT, WIFI } - // ADFA-5157: the "section" holder and its setQr/setFallback logic moved to the shared QrSection // class so the Clone (Send) redesign reuses it instead of copying it. Three instances here — Join, // Open, and the single container used for Wi-Fi / failed / no-system. - private Mode mode = Mode.HOTSPOT; + // K2GO-577: the shared Hotspot / Wi-Fi rule (Clone and Share use it too): the choice and Connect's + // hold. Wi-Fi gives the hotspot back; leaving the screen keeps it, so joined devices keep browsing. + private HotspotMode hsMode; // ADFA-5150: Connect shares this device's library — with no system there is nothing to serve, and // the QR would point at a dead port. Read on onResume (a system is not gained while this is open). @@ -63,12 +66,11 @@ private enum Mode { HOTSPOT, WIFI } @Override public void onCreate(@Nullable Bundle s) { super.onCreate(s); + hsMode = HotspotMode.of(requireContext(), HotspotHolders.Holder.CONNECT, Mode.HOTSPOT); hotspotPerm = registerForActivityResult( new ActivityResultContracts.RequestMultiplePermissions(), result -> { - if (HotspotPermissions.granted(requireContext())) { - hs.acquire(requireContext().getApplicationContext(), HotspotHolders.Holder.CONNECT); - } + hsMode.resume(); render(); }); } @@ -98,8 +100,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c finish = v.findViewById(R.id.k2go_conn_finish); connFooter = v.findViewById(R.id.k2go_conn_footer); - tabHotspot.setOnClickListener(x -> setMode(Mode.HOTSPOT)); - tabWifi.setOnClickListener(x -> setMode(Mode.WIFI)); + tabHotspot.setOnClickListener(x -> requestMode(Mode.HOTSPOT)); + tabWifi.setOnClickListener(x -> requestMode(Mode.WIFI)); finish.setOnClickListener(x -> { finish.setEnabled(false); new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> { @@ -120,19 +122,23 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c return v; } - private void setMode(Mode m) { - mode = m; - if (m == Mode.HOTSPOT) ensureHotspot(); - render(); + /** A tab tap. Leaving Hotspot gives it back and drops joined devices, so warn when some may be on. */ + private void requestMode(Mode target) { + LocalHotspotManager.State st = hs.state().getValue(); + boolean dropsClients = hsMode.isHotspot() && target == Mode.WIFI && st != null && st.mayHaveClients(); + if (!dropsClients) { setMode(target); return; } + new BrandDialog(requireContext()) + .setTitle(getString(R.string.k2go_clone_switch_title, getString(R.string.k2go_wifi))) + .setMessage(R.string.k2go_connect_switch_msg) + .setNegative(R.string.k2go_cancel, null) + .setPositive(R.string.k2go_clone_switch_confirm, () -> { if (isAdded()) setMode(target); }) + .show(); } - private void ensureHotspot() { - if (!LocalHotspotManager.isSupported()) return; - if (HotspotPermissions.granted(requireContext())) { - hs.acquire(requireContext().getApplicationContext(), HotspotHolders.Holder.CONNECT); - } else if (!hs.isOn()) { - hotspotPerm.launch(HotspotPermissions.required()); - } + /** A fresh choice: Hotspot holds it (one permission prompt), Wi-Fi gives it back. */ + private void setMode(Mode m) { + if (hsMode.choose(m)) hotspotPerm.launch(HotspotPermissions.required()); + render(); } private static String browseUrl(String ip) { return "http://" + ip + ":8085"; } @@ -143,11 +149,9 @@ public void onResume() { // ADFA-5150/5312: redraw on the way to the front — a system may have been recovered, or an // install may have finished, while the user was away. render() re-reads the shared verdict. // K2GO-439: if the hotspot permission was granted while away (e.g. in Settings), start it now so - // the user is not stuck on "Starting...". Only when already granted: do NOT re-launch the request - // here, which would re-prompt on every resume (ensureHotspot has no one-shot guard in Connect). - if (mode == Mode.HOTSPOT && HotspotPermissions.granted(requireContext())) { - ensureHotspot(); - } + // the user is not stuck on "Starting...". resume() never re-launches the request, which would + // re-prompt on every resume. + hsMode.resume(); render(); } @@ -162,8 +166,8 @@ public void onDestroyView() { private void render() { if (!isAdded() || secSingle == null) return; - SegmentedTabs.paint(tabHotspot, mode == Mode.HOTSPOT); - SegmentedTabs.paint(tabWifi, mode == Mode.WIFI); + SegmentedTabs.paint(tabHotspot, hsMode.isHotspot()); + SegmentedTabs.paint(tabWifi, !hsMode.isHotspot()); finish.setVisibility(View.GONE); connFooter.setVisibility(View.VISIBLE); // default; the no-system state hides it advance.setVisibility(View.GONE); @@ -178,7 +182,7 @@ private void render() { default: break; // READY / CLONE_* -> the normal share render handles it } - if (mode == Mode.HOTSPOT) renderHotspot(); else renderWifi(); + if (hsMode.isHotspot()) renderHotspot(); else renderWifi(); } /** @@ -233,8 +237,8 @@ private void renderHotspot() { advance.setText(R.string.k2go_home_retry); styleAdvance(true); // K2GO-471 review: hs.stop runs onDone after an async teardown; guard against the fragment - // being gone by then, since ensureHotspot calls requireContext(). - advance.setOnClickListener(x -> hs.stop(() -> { if (isAdded()) ensureHotspot(); })); + // being gone by then. A retry is a fresh choice, so it may ask the permission again. + advance.setOnClickListener(x -> hs.stop(() -> { if (isAdded()) setMode(Mode.HOTSPOT); })); connFooter.setVisibility(View.GONE); return; } @@ -252,17 +256,11 @@ private void renderHotspot() { boolean on = (phase == LocalHotspotManager.Phase.ON); if (on) { - String ssid = (st != null && st.ssid != null) ? st.ssid : ""; - String pass = (st != null && st.passphrase != null) ? st.passphrase : ""; // K2GO-375: one source for the hotspot IP — the reservation's owner. Null until the AP // interface has its address; the owner re-emits State when it lands, which reruns render(). String ip = (st != null) ? st.hotspotIp : null; - secJoin.setQr(requireContext(), "WIFI:S:" + ssid + ";T:WPA;P:" + pass + ";;", null); - secJoin.caption.setText(R.string.k2go_just_scan); - secJoin.subCaption.setText(""); - secJoin.setFallback(requireContext(), new String[]{ - getString(R.string.k2go_fallback_wifi, ssid), getString(R.string.k2go_fallback_pass, pass)}); + secJoin.setWifiJoin(requireContext(), st.ssid, st.passphrase, R.string.k2go_just_scan); secOpen.caption.setText(R.string.k2go_connect_readonly); secOpen.subCaption.setText(""); diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/QrSection.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/QrSection.java index b696eaaf4..1c82bd985 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/QrSection.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/QrSection.java @@ -20,6 +20,7 @@ import androidx.core.content.ContextCompat; import org.appdevforall.k2go.R; +import org.appdevforall.k2go.hotspot.domain.WifiQr; import org.appdevforall.k2go.sync.transport.QrCodec; import org.appdevforall.k2go.util.EllipsisAnimator; import org.appdevforall.k2go.util.M3Text; @@ -107,6 +108,20 @@ public void stopPending() { * caption above says what this is (".. or use the following credentials instead:"). The old * "Scan didn't work?" / "Hide" toggle is gone. */ + /** + * The join-the-hotspot card that Connect, Clone and Share show (K2GO-577): the Wi-Fi auto-join QR, + * [captionRes] under it, and the name and password as the fallback. Null values show as empty. + */ + public void setWifiJoin(Context ctx, String ssid, String pass, int captionRes) { + String name = ssid != null ? ssid : ""; + String key = pass != null ? pass : ""; + setQr(ctx, WifiQr.payload(name, key), null); + caption.setText(captionRes); + subCaption.setText(""); + setFallback(ctx, new String[]{ + ctx.getString(R.string.k2go_fallback_wifi, name), ctx.getString(R.string.k2go_fallback_pass, key)}); + } + public void setFallback(Context ctx, String[] vals) { fallbackToggle.setVisibility(View.GONE); // ADFA-5236: no reveal toggle anymore fallbackValues.removeAllViews(); diff --git a/controller/app/src/main/res/layout/fragment_k2go_content_share.xml b/controller/app/src/main/res/layout/fragment_k2go_content_share.xml index 236ee0308..778ab6443 100644 --- a/controller/app/src/main/res/layout/fragment_k2go_content_share.xml +++ b/controller/app/src/main/res/layout/fragment_k2go_content_share.xml @@ -32,10 +32,9 @@ android:textColor="@color/k2go_muted" /> + SegmentedTabs). Hotspot (the default) holds the hotspot and the receiver joins it; Wi-Fi + gives the hotspot back and the receiver uses the same network, so the join section hides + (K2GO-577). Shown once the invite is ready. --> امسح على الهاتف الآخر للانضمام إلى نقطة الاتصال هذه. لا يمكن لهذا الهاتف بدء نقطة اتصال للمشاركة. تعذّر بدء نقطة الاتصال. - إذن نقطة الاتصال مطلوب للمشاركة. تعذّر بدء المشاركة. أبقِ هذه الشاشة مفتوحة حتى ينتهي الهاتف الآخر. تم diff --git a/controller/app/src/main/res/values-az/strings.xml b/controller/app/src/main/res/values-az/strings.xml index 8c1a6f572..fd2eb8cce 100644 --- a/controller/app/src/main/res/values-az/strings.xml +++ b/controller/app/src/main/res/values-az/strings.xml @@ -1529,7 +1529,6 @@ Bu hotspota qoşulmaq üçün digər telefonda skan edin. Bu telefon paylaşmaq üçün hotspot başlada bilmir. Hotspot başladıla bilmədi. - Paylaşmaq üçün hotspot icazəsi lazımdır. Paylaşma başladıla bilmədi. Digər telefon bitirənə qədər bu ekranı açıq saxlayın. Hazırdır diff --git a/controller/app/src/main/res/values-bg/strings.xml b/controller/app/src/main/res/values-bg/strings.xml index 8ab1fe574..58e26d0c4 100644 --- a/controller/app/src/main/res/values-bg/strings.xml +++ b/controller/app/src/main/res/values-bg/strings.xml @@ -1516,7 +1516,6 @@ Сканирайте на другия телефон, за да се присъедините към тази точка за достъп. Този телефон не може да стартира точка за достъп за споделяне. Точката за достъп не можа да се стартира. - За споделяне е необходимо разрешение за точка за достъп. Споделянето не можа да стартира. Дръжте този екран отворен, докато другият телефон приключи. Готово diff --git a/controller/app/src/main/res/values-bn/strings.xml b/controller/app/src/main/res/values-bn/strings.xml index 0bed3a3d8..e9e25652f 100644 --- a/controller/app/src/main/res/values-bn/strings.xml +++ b/controller/app/src/main/res/values-bn/strings.xml @@ -1522,7 +1522,6 @@ এই হটস্পটে যোগ দিতে অন্য ফোনে স্ক্যান করুন। এই ফোনটি শেয়ার করার জন্য হটস্পট চালু করতে পারে না। হটস্পট চালু করা যায়নি। - শেয়ার করার জন্য হটস্পট অনুমতি প্রয়োজন। শেয়ার করা শুরু করা যায়নি। অন্য ফোনটি শেষ না হওয়া পর্যন্ত এই স্ক্রিনটি খোলা রাখুন। সম্পন্ন diff --git a/controller/app/src/main/res/values-cs/strings.xml b/controller/app/src/main/res/values-cs/strings.xml index f01a19e68..d7eb6ecd0 100644 --- a/controller/app/src/main/res/values-cs/strings.xml +++ b/controller/app/src/main/res/values-cs/strings.xml @@ -1516,7 +1516,6 @@ Naskenujte na druhém telefonu a připojte se k tomuto hotspotu. Tento telefon nemůže spustit hotspot pro sdílení. Hotspot se nepodařilo spustit. - Pro sdílení je potřeba oprávnění hotspotu. Sdílení se nepodařilo spustit. Nechte tuto obrazovku otevřenou, dokud druhý telefon nedokončí. Hotovo diff --git a/controller/app/src/main/res/values-de/strings.xml b/controller/app/src/main/res/values-de/strings.xml index 15d82d876..5c98f4419 100644 --- a/controller/app/src/main/res/values-de/strings.xml +++ b/controller/app/src/main/res/values-de/strings.xml @@ -1509,7 +1509,6 @@ Auf dem anderen Telefon scannen, um diesem Hotspot beizutreten. Dieses Telefon kann keinen Hotspot zum Teilen starten. Hotspot konnte nicht gestartet werden. - Die Hotspot-Berechtigung ist zum Teilen erforderlich. Teilen konnte nicht gestartet werden. Lassen Sie diesen Bildschirm geöffnet, bis das andere Telefon fertig ist. Fertig diff --git a/controller/app/src/main/res/values-el/strings.xml b/controller/app/src/main/res/values-el/strings.xml index 8bd6051b8..05a76eb75 100644 --- a/controller/app/src/main/res/values-el/strings.xml +++ b/controller/app/src/main/res/values-el/strings.xml @@ -1516,7 +1516,6 @@ Σαρώστε στο άλλο τηλέφωνο για να συνδεθείτε σε αυτό το hotspot. Αυτό το τηλέφωνο δεν μπορεί να ξεκινήσει hotspot για κοινή χρήση. Δεν ήταν δυνατή η εκκίνηση του hotspot. - Απαιτείται η άδεια hotspot για κοινή χρήση. Δεν ήταν δυνατή η έναρξη της κοινής χρήσης. Κρατήστε αυτήν την οθόνη ανοιχτή μέχρι να τελειώσει το άλλο τηλέφωνο. Τέλος diff --git a/controller/app/src/main/res/values-es/strings.xml b/controller/app/src/main/res/values-es/strings.xml index 4564ed66f..4036a7bf2 100644 --- a/controller/app/src/main/res/values-es/strings.xml +++ b/controller/app/src/main/res/values-es/strings.xml @@ -1585,7 +1585,6 @@ Escanea en el otro teléfono para unirte a este punto de acceso. Este teléfono no puede iniciar un punto de acceso para compartir. No se pudo iniciar el punto de acceso. - Se necesita el permiso del punto de acceso para compartir. No se pudo iniciar el uso compartido. Mantén esta pantalla abierta hasta que el otro teléfono termine. Listo diff --git a/controller/app/src/main/res/values-fa/strings.xml b/controller/app/src/main/res/values-fa/strings.xml index 2681cceb6..cfabd1690 100644 --- a/controller/app/src/main/res/values-fa/strings.xml +++ b/controller/app/src/main/res/values-fa/strings.xml @@ -1509,7 +1509,6 @@ برای پیوستن به این نقطه اتصال، در تلفن دیگر اسکن کنید. این تلفن نمی‌تواند برای اشتراک‌گذاری نقطه اتصال راه‌اندازی کند. نقطه اتصال راه‌اندازی نشد. - برای اشتراک‌گذاری به اجازه نقطه اتصال نیاز است. اشتراک‌گذاری آغاز نشد. این صفحه را باز نگه دارید تا تلفن دیگر تمام شود. انجام شد diff --git a/controller/app/src/main/res/values-fr/strings.xml b/controller/app/src/main/res/values-fr/strings.xml index 7e6853ddc..0a1f1927b 100644 --- a/controller/app/src/main/res/values-fr/strings.xml +++ b/controller/app/src/main/res/values-fr/strings.xml @@ -1596,7 +1596,6 @@ Scannez sur l\'autre téléphone pour rejoindre ce point d\'accès. Ce téléphone ne peut pas démarrer un point d\'accès pour partager. Impossible de démarrer le point d\'accès. - L\'autorisation du point d\'accès est nécessaire pour partager. Impossible de démarrer le partage. Gardez cet écran ouvert jusqu\'à ce que l\'autre téléphone ait terminé. Terminé diff --git a/controller/app/src/main/res/values-gu/strings.xml b/controller/app/src/main/res/values-gu/strings.xml index 37da72c15..304e09237 100644 --- a/controller/app/src/main/res/values-gu/strings.xml +++ b/controller/app/src/main/res/values-gu/strings.xml @@ -1522,7 +1522,6 @@ આ હોટ્સ્પોટમાં જોડાવા માટે બીજા ફોન પર સ્કૅન કરો. આ ફોન શેર કરવા માટે હોટ્સ્પોટ શરૂ કરી શકતો નથી. હોટ્સ્પોટ શરૂ કરી શકાયું નથી. - શેર કરવા માટે હોટ્સ્પોટ પરવાની જરૂરી છે. શેર કરવાનું શરૂ કરી શકાયું નથી. બીજો ફોન પૂર્ણ થાય ત્યાં સુધી આ સ્ક્રીન ખુલ્લી રાખો. પૂર્ણ થયું diff --git a/controller/app/src/main/res/values-hi/strings.xml b/controller/app/src/main/res/values-hi/strings.xml index 54c554179..7631c79a6 100644 --- a/controller/app/src/main/res/values-hi/strings.xml +++ b/controller/app/src/main/res/values-hi/strings.xml @@ -1586,7 +1586,6 @@ इस हॉटस्पॉट से जुड़ने के लिए दूसरे फ़ोन पर स्कैन करें। यह फ़ोन साझा करने के लिए हॉटस्पॉट शुरू नहीं कर सकता। हॉटस्पॉट शुरू नहीं किया जा सका। - साझा करने के लिए हॉटस्पॉट अनुमति आवश्यक है। साझा करना शुरू नहीं किया जा सका। दूसरे फ़ोन के पूरा होने तक इस स्क्रीन को खुला रखें। हो गया diff --git a/controller/app/src/main/res/values-hu/strings.xml b/controller/app/src/main/res/values-hu/strings.xml index 5f7c8c531..a55b5817e 100644 --- a/controller/app/src/main/res/values-hu/strings.xml +++ b/controller/app/src/main/res/values-hu/strings.xml @@ -1509,7 +1509,6 @@ Olvassa be a másik telefonon a hotspothoz való csatlakozáshoz. Ez a telefon nem tud hotspotot indítani a megosztáshoz. A hotspot indítása nem sikerült. - A megosztáshoz hotspot engedély szükséges. A megosztás indítása nem sikerült. Tartsa nyitva ezt a képernyőt, amíg a másik telefon be nem fejezi. Kész diff --git a/controller/app/src/main/res/values-in/strings.xml b/controller/app/src/main/res/values-in/strings.xml index 70f24335d..271c61eeb 100644 --- a/controller/app/src/main/res/values-in/strings.xml +++ b/controller/app/src/main/res/values-in/strings.xml @@ -1516,7 +1516,6 @@ Pindai di ponsel lain untuk bergabung ke hotspot ini. Ponsel ini tidak dapat memulai hotspot untuk berbagi. Tidak dapat memulai hotspot. - Izin hotspot diperlukan untuk berbagi. Tidak dapat memulai berbagi. Biarkan layar ini terbuka hingga ponsel lain selesai. Selesai diff --git a/controller/app/src/main/res/values-it/strings.xml b/controller/app/src/main/res/values-it/strings.xml index 999ae83bd..40cead83b 100644 --- a/controller/app/src/main/res/values-it/strings.xml +++ b/controller/app/src/main/res/values-it/strings.xml @@ -1509,7 +1509,6 @@ Esegui la scansione sull\'altro telefono per partecipare a questo hotspot. Questo telefono non può avviare un hotspot per la condivisione. Impossibile avviare l\'hotspot. - L\'autorizzazione hotspot è necessaria per la condivisione. Impossibile avviare la condivisione. Tieni questa schermata aperta finché l\'altro telefono non ha terminato. Fatto diff --git a/controller/app/src/main/res/values-ja/strings.xml b/controller/app/src/main/res/values-ja/strings.xml index 595e7e568..748bf6d56 100644 --- a/controller/app/src/main/res/values-ja/strings.xml +++ b/controller/app/src/main/res/values-ja/strings.xml @@ -1510,7 +1510,6 @@ このホットスポットに参加するには、もう一方のスマートフォンでスキャンしてください。 このスマートフォンは共有用のホットスポットを開始できません。 ホットスポットを開始できませんでした。 - 共有にはホットスポットの権限が必要です。 共有を開始できませんでした。 もう一方のスマートフォンが完了するまで、この画面を開いたままにしてください。 完了 diff --git a/controller/app/src/main/res/values-ko/strings.xml b/controller/app/src/main/res/values-ko/strings.xml index 0d8199e73..f2b97ce49 100644 --- a/controller/app/src/main/res/values-ko/strings.xml +++ b/controller/app/src/main/res/values-ko/strings.xml @@ -1510,7 +1510,6 @@ 이 핫스팅에 참가하려면 다른 휴대전화에서 스캔하세요. 이 휴대전화는 공유용 핫스팅을 시작할 수 없습니다. 핫스팅을 시작할 수 없습니다. - 공유하려면 핫스팅 권한이 필요합니다. 공유를 시작할 수 없습니다. 다른 휴대전화가 완료될 때까지 이 화면을 열어 두세요. 완료 diff --git a/controller/app/src/main/res/values-lt/strings.xml b/controller/app/src/main/res/values-lt/strings.xml index cae017e4b..880ae0583 100644 --- a/controller/app/src/main/res/values-lt/strings.xml +++ b/controller/app/src/main/res/values-lt/strings.xml @@ -1526,7 +1526,6 @@ Nuskaitykite kitame telefone, kad prisijungtumėte prie šios viešosios interneto prieigos. Šis telefonas negali paleisti viešosios interneto prieigos bendrinimui. Nepavyko paleisti viešosios interneto prieigos. - Bendrinti reikia viešosios interneto prieigos leidimo. Nepavyko pradėti bendrinimo. Laikykite šį ekraną atidarytą, kol kitas telefonas baigs. Atlikta diff --git a/controller/app/src/main/res/values-nl/strings.xml b/controller/app/src/main/res/values-nl/strings.xml index da01be302..eb1b0a62f 100644 --- a/controller/app/src/main/res/values-nl/strings.xml +++ b/controller/app/src/main/res/values-nl/strings.xml @@ -1509,7 +1509,6 @@ Scan op de andere telefoon om deel te nemen aan deze hotspot. Deze telefoon kan geen hotspot starten om te delen. Kan de hotspot niet starten. - De hotspot-machtiging is nodig om te delen. Kan het delen niet starten. Houd dit scherm open totdat de andere telefoon klaar is. Klaar diff --git a/controller/app/src/main/res/values-no/strings.xml b/controller/app/src/main/res/values-no/strings.xml index 521441624..ad5cd7f2d 100644 --- a/controller/app/src/main/res/values-no/strings.xml +++ b/controller/app/src/main/res/values-no/strings.xml @@ -1519,7 +1519,6 @@ Skann på den andre telefonen for å bli med i denne hotspoten. Denne telefonen kan ikke starte en hotspot for deling. Kunne ikke starte hotspoten. - Hotspot-tillatelsen er nødvendig for å dele. Kunne ikke starte deling. Hold denne skjermen åpen til den andre telefonen er ferdig. Ferdig diff --git a/controller/app/src/main/res/values-pl/strings.xml b/controller/app/src/main/res/values-pl/strings.xml index 035c280da..1d6a6a6fa 100644 --- a/controller/app/src/main/res/values-pl/strings.xml +++ b/controller/app/src/main/res/values-pl/strings.xml @@ -1519,7 +1519,6 @@ Zeskanuj na drugim telefonie, aby dołączyć do tego hotspotu. Ten telefon nie może uruchomić hotspotu do udostępniania. Nie można uruchomić hotspotu. - Do udostępniania wymagane jest uprawnienie hotspotu. Nie można rozpocząć udostępniania. Pozostaw ten ekran otwarty, aż drugi telefon zakończy. Gotowe diff --git a/controller/app/src/main/res/values-pt/strings.xml b/controller/app/src/main/res/values-pt/strings.xml index 698b32ced..49863b5da 100644 --- a/controller/app/src/main/res/values-pt/strings.xml +++ b/controller/app/src/main/res/values-pt/strings.xml @@ -1588,7 +1588,6 @@ Leia no outro telefone para se juntar a este hotspot. Este telefone não consegue iniciar um hotspot para partilhar. Não foi possível iniciar o hotspot. - A permissão do hotspot é necessária para partilhar. Não foi possível iniciar a partilha. Mantenha este ecrã aberto até o outro telefone terminar. Concluído diff --git a/controller/app/src/main/res/values-ro/strings.xml b/controller/app/src/main/res/values-ro/strings.xml index a9809c289..1d6548495 100644 --- a/controller/app/src/main/res/values-ro/strings.xml +++ b/controller/app/src/main/res/values-ro/strings.xml @@ -1509,7 +1509,6 @@ Scanează pe celălalt telefon pentru a te alătura acestui hotspot. Acest telefon nu poate porni un hotspot pentru partajare. Hotspotul nu a putut fi pornit. - Permisiunea pentru hotspot este necesară pentru partajare. Partajarea nu a putut fi pornită. Ține acest ecran deschis până când celălalt telefon termină. Gata diff --git a/controller/app/src/main/res/values-ru-rRU/strings.xml b/controller/app/src/main/res/values-ru-rRU/strings.xml index 7db045eed..e69350b5c 100644 --- a/controller/app/src/main/res/values-ru-rRU/strings.xml +++ b/controller/app/src/main/res/values-ru-rRU/strings.xml @@ -1585,7 +1585,6 @@ Отсканируйте на другом телефоне, чтобы присоединиться к этой точке доступа. Этот телефон не может запустить точку доступа для обмена. Не удалось запустить точку доступа. - Для обмена требуется разрешение на точку доступа. Не удалось начать обмен. Держите этот экран открытым, пока другой телефон не завершит. Готово diff --git a/controller/app/src/main/res/values-sk/strings.xml b/controller/app/src/main/res/values-sk/strings.xml index 66ddf3d91..b214e795b 100644 --- a/controller/app/src/main/res/values-sk/strings.xml +++ b/controller/app/src/main/res/values-sk/strings.xml @@ -1516,7 +1516,6 @@ Naskenujte na druhom telefóne a pripojte sa k tomuto hotspotu. Tento telefón nemôže spustiť hotspot na zdieľanie. Hotspot sa nepodarilo spustiť. - Na zdieľanie je potrebné povolenie hotspotu. Zdieľanie sa nepodarilo spustiť. Nechajte túto obrazovku otvorenú, kým druhý telefón neskončí. Hotovo diff --git a/controller/app/src/main/res/values-sr/strings.xml b/controller/app/src/main/res/values-sr/strings.xml index e0d7a9933..c5f63585b 100644 --- a/controller/app/src/main/res/values-sr/strings.xml +++ b/controller/app/src/main/res/values-sr/strings.xml @@ -1522,7 +1522,6 @@ Скенирај на другом телефону да се придружиш овом хотспоту. Овај телефон не може да покрене хотспот за дељење. Хотспот није могуће покренути. - За дељење је потребна дозвола за хотспот. Дељење није могуће покренути. Држи овај екран отворен док други телефон не заврши. Готово diff --git a/controller/app/src/main/res/values-sw/strings.xml b/controller/app/src/main/res/values-sw/strings.xml index 3047bf816..0f6411f46 100644 --- a/controller/app/src/main/res/values-sw/strings.xml +++ b/controller/app/src/main/res/values-sw/strings.xml @@ -1529,7 +1529,6 @@ Changanua kwenye simu nyingine ili kujiunga na hotspot hii. Simu hii haiwezi kuanzisha hotspot ya kushiriki. Imeshindwa kuanzisha hotspot. - Ruhusa ya hotspot inahitajika ili kushiriki. Imeshindwa kuanza kushiriki. Weka skrini hii wazi hadi simu nyingine imalize. Imekamilika diff --git a/controller/app/src/main/res/values-ta/strings.xml b/controller/app/src/main/res/values-ta/strings.xml index b8eac2451..f7425162b 100644 --- a/controller/app/src/main/res/values-ta/strings.xml +++ b/controller/app/src/main/res/values-ta/strings.xml @@ -1529,7 +1529,6 @@ இந்த ஹாட்ஸ்பாட்டில் இணைய மற்றொரு ஃபோனில் ஸ்கேன் செய்யவும். இந்த ஃபோன் பகிர்வதற்கு ஹாட்ஸ்பாட்டைத் தொடங்க முடியாது. ஹாட்ஸ்பாட்டைத் தொடங்க முடியவில்லை. - பகிர்வதற்கு ஹாட்ஸ்பாட் அனுமதி தேவை. பகிர்வதைத் தொடங்க முடியவில்லை. மற்றொரு ஃபோன் முடிக்கும் வரை இந்தத் திரையைத் திறந்தே வையுங்கள். முடிந்தது diff --git a/controller/app/src/main/res/values-tr/strings.xml b/controller/app/src/main/res/values-tr/strings.xml index 42c5956be..3d929a56d 100644 --- a/controller/app/src/main/res/values-tr/strings.xml +++ b/controller/app/src/main/res/values-tr/strings.xml @@ -1509,7 +1509,6 @@ Bu etkin noktaya katılmak için diğer telefonda tarayın. Bu telefon paylaşım için etkin nokta başlatamıyor. Etkin nokta başlatılamadı. - Paylaşım için etkin nokta izni gerekiyor. Paylaşım başlatılamadı. Diğer telefon bitene kadar bu ekranı açık tutun. Bitti diff --git a/controller/app/src/main/res/values-uk/strings.xml b/controller/app/src/main/res/values-uk/strings.xml index 84de5fcbd..51376a713 100644 --- a/controller/app/src/main/res/values-uk/strings.xml +++ b/controller/app/src/main/res/values-uk/strings.xml @@ -1509,7 +1509,6 @@ Відскануйте на іншому телефоні, щоб приєднатися до цієї точки доступу. Цей телефон не може запустити точку доступу для надсилання. Не вдалося запустити точку доступу. - Для надсилання потрібен дозвіл на точку доступу. Не вдалося розпочати надсилання. Тримайте цей екран відкритим, доки інший телефон не завершить. Готово diff --git a/controller/app/src/main/res/values-vi/strings.xml b/controller/app/src/main/res/values-vi/strings.xml index d90b97061..ccf5d9cb3 100644 --- a/controller/app/src/main/res/values-vi/strings.xml +++ b/controller/app/src/main/res/values-vi/strings.xml @@ -1509,7 +1509,6 @@ Quét trên điện thoại kia để tham gia điểm phát sóng này. Điện thoại này không thể khởi động điểm phát sóng để chia sẻ. Không thể khởi động điểm phát sóng. - Cần có quyền điểm phát sóng để chia sẻ. Không thể bắt đầu chia sẻ. Giữ màn hình này mở cho đến khi điện thoại kia hoàn tất. Xong diff --git a/controller/app/src/main/res/values-yo/strings.xml b/controller/app/src/main/res/values-yo/strings.xml index 8b5504629..8d426bac4 100644 --- a/controller/app/src/main/res/values-yo/strings.xml +++ b/controller/app/src/main/res/values-yo/strings.xml @@ -1529,7 +1529,6 @@ Ṣàyẹ̀wò lórí fóònù kejì látì darapọ̀ mọ́ hotspot yìí. Fóònù yìí kò lè bẹ̀rẹ̀ hotspot látì pín. Kò lè bẹ̀rẹ̀ hotspot. - A nílò ìọ̀nda hotspot látì pín. Kò lè bẹ̀rẹ̀ pínpín. Jẹ́ kí ojú-ìwé yìí ṣí sílẹ̀ títí fóònù kejì yóò fi parí. Ó parí diff --git a/controller/app/src/main/res/values-zh-rCN/strings.xml b/controller/app/src/main/res/values-zh-rCN/strings.xml index 1f7aee20c..fd0d192fa 100644 --- a/controller/app/src/main/res/values-zh-rCN/strings.xml +++ b/controller/app/src/main/res/values-zh-rCN/strings.xml @@ -1510,7 +1510,6 @@ 在另一部手机上扫描以加入此热点。 此手机无法启动用于共享的热点。 无法启动热点。 - 共享需要热点权限。 无法开始共享。 请保持此屏幕打开,直到另一部手机完成。 完成 diff --git a/controller/app/src/main/res/values/strings.xml b/controller/app/src/main/res/values/strings.xml index f5297dd2f..76dc2ba7a 100644 --- a/controller/app/src/main/res/values/strings.xml +++ b/controller/app/src/main/res/values/strings.xml @@ -1704,7 +1704,6 @@ Scan on the other phone to join this hotspot. This phone cannot start a hotspot to share. Could not start the hotspot. - The hotspot permission is needed to share. Could not start sharing. Keep this screen open until the other phone finishes. Done diff --git a/controller/app/src/main/res/values/strings_untranslated.xml b/controller/app/src/main/res/values/strings_untranslated.xml index c5ed0df5b..e062393d5 100644 --- a/controller/app/src/main/res/values/strings_untranslated.xml +++ b/controller/app/src/main/res/values/strings_untranslated.xml @@ -10,5 +10,6 @@ strings.xml. --> - + + Devices joined to this hotspot lose their connection. diff --git a/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java new file mode 100644 index 000000000..b5469b29a --- /dev/null +++ b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java @@ -0,0 +1,79 @@ +package org.appdevforall.k2go.hotspot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** K2GO-577: the one Hotspot / Wi-Fi rule shared by Connect, Clone and Share. */ +public class HotspotModeTest { + + private static final class FakePort implements HotspotMode.Port { + boolean supported = true; + boolean permitted = true; + boolean on; + int acquires; + int releases; + + @Override public boolean supported() { return supported; } + @Override public boolean permitted() { return permitted; } + @Override public boolean isOn() { return on; } + @Override public void acquire() { acquires++; on = true; } + @Override public void release() { releases++; } + } + + @Test + public void hotspotHoldsAndWifiReleases() { + FakePort port = new FakePort(); + HotspotMode m = new HotspotMode(port, HotspotMode.Mode.HOTSPOT); + assertFalse(m.choose(HotspotMode.Mode.HOTSPOT)); + assertEquals(1, port.acquires); + assertFalse(m.choose(HotspotMode.Mode.WIFI)); + assertEquals(1, port.releases); // K2GO-561: a switch to Wi-Fi lets the hotspot go + assertFalse(m.isHotspot()); + } + + @Test + public void missingPermissionIsAskedOncePerChoice() { + FakePort port = new FakePort(); + port.permitted = false; + HotspotMode m = new HotspotMode(port, HotspotMode.Mode.HOTSPOT); + assertTrue(m.choose(HotspotMode.Mode.HOTSPOT)); + assertFalse(m.ensure()); // a re-render does not ask again + assertFalse(m.ensure()); + m.choose(HotspotMode.Mode.WIFI); + assertTrue(m.choose(HotspotMode.Mode.HOTSPOT)); // a new choice may ask once more + assertEquals(0, port.acquires); + } + + @Test + public void resumeNeverAsksAndHoldsOnceGranted() { + FakePort port = new FakePort(); + port.permitted = false; + HotspotMode m = new HotspotMode(port, HotspotMode.Mode.HOTSPOT); + m.resume(); + assertEquals(0, port.acquires); + port.permitted = true; // granted in the dialog or in Settings + m.resume(); + assertEquals(1, port.acquires); + } + + @Test + public void unsupportedPhoneNeverAsksNorHolds() { + FakePort port = new FakePort(); + port.supported = false; + HotspotMode m = new HotspotMode(port, HotspotMode.Mode.HOTSPOT); + assertFalse(m.choose(HotspotMode.Mode.HOTSPOT)); + assertEquals(0, port.acquires); + } + + @Test + public void releaseGivesBackTheHold() { + FakePort port = new FakePort(); + HotspotMode m = new HotspotMode(port, HotspotMode.Mode.HOTSPOT); + m.choose(HotspotMode.Mode.HOTSPOT); + m.release(); + assertEquals(1, port.releases); + } +} diff --git a/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/WifiQrTest.java b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/WifiQrTest.java new file mode 100644 index 000000000..2e53f47ab --- /dev/null +++ b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/WifiQrTest.java @@ -0,0 +1,25 @@ +package org.appdevforall.k2go.hotspot.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class WifiQrTest { + + @Test + public void wpaNetwork() { + assertEquals("WIFI:T:WPA;S:DIRECT-K2GO-ab;P:KnowledgeToGo;;", + WifiQr.payload("DIRECT-K2GO-ab", "KnowledgeToGo")); + } + + @Test + public void openNetworkWhenNoPassword() { + assertEquals("WIFI:T:nopass;S:Cafe;;", WifiQr.payload("Cafe", "")); + assertEquals("WIFI:T:nopass;S:Cafe;;", WifiQr.payload("Cafe", null)); + } + + @Test + public void reservedCharactersAreEscaped() { + assertEquals("WIFI:T:WPA;S:a\\;b\\:c;P:p\\,q\\\"r\\\\;;", WifiQr.payload("a;b:c", "p,q\"r\\")); + } +} From 257371efcb59d85780a1b767cab759ffd4896b59 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 16 Nov 2026 16:29:56 -0600 Subject: [PATCH 2/3] K2GO-577 fix(contentexchange): Receive stops our hotspot only on an address clash A sender on the shared Wi-Fi no longer cuts Connect. The Connect switch warning ships in all locales. --- .../presentation/ContentManagerFragment.java | 8 ++------ .../presentation/ContentReceiveFragment.java | 19 ++++++++++++++++--- .../app/src/main/res/values-ar/strings.xml | 1 + .../app/src/main/res/values-az/strings.xml | 1 + .../app/src/main/res/values-bg/strings.xml | 1 + .../app/src/main/res/values-bn/strings.xml | 1 + .../app/src/main/res/values-cs/strings.xml | 1 + .../app/src/main/res/values-de/strings.xml | 1 + .../app/src/main/res/values-el/strings.xml | 1 + .../app/src/main/res/values-es/strings.xml | 1 + .../app/src/main/res/values-fa/strings.xml | 1 + .../app/src/main/res/values-fr/strings.xml | 1 + .../app/src/main/res/values-gu/strings.xml | 1 + .../app/src/main/res/values-hi/strings.xml | 1 + .../app/src/main/res/values-hu/strings.xml | 1 + .../app/src/main/res/values-in/strings.xml | 1 + .../app/src/main/res/values-it/strings.xml | 1 + .../app/src/main/res/values-ja/strings.xml | 1 + .../app/src/main/res/values-ko/strings.xml | 3 ++- .../app/src/main/res/values-lt/strings.xml | 1 + .../app/src/main/res/values-nl/strings.xml | 1 + .../app/src/main/res/values-no/strings.xml | 1 + .../app/src/main/res/values-pl/strings.xml | 1 + .../app/src/main/res/values-pt/strings.xml | 1 + .../app/src/main/res/values-ro/strings.xml | 1 + .../src/main/res/values-ru-rRU/strings.xml | 1 + .../app/src/main/res/values-sk/strings.xml | 1 + .../app/src/main/res/values-sr/strings.xml | 1 + .../app/src/main/res/values-sw/strings.xml | 1 + .../app/src/main/res/values-ta/strings.xml | 1 + .../app/src/main/res/values-tr/strings.xml | 1 + .../app/src/main/res/values-uk/strings.xml | 1 + .../app/src/main/res/values-vi/strings.xml | 1 + .../app/src/main/res/values-yo/strings.xml | 1 + .../src/main/res/values-zh-rCN/strings.xml | 1 + .../app/src/main/res/values/strings.xml | 1 + .../main/res/values/strings_untranslated.xml | 3 +-- 37 files changed, 54 insertions(+), 12 deletions(-) diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java index 1edc2cb5b..472bd8d3c 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentManagerFragment.java @@ -39,7 +39,6 @@ import org.appdevforall.k2go.contentexchange.domain.ItemRef; import org.appdevforall.k2go.contentexchange.domain.ManagedContent; import org.appdevforall.k2go.contentexchange.domain.StorageStatus; -import org.appdevforall.k2go.hotspot.LocalHotspotManager; import org.appdevforall.k2go.storage.StorageProbe; import org.appdevforall.k2go.ui.dialog.BrandDialog; import org.appdevforall.k2go.util.ByteFormatter; @@ -325,11 +324,8 @@ private void onReceiveClicked() { showImportProgress(); return; } - // Tear our own hotspot down the moment Receive starts: the sender's AP IP (always 192.168.49.1) - // collides with our own hotspot IP if we are hosting, which traps the connection locally. - // Stopping here lets the interface release while the user joins and scans; ContentReceiveFragment - // also waits for the release before it connects. K2GO-376. - LocalHotspotManager.get().stop(); + // Our own hotspot stays up here: ContentReceiveFragment stops it only when the sender's address + // collides with it (K2GO-376, K2GO-577), so a Wi-Fi share does not cut Connect. requireActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.k2go_setup_host, new ContentReceiveStartFragment()) .addToBackStack(null) diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentReceiveFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentReceiveFragment.java index 808f54343..f90e12bb6 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentReceiveFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentReceiveFragment.java @@ -114,12 +114,25 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c * the kernel traps the connection on loopback (the local route beats any per-Network binding) and * the receiver reaches itself instead of the sender ("Could not reach the sender"). Tear our own * hotspot down and wait until the sender address is no longer one of our interfaces, then fetch. - * The hotspot stays off; only Share starts it again. K2GO-376. + * K2GO-376. Only on that collision (K2GO-577): a sender on the shared Wi-Fi does not touch our + * hotspot, so Connect keeps serving while this phone receives. */ private void prepareThenFetch() { showConnecting(); - LocalHotspotManager.get().stop(); // no-op if we are not hosting - waitHostRemoteThenFetch(0); + worker.execute(() -> { + boolean collides = NetworkInterfaces.isLocalAddress(host); + main.post(() -> { + if (!isAdded() || getView() == null) { + return; + } + if (collides) { + LocalHotspotManager.get().stop(); + waitHostRemoteThenFetch(0); + } else { + fetchManifest(); + } + }); + }); } /** Poll off the main thread until the sender address is no longer a local interface address, then diff --git a/controller/app/src/main/res/values-ar/strings.xml b/controller/app/src/main/res/values-ar/strings.xml index 74be1fc21..133bf9f31 100644 --- a/controller/app/src/main/res/values-ar/strings.xml +++ b/controller/app/src/main/res/values-ar/strings.xml @@ -1599,4 +1599,5 @@ تم نسخ التفاصيل %1$s (API %2$d) هذا يوقف أي نسخ جارٍ. يفقد الهاتف الآخر تقدّمه ويجب أن يبدأ من جديد برمز جديد. + تفقد الأجهزة المتصلة بنقطة الاتصال هذه اتصالها. diff --git a/controller/app/src/main/res/values-az/strings.xml b/controller/app/src/main/res/values-az/strings.xml index fd2eb8cce..47eae61f5 100644 --- a/controller/app/src/main/res/values-az/strings.xml +++ b/controller/app/src/main/res/values-az/strings.xml @@ -1619,4 +1619,5 @@ Təfərrüatlar kopyalandı %1$s (API %2$d) Bu, davam edən istənilən köçürməni dayandırır. Digər telefon irəliləyişini itirir və yeni kodla yenidən başlamalıdır. + Bu hotspota qoşulmuş cihazların bağlantısı kəsiləcək. diff --git a/controller/app/src/main/res/values-bg/strings.xml b/controller/app/src/main/res/values-bg/strings.xml index 58e26d0c4..30b0fdcb3 100644 --- a/controller/app/src/main/res/values-bg/strings.xml +++ b/controller/app/src/main/res/values-bg/strings.xml @@ -1606,4 +1606,5 @@ Подробностите са копирани %1$s (API %2$d) Това спира всяко копиране в ход. Другият телефон губи напредъка си и трябва да започне отново с нов код. + Устройствата, свързани към тази точка за достъп, губят връзката си. diff --git a/controller/app/src/main/res/values-bn/strings.xml b/controller/app/src/main/res/values-bn/strings.xml index e9e25652f..9b66716c7 100644 --- a/controller/app/src/main/res/values-bn/strings.xml +++ b/controller/app/src/main/res/values-bn/strings.xml @@ -1612,4 +1612,5 @@ বিবরণ কপি হয়েছে %1$s (API %2$d) এটি চলমান যেকোনো কপি বন্ধ করে। অন্য ফোনটি তার অগ্রগতি হারায় এবং নতুন কোড দিয়ে আবার শুরু করতে হবে। + এই হটস্পটে যুক্ত ডিভাইসগুলির সংযোগ বিচ্ছিন্ন হবে। diff --git a/controller/app/src/main/res/values-cs/strings.xml b/controller/app/src/main/res/values-cs/strings.xml index d7eb6ecd0..2a208708b 100644 --- a/controller/app/src/main/res/values-cs/strings.xml +++ b/controller/app/src/main/res/values-cs/strings.xml @@ -1606,4 +1606,5 @@ Podrobnosti zkopírovány %1$s (API %2$d) Tím se zastaví probíhající kopírování. Druhý telefon ztratí průběh a musí začít znovu s novým kódem. + Zařízení připojená k tomuto hotspotu ztratí připojení. diff --git a/controller/app/src/main/res/values-de/strings.xml b/controller/app/src/main/res/values-de/strings.xml index 5c98f4419..50803dd53 100644 --- a/controller/app/src/main/res/values-de/strings.xml +++ b/controller/app/src/main/res/values-de/strings.xml @@ -1599,4 +1599,5 @@ Details kopiert %1$s (API %2$d) Dadurch wird jede laufende Kopie gestoppt. Das andere Telefon verliert seinen Fortschritt und muss mit einem neuen Code neu beginnen. + Geräte, die mit diesem Hotspot verbunden sind, verlieren ihre Verbindung. diff --git a/controller/app/src/main/res/values-el/strings.xml b/controller/app/src/main/res/values-el/strings.xml index 05a76eb75..51d6b7b4e 100644 --- a/controller/app/src/main/res/values-el/strings.xml +++ b/controller/app/src/main/res/values-el/strings.xml @@ -1606,4 +1606,5 @@ Οι λεπτομέρειες αντιγράφηκαν %1$s (API %2$d) Αυτό σταματά κάθε αντιγραφή σε εξέλιξη. Το άλλο τηλέφωνο χάνει την πρόοδό του και πρέπει να ξεκινήσει ξανά με νέο κωδικό. + Οι συσκευές που είναι συνδεδεμένες σε αυτό το hotspot χάνουν τη σύνδεσή τους. diff --git a/controller/app/src/main/res/values-es/strings.xml b/controller/app/src/main/res/values-es/strings.xml index 4036a7bf2..4bf4d7840 100644 --- a/controller/app/src/main/res/values-es/strings.xml +++ b/controller/app/src/main/res/values-es/strings.xml @@ -1675,4 +1675,5 @@ Detalles copiados %1$s (API %2$d) Esto detiene cualquier copia en curso. El otro teléfono pierde su avance y debe empezar de nuevo con un código nuevo. + Los dispositivos conectados a este punto de acceso pierden la conexión. diff --git a/controller/app/src/main/res/values-fa/strings.xml b/controller/app/src/main/res/values-fa/strings.xml index cfabd1690..9c19d49eb 100644 --- a/controller/app/src/main/res/values-fa/strings.xml +++ b/controller/app/src/main/res/values-fa/strings.xml @@ -1599,4 +1599,5 @@ جزئیات کپی شد %1$s (API %2$d) این کار هر کپی در حال انجام را متوقف می‌کند. تلفن دیگر پیشرفت خود را از دست می‌دهد و باید با یک کد جدید دوباره شروع کند. + دستگاه‌های متصل به این نقطه اتصال، اتصال خود را از دست می‌دهند. diff --git a/controller/app/src/main/res/values-fr/strings.xml b/controller/app/src/main/res/values-fr/strings.xml index 0a1f1927b..da1b6f43c 100644 --- a/controller/app/src/main/res/values-fr/strings.xml +++ b/controller/app/src/main/res/values-fr/strings.xml @@ -1686,4 +1686,5 @@ Détails copiés %1$s (API %2$d) Cela arrête toute copie en cours. L\'autre téléphone perd sa progression et doit recommencer avec un nouveau code. + Les appareils connectés à ce point d\'accès perdent leur connexion. diff --git a/controller/app/src/main/res/values-gu/strings.xml b/controller/app/src/main/res/values-gu/strings.xml index 304e09237..0fe3fc4ee 100644 --- a/controller/app/src/main/res/values-gu/strings.xml +++ b/controller/app/src/main/res/values-gu/strings.xml @@ -1612,4 +1612,5 @@ વિગતો કૉપિ થઈ %1$s (API %2$d) આ ચાલુ કોઈપણ નકલ બંધ કરે છે. બીજો ફોન તેની પ્રગતિ ગુમાવે છે અને નવા કોડ સાથે ફરી શરૂ કરવો પડશે. + આ હોટ્સ્પોટ સાથે જોડાયેલા ઉપકરણોનું કનેક્શન તૂટી જશે. diff --git a/controller/app/src/main/res/values-hi/strings.xml b/controller/app/src/main/res/values-hi/strings.xml index 7631c79a6..282c81992 100644 --- a/controller/app/src/main/res/values-hi/strings.xml +++ b/controller/app/src/main/res/values-hi/strings.xml @@ -1676,4 +1676,5 @@ विवरण कॉपी हो गया %1$s (API %2$d) इससे चल रही कोई भी कॉपी रुक जाती है। दूसरा फ़ोन अपनी प्रगति खो देता है और उसे नए कोड के साथ फिर से शुरू करना होगा। + इस हॉटस्पॉट से जुड़े डिवाइस का कनेक्शन टूट जाएगा। diff --git a/controller/app/src/main/res/values-hu/strings.xml b/controller/app/src/main/res/values-hu/strings.xml index a55b5817e..ec104be7e 100644 --- a/controller/app/src/main/res/values-hu/strings.xml +++ b/controller/app/src/main/res/values-hu/strings.xml @@ -1599,4 +1599,5 @@ Részletek másolva %1$s (API %2$d) Ez leállít minden folyamatban lévő másolást. A másik telefon elveszíti az előrehaladását, és új kóddal kell újrakezdenie. + A hotspothoz csatlakozott eszközök elveszítik a kapcsolatot. diff --git a/controller/app/src/main/res/values-in/strings.xml b/controller/app/src/main/res/values-in/strings.xml index 271c61eeb..3112cc63a 100644 --- a/controller/app/src/main/res/values-in/strings.xml +++ b/controller/app/src/main/res/values-in/strings.xml @@ -1606,4 +1606,5 @@ Detail disalin %1$s (API %2$d) Ini menghentikan penyalinan yang sedang berlangsung. Ponsel lain kehilangan progresnya dan harus mulai lagi dengan kode baru. + Perangkat yang tergabung ke hotspot ini akan kehilangan koneksi. diff --git a/controller/app/src/main/res/values-it/strings.xml b/controller/app/src/main/res/values-it/strings.xml index 40cead83b..4b8053f6b 100644 --- a/controller/app/src/main/res/values-it/strings.xml +++ b/controller/app/src/main/res/values-it/strings.xml @@ -1599,4 +1599,5 @@ Dettagli copiati %1$s (API %2$d) Questo interrompe qualsiasi copia in corso. L\'altro telefono perde i progressi e deve ricominciare con un nuovo codice. + I dispositivi connessi a questo hotspot perdono la connessione. diff --git a/controller/app/src/main/res/values-ja/strings.xml b/controller/app/src/main/res/values-ja/strings.xml index 748bf6d56..c728f4f6e 100644 --- a/controller/app/src/main/res/values-ja/strings.xml +++ b/controller/app/src/main/res/values-ja/strings.xml @@ -1600,4 +1600,5 @@ 詳細をコピーしました %1$s (API %2$d) 進行中のコピーはすべて停止します。もう一方のスマートフォンは進捗を失い、新しいコードでやり直す必要があります。 + このホットスポットに接続しているデバイスは接続が切れます。 diff --git a/controller/app/src/main/res/values-ko/strings.xml b/controller/app/src/main/res/values-ko/strings.xml index f2b97ce49..326153593 100644 --- a/controller/app/src/main/res/values-ko/strings.xml +++ b/controller/app/src/main/res/values-ko/strings.xml @@ -1507,7 +1507,7 @@ 핫스팅 주소 찾는 중... 참가 받기 - 이 핫스팅에 참가하려면 다른 휴대전화에서 스캔하세요. + 이 핫스팟에 참가하려면 다른 휴대전화에서 스캔하세요. 이 휴대전화는 공유용 핫스팅을 시작할 수 없습니다. 핫스팅을 시작할 수 없습니다. 공유를 시작할 수 없습니다. @@ -1600,4 +1600,5 @@ 세부정보를 복사했습니다 %1$s (API %2$d) 진행 중인 복사가 모두 중지됩니다. 다른 휴대전화는 진행 상황을 잃으며 새 코드로 다시 시작해야 합니다. + 이 핫스팟에 연결된 기기는 연결이 끊어집니다. diff --git a/controller/app/src/main/res/values-lt/strings.xml b/controller/app/src/main/res/values-lt/strings.xml index 880ae0583..862515fa5 100644 --- a/controller/app/src/main/res/values-lt/strings.xml +++ b/controller/app/src/main/res/values-lt/strings.xml @@ -1616,4 +1616,5 @@ Informacija nukopijuota %1$s (API %2$d) Tai sustabdo bet kokį vykstantį kopijavimą. Kitas telefonas praranda pažangą ir turi pradėti iš naujo su nauju kodu. + Prie šios viešosios interneto prieigos prisijungę įrenginiai praras ryšį. diff --git a/controller/app/src/main/res/values-nl/strings.xml b/controller/app/src/main/res/values-nl/strings.xml index eb1b0a62f..e75f96029 100644 --- a/controller/app/src/main/res/values-nl/strings.xml +++ b/controller/app/src/main/res/values-nl/strings.xml @@ -1599,4 +1599,5 @@ Details gekopieerd %1$s (API %2$d) Dit stopt elke lopende kopie. De andere telefoon verliest zijn voortgang en moet opnieuw beginnen met een nieuwe code. + Apparaten die met deze hotspot zijn verbonden, verliezen hun verbinding. diff --git a/controller/app/src/main/res/values-no/strings.xml b/controller/app/src/main/res/values-no/strings.xml index ad5cd7f2d..8043d2507 100644 --- a/controller/app/src/main/res/values-no/strings.xml +++ b/controller/app/src/main/res/values-no/strings.xml @@ -1609,4 +1609,5 @@ Detaljer kopiert %1$s (API %2$d) Dette stopper all kopiering som pågår. Den andre telefonen mister fremdriften og må starte på nytt med en ny kode. + Enheter som er koblet til denne hotspoten, mister tilkoblingen. diff --git a/controller/app/src/main/res/values-pl/strings.xml b/controller/app/src/main/res/values-pl/strings.xml index 1d6a6a6fa..4cd5c1f89 100644 --- a/controller/app/src/main/res/values-pl/strings.xml +++ b/controller/app/src/main/res/values-pl/strings.xml @@ -1609,4 +1609,5 @@ Skopiowano szczegóły %1$s (API %2$d) To zatrzymuje każde trwające kopiowanie. Drugi telefon traci postęp i musi zacząć od nowa z nowym kodem. + Urządzenia połączone z tym hotspotem utracą połączenie. diff --git a/controller/app/src/main/res/values-pt/strings.xml b/controller/app/src/main/res/values-pt/strings.xml index 49863b5da..dc9ef0597 100644 --- a/controller/app/src/main/res/values-pt/strings.xml +++ b/controller/app/src/main/res/values-pt/strings.xml @@ -1678,4 +1678,5 @@ Detalhes copiados %1$s (API %2$d) Isso interrompe qualquer cópia em andamento. O outro telefone perde o progresso e precisa começar de novo com um novo código. + Os dispositivos ligados a este hotspot perdem a ligação. diff --git a/controller/app/src/main/res/values-ro/strings.xml b/controller/app/src/main/res/values-ro/strings.xml index 1d6548495..4076cc657 100644 --- a/controller/app/src/main/res/values-ro/strings.xml +++ b/controller/app/src/main/res/values-ro/strings.xml @@ -1599,4 +1599,5 @@ Detalii copiate %1$s (API %2$d) Aceasta oprește orice copiere în curs. Celălalt telefon își pierde progresul și trebuie să înceapă din nou cu un cod nou. + Dispozitivele conectate la acest hotspot își pierd conexiunea. diff --git a/controller/app/src/main/res/values-ru-rRU/strings.xml b/controller/app/src/main/res/values-ru-rRU/strings.xml index e69350b5c..a3ab65d2d 100644 --- a/controller/app/src/main/res/values-ru-rRU/strings.xml +++ b/controller/app/src/main/res/values-ru-rRU/strings.xml @@ -1675,4 +1675,5 @@ Сведения скопированы %1$s (API %2$d) Это остановит любое текущее копирование. Другой телефон потеряет прогресс и должен будет начать заново с новым кодом. + Устройства, подключённые к этой точке доступа, потеряют соединение. diff --git a/controller/app/src/main/res/values-sk/strings.xml b/controller/app/src/main/res/values-sk/strings.xml index b214e795b..b354fd7e8 100644 --- a/controller/app/src/main/res/values-sk/strings.xml +++ b/controller/app/src/main/res/values-sk/strings.xml @@ -1606,4 +1606,5 @@ Podrobnosti skopírované %1$s (API %2$d) Tým sa zastaví prebiehajúce kopírovanie. Druhý telefón stratí priebeh a musí začať znova s novým kódom. + Zariadenia pripojené k tomuto hotspotu stratia pripojenie. diff --git a/controller/app/src/main/res/values-sr/strings.xml b/controller/app/src/main/res/values-sr/strings.xml index c5f63585b..085ed6346 100644 --- a/controller/app/src/main/res/values-sr/strings.xml +++ b/controller/app/src/main/res/values-sr/strings.xml @@ -1612,4 +1612,5 @@ Детаљи су копирани %1$s (API %2$d) Ово зауставља свако копирање у току. Други телефон губи напредак и мора да почне поново са новим кодом. + Уређаји повезани на овај хотспот губе везу. diff --git a/controller/app/src/main/res/values-sw/strings.xml b/controller/app/src/main/res/values-sw/strings.xml index 0f6411f46..85af1aefd 100644 --- a/controller/app/src/main/res/values-sw/strings.xml +++ b/controller/app/src/main/res/values-sw/strings.xml @@ -1619,4 +1619,5 @@ Maelezo yamenakiliwa %1$s (API %2$d) Hii inasimamisha unakili wowote unaoendelea. Simu nyingine inapoteza maendeleo yake na lazima ianze upya kwa msimbo mpya. + Vifaa vilivyounganishwa kwenye hotspot hii vitapoteza muunganisho. diff --git a/controller/app/src/main/res/values-ta/strings.xml b/controller/app/src/main/res/values-ta/strings.xml index f7425162b..70f9617a5 100644 --- a/controller/app/src/main/res/values-ta/strings.xml +++ b/controller/app/src/main/res/values-ta/strings.xml @@ -1619,4 +1619,5 @@ விவரங்கள் நகலெடுக்கப்பட்டன %1$s (API %2$d) இது நடந்துகொண்டிருக்கும் எந்த நகலெடுப்பையும் நிறுத்துகிறது. மற்ற ஃபோன் அதன் முன்னேற்றத்தை இழக்கும், புதிய குறியீட்டுடன் மீண்டும் தொடங்க வேண்டும். + இந்த ஹாட்ஸ்பாட்டுடன் இணைந்த சாதனங்கள் இணைப்பை இழக்கும். diff --git a/controller/app/src/main/res/values-tr/strings.xml b/controller/app/src/main/res/values-tr/strings.xml index 3d929a56d..fe0112e03 100644 --- a/controller/app/src/main/res/values-tr/strings.xml +++ b/controller/app/src/main/res/values-tr/strings.xml @@ -1599,4 +1599,5 @@ Ayrıntılar kopyalandı %1$s (API %2$d) Bu, devam eden tüm kopyalamaları durdurur. Diğer telefon ilerlemesini kaybeder ve yeni bir kodla yeniden başlamalıdır. + Bu etkin noktaya bağlı cihazların bağlantısı kesilir. diff --git a/controller/app/src/main/res/values-uk/strings.xml b/controller/app/src/main/res/values-uk/strings.xml index 51376a713..990e23f2d 100644 --- a/controller/app/src/main/res/values-uk/strings.xml +++ b/controller/app/src/main/res/values-uk/strings.xml @@ -1599,4 +1599,5 @@ Відомості скопійовано %1$s (API %2$d) Це зупиняє будь-яке поточне копіювання. Інший телефон втрачає прогрес і має почати знову з новим кодом. + Пристрої, приєднані до цієї точки доступу, втратять з\'єднання. diff --git a/controller/app/src/main/res/values-vi/strings.xml b/controller/app/src/main/res/values-vi/strings.xml index ccf5d9cb3..7626e8260 100644 --- a/controller/app/src/main/res/values-vi/strings.xml +++ b/controller/app/src/main/res/values-vi/strings.xml @@ -1599,4 +1599,5 @@ Đã sao chép chi tiết %1$s (API %2$d) Thao tác này dừng mọi quá trình sao chép đang diễn ra. Điện thoại kia sẽ mất tiến trình và phải bắt đầu lại bằng mã mới. + Các thiết bị đã tham gia điểm phát sóng này sẽ mất kết nối. diff --git a/controller/app/src/main/res/values-yo/strings.xml b/controller/app/src/main/res/values-yo/strings.xml index 8d426bac4..6d87b403c 100644 --- a/controller/app/src/main/res/values-yo/strings.xml +++ b/controller/app/src/main/res/values-yo/strings.xml @@ -1619,4 +1619,5 @@ A ti da àlàyé kọ %1$s (API %2$d) Èyí dá ẹ̀dà èyíkéyìí tí ń lọ lọ́wọ́ dúró. Fóònù kejì yóò pàdánù ìlọsíwájú rẹ̀, ó sì gbọ́dọ̀ bẹ̀rẹ̀ lẹ́ẹ̀kan sí i pẹ̀lú kóòdù tuntun. + Àwọn ẹ̀rọ tí ó darapọ̀ mọ́ hotspot yìí yóò pàdánù ìsopọ̀ wọn. diff --git a/controller/app/src/main/res/values-zh-rCN/strings.xml b/controller/app/src/main/res/values-zh-rCN/strings.xml index fd0d192fa..dd5b5f62d 100644 --- a/controller/app/src/main/res/values-zh-rCN/strings.xml +++ b/controller/app/src/main/res/values-zh-rCN/strings.xml @@ -1600,4 +1600,5 @@ 已复制详细信息 %1$s(API %2$d) 这会停止所有正在进行的复制。另一部手机会丢失进度,必须使用新代码重新开始。 + 已加入此热点的设备将断开连接。 diff --git a/controller/app/src/main/res/values/strings.xml b/controller/app/src/main/res/values/strings.xml index 76dc2ba7a..660d23663 100644 --- a/controller/app/src/main/res/values/strings.xml +++ b/controller/app/src/main/res/values/strings.xml @@ -1796,4 +1796,5 @@ Details copied %1$s (API %2$d) This stops any copy in progress. The other phone loses its progress and must start again with a new code. + Devices joined to this hotspot lose their connection. diff --git a/controller/app/src/main/res/values/strings_untranslated.xml b/controller/app/src/main/res/values/strings_untranslated.xml index e062393d5..c5ed0df5b 100644 --- a/controller/app/src/main/res/values/strings_untranslated.xml +++ b/controller/app/src/main/res/values/strings_untranslated.xml @@ -10,6 +10,5 @@ strings.xml. --> - - Devices joined to this hotspot lose their connection. + From b19761e189cb0f19cc83ff74a96143e68dec5625 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 16 Nov 2026 16:33:06 -0600 Subject: [PATCH 3/3] K2GO-577 fix(hotspot): Share holds the hotspot on its first render, warn only on a real drop The switch warning asks the hotspot owner whether this screen is its last holder. The share notification no longer claims a hotspot on Wi-Fi. --- .../presentation/ContentShareFragment.java | 15 ++++++--------- .../presentation/ContentShareService.java | 2 +- .../appdevforall/k2go/hotspot/HotspotMode.java | 10 ++++++++++ .../k2go/hotspot/LocalHotspotManager.java | 6 ++++++ .../k2go/hotspot/domain/HotspotHolders.java | 5 +++++ .../k2go/redesign/ConnectFragment.java | 4 +--- controller/app/src/main/res/values-ar/strings.xml | 2 +- controller/app/src/main/res/values-az/strings.xml | 2 +- controller/app/src/main/res/values-bg/strings.xml | 2 +- controller/app/src/main/res/values-bn/strings.xml | 2 +- controller/app/src/main/res/values-cs/strings.xml | 2 +- controller/app/src/main/res/values-de/strings.xml | 2 +- controller/app/src/main/res/values-el/strings.xml | 2 +- controller/app/src/main/res/values-es/strings.xml | 2 +- controller/app/src/main/res/values-fa/strings.xml | 2 +- controller/app/src/main/res/values-fr/strings.xml | 2 +- controller/app/src/main/res/values-gu/strings.xml | 2 +- controller/app/src/main/res/values-hi/strings.xml | 2 +- controller/app/src/main/res/values-hu/strings.xml | 2 +- controller/app/src/main/res/values-in/strings.xml | 2 +- controller/app/src/main/res/values-it/strings.xml | 2 +- controller/app/src/main/res/values-ja/strings.xml | 2 +- controller/app/src/main/res/values-ko/strings.xml | 2 +- controller/app/src/main/res/values-lt/strings.xml | 2 +- controller/app/src/main/res/values-nl/strings.xml | 2 +- controller/app/src/main/res/values-no/strings.xml | 2 +- controller/app/src/main/res/values-pl/strings.xml | 2 +- controller/app/src/main/res/values-pt/strings.xml | 2 +- controller/app/src/main/res/values-ro/strings.xml | 2 +- .../app/src/main/res/values-ru-rRU/strings.xml | 2 +- controller/app/src/main/res/values-sk/strings.xml | 2 +- controller/app/src/main/res/values-sr/strings.xml | 2 +- controller/app/src/main/res/values-sw/strings.xml | 2 +- controller/app/src/main/res/values-ta/strings.xml | 2 +- controller/app/src/main/res/values-tr/strings.xml | 2 +- controller/app/src/main/res/values-uk/strings.xml | 2 +- controller/app/src/main/res/values-vi/strings.xml | 2 +- controller/app/src/main/res/values-yo/strings.xml | 2 +- .../app/src/main/res/values-zh-rCN/strings.xml | 2 +- controller/app/src/main/res/values/strings.xml | 2 +- .../k2go/hotspot/HotspotModeTest.java | 14 ++++++++++++++ .../k2go/hotspot/domain/HotspotHoldersTest.java | 9 +++++++++ 42 files changed, 86 insertions(+), 47 deletions(-) diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java index 8a1066679..df58e63f9 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareFragment.java @@ -153,11 +153,6 @@ public void onResume() { render(); } }); - // Apply the choice on entry and on every return: Hotspot holds the hotspot (asks the - // permission once), Wi-Fi keeps it released. - if (session.hasSession() && mode().ensure()) { - hotspotPerm.launch(HotspotPermissions.required()); - } render(); } @@ -189,6 +184,11 @@ private void render() { goBack(); return; } + // Apply the choice on every render, not only on resume: the service opens the session after + // this screen first resumes. Hotspot holds the hotspot and asks the permission at most once. + if (mode().ensure()) { + hotspotPerm.launch(HotspotPermissions.required()); + } // Same "N selected : size" line Content manager showed before Share. subtitle.setText(getString(R.string.k2go_cx_selected_fmt, session.itemCount(), ByteFormatter.humanBytes(session.totalBytes()))); @@ -290,10 +290,7 @@ private void showInviteText(@Nullable String invite) { * after a denied permission). */ private void requestMode(HotspotMode.Mode target) { - LocalHotspotManager.State st = hs.state().getValue(); - boolean dropsClients = mode().isHotspot() && target == HotspotMode.Mode.WIFI - && st != null && st.mayHaveClients(); - if (!dropsClients) { + if (!mode().switchDropsClients(target)) { setMode(target); return; } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java index bc7fcbf3a..f4764c90b 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/contentexchange/presentation/ContentShareService.java @@ -244,7 +244,7 @@ private Notification buildNotification() { PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); return new NotificationCompat.Builder(this, CHANNEL_ID) .setContentTitle(getString(R.string.k2go_cx_share_notif_title)) - .setContentText(getString(R.string.k2go_cx_share_notif_text)) + .setContentText(getString(R.string.k2go_cx_share_notif_open)) .setSmallIcon(android.R.drawable.stat_sys_upload) .setOngoing(true) .setPriority(NotificationCompat.PRIORITY_LOW) diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java index 301dee296..d27e9d576 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/HotspotMode.java @@ -28,6 +28,7 @@ public interface Port { boolean isOn(); void acquire(); void release(); + boolean releaseDropsClients(); } private final Port port; @@ -51,6 +52,7 @@ public static HotspotMode of(Context context, HotspotHolders.Holder holder, Mode @Override public boolean isOn() { return hs.isOn(); } @Override public void acquire() { hs.acquire(app, holder); } @Override public void release() { hs.release(holder); } + @Override public boolean releaseDropsClients() { return hs.releaseDropsClients(holder); } }, initial); } @@ -96,6 +98,14 @@ public boolean ensure() { return false; } + /** + * True when a switch to [target] turns off a hotspot that someone may be joined to: this screen + * is its last holder. The screen asks the user first. + */ + public boolean switchDropsClients(Mode target) { + return mode == Mode.HOTSPOT && target == Mode.WIFI && port.releaseDropsClients(); + } + /** Re-apply on a return to the screen or after the permission answer; never asks again. */ public void resume() { if (mode == Mode.WIFI || port.permitted()) { diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java index 318a1ef56..37f69e68e 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/LocalHotspotManager.java @@ -329,6 +329,12 @@ public void acquire(Context context, HotspotHolders.Holder holder) { start(context); } + /** True when releasing [holder] stops a hotspot that someone is, or may be, joined to. */ + public boolean releaseDropsClients(HotspotHolders.Holder holder) { + State s = state.getValue(); + return s != null && s.mayHaveClients() && holders.isOnly(holder); + } + /** [holder] no longer needs the hotspot. Stops it when no other holder is left. */ public void release(HotspotHolders.Holder holder) { if (holders.releaseLast(holder)) stop(); diff --git a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/HotspotHolders.java b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/HotspotHolders.java index f007873ed..a255101a7 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/HotspotHolders.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/hotspot/domain/HotspotHolders.java @@ -26,6 +26,11 @@ public synchronized boolean releaseLast(Holder holder) { return held.remove(holder) && held.isEmpty(); } + /** True when [holder] is the only one left, so its release stops the hotspot. */ + public synchronized boolean isOnly(Holder holder) { + return held.size() == 1 && held.contains(holder); + } + /** The hotspot went down for everyone. */ public synchronized void clear() { held.clear(); } diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java index ce7321e98..fcc4f9cde 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/ConnectFragment.java @@ -124,9 +124,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c /** A tab tap. Leaving Hotspot gives it back and drops joined devices, so warn when some may be on. */ private void requestMode(Mode target) { - LocalHotspotManager.State st = hs.state().getValue(); - boolean dropsClients = hsMode.isHotspot() && target == Mode.WIFI && st != null && st.mayHaveClients(); - if (!dropsClients) { setMode(target); return; } + if (!hsMode.switchDropsClients(target)) { setMode(target); return; } new BrandDialog(requireContext()) .setTitle(getString(R.string.k2go_clone_switch_title, getString(R.string.k2go_wifi))) .setMessage(R.string.k2go_connect_switch_msg) diff --git a/controller/app/src/main/res/values-ar/strings.xml b/controller/app/src/main/res/values-ar/strings.xml index 133bf9f31..a614ad3af 100644 --- a/controller/app/src/main/res/values-ar/strings.xml +++ b/controller/app/src/main/res/values-ar/strings.xml @@ -1514,7 +1514,6 @@ تم إيقاف جارٍ مشاركة المحتوى - تظل نقطة الاتصال والمشاركة مفتوحتين. مشاركة المحتوى إظهار أو إخفاء العناصر @@ -1600,4 +1599,5 @@ %1$s (API %2$d) هذا يوقف أي نسخ جارٍ. يفقد الهاتف الآخر تقدّمه ويجب أن يبدأ من جديد برمز جديد. تفقد الأجهزة المتصلة بنقطة الاتصال هذه اتصالها. + تبقى المشاركة مفتوحة حتى توقفها. diff --git a/controller/app/src/main/res/values-az/strings.xml b/controller/app/src/main/res/values-az/strings.xml index 47eae61f5..a3836f449 100644 --- a/controller/app/src/main/res/values-az/strings.xml +++ b/controller/app/src/main/res/values-az/strings.xml @@ -1534,7 +1534,6 @@ Hazırdır Dayandır Məzmun paylaşılır - Hotspot və paylaşma açıq qalır. Məzmun paylaşımı Elementləri göstər və ya gizlət @@ -1620,4 +1619,5 @@ %1$s (API %2$d) Bu, davam edən istənilən köçürməni dayandırır. Digər telefon irəliləyişini itirir və yeni kodla yenidən başlamalıdır. Bu hotspota qoşulmuş cihazların bağlantısı kəsiləcək. + Paylaşım siz dayandırana qədər açıq qalır. diff --git a/controller/app/src/main/res/values-bg/strings.xml b/controller/app/src/main/res/values-bg/strings.xml index 30b0fdcb3..3b5fabc09 100644 --- a/controller/app/src/main/res/values-bg/strings.xml +++ b/controller/app/src/main/res/values-bg/strings.xml @@ -1521,7 +1521,6 @@ Готово Спиране Споделяне на съдържание - Точката за достъп и споделянето остават отворени. Споделяне на съдържание Показване или скриване на елементите @@ -1607,4 +1606,5 @@ %1$s (API %2$d) Това спира всяко копиране в ход. Другият телефон губи напредъка си и трябва да започне отново с нов код. Устройствата, свързани към тази точка за достъп, губят връзката си. + Споделянето остава отворено, докато не го спрете. diff --git a/controller/app/src/main/res/values-bn/strings.xml b/controller/app/src/main/res/values-bn/strings.xml index 9b66716c7..276d301c8 100644 --- a/controller/app/src/main/res/values-bn/strings.xml +++ b/controller/app/src/main/res/values-bn/strings.xml @@ -1527,7 +1527,6 @@ সম্পন্ন বন্ধ করুন কন্টেন্ট শেয়ার করা হচ্ছে - হটস্পট এবং শেয়ার খোলা থাকে। কন্টেন্ট শেয়ারিং আইটেম দেখান বা লুকান @@ -1613,4 +1612,5 @@ %1$s (API %2$d) এটি চলমান যেকোনো কপি বন্ধ করে। অন্য ফোনটি তার অগ্রগতি হারায় এবং নতুন কোড দিয়ে আবার শুরু করতে হবে। এই হটস্পটে যুক্ত ডিভাইসগুলির সংযোগ বিচ্ছিন্ন হবে। + আপনি বন্ধ না করা পর্যন্ত শেয়ার খোলা থাকে। diff --git a/controller/app/src/main/res/values-cs/strings.xml b/controller/app/src/main/res/values-cs/strings.xml index 2a208708b..b217ec120 100644 --- a/controller/app/src/main/res/values-cs/strings.xml +++ b/controller/app/src/main/res/values-cs/strings.xml @@ -1521,7 +1521,6 @@ Hotovo Zastavit Sdílení obsahu - Hotspot a sdílení zůstávají otevřené. Sdílení obsahu Zobrazit nebo skrýt položky @@ -1607,4 +1606,5 @@ %1$s (API %2$d) Tím se zastaví probíhající kopírování. Druhý telefon ztratí průběh a musí začít znovu s novým kódem. Zařízení připojená k tomuto hotspotu ztratí připojení. + Sdílení zůstane otevřené, dokud ho nezastavíte. diff --git a/controller/app/src/main/res/values-de/strings.xml b/controller/app/src/main/res/values-de/strings.xml index 50803dd53..152caa751 100644 --- a/controller/app/src/main/res/values-de/strings.xml +++ b/controller/app/src/main/res/values-de/strings.xml @@ -1514,7 +1514,6 @@ Fertig Stopp Inhalt wird geteilt - Der Hotspot und die Freigabe bleiben geöffnet. Inhaltsfreigabe Elemente ein- oder ausblenden @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Dadurch wird jede laufende Kopie gestoppt. Das andere Telefon verliert seinen Fortschritt und muss mit einem neuen Code neu beginnen. Geräte, die mit diesem Hotspot verbunden sind, verlieren ihre Verbindung. + Die Freigabe bleibt offen, bis Sie sie beenden. diff --git a/controller/app/src/main/res/values-el/strings.xml b/controller/app/src/main/res/values-el/strings.xml index 51d6b7b4e..47a99d3a8 100644 --- a/controller/app/src/main/res/values-el/strings.xml +++ b/controller/app/src/main/res/values-el/strings.xml @@ -1521,7 +1521,6 @@ Τέλος Διακοπή Κοινή χρήση περιεχομένου - Το hotspot και η κοινή χρήση παραμένουν ανοιχτά. Κοινή χρήση περιεχομένου Εμφάνιση ή απόκρυψη στοιχείων @@ -1607,4 +1606,5 @@ %1$s (API %2$d) Αυτό σταματά κάθε αντιγραφή σε εξέλιξη. Το άλλο τηλέφωνο χάνει την πρόοδό του και πρέπει να ξεκινήσει ξανά με νέο κωδικό. Οι συσκευές που είναι συνδεδεμένες σε αυτό το hotspot χάνουν τη σύνδεσή τους. + Η κοινή χρήση παραμένει ανοιχτή μέχρι να τη σταματήσετε. diff --git a/controller/app/src/main/res/values-es/strings.xml b/controller/app/src/main/res/values-es/strings.xml index 4bf4d7840..1e8787468 100644 --- a/controller/app/src/main/res/values-es/strings.xml +++ b/controller/app/src/main/res/values-es/strings.xml @@ -1590,7 +1590,6 @@ Listo Detener Compartiendo contenido - El punto de acceso y el uso compartido permanecen abiertos. Uso compartido de contenido Mostrar u ocultar elementos @@ -1676,4 +1675,5 @@ %1$s (API %2$d) Esto detiene cualquier copia en curso. El otro teléfono pierde su avance y debe empezar de nuevo con un código nuevo. Los dispositivos conectados a este punto de acceso pierden la conexión. + El uso compartido sigue abierto hasta que lo detengas. diff --git a/controller/app/src/main/res/values-fa/strings.xml b/controller/app/src/main/res/values-fa/strings.xml index 9c19d49eb..126429f2d 100644 --- a/controller/app/src/main/res/values-fa/strings.xml +++ b/controller/app/src/main/res/values-fa/strings.xml @@ -1514,7 +1514,6 @@ انجام شد توقف در حال اشتراک‌گذاری محتوا - نقطه اتصال و اشتراک‌گذاری باز می‌مانند. اشتراک‌گذاری محتوا نمایش یا پنهان کردن موارد @@ -1600,4 +1599,5 @@ %1$s (API %2$d) این کار هر کپی در حال انجام را متوقف می‌کند. تلفن دیگر پیشرفت خود را از دست می‌دهد و باید با یک کد جدید دوباره شروع کند. دستگاه‌های متصل به این نقطه اتصال، اتصال خود را از دست می‌دهند. + اشتراک‌گذاری تا زمانی که آن را متوقف کنید باز می‌ماند. diff --git a/controller/app/src/main/res/values-fr/strings.xml b/controller/app/src/main/res/values-fr/strings.xml index da1b6f43c..bccf91deb 100644 --- a/controller/app/src/main/res/values-fr/strings.xml +++ b/controller/app/src/main/res/values-fr/strings.xml @@ -1601,7 +1601,6 @@ Terminé Arrêter Partage du contenu - Le point d\'accès et le partage restent ouverts. Partage de contenu Afficher ou masquer les éléments @@ -1687,4 +1686,5 @@ %1$s (API %2$d) Cela arrête toute copie en cours. L\'autre téléphone perd sa progression et doit recommencer avec un nouveau code. Les appareils connectés à ce point d\'accès perdent leur connexion. + Le partage reste ouvert jusqu\'à ce que vous l\'arrêtiez. diff --git a/controller/app/src/main/res/values-gu/strings.xml b/controller/app/src/main/res/values-gu/strings.xml index 0fe3fc4ee..e089a0228 100644 --- a/controller/app/src/main/res/values-gu/strings.xml +++ b/controller/app/src/main/res/values-gu/strings.xml @@ -1527,7 +1527,6 @@ પૂર્ણ થયું બંધ કરો સામગ્રી શેર કરી રહ્યા છે - હોટ્સ્પોટ અને શેરિંગ ખુલ્લા રહે છે. સામગ્રી શેરिંગ આઇટમ્સ બતાવો અથવા છુપાવો @@ -1613,4 +1612,5 @@ %1$s (API %2$d) આ ચાલુ કોઈપણ નકલ બંધ કરે છે. બીજો ફોન તેની પ્રગતિ ગુમાવે છે અને નવા કોડ સાથે ફરી શરૂ કરવો પડશે. આ હોટ્સ્પોટ સાથે જોડાયેલા ઉપકરણોનું કનેક્શન તૂટી જશે. + તમે તેને બંધ ન કરો ત્યાં સુધી શેર ખુલ્લું રહે છે. diff --git a/controller/app/src/main/res/values-hi/strings.xml b/controller/app/src/main/res/values-hi/strings.xml index 282c81992..5c20212c7 100644 --- a/controller/app/src/main/res/values-hi/strings.xml +++ b/controller/app/src/main/res/values-hi/strings.xml @@ -1591,7 +1591,6 @@ हो गया रोकें सामग्री साझा की जा रही है - हॉटस्पॉट और शेयरिंग खुले रहते हैं। सामग्री शेयरिंग आइटम दिखाएँ या छिपाएँ @@ -1677,4 +1676,5 @@ %1$s (API %2$d) इससे चल रही कोई भी कॉपी रुक जाती है। दूसरा फ़ोन अपनी प्रगति खो देता है और उसे नए कोड के साथ फिर से शुरू करना होगा। इस हॉटस्पॉट से जुड़े डिवाइस का कनेक्शन टूट जाएगा। + जब तक आप इसे रोकते नहीं, साझा करना खुला रहता है। diff --git a/controller/app/src/main/res/values-hu/strings.xml b/controller/app/src/main/res/values-hu/strings.xml index ec104be7e..8333c86c2 100644 --- a/controller/app/src/main/res/values-hu/strings.xml +++ b/controller/app/src/main/res/values-hu/strings.xml @@ -1514,7 +1514,6 @@ Kész Leállítás Tartalom megosztása - A hotspot és a megosztás nyitva marad. Tartalommegosztás Elemek megjelenítése vagy elrejtése @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Ez leállít minden folyamatban lévő másolást. A másik telefon elveszíti az előrehaladását, és új kóddal kell újrakezdenie. A hotspothoz csatlakozott eszközök elveszítik a kapcsolatot. + A megosztás nyitva marad, amíg le nem állítja. diff --git a/controller/app/src/main/res/values-in/strings.xml b/controller/app/src/main/res/values-in/strings.xml index 3112cc63a..db6a4f30a 100644 --- a/controller/app/src/main/res/values-in/strings.xml +++ b/controller/app/src/main/res/values-in/strings.xml @@ -1521,7 +1521,6 @@ Selesai Hentikan Membagikan konten - Hotspot dan sesi berbagi tetap terbuka. Berbagi konten Tampilkan atau sembunyikan item @@ -1607,4 +1606,5 @@ %1$s (API %2$d) Ini menghentikan penyalinan yang sedang berlangsung. Ponsel lain kehilangan progresnya dan harus mulai lagi dengan kode baru. Perangkat yang tergabung ke hotspot ini akan kehilangan koneksi. + Berbagi tetap terbuka sampai Anda menghentikannya. diff --git a/controller/app/src/main/res/values-it/strings.xml b/controller/app/src/main/res/values-it/strings.xml index 4b8053f6b..749e1bfa0 100644 --- a/controller/app/src/main/res/values-it/strings.xml +++ b/controller/app/src/main/res/values-it/strings.xml @@ -1514,7 +1514,6 @@ Fatto Interrompi Condivisione dei contenuti - L\'hotspot e la condivisione restano aperti. Condivisione contenuti Mostra o nascondi gli elementi @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Questo interrompe qualsiasi copia in corso. L\'altro telefono perde i progressi e deve ricominciare con un nuovo codice. I dispositivi connessi a questo hotspot perdono la connessione. + La condivisione resta aperta finché non la interrompi. diff --git a/controller/app/src/main/res/values-ja/strings.xml b/controller/app/src/main/res/values-ja/strings.xml index c728f4f6e..9ac2f1aae 100644 --- a/controller/app/src/main/res/values-ja/strings.xml +++ b/controller/app/src/main/res/values-ja/strings.xml @@ -1515,7 +1515,6 @@ 完了 停止 コンテンツを共有中 - ホットスポットと共有は開いたままになります。 コンテンツ共有 項目を表示または非表示 @@ -1601,4 +1600,5 @@ %1$s (API %2$d) 進行中のコピーはすべて停止します。もう一方のスマートフォンは進捗を失い、新しいコードでやり直す必要があります。 このホットスポットに接続しているデバイスは接続が切れます。 + 停止するまで共有は開いたままです。 diff --git a/controller/app/src/main/res/values-ko/strings.xml b/controller/app/src/main/res/values-ko/strings.xml index 326153593..39269ea41 100644 --- a/controller/app/src/main/res/values-ko/strings.xml +++ b/controller/app/src/main/res/values-ko/strings.xml @@ -1515,7 +1515,6 @@ 완료 중지 콘텐츠 공유 중 - 핫스팅과 공유가 열린 상태로 유지됩니다. 콘텐츠 공유 항목 표시 또는 숨기기 @@ -1601,4 +1600,5 @@ %1$s (API %2$d) 진행 중인 복사가 모두 중지됩니다. 다른 휴대전화는 진행 상황을 잃으며 새 코드로 다시 시작해야 합니다. 이 핫스팟에 연결된 기기는 연결이 끊어집니다. + 중지할 때까지 공유가 열려 있습니다. diff --git a/controller/app/src/main/res/values-lt/strings.xml b/controller/app/src/main/res/values-lt/strings.xml index 862515fa5..93e2741da 100644 --- a/controller/app/src/main/res/values-lt/strings.xml +++ b/controller/app/src/main/res/values-lt/strings.xml @@ -1531,7 +1531,6 @@ Atlikta Stabdyti Bendrinamas turinys - Viešoji interneto prieiga ir bendrinimas lieka atidaryti. Turinio bendrinimas Rodyti arba slėpti elementus @@ -1617,4 +1616,5 @@ %1$s (API %2$d) Tai sustabdo bet kokį vykstantį kopijavimą. Kitas telefonas praranda pažangą ir turi pradėti iš naujo su nauju kodu. Prie šios viešosios interneto prieigos prisijungę įrenginiai praras ryšį. + Bendrinimas lieka atviras, kol jo nesustabdysite. diff --git a/controller/app/src/main/res/values-nl/strings.xml b/controller/app/src/main/res/values-nl/strings.xml index e75f96029..ce775c68f 100644 --- a/controller/app/src/main/res/values-nl/strings.xml +++ b/controller/app/src/main/res/values-nl/strings.xml @@ -1514,7 +1514,6 @@ Klaar Stoppen Inhoud delen - De hotspot en het delen blijven open. Inhoud delen Items tonen of verbergen @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Dit stopt elke lopende kopie. De andere telefoon verliest zijn voortgang en moet opnieuw beginnen met een nieuwe code. Apparaten die met deze hotspot zijn verbonden, verliezen hun verbinding. + Het delen blijft open tot je het stopt. diff --git a/controller/app/src/main/res/values-no/strings.xml b/controller/app/src/main/res/values-no/strings.xml index 8043d2507..28b58eda9 100644 --- a/controller/app/src/main/res/values-no/strings.xml +++ b/controller/app/src/main/res/values-no/strings.xml @@ -1524,7 +1524,6 @@ Ferdig Stopp Deler innhold - Hotspoten og delingen forblir åpne. Innholdsdeling Vis eller skjul elementer @@ -1610,4 +1609,5 @@ %1$s (API %2$d) Dette stopper all kopiering som pågår. Den andre telefonen mister fremdriften og må starte på nytt med en ny kode. Enheter som er koblet til denne hotspoten, mister tilkoblingen. + Delingen er åpen til du stopper den. diff --git a/controller/app/src/main/res/values-pl/strings.xml b/controller/app/src/main/res/values-pl/strings.xml index 4cd5c1f89..bca14d7ec 100644 --- a/controller/app/src/main/res/values-pl/strings.xml +++ b/controller/app/src/main/res/values-pl/strings.xml @@ -1524,7 +1524,6 @@ Gotowe Zatrzymaj Udostępnianie zawartości - Hotspot i udostępnianie pozostają otwarte. Udostępnianie zawartości Pokaż lub ukryj elementy @@ -1610,4 +1609,5 @@ %1$s (API %2$d) To zatrzymuje każde trwające kopiowanie. Drugi telefon traci postęp i musi zacząć od nowa z nowym kodem. Urządzenia połączone z tym hotspotem utracą połączenie. + Udostępnianie pozostaje otwarte, dopóki go nie zatrzymasz. diff --git a/controller/app/src/main/res/values-pt/strings.xml b/controller/app/src/main/res/values-pt/strings.xml index dc9ef0597..7e15f3d9f 100644 --- a/controller/app/src/main/res/values-pt/strings.xml +++ b/controller/app/src/main/res/values-pt/strings.xml @@ -1593,7 +1593,6 @@ Concluído Parar A partilhar conteúdo - O hotspot e a partilha permanecem abertos. Partilha de conteúdo Mostrar ou ocultar itens @@ -1679,4 +1678,5 @@ %1$s (API %2$d) Isso interrompe qualquer cópia em andamento. O outro telefone perde o progresso e precisa começar de novo com um novo código. Os dispositivos ligados a este hotspot perdem a ligação. + A partilha fica aberta até a parar. diff --git a/controller/app/src/main/res/values-ro/strings.xml b/controller/app/src/main/res/values-ro/strings.xml index 4076cc657..b5439fe1c 100644 --- a/controller/app/src/main/res/values-ro/strings.xml +++ b/controller/app/src/main/res/values-ro/strings.xml @@ -1514,7 +1514,6 @@ Gata Oprește Se partajează conținutul - Hotspotul și partajarea rămân deschise. Partajarea conținutului Afișați sau ascundeți elementele @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Aceasta oprește orice copiere în curs. Celălalt telefon își pierde progresul și trebuie să înceapă din nou cu un cod nou. Dispozitivele conectate la acest hotspot își pierd conexiunea. + Partajarea rămâne deschisă până când o oprești. diff --git a/controller/app/src/main/res/values-ru-rRU/strings.xml b/controller/app/src/main/res/values-ru-rRU/strings.xml index a3ab65d2d..66160708f 100644 --- a/controller/app/src/main/res/values-ru-rRU/strings.xml +++ b/controller/app/src/main/res/values-ru-rRU/strings.xml @@ -1590,7 +1590,6 @@ Готово Остановить Отправка контента - Точка доступа и обмен остаются открытыми. Обмен контентом Показать или скрыть элементы @@ -1676,4 +1675,5 @@ %1$s (API %2$d) Это остановит любое текущее копирование. Другой телефон потеряет прогресс и должен будет начать заново с новым кодом. Устройства, подключённые к этой точке доступа, потеряют соединение. + Передача остаётся открытой, пока вы её не остановите. diff --git a/controller/app/src/main/res/values-sk/strings.xml b/controller/app/src/main/res/values-sk/strings.xml index b354fd7e8..64b07ab77 100644 --- a/controller/app/src/main/res/values-sk/strings.xml +++ b/controller/app/src/main/res/values-sk/strings.xml @@ -1521,7 +1521,6 @@ Hotovo Zastaviť Zdieľanie obsahu - Hotspot a zdieľanie zóstajú otvorené. Zdieľanie obsahu Zobraziť alebo skryť položky @@ -1607,4 +1606,5 @@ %1$s (API %2$d) Tým sa zastaví prebiehajúce kopírovanie. Druhý telefón stratí priebeh a musí začať znova s novým kódom. Zariadenia pripojené k tomuto hotspotu stratia pripojenie. + Zdieľanie zostane otvorené, kým ho nezastavíte. diff --git a/controller/app/src/main/res/values-sr/strings.xml b/controller/app/src/main/res/values-sr/strings.xml index 085ed6346..61206cffa 100644 --- a/controller/app/src/main/res/values-sr/strings.xml +++ b/controller/app/src/main/res/values-sr/strings.xml @@ -1527,7 +1527,6 @@ Готово Заустави Дељење садржаја - Хотспот и дељење остају отворени. Дељење садржаја Прикажи или сакриј ставке @@ -1613,4 +1612,5 @@ %1$s (API %2$d) Ово зауставља свако копирање у току. Други телефон губи напредак и мора да почне поново са новим кодом. Уређаји повезани на овај хотспот губе везу. + Дељење остаје отворено док га не зауставите. diff --git a/controller/app/src/main/res/values-sw/strings.xml b/controller/app/src/main/res/values-sw/strings.xml index 85af1aefd..8a8e85b50 100644 --- a/controller/app/src/main/res/values-sw/strings.xml +++ b/controller/app/src/main/res/values-sw/strings.xml @@ -1534,7 +1534,6 @@ Imekamilika Simamisha Inashiriki maudhui - Hotspot na ushirikishaji vinasalia wazi. Ushirikishaji wa maudhui Onyesha au ficha vipengele @@ -1620,4 +1619,5 @@ %1$s (API %2$d) Hii inasimamisha unakili wowote unaoendelea. Simu nyingine inapoteza maendeleo yake na lazima ianze upya kwa msimbo mpya. Vifaa vilivyounganishwa kwenye hotspot hii vitapoteza muunganisho. + Kushiriki kunabaki wazi hadi ukisimamishe. diff --git a/controller/app/src/main/res/values-ta/strings.xml b/controller/app/src/main/res/values-ta/strings.xml index 70f9617a5..a84e02c90 100644 --- a/controller/app/src/main/res/values-ta/strings.xml +++ b/controller/app/src/main/res/values-ta/strings.xml @@ -1534,7 +1534,6 @@ முடிந்தது நிறுத்து உள்ளடக்கம் பகிரப்படுகிறது - ஹாட்ஸ்பாட்டும் பகிர்வும் திறந்தே இருக்கும். உள்ளடக்கப் பகிர்வு உருப்படிகளைக் காட்டு அல்லது மறை @@ -1620,4 +1619,5 @@ %1$s (API %2$d) இது நடந்துகொண்டிருக்கும் எந்த நகலெடுப்பையும் நிறுத்துகிறது. மற்ற ஃபோன் அதன் முன்னேற்றத்தை இழக்கும், புதிய குறியீட்டுடன் மீண்டும் தொடங்க வேண்டும். இந்த ஹாட்ஸ்பாட்டுடன் இணைந்த சாதனங்கள் இணைப்பை இழக்கும். + நீங்கள் நிறுத்தும் வரை பகிர்வு திறந்திருக்கும். diff --git a/controller/app/src/main/res/values-tr/strings.xml b/controller/app/src/main/res/values-tr/strings.xml index fe0112e03..5fcf6c70d 100644 --- a/controller/app/src/main/res/values-tr/strings.xml +++ b/controller/app/src/main/res/values-tr/strings.xml @@ -1514,7 +1514,6 @@ Bitti Durdur İçerik paylaşılıyor - Etkin nokta ve paylaşım açık kalır. İçerik paylaşımı Öğeleri göster veya gizle @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Bu, devam eden tüm kopyalamaları durdurur. Diğer telefon ilerlemesini kaybeder ve yeni bir kodla yeniden başlamalıdır. Bu etkin noktaya bağlı cihazların bağlantısı kesilir. + Paylaşım siz durdurana kadar açık kalır. diff --git a/controller/app/src/main/res/values-uk/strings.xml b/controller/app/src/main/res/values-uk/strings.xml index 990e23f2d..baf06f272 100644 --- a/controller/app/src/main/res/values-uk/strings.xml +++ b/controller/app/src/main/res/values-uk/strings.xml @@ -1514,7 +1514,6 @@ Готово Зупинити Надсилання вмісту - Точка доступу та надсилання залишаються відкритими. Обмін вмістом Показати або сховати елементи @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Це зупиняє будь-яке поточне копіювання. Інший телефон втрачає прогрес і має почати знову з новим кодом. Пристрої, приєднані до цієї точки доступу, втратять з\'єднання. + Надсилання залишається відкритим, доки ви його не зупините. diff --git a/controller/app/src/main/res/values-vi/strings.xml b/controller/app/src/main/res/values-vi/strings.xml index 7626e8260..bf4301830 100644 --- a/controller/app/src/main/res/values-vi/strings.xml +++ b/controller/app/src/main/res/values-vi/strings.xml @@ -1514,7 +1514,6 @@ Xong Dừng Đang chia sẻ nội dung - Điểm phát sóng và phiên chia sẻ vẫn mở. Chia sẻ nội dung Hiện hoặc ẩn các mục @@ -1600,4 +1599,5 @@ %1$s (API %2$d) Thao tác này dừng mọi quá trình sao chép đang diễn ra. Điện thoại kia sẽ mất tiến trình và phải bắt đầu lại bằng mã mới. Các thiết bị đã tham gia điểm phát sóng này sẽ mất kết nối. + Chia sẻ vẫn mở cho đến khi bạn dừng. diff --git a/controller/app/src/main/res/values-yo/strings.xml b/controller/app/src/main/res/values-yo/strings.xml index 6d87b403c..781162d84 100644 --- a/controller/app/src/main/res/values-yo/strings.xml +++ b/controller/app/src/main/res/values-yo/strings.xml @@ -1534,7 +1534,6 @@ Ó parí Dúró ń pín àkóónú - Hotspot àti pínpín yóò wà ní ṣíṣí. Pínpín àkóónú Fi han tabi fi awọn nkan pamọ @@ -1620,4 +1619,5 @@ %1$s (API %2$d) Èyí dá ẹ̀dà èyíkéyìí tí ń lọ lọ́wọ́ dúró. Fóònù kejì yóò pàdánù ìlọsíwájú rẹ̀, ó sì gbọ́dọ̀ bẹ̀rẹ̀ lẹ́ẹ̀kan sí i pẹ̀lú kóòdù tuntun. Àwọn ẹ̀rọ tí ó darapọ̀ mọ́ hotspot yìí yóò pàdánù ìsopọ̀ wọn. + Pínpín yóò wà ní ṣíṣí títí o fi dá a dúró. diff --git a/controller/app/src/main/res/values-zh-rCN/strings.xml b/controller/app/src/main/res/values-zh-rCN/strings.xml index dd5b5f62d..654ab80ba 100644 --- a/controller/app/src/main/res/values-zh-rCN/strings.xml +++ b/controller/app/src/main/res/values-zh-rCN/strings.xml @@ -1515,7 +1515,6 @@ 完成 停止 正在共享内容 - 热点和共享将保持打开状态。 内容共享 显示或隐藏项目 @@ -1601,4 +1600,5 @@ %1$s(API %2$d) 这会停止所有正在进行的复制。另一部手机会丢失进度,必须使用新代码重新开始。 已加入此热点的设备将断开连接。 + 共享会保持开启,直到你停止。 diff --git a/controller/app/src/main/res/values/strings.xml b/controller/app/src/main/res/values/strings.xml index 660d23663..906f98b63 100644 --- a/controller/app/src/main/res/values/strings.xml +++ b/controller/app/src/main/res/values/strings.xml @@ -1709,7 +1709,6 @@ Done Stop Sharing content - The hotspot and the share stay open. Content sharing Show or hide items @@ -1797,4 +1796,5 @@ %1$s (API %2$d) This stops any copy in progress. The other phone loses its progress and must start again with a new code. Devices joined to this hotspot lose their connection. + The share stays open until you stop it. diff --git a/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java index b5469b29a..040033e86 100644 --- a/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java +++ b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/HotspotModeTest.java @@ -15,12 +15,14 @@ private static final class FakePort implements HotspotMode.Port { boolean on; int acquires; int releases; + boolean dropsClients; @Override public boolean supported() { return supported; } @Override public boolean permitted() { return permitted; } @Override public boolean isOn() { return on; } @Override public void acquire() { acquires++; on = true; } @Override public void release() { releases++; } + @Override public boolean releaseDropsClients() { return dropsClients; } } @Test @@ -68,6 +70,18 @@ public void unsupportedPhoneNeverAsksNorHolds() { assertEquals(0, port.acquires); } + @Test + public void onlyLeavingHotspotWithClientsWarns() { + FakePort port = new FakePort(); + HotspotMode m = new HotspotMode(port, HotspotMode.Mode.HOTSPOT); + assertFalse(m.switchDropsClients(HotspotMode.Mode.WIFI)); // nobody joined, or another holder + port.dropsClients = true; + assertTrue(m.switchDropsClients(HotspotMode.Mode.WIFI)); + assertFalse(m.switchDropsClients(HotspotMode.Mode.HOTSPOT)); + m.choose(HotspotMode.Mode.WIFI); + assertFalse(m.switchDropsClients(HotspotMode.Mode.WIFI)); + } + @Test public void releaseGivesBackTheHold() { FakePort port = new FakePort(); diff --git a/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/HotspotHoldersTest.java b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/HotspotHoldersTest.java index 5ad0a87e1..82111ec75 100644 --- a/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/HotspotHoldersTest.java +++ b/controller/app/src/test/java/org/appdevforall/k2go/hotspot/domain/HotspotHoldersTest.java @@ -53,4 +53,13 @@ public final class HotspotHoldersTest { assertTrue(h.isEmpty()); assertFalse(h.releaseLast(Holder.CONNECT)); } + + @Test public void isOnly_trueOnlyForTheLastHolder() { + HotspotHolders h = new HotspotHolders(); + assertFalse(h.isOnly(Holder.CONNECT)); + h.add(Holder.CONNECT); + assertTrue(h.isOnly(Holder.CONNECT)); + h.add(Holder.CONTENT_SHARE); // K2GO-577: Connect's release keeps the hotspot up for Share + assertFalse(h.isOnly(Holder.CONNECT)); + } }