diff --git a/.gradle/8.0/checksums/checksums.lock b/.gradle/8.0/checksums/checksums.lock new file mode 100644 index 0000000..2fef4f8 Binary files /dev/null and b/.gradle/8.0/checksums/checksums.lock differ diff --git a/.gradle/8.0/checksums/md5-checksums.bin b/.gradle/8.0/checksums/md5-checksums.bin new file mode 100644 index 0000000..7cdb3d2 Binary files /dev/null and b/.gradle/8.0/checksums/md5-checksums.bin differ diff --git a/.gradle/8.0/checksums/sha1-checksums.bin b/.gradle/8.0/checksums/sha1-checksums.bin new file mode 100644 index 0000000..08a1cef Binary files /dev/null and b/.gradle/8.0/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock b/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..1e895c0 Binary files /dev/null and b/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/8.0/dependencies-accessors/gc.properties b/.gradle/8.0/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/8.0/executionHistory/executionHistory.bin b/.gradle/8.0/executionHistory/executionHistory.bin new file mode 100644 index 0000000..824f8d9 Binary files /dev/null and b/.gradle/8.0/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.0/executionHistory/executionHistory.lock b/.gradle/8.0/executionHistory/executionHistory.lock new file mode 100644 index 0000000..e3ce551 Binary files /dev/null and b/.gradle/8.0/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.0/fileChanges/last-build.bin b/.gradle/8.0/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/8.0/fileChanges/last-build.bin differ diff --git a/.gradle/8.0/fileHashes/fileHashes.bin b/.gradle/8.0/fileHashes/fileHashes.bin new file mode 100644 index 0000000..beb7754 Binary files /dev/null and b/.gradle/8.0/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.0/fileHashes/fileHashes.lock b/.gradle/8.0/fileHashes/fileHashes.lock new file mode 100644 index 0000000..c83b8d0 Binary files /dev/null and b/.gradle/8.0/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.0/fileHashes/resourceHashesCache.bin b/.gradle/8.0/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..133091a Binary files /dev/null and b/.gradle/8.0/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/8.0/gc.properties b/.gradle/8.0/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..b21f530 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..286f460 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Aug 30 11:07:45 AEST 2023 +gradle.version=8.0 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..783305a Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..f40ac54 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +HNS Browser \ No newline at end of file diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..2a9c5e0 --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..abb0da7 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..ae388c2 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8978d23 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..cbabc35 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "com.woodburn.hnsbrowser" + compileSdk = 33 + + defaultConfig { + applicationId = "com.woodburn.hnsbrowser" + minSdk = 30 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.9.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation("androidx.webkit:webkit:1.3.0") + implementation("androidx.core:core-splashscreen:1.0.0") +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/woodburn/hnsbrowser/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/woodburn/hnsbrowser/ExampleInstrumentedTest.java new file mode 100644 index 0000000..308e0c2 --- /dev/null +++ b/app/src/androidTest/java/com/woodburn/hnsbrowser/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.woodburn.hnsbrowser; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.woodburn.hnsbrowser", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4ee569c --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/woodburn/hnsbrowser/MainActivity.java b/app/src/main/java/com/woodburn/hnsbrowser/MainActivity.java new file mode 100644 index 0000000..a842ce6 --- /dev/null +++ b/app/src/main/java/com/woodburn/hnsbrowser/MainActivity.java @@ -0,0 +1,43 @@ +package com.woodburn.hnsbrowser; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.EditText; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + findViewById(R.id.navigate_button).setOnClickListener(v -> navigate()); + ((EditText)findViewById(R.id.url_textbox)).setOnEditorActionListener((v, actionId, event) -> { + navigate(); + return true; + }); + } + + void navigate() { + // Get inputted text from url text box + String url = ((EditText)findViewById(R.id.url_textbox)).getText().toString(); + url = url.trim(); + if (url.length() < 2){ + return; + } + if (url.contains("http")){ + if (url.contains("http://")){ // Force https + url = url.replace("http://", "https://"); + } + } else { + url = "https://" + url; + } + + // Send url to WebActivity + Intent intent = new Intent(this, WebActivity.class); + intent.putExtra("url", url); + startActivity(intent); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java b/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java new file mode 100644 index 0000000..1988120 --- /dev/null +++ b/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java @@ -0,0 +1,77 @@ +package com.woodburn.hnsbrowser; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.webkit.ProxyConfig; +import androidx.webkit.ProxyController; + +import android.net.http.SslError; +import android.os.Bundle; +import android.webkit.HttpAuthHandler; +import android.webkit.SslErrorHandler; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.Toast; + +import java.util.concurrent.Executor; + +public class WebActivity extends AppCompatActivity { + + boolean sslError = false; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_web); + + Bundle bundle = getIntent().getExtras(); + String url = bundle.getString("url"); + // Validate + if (url == null || url.isEmpty()) { + // Display toast + Toast.makeText(this, "Invalid URL!", Toast.LENGTH_SHORT).show(); + // Close activity + finish(); + } + + // Open webview with bookmark + WebView webView = (WebView) findViewById(R.id.webviewer); + + // Set proxy to https://proxy.hnsproxy.au + WebSettings webSettings = webView.getSettings(); + webView.setWebViewClient(new WebViewClient() { + @Override + public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm){ + + handler.proceed("userName", "password"); + } + @Override + public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { + if (!sslError) { + Toast.makeText(WebActivity.this, "SSL error", Toast.LENGTH_SHORT).show(); + Toast.makeText(WebActivity.this, "Make sure you have installed the SSL certificate", Toast.LENGTH_SHORT).show(); + } + sslError = true; + handler.proceed(); // Ignore SSL certificate errors + } + }); + setProxy(); + webView.loadUrl(url); + + } + private void setProxy() { + ProxyConfig proxyConfig = new ProxyConfig.Builder() + .addProxyRule("https://proxy.hnsproxy.au") + .addDirect().build(); + ProxyController.getInstance().setProxyOverride(proxyConfig, new Executor() { + @Override + public void execute(Runnable command) { + //do nothing + } + }, new Runnable() { + @Override + public void run() { + + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/favicon.png b/app/src/main/res/drawable/favicon.png new file mode 100644 index 0000000..b325464 Binary files /dev/null and b/app/src/main/res/drawable/favicon.png differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f4a8b32 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,48 @@ + + + + + +