Start Mebis
Fix App crash DSBmobile
This commit is contained in:
@@ -29,7 +29,10 @@ suspend fun downloadDSB(context: Context): Int{
|
||||
|
||||
val mainDir = createDataFolder(context)
|
||||
|
||||
val jsonResponse = JSONObject(downloadDataTask(username = username, password = password))
|
||||
val response = downloadDataTask(username = username, password = password)
|
||||
if(response == "-1")
|
||||
return NO_INTERNET_CONNECTION_CODE
|
||||
val jsonResponse = JSONObject(response)
|
||||
if(jsonResponse.get("Resultcode") != 0)
|
||||
return jsonResponse.getInt("Resultcode")
|
||||
|
||||
@@ -215,6 +218,11 @@ private fun clearFolder(directory: File) {
|
||||
private fun isInternetAvailable(context: Context): Boolean {
|
||||
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val network = connectivityManager.activeNetwork
|
||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
|
||||
return networkCapabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) ?: false
|
||||
return try {
|
||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
|
||||
networkCapabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) ?: false
|
||||
} catch (e: SecurityException) {
|
||||
Log.e("Internet", e.toString())
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.schoolapp.cleverclass
|
||||
|
||||
import android.os.Bundle
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
@@ -20,6 +23,7 @@ import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||
|
||||
class MebisActivity : ComponentActivity() {
|
||||
@@ -42,7 +46,7 @@ class MebisActivity : ComponentActivity() {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun MebisContent(activity: ComponentActivity){
|
||||
Column() {
|
||||
Column {
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
|
||||
title = {
|
||||
@@ -63,8 +67,23 @@ fun MebisContent(activity: ComponentActivity){
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
Column() {
|
||||
AndroidView(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(8.dp),
|
||||
factory = { context ->
|
||||
WebView(context).apply {
|
||||
webViewClient = WebViewClient()
|
||||
settings.apply {
|
||||
loadWithOverviewMode = true
|
||||
useWideViewPort = true
|
||||
domStorageEnabled = true
|
||||
javaScriptEnabled = true
|
||||
}
|
||||
|
||||
}
|
||||
loadUrl("https://mebis.bycs.de/")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user