@@ -280,8 +280,8 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
280
280
// The app is being opened - nothing to do here
281
281
}
282
282
283
- else -> Log .w(
284
- TAG , " Ignoring unknown intent. Action ${
283
+ else -> Log .w(TAG ,
284
+ " Ignoring unknown intent. Action ${
285
285
intent.action
286
286
} , data: ${
287
287
intent.data
@@ -525,11 +525,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
525
525
startActivity(
526
526
Intent (
527
527
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)
533
531
).apply {
534
532
if (browserPackage != null ) setPackage(browserPackage)
535
533
}
@@ -549,20 +547,20 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
549
547
super .onActivityResult(requestCode, resultCode, data)
550
548
551
549
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
+ )
566
564
)
567
565
568
566
if (resultOk) {
@@ -702,14 +700,14 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
702
700
.setIcon(R .drawable.ic_info_circle)
703
701
.setMessage(
704
702
" 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."
713
711
)
714
712
.setPositiveButton(" Install" ) { _, _ ->
715
713
val certInstallIntent = KeyChain .createInstallIntent()
@@ -766,35 +764,34 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
766
764
"""
767
765
<p>
768
766
${
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
+ }
774
772
</p>
775
773
<p>
776
774
To allow HTTP Toolkit to intercept HTTPS traffic:
777
775
</p>
778
776
<ul>
779
777
${
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
+ }
793
791
<li> Select "<b>Install a certificate</b>", then "<b>CA Certificate</b>"</li>
794
792
<li> <b>Select the HTTP Toolkit certificate in your Downloads folder</b></li>
795
793
</ul>
796
- """ , 0
797
- )
794
+ """ , 0 )
798
795
)
799
796
.setPositiveButton(" Open security settings" ) { _, _ ->
800
797
startActivityForResult(Intent (Settings .ACTION_SECURITY_SETTINGS ), INSTALL_CERT_REQUEST )
@@ -897,7 +894,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
897
894
.setIcon(R .drawable.ic_exclamation_triangle)
898
895
.setMessage(
899
896
" Please allow notifications to use HTTP Toolkit. This is used " +
900
- " exclusively for VPN connection status indicators."
897
+ " exclusively for VPN connection status indicators."
901
898
)
902
899
.setPositiveButton(" Ok" ) { _, _ -> }
903
900
.setOnDismissListener { _ ->
@@ -947,9 +944,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
947
944
.setIcon(R .drawable.ic_exclamation_triangle)
948
945
.setMessage(
949
946
" 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."
953
950
)
954
951
.setNegativeButton(" Ignore" ) { _, _ -> }
955
952
.setPositiveButton(" Go to settings" ) { _, _ ->
@@ -989,9 +986,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
989
986
.setIcon(R .drawable.ic_exclamation_triangle)
990
987
.setMessage(
991
988
" 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."
995
992
)
996
993
.setNeutralButton(" OK" ) { _, _ -> }
997
994
.show()
@@ -1003,10 +1000,10 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
1003
1000
.setIcon(R .drawable.ic_exclamation_triangle)
1004
1001
.setMessage(
1005
1002
" 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."
1010
1007
)
1011
1008
.setNegativeButton(" Cancel" ) { _, _ -> }
1012
1009
.setPositiveButton(" Open VPN Settings" ) { _, _ ->
0 commit comments