@@ -280,8 +280,8 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
280280 // The app is being opened - nothing to do here
281281 }
282282
283- else -> Log .w(
284- TAG , " Ignoring unknown intent. Action ${
283+ else -> Log .w(TAG ,
284+ " Ignoring unknown intent. Action ${
285285 intent.action
286286 } , data: ${
287287 intent.data
@@ -525,11 +525,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
525525 startActivity(
526526 Intent (
527527 Intent .ACTION_VIEW ,
528- Uri .parse(
529- (
530- if (canUseHttps) " https" else " http"
531- ) + " ://" + uri
532- )
528+ Uri .parse((
529+ if (canUseHttps) " https" else " http"
530+ ) + " ://" + uri)
533531 ).apply {
534532 if (browserPackage != null ) setPackage(browserPackage)
535533 }
@@ -549,20 +547,20 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
549547 super .onActivityResult(requestCode, resultCode, data)
550548
551549 val resultOk = resultCode == RESULT_OK ||
552- (requestCode == INSTALL_CERT_REQUEST && whereIsCertTrusted(currentProxyConfig!! ) != null ) ||
553- (requestCode == ENABLE_NOTIFICATIONS_REQUEST && areNotificationsEnabled())
554-
555- Log .i(
556- TAG , " onActivityResult: " + (
557- when (requestCode) {
558- START_VPN_REQUEST -> " start-vpn"
559- INSTALL_CERT_REQUEST -> " install-cert"
560- ENABLE_NOTIFICATIONS_REQUEST -> " enable-notifications"
561- else -> requestCode.toString()
562- }
563- ) + " - result: " + (
564- if (resultOk) " ok" else resultCode.toString()
565- )
550+ (requestCode == INSTALL_CERT_REQUEST && whereIsCertTrusted(currentProxyConfig!! ) != null ) ||
551+ (requestCode == ENABLE_NOTIFICATIONS_REQUEST && areNotificationsEnabled())
552+
553+ Log .i(TAG ,
554+ " onActivityResult: " + (
555+ when (requestCode) {
556+ START_VPN_REQUEST -> " start-vpn"
557+ INSTALL_CERT_REQUEST -> " install-cert"
558+ ENABLE_NOTIFICATIONS_REQUEST -> " enable-notifications"
559+ else -> requestCode.toString()
560+ }
561+ ) + " - result: " + (
562+ if (resultOk) " ok" else resultCode.toString()
563+ )
566564 )
567565
568566 if (resultOk) {
@@ -702,14 +700,14 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
702700 .setIcon(R .drawable.ic_info_circle)
703701 .setMessage(
704702 " To intercept HTTPS traffic from this device, you need to " +
705- " trust your HTTP Toolkit's certificate authority. " +
706- " \n\n " +
707- " Please accept the following prompts to allow this." +
708- if (! isDeviceSecured(applicationContext))
709- " \n\n " +
710- " Due to Android security requirements, trusting the certificate will " +
711- " require you to set a PIN, password or pattern for this device."
712- else " To trust the certificate, your device PIN will be required."
703+ " trust your HTTP Toolkit's certificate authority. " +
704+ " \n\n " +
705+ " Please accept the following prompts to allow this." +
706+ if (! isDeviceSecured(applicationContext))
707+ " \n\n " +
708+ " Due to Android security requirements, trusting the certificate will " +
709+ " require you to set a PIN, password or pattern for this device."
710+ else " To trust the certificate, your device PIN will be required."
713711 )
714712 .setPositiveButton(" Install" ) { _, _ ->
715713 val certInstallIntent = KeyChain .createInstallIntent()
@@ -766,35 +764,34 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
766764 """
767765 <p>
768766 ${
769- if (PROMPTED_CERT_SETUP_SUPPORTED )
770- " Automatic certificate installation failed, so it must be done manually."
771- else
772- " Android ${Build .VERSION .RELEASE } doesn't allow automatic certificate setup."
773- }
767+ if (PROMPTED_CERT_SETUP_SUPPORTED )
768+ " Automatic certificate installation failed, so it must be done manually."
769+ else
770+ " Android ${Build .VERSION .RELEASE } doesn't allow automatic certificate setup."
771+ }
774772 </p>
775773 <p>
776774 To allow HTTP Toolkit to intercept HTTPS traffic:
777775 </p>
778776 <ul>
779777 ${
780- if (Build .VERSION .SDK_INT > Build .VERSION_CODES .R ) // Android 12+
781- """
782- <li> Open "<b>${
783- // Slightly different UI for Android 12 and 13:
784- if (Build .VERSION .SDK_INT < 33 ) " Advanced Settings" else " More security settings"
785- } </b>" in your security settings</li>
786- <li> Open "<b>Encryption & Credentials</b>"</li>
787- """
788- else
789- """
790- <li> Open "<b>Encryption & Credentials</b>" in your security settings</li>
791- """
792- }
778+ if (Build .VERSION .SDK_INT > Build .VERSION_CODES .R ) // Android 12+
779+ """
780+ <li> Open "<b>${
781+ // Slightly different UI for Android 12 and 13:
782+ if (Build .VERSION .SDK_INT < 33 ) " Advanced Settings" else " More security settings"
783+ } </b>" in your security settings</li>
784+ <li> Open "<b>Encryption & Credentials</b>"</li>
785+ """
786+ else
787+ """
788+ <li> Open "<b>Encryption & Credentials</b>" in your security settings</li>
789+ """
790+ }
793791 <li> Select "<b>Install a certificate</b>", then "<b>CA Certificate</b>"</li>
794792 <li> <b>Select the HTTP Toolkit certificate in your Downloads folder</b></li>
795793 </ul>
796- """ , 0
797- )
794+ """ , 0 )
798795 )
799796 .setPositiveButton(" Open security settings" ) { _, _ ->
800797 startActivityForResult(Intent (Settings .ACTION_SECURITY_SETTINGS ), INSTALL_CERT_REQUEST )
@@ -897,7 +894,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
897894 .setIcon(R .drawable.ic_exclamation_triangle)
898895 .setMessage(
899896 " Please allow notifications to use HTTP Toolkit. This is used " +
900- " exclusively for VPN connection status indicators."
897+ " exclusively for VPN connection status indicators."
901898 )
902899 .setPositiveButton(" Ok" ) { _, _ -> }
903900 .setOnDismissListener { _ ->
@@ -947,9 +944,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
947944 .setIcon(R .drawable.ic_exclamation_triangle)
948945 .setMessage(
949946 " HTTP Toolkit interception was shut down automatically by Android. " +
950- " This is usually caused by overly strict power management of background processes. " +
951- " \n\n " +
952- " To fix this, disable battery optimization for HTTP Toolkit in your settings."
947+ " This is usually caused by overly strict power management of background processes. " +
948+ " \n\n " +
949+ " To fix this, disable battery optimization for HTTP Toolkit in your settings."
953950 )
954951 .setNegativeButton(" Ignore" ) { _, _ -> }
955952 .setPositiveButton(" Go to settings" ) { _, _ ->
@@ -989,9 +986,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
989986 .setIcon(R .drawable.ic_exclamation_triangle)
990987 .setMessage(
991988 " HTTP Toolkit could not open a browser on this device. " +
992- " This usually means you don't have any browser installed. To visit " +
993- uri +
994- " please install a browser app."
989+ " This usually means you don't have any browser installed. To visit " +
990+ uri +
991+ " please install a browser app."
995992 )
996993 .setNeutralButton(" OK" ) { _, _ -> }
997994 .show()
@@ -1003,10 +1000,10 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
10031000 .setIcon(R .drawable.ic_exclamation_triangle)
10041001 .setMessage(
10051002 " HTTP Toolkit could not be configured as a VPN on your device." +
1006- " \n\n " +
1007- " This usually means you have an always-on VPN configured, which blocks " +
1008- " installation of other VPNs. To activate HTTP Toolkit you'll need to " +
1009- " deactivate that VPN first."
1003+ " \n\n " +
1004+ " This usually means you have an always-on VPN configured, which blocks " +
1005+ " installation of other VPNs. To activate HTTP Toolkit you'll need to " +
1006+ " deactivate that VPN first."
10101007 )
10111008 .setNegativeButton(" Cancel" ) { _, _ -> }
10121009 .setPositiveButton(" Open VPN Settings" ) { _, _ ->
0 commit comments