Add Options in settings
Add License and Readme Fixed color issues Update About page Fixed About button and package
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.schoolapp.cleverclass
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.SharedPreferences.Editor
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@@ -14,6 +16,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
@@ -29,12 +32,14 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.schoolapp.cleverclass.ui.theme.AboutActivity
|
||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||
|
||||
|
||||
class SettingsActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -52,12 +57,17 @@ class SettingsActivity : ComponentActivity() {
|
||||
// Content of Settings
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsContent(activity: ComponentActivity){
|
||||
Column {
|
||||
fun SettingsContent(activity: ComponentActivity) {
|
||||
val sharedPreferences = activity.getSharedPreferences("Settings", Context.MODE_PRIVATE)
|
||||
val editor = sharedPreferences.edit()
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
// Top AppBar
|
||||
TopAppBar(
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
|
||||
title = {
|
||||
Text(text = "Einstellungen",
|
||||
Text(
|
||||
text = "Einstellungen",
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
)
|
||||
},
|
||||
@@ -74,39 +84,57 @@ fun SettingsContent(activity: ComponentActivity){
|
||||
)
|
||||
|
||||
// Settings
|
||||
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
|
||||
Setting(text = "Stundenplan")
|
||||
Setting(text = "Noten")
|
||||
Setting(text = "Periodensystem")
|
||||
Setting(text = "Mebis")
|
||||
Setting(text = "DSBmobile")
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.verticalScroll(rememberScrollState())
|
||||
.fillMaxWidth()
|
||||
|
||||
) {
|
||||
Setting(text = "Stundenplan", sharedPreferences, editor)
|
||||
Setting(text = "Noten", sharedPreferences, editor)
|
||||
Setting(text = "Periodensystem", sharedPreferences, editor)
|
||||
Setting(text = "Mebis", sharedPreferences, editor)
|
||||
Setting(text = "DSBmobile", sharedPreferences, editor)
|
||||
}
|
||||
|
||||
// About Button
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.Bottom,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,)
|
||||
{
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Divider()
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(text = "About",
|
||||
Text(
|
||||
text = "About",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.clickable {
|
||||
val intent = Intent(activity, AboutActivity::class.java)
|
||||
activity.startActivity(intent)},
|
||||
style = MaterialTheme.typography.bodySmall)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun Setting(text : String){
|
||||
fun Setting(text : String, sharedPreferences: SharedPreferences, editor: Editor){
|
||||
val checkedState = remember { mutableStateOf(sharedPreferences.getBoolean(text, true)) }
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Switch(checked = true, onCheckedChange = null)
|
||||
Switch(
|
||||
checked = checkedState.value,
|
||||
onCheckedChange = { isChecked ->
|
||||
checkedState.value = isChecked
|
||||
editor.putBoolean(text, isChecked)
|
||||
editor.apply()
|
||||
}
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(text = text,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
|
||||
Reference in New Issue
Block a user