Fix PSE jsonIndex
Update About Page
This commit is contained in:
@@ -24,6 +24,7 @@ import androidx.compose.material3.TopAppBar
|
|||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||||
|
|
||||||
@@ -70,14 +71,18 @@ fun AboutContent(activity: ComponentActivity){
|
|||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.fillMaxWidth())
|
.fillMaxWidth())
|
||||||
{
|
{
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
AboutTextElement("This Product is published under the\nGNU General Public License\nVersion 3, 29 June 2007", 16.dp)
|
||||||
Text(text = "This Product is published under the\nGNU General Public License\nVersion 3, 29 June 2007",
|
AboutTextElement("Developed by:\n- Paul Posch\n- Matthias Meyer\n- Jakub Szarko\n- Emilian Bührer", 32.dp)
|
||||||
style = MaterialTheme.typography.bodySmall,
|
AboutTextElement("Fun Facts:\nThis app consists of 2.873 lines of code\nThe repository is 413KB big\nThe development took about 3 month", 64.dp) //TODO: Update before launch
|
||||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp))
|
}
|
||||||
Spacer(modifier = Modifier.height(32.dp))
|
}
|
||||||
Text(text = "Developed by:\n- Paul Posch\n- Matthias Meyer\n- Jakub Szarko\n- Emilian Bührer",
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AboutTextElement(text: String, space: Dp){
|
||||||
|
Spacer(modifier = Modifier.height(space))
|
||||||
|
Text(text = text,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp))
|
modifier = Modifier.padding(start = 16.dp, end = 16.dp))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.schoolapp.cleverclass
|
package com.schoolapp.cleverclass
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@@ -94,17 +93,7 @@ private val shells = listOf(
|
|||||||
"K", "L", "M", "N", "O", "P", "Q"
|
"K", "L", "M", "N", "O", "P", "Q"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Content of PSE
|
private val elementNameList = listOf(
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
|
||||||
fun PSEMainContent(activity: ComponentActivity) {
|
|
||||||
var showInfo by remember {
|
|
||||||
mutableStateOf(false)
|
|
||||||
}
|
|
||||||
var dialogChooser by remember {
|
|
||||||
mutableStateOf(-1)
|
|
||||||
}
|
|
||||||
val elementNameList = listOf(
|
|
||||||
"H", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "He",
|
"H", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "He",
|
||||||
"Li", "Be", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "B", "C", "N", "O", "F", "Ne",
|
"Li", "Be", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "B", "C", "N", "O", "F", "Ne",
|
||||||
"Na", "Mg", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Al", "Si", "P", "S", "Cl", "Ar",
|
"Na", "Mg", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Al", "Si", "P", "S", "Cl", "Ar",
|
||||||
@@ -113,7 +102,7 @@ fun PSEMainContent(activity: ComponentActivity) {
|
|||||||
"Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn",
|
"Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn",
|
||||||
"Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"
|
"Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"
|
||||||
)
|
)
|
||||||
val elementButtonColors = listOf(
|
private val elementButtonColors = listOf(
|
||||||
0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
|
0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
|
||||||
1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1,
|
1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1,
|
||||||
2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2,
|
2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2,
|
||||||
@@ -122,6 +111,20 @@ fun PSEMainContent(activity: ComponentActivity) {
|
|||||||
5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
|
5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
|
||||||
6, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6
|
6, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Content of PSE
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun PSEMainContent(activity: ComponentActivity) {
|
||||||
|
val inputStream = activity.assets.open("elements_data.json")
|
||||||
|
val rootObj = JSONObject(InputStreamReader(inputStream).readText())
|
||||||
|
|
||||||
|
var showInfo by remember {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
var dialogChooser by remember {
|
||||||
|
mutableStateOf(-1)
|
||||||
|
}
|
||||||
Column {
|
Column {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
|
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
|
||||||
@@ -174,22 +177,9 @@ fun PSEMainContent(activity: ComponentActivity) {
|
|||||||
for (element in 0..31) {
|
for (element in 0..31) {
|
||||||
val index = row * 32 + element
|
val index = row * 32 + element
|
||||||
if (elementNameList[index] != "") {
|
if (elementNameList[index] != "") {
|
||||||
Box(modifier = Modifier
|
val elementJsonIndex = dialogCounter
|
||||||
.padding(3.dp)
|
++dialogCounter
|
||||||
.size(60.dp)
|
ElementBox(arrayIndex = index, onClick = { dialogChooser = elementJsonIndex })
|
||||||
.background(
|
|
||||||
color = colors[elementButtonColors[index]],
|
|
||||||
shape = RoundedCornerShape(5)
|
|
||||||
)
|
|
||||||
.clickable { dialogChooser = ++dialogCounter }
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.align(Alignment.Center),
|
|
||||||
text = elementNameList[index],
|
|
||||||
color = com.schoolapp.cleverclass.ui.theme.TextOnColouredButton,
|
|
||||||
style = MaterialTheme.typography.labelLarge
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -214,7 +204,7 @@ fun PSEMainContent(activity: ComponentActivity) {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.horizontalScroll(rememberScrollState()),
|
.horizontalScroll(rememberScrollState()),
|
||||||
text = readElementData(activity, dcValue),
|
text = readElementData(rootObj, dcValue),
|
||||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||||
style = MaterialTheme.typography.labelMedium
|
style = MaterialTheme.typography.labelMedium
|
||||||
)
|
)
|
||||||
@@ -264,6 +254,26 @@ fun PSEMainContent(activity: ComponentActivity) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ElementBox(arrayIndex: Int, onClick: () -> Unit){
|
||||||
|
Box(modifier = Modifier
|
||||||
|
.padding(3.dp)
|
||||||
|
.size(60.dp)
|
||||||
|
.background(
|
||||||
|
color = colors[elementButtonColors[arrayIndex]],
|
||||||
|
shape = RoundedCornerShape(5)
|
||||||
|
)
|
||||||
|
.clickable { onClick() }
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.align(Alignment.Center),
|
||||||
|
text = elementNameList[arrayIndex],
|
||||||
|
color = com.schoolapp.cleverclass.ui.theme.TextOnColouredButton,
|
||||||
|
style = MaterialTheme.typography.labelLarge
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun InformationBox(text: String, color: Color){
|
fun InformationBox(text: String, color: Color){
|
||||||
Box(modifier = Modifier
|
Box(modifier = Modifier
|
||||||
@@ -283,10 +293,8 @@ fun InformationBox(text: String, color: Color){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readElementData(context: Context, int: Int): String {
|
private fun readElementData(jsonObject: JSONObject, int: Int): String {
|
||||||
val inputStream = context.assets.open("elements_data.json")
|
val elementData = jsonObject.getJSONArray("elements").getJSONObject(int)
|
||||||
val rootObj = JSONObject(InputStreamReader(inputStream).readText())
|
|
||||||
val elementData = rootObj.getJSONArray("elements").getJSONObject(int)
|
|
||||||
return "Name:\n${elementData.get("Name")}\n\n" +
|
return "Name:\n${elementData.get("Name")}\n\n" +
|
||||||
"Ordnungszahl:\n${elementData.get("Ordnungszahl")}\n\n" +
|
"Ordnungszahl:\n${elementData.get("Ordnungszahl")}\n\n" +
|
||||||
"Gruppe:\n${elementData.get("Gruppe")}\n\n" +
|
"Gruppe:\n${elementData.get("Gruppe")}\n\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user