Skip to content
Snippets Groups Projects
Commit 05205190 authored by cyberta's avatar cyberta
Browse files

fix tethering hint (#8979)

parent e5fab9c5
Branches
No related tags found
No related merge requests found
...@@ -22,35 +22,37 @@ import android.view.LayoutInflater; ...@@ -22,35 +22,37 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; 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 * Copyright (c) 2020 LEAP Encryption Access Project and contributers
* * <p>
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* * <p>
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* * <p>
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
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 class TetheringDialog extends AppCompatDialogFragment implements Observer {
public final static String TAG = TetheringDialog.class.getName(); public final static String TAG = TetheringDialog.class.getName();
...@@ -191,12 +193,17 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer ...@@ -191,12 +193,17 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer
private CharSequence createUserMessage() { private CharSequence createUserMessage() {
String tetheringMessage = getString(R.string.tethering_message); String tetheringMessage = getString(R.string.tethering_message);
String systemSettings = getString(R.string.tethering_system_settings); String systemSettingsMessage = getString(R.string.tethering_enabled_message);
String systemSettingsMessage = getString(R.string.tethering_enabled_message, systemSettings); Pattern pattern = Pattern.compile("([\\w .]*)(<b>)+([\\w ]*)(</b>)([\\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("<b>", "").replace("</b>", "");
String wholeMessage = systemSettingsMessage + "\n\n" + tetheringMessage; String wholeMessage = systemSettingsMessage + "\n\n" + tetheringMessage;
int startIndex = wholeMessage.indexOf(systemSettings, 0);
int endIndex = startIndex + systemSettings.length();
Spannable spannable = new SpannableString(wholeMessage); Spannable spannable = new SpannableString(wholeMessage);
spannable.setSpan(new ClickableSpan() { spannable.setSpan(new ClickableSpan() {
@Override @Override
......
...@@ -111,8 +111,7 @@ ...@@ -111,8 +111,7 @@
<string name="require_root">Requires root permissions</string> <string name="require_root">Requires root permissions</string>
<string name="show_experimental">Show experimental features</string> <string name="show_experimental">Show experimental features</string>
<string name="hide_experimental">Hide experimental features</string> <string name="hide_experimental">Hide experimental features</string>
<string name="tethering_enabled_message">Please make sure to enable tethering in the %s first!</string> <string name="tethering_enabled_message">Please make sure to enable tethering in the <![CDATA[<b>system settings</b>]]> first.</string>
<string name="tethering_system_settings">system settings</string>
<string name="tethering_message">Share your VPN with other devices via:</string> <string name="tethering_message">Share your VPN with other devices via:</string>
<string name="tethering_wifi">Wifi hotspot</string> <string name="tethering_wifi">Wifi hotspot</string>
<string name="tethering_usb">USB tethering</string> <string name="tethering_usb">USB tethering</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment