added base files
21
FastDocumentation/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.FastDocumentation">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
93
FastDocumentation/app/src/main/java/MainActivity.kt
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.example.FastDocumentation
|
||||
|
||||
import android.os.Bundle
|
||||
import android.webkit.HttpAuthHandler
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.app.AlertDialog // NEW IMPORT for the dialog
|
||||
import android.widget.EditText // NEW IMPORT for text inputs
|
||||
import android.widget.LinearLayout // NEW IMPORT for dialog layout
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT // NEW IMPORT for layout
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT // NEW IMPORT for layout
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var myWebView: WebView
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
myWebView = findViewById(R.id.webview)
|
||||
|
||||
// 1. Configure WebView Settings
|
||||
val settings = myWebView.settings
|
||||
settings.javaScriptEnabled = true
|
||||
settings.domStorageEnabled = true
|
||||
|
||||
// 2. Keep navigation inside the WebView AND handle HTTP Auth (MODIFIED)
|
||||
myWebView.webViewClient = object : WebViewClient() {
|
||||
|
||||
// This method is called when the server requests HTTP authentication (like Basic Auth)
|
||||
override fun onReceivedHttpAuthRequest(
|
||||
view: WebView?,
|
||||
handler: HttpAuthHandler?,
|
||||
host: String?,
|
||||
realm: String?
|
||||
) {
|
||||
// Manually trigger the popup using an AlertDialog
|
||||
if (handler != null) {
|
||||
showHttpAuthDialog(handler, host, realm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Load the Target URL
|
||||
val urlToLoad = "https://docs.nxs.solutions/Fast"
|
||||
myWebView.loadUrl(urlToLoad)
|
||||
}
|
||||
|
||||
// NEW FUNCTION: Manually constructs and shows the HTTP Auth dialog
|
||||
private fun showHttpAuthDialog(handler: HttpAuthHandler, host: String?, realm: String?) {
|
||||
val usernameInput = EditText(this).apply { hint = "Username" }
|
||||
val passwordInput = EditText(this).apply {
|
||||
hint = "Password"
|
||||
inputType = android.text.InputType.TYPE_CLASS_TEXT or android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||
}
|
||||
|
||||
// Create a simple vertical layout for the two text fields
|
||||
val layout = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(50, 20, 50, 20) // Add some padding
|
||||
addView(usernameInput, LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT))
|
||||
addView(passwordInput, LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT))
|
||||
}
|
||||
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Authentication Required")
|
||||
.setMessage("Please enter credentials for $realm on $host")
|
||||
.setView(layout) // Set the custom layout
|
||||
.setPositiveButton("Log In") { _, _ ->
|
||||
// When the user clicks "Log In", proceed with the provided credentials
|
||||
val username = usernameInput.text.toString()
|
||||
val password = passwordInput.text.toString()
|
||||
handler.proceed(username, password)
|
||||
}
|
||||
.setNegativeButton("Cancel") { _, _ ->
|
||||
// If the user cancels, cancel the authentication request
|
||||
handler.cancel()
|
||||
}
|
||||
.setCancelable(false)
|
||||
.show()
|
||||
}
|
||||
|
||||
// 4. Handle the device's back button
|
||||
override fun onBackPressed() {
|
||||
if (myWebView.canGoBack()) {
|
||||
myWebView.goBack()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 156 KiB |
14
FastDocumentation/app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
BIN
FastDocumentation/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 156 KiB |
BIN
FastDocumentation/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 156 KiB |
BIN
FastDocumentation/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 156 KiB |
BIN
FastDocumentation/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 156 KiB |
8
FastDocumentation/app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#1A237E</color>
|
||||
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
</resources>
|
||||
4
FastDocumentation/app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">FastDocumentation</string>
|
||||
</resources>
|
||||
7
FastDocumentation/app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="Theme.FastDocumentation" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">#6200EE</item>
|
||||
<item name="colorPrimaryDark">#3700B3</item>
|
||||
<item name="colorAccent">#03DAC5</item>
|
||||
</style>
|
||||
</resources>
|
||||