Add Options in settings
Add License and Readme Fixed color issues Update About page Fixed About button and package
This commit is contained in:
@@ -63,6 +63,8 @@ dependencies {
|
||||
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
@@ -72,6 +74,8 @@ dependencies {
|
||||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
|
||||
debugImplementation("androidx.compose.ui:ui-tooling")
|
||||
debugImplementation("androidx.compose.ui:ui-test-manifest")
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -11,9 +11,9 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.CleverClass"
|
||||
tools:targetApi="31">
|
||||
tools:targetApi="31" >
|
||||
<activity
|
||||
android:name=".ui.theme.AboutActivity"
|
||||
android:name=".AboutActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_about"
|
||||
android:theme="@style/Theme.CleverClass" />
|
||||
@@ -31,7 +31,7 @@
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.CleverClass">
|
||||
android:theme="@style/Theme.CleverClass" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.schoolapp.cleverclass.ui.theme
|
||||
package com.schoolapp.cleverclass
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
@@ -25,6 +25,7 @@ import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||
|
||||
class AboutActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -68,7 +69,7 @@ fun AboutContent(activity: ComponentActivity){
|
||||
.fillMaxWidth())
|
||||
{
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(text = "This Product is published under the GNU General Public License",
|
||||
Text(text = "This Product is published under the\nGNU General Public License\nVersion 3, 29 June 2007",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp))
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.schoolapp.cleverclass
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
@@ -27,6 +28,11 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@@ -53,6 +59,7 @@ class MainActivity : ComponentActivity() {
|
||||
@Composable
|
||||
fun MainContent(){
|
||||
val context = LocalContext.current
|
||||
val sharedPreferences = context.getSharedPreferences("Settings", Context.MODE_PRIVATE)
|
||||
|
||||
Column{
|
||||
TopAppBar(
|
||||
@@ -75,11 +82,11 @@ fun MainContent(){
|
||||
)
|
||||
|
||||
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
|
||||
MainButton(onClick = { /*TODO: Stundenplan activity*/ }, color = Color(0xFFFF4081), text = "Stundenplan")
|
||||
MainButton(onClick = { /*TODO: Noten activity*/ }, color = Color(0xFFFFAB40), text = "Noten")
|
||||
MainButton(onClick = { switchToActivity(context, PSEActivity::class.java) }, color = Color(0xFF536DFE), text = "Periodensystem")
|
||||
MainButton(onClick = { /*TODO: Mebis activity*/ }, color = Color(0xFFE040FB), text = "Mebis")
|
||||
MainButton(onClick = { /*TODO: DSBmobile activity*/ }, color = Color(0xFFFF6E40), text = "DSBmobile")
|
||||
MainButton(onClick = { /*TODO: Stundenplan activity*/ }, color = Color(0xFFFF4081), text = "Stundenplan", sharedPreferences)
|
||||
MainButton(onClick = { /*TODO: Noten activity*/ }, color = Color(0xFFFFAB40), text = "Noten", sharedPreferences)
|
||||
MainButton(onClick = { switchToActivity(context, PSEActivity::class.java) }, color = Color(0xFF536DFE), text = "Periodensystem", sharedPreferences)
|
||||
MainButton(onClick = { /*TODO: Mebis activity*/ }, color = Color(0xFFE040FB), text = "Mebis", sharedPreferences)
|
||||
MainButton(onClick = { /*TODO: DSBmobile activity*/ }, color = Color(0xFFFF6E40), text = "DSBmobile", sharedPreferences)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,20 +94,47 @@ fun MainContent(){
|
||||
|
||||
// Main-menu Buttons
|
||||
@Composable
|
||||
fun MainButton(onClick: () -> Unit, color : Color, text : String) {
|
||||
fun MainButton(onClick: () -> Unit, color : Color, text : String, sharedPreferences: SharedPreferences) {
|
||||
var enabledState by remember(text) {
|
||||
mutableStateOf(getButtonEnabledState(sharedPreferences, text))
|
||||
}
|
||||
|
||||
Button(
|
||||
enabled = enabledState,
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(40),
|
||||
colors = ButtonDefaults.outlinedButtonColors(containerColor = color),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(128.dp)
|
||||
.height(if (enabledState) 128.dp else 0.dp)
|
||||
.padding(start = 16.dp, end = 16.dp, top = 16.dp)
|
||||
) {
|
||||
Text(text,
|
||||
color = MaterialTheme.colorScheme.background,
|
||||
style = MaterialTheme.typography.labelMedium)
|
||||
}
|
||||
|
||||
|
||||
// changes state when Shared Preference is updated
|
||||
val observer = remember {
|
||||
SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
if (key == text) {
|
||||
enabledState = getButtonEnabledState(sharedPreferences, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handles observer creation and disposal
|
||||
DisposableEffect(Unit) {
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(observer)
|
||||
onDispose {
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(observer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getButtonEnabledState(sharedPreferences: SharedPreferences, key: String): Boolean {
|
||||
return sharedPreferences.getBoolean(key, true)
|
||||
}
|
||||
|
||||
fun switchToActivity(context : Context, activity : Class<*>){
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
@@ -18,13 +19,15 @@ import androidx.core.view.WindowCompat
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
background = Black90,
|
||||
primaryContainer = Black70,
|
||||
onPrimary = White100
|
||||
onPrimary = White100,
|
||||
primary = Color(0xFF536DFE)
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
background = White90,
|
||||
primaryContainer = White70,
|
||||
onPrimary = Black100
|
||||
onPrimary = Black100,
|
||||
primary = Color(0xFF8396FF)
|
||||
)
|
||||
|
||||
@Composable
|
||||
@@ -47,7 +50,7 @@ fun CleverClassTheme(
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
val window = (view.context as Activity).window
|
||||
window.statusBarColor = colorScheme.primary.toArgb()
|
||||
window.statusBarColor = colorScheme.primaryContainer.toArgb()
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
<resources />
|
||||
Reference in New Issue
Block a user