From 05205190ee65a5fa14f18d12f86f5427368bea44 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 16 Mar 2020 23:49:13 +0100 Subject: fix tethering hint (#8979) --- .../bitmaskclient/fragments/TetheringDialog.java | 47 +++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/se/leap/bitmaskclient/fragments/TetheringDialog.java b/app/src/main/java/se/leap/bitmaskclient/fragments/TetheringDialog.java index 900d1885..77acb657 100644 --- a/app/src/main/java/se/leap/bitmaskclient/fragments/TetheringDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/fragments/TetheringDialog.java @@ -22,35 +22,37 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import java.util.Observable; +import java.util.Observer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import butterknife.ButterKnife; +import butterknife.InjectView; +import de.blinkt.openvpn.core.VpnStatus; +import se.leap.bitmaskclient.R; +import se.leap.bitmaskclient.firewall.FirewallManager; +import se.leap.bitmaskclient.tethering.TetheringObservable; +import se.leap.bitmaskclient.utils.PreferenceHelper; +import se.leap.bitmaskclient.views.IconCheckboxEntry; + /** * Copyright (c) 2020 LEAP Encryption Access Project and contributers - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -import java.util.Observable; -import java.util.Observer; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import de.blinkt.openvpn.core.VpnStatus; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.firewall.FirewallManager; -import se.leap.bitmaskclient.tethering.TetheringObservable; -import se.leap.bitmaskclient.utils.PreferenceHelper; -import se.leap.bitmaskclient.views.IconCheckboxEntry; - public class TetheringDialog extends AppCompatDialogFragment implements Observer { public final static String TAG = TetheringDialog.class.getName(); @@ -191,12 +193,17 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer private CharSequence createUserMessage() { String tetheringMessage = getString(R.string.tethering_message); - String systemSettings = getString(R.string.tethering_system_settings); - String systemSettingsMessage = getString(R.string.tethering_enabled_message, systemSettings); + String systemSettingsMessage = getString(R.string.tethering_enabled_message); + Pattern pattern = Pattern.compile("([\\w .]*)()+([\\w ]*)()([\\w .]*)"); + Matcher matcher = pattern.matcher(systemSettingsMessage); + int startIndex = 0; + int endIndex = 0; + if (matcher.matches()) { + startIndex = matcher.start(2); + endIndex = startIndex + matcher.group(3).length(); + } + systemSettingsMessage = systemSettingsMessage.replace("", "").replace("", ""); String wholeMessage = systemSettingsMessage + "\n\n" + tetheringMessage; - int startIndex = wholeMessage.indexOf(systemSettings, 0); - int endIndex = startIndex + systemSettings.length(); - Spannable spannable = new SpannableString(wholeMessage); spannable.setSpan(new ClickableSpan() { @Override -- cgit v1.2.3