Reformat code
This commit is contained in:
1 parent
3519756da3
commit
379422f457
8 files changed
+565
-552
No files matched your search
@@ -33,10 +33,12 @@ import eu.kanade.tachiyomi.util.system.isNightMode
|
||||
import eu.kanade.tachiyomi.util.view.setSecureScreen
|
||||
import rikka.insets.WindowInsetsHelper
|
||||
import rikka.layoutinflater.view.LayoutInflaterFactory
|
||||
enum class ScreenDimension(val screenDimensionType: Int){
|
||||
|
||||
enum class ScreenDimension(val screenDimensionType: Int) {
|
||||
ScreenRotationLandscape(1),
|
||||
ScreenRotationPortrait(2)
|
||||
}
|
||||
|
||||
abstract class EhActivity : AppCompatActivity() {
|
||||
@StyleRes
|
||||
fun getThemeStyleRes(): Int {
|
||||
@@ -97,9 +99,9 @@ abstract class EhActivity : AppCompatActivity() {
|
||||
var screenDimensionStatus = ScreenDimension.ScreenRotationLandscape
|
||||
|
||||
if (screenWidth != null) {
|
||||
screenDimensionStatus = if(screenWidth > screenHeight!!)
|
||||
screenDimensionStatus = if (screenWidth > screenHeight!!)
|
||||
ScreenDimension.ScreenRotationLandscape
|
||||
else{
|
||||
else {
|
||||
ScreenDimension.ScreenRotationPortrait
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.progressindicator.CircularProgressIndicator;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhCookieStore;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
|
||||
@@ -66,7 +66,7 @@ import okhttp3.Cookie
|
||||
import java.util.Locale
|
||||
|
||||
@Composable
|
||||
fun CookieSignInScene(currentScreenDimension : ScreenDimension) {
|
||||
fun CookieSignInScene(currentScreenDimension: ScreenDimension) {
|
||||
val navController = LocalNavController.current
|
||||
val clipboardManager = LocalClipboardManager.current
|
||||
val focusManager = LocalFocusManager.current
|
||||
@@ -184,112 +184,112 @@ fun CookieSignInScene(currentScreenDimension : ScreenDimension) {
|
||||
}
|
||||
}
|
||||
|
||||
when(currentScreenDimension){
|
||||
ScreenDimension.ScreenRotationPortrait->Box(
|
||||
when (currentScreenDimension) {
|
||||
ScreenDimension.ScreenRotationPortrait -> Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Scaffold(
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(hostState = snackbarHostState)
|
||||
}
|
||||
) { padding ->
|
||||
Column(
|
||||
) { padding ->
|
||||
Column(
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.padding(padding)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.padding(padding)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Cookie,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.size(48.dp),
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.size(48.dp),
|
||||
tint = Color(0xff795548)
|
||||
)
|
||||
Text(
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.cookie_explain),
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = 32.dp,
|
||||
vertical = dimensionResource(id = R.dimen.keyline_margin)
|
||||
),
|
||||
.padding(
|
||||
horizontal = 32.dp,
|
||||
vertical = dimensionResource(id = R.dimen.keyline_margin)
|
||||
),
|
||||
fontSize = 16.sp
|
||||
)
|
||||
OutlinedTextField(
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = ipbMemberId,
|
||||
onValueChange = { ipbMemberId = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "ipb_member_id") },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
supportingText = { if (ipbMemberIdErrorState) Text(stringResource(R.string.text_is_empty)) },
|
||||
trailingIcon = {
|
||||
if (ipbMemberIdErrorState) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
isError = ipbMemberIdErrorState,
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = ipbPassHash,
|
||||
onValueChange = { ipbPassHash = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "ipb_pass_hash") },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
supportingText = { if (ipbPassHashErrorState) Text(stringResource(R.string.text_is_empty)) },
|
||||
trailingIcon = {
|
||||
if (ipbPassHashErrorState) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
isError = ipbPassHashErrorState,
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = igneous,
|
||||
onValueChange = { igneous = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "igneous") },
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { login() }
|
||||
onDone = { login() }
|
||||
),
|
||||
singleLine = true
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Button(
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Button(
|
||||
onClick = { login() },
|
||||
Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(text = stringResource(id = android.R.string.ok))
|
||||
}
|
||||
TextButton(onClick = { fillCookiesFromClipboard() }) {
|
||||
Text(
|
||||
) {
|
||||
Text(text = stringResource(id = android.R.string.ok))
|
||||
}
|
||||
TextButton(onClick = { fillCookiesFromClipboard() }) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.from_clipboard))
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 8.dp)
|
||||
)
|
||||
.padding(horizontal = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isProgressIndicatorVisible)
|
||||
CircularProgressIndicator()
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
if (isProgressIndicatorVisible)
|
||||
CircularProgressIndicator()
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
@@ -305,118 +305,123 @@ fun CookieSignInScene(currentScreenDimension : ScreenDimension) {
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
text =
|
||||
"""
|
||||
${ExceptionUtils.getReadableString(loginErrorException!!)}
|
||||
${stringResource(R.string.wrong_cookie_warning)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
ScreenDimension.ScreenRotationLandscape->Box(
|
||||
contentAlignment = Alignment.Center
|
||||
|
||||
ScreenDimension.ScreenRotationLandscape -> Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Scaffold(
|
||||
snackbarHost = {
|
||||
SnackbarHost(hostState = snackbarHostState)
|
||||
}
|
||||
snackbarHost = {
|
||||
SnackbarHost(hostState = snackbarHostState)
|
||||
}
|
||||
) { padding ->
|
||||
Row(
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.width(dimensionResource(id = R.dimen.signinscreen_landscape_caption_frame_width))
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin)),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
Modifier
|
||||
.width(dimensionResource(id = R.dimen.signinscreen_landscape_caption_frame_width))
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin)),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Cookie,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.size(48.dp),
|
||||
tint = Color(0xff795548)
|
||||
imageVector = Icons.Default.Cookie,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.size(48.dp),
|
||||
tint = Color(0xff795548)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.cookie_explain),
|
||||
Modifier.widthIn(max = dimensionResource(id = R.dimen.signinscreen_landscape_caption_text_width))
|
||||
.padding(top = 24.dp),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
text = stringResource(id = R.string.cookie_explain),
|
||||
Modifier
|
||||
.widthIn(max = dimensionResource(id = R.dimen.signinscreen_landscape_caption_text_width))
|
||||
.padding(top = 24.dp),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
}
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
OutlinedTextField(
|
||||
value = ipbMemberId,
|
||||
onValueChange = { ipbMemberId = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "ipb_member_id") },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
supportingText = { if (ipbMemberIdErrorState) Text(stringResource(R.string.text_is_empty)) },
|
||||
trailingIcon = {
|
||||
if (ipbMemberIdErrorState) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
isError = ipbMemberIdErrorState,
|
||||
singleLine = true
|
||||
value = ipbMemberId,
|
||||
onValueChange = { ipbMemberId = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "ipb_member_id") },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
supportingText = { if (ipbMemberIdErrorState) Text(stringResource(R.string.text_is_empty)) },
|
||||
trailingIcon = {
|
||||
if (ipbMemberIdErrorState) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
isError = ipbMemberIdErrorState,
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = ipbPassHash,
|
||||
onValueChange = { ipbPassHash = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "ipb_pass_hash") },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
supportingText = { if (ipbPassHashErrorState) Text(stringResource(R.string.text_is_empty)) },
|
||||
trailingIcon = {
|
||||
if (ipbPassHashErrorState) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
isError = ipbPassHashErrorState,
|
||||
singleLine = true
|
||||
value = ipbPassHash,
|
||||
onValueChange = { ipbPassHash = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "ipb_pass_hash") },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
supportingText = { if (ipbPassHashErrorState) Text(stringResource(R.string.text_is_empty)) },
|
||||
trailingIcon = {
|
||||
if (ipbPassHashErrorState) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
isError = ipbPassHashErrorState,
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = igneous,
|
||||
onValueChange = { igneous = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "igneous") },
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { login() }
|
||||
),
|
||||
singleLine = true
|
||||
value = igneous,
|
||||
onValueChange = { igneous = it.trim { char -> char <= ' ' } },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(text = "igneous") },
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { login() }
|
||||
),
|
||||
singleLine = true
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Button(
|
||||
onClick = { login() },
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
.width(128.dp)
|
||||
onClick = { login() },
|
||||
Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.width(128.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = android.R.string.ok))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
TextButton(onClick = { fillCookiesFromClipboard() }, modifier = Modifier
|
||||
.padding(horizontal = 4.dp)) {
|
||||
TextButton(
|
||||
onClick = { fillCookiesFromClipboard() }, modifier = Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.from_clipboard))
|
||||
}
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.from_clipboard))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -426,30 +431,31 @@ fun CookieSignInScene(currentScreenDimension : ScreenDimension) {
|
||||
CircularProgressIndicator()
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
onDismissRequest = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showErrorDialog = false
|
||||
}) {
|
||||
Text(text = stringResource(id = R.string.get_it))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.sign_in_failed))
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
}) {
|
||||
Text(text = stringResource(id = R.string.get_it))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.sign_in_failed))
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
${ExceptionUtils.getReadableString(loginErrorException!!)}
|
||||
${stringResource(R.string.wrong_cookie_warning)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.hippo.ehviewer.ui.login
|
||||
|
||||
import android.os.Bundle
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.content.res.Resources.Theme
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.SideEffect
|
||||
@@ -16,7 +13,6 @@ import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.accompanist.themeadapter.material3.Mdc3Theme
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.EhCookieStore
|
||||
|
||||
@@ -69,7 +69,7 @@ import kotlinx.coroutines.Job
|
||||
import rikka.core.util.ContextUtils.requireActivity
|
||||
|
||||
@Composable
|
||||
fun SignInScreen(currentScreenDimension : ScreenDimension) {
|
||||
fun SignInScreen(currentScreenDimension: ScreenDimension) {
|
||||
val navController = LocalNavController.current
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val focusManager = LocalFocusManager.current
|
||||
@@ -131,215 +131,24 @@ fun SignInScreen(currentScreenDimension : ScreenDimension) {
|
||||
|
||||
|
||||
|
||||
when(currentScreenDimension){
|
||||
ScreenDimension.ScreenRotationPortrait -> Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
when (currentScreenDimension) {
|
||||
ScreenDimension.ScreenRotationPortrait -> Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||
contentDescription = null,
|
||||
Modifier.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = username,
|
||||
onValueChange = { username = it },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(stringResource(R.string.username)) },
|
||||
supportingText = { if (showUsernameError) Text(stringResource(R.string.error_username_cannot_empty)) },
|
||||
trailingIcon = {
|
||||
if (showUsernameError) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
singleLine = true,
|
||||
isError = showUsernameError
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = password,
|
||||
onValueChange = { password = it },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(stringResource(R.string.password)) },
|
||||
visualTransformation = if (passwordHidden) PasswordVisualTransformation() else VisualTransformation.None,
|
||||
supportingText = { if (showPasswordError) Text(stringResource(R.string.error_password_cannot_empty)) },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { signIn() }
|
||||
),
|
||||
trailingIcon = {
|
||||
if (showPasswordError)
|
||||
Icon(imageVector = Icons.Filled.Info, contentDescription = null)
|
||||
else
|
||||
IconButton(onClick = { passwordHidden = !passwordHidden }) {
|
||||
val visibilityIcon =
|
||||
if (passwordHidden) Icons.Filled.Visibility else Icons.Filled.VisibilityOff
|
||||
Icon(imageVector = visibilityIcon, contentDescription = null)
|
||||
}
|
||||
},
|
||||
singleLine = true,
|
||||
isError = showPasswordError
|
||||
)
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_waring),
|
||||
Modifier
|
||||
.widthIn(max = dimensionResource(id = R.dimen.single_max_width))
|
||||
.padding(top = 24.dp),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Row {
|
||||
FilledTonalButton(
|
||||
onClick = {
|
||||
UrlOpener.openUrl(
|
||||
requireActivity(context),
|
||||
EhUrl.URL_REGISTER,
|
||||
false
|
||||
)
|
||||
},
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.register))
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { signIn() },
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.sign_in))
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
Column(
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
TextButton(
|
||||
onClick = { navController.navigate(WEBVIEW_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_webview))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = { navController.navigate(COOKIE_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_cookies))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
Settings.putSelectSite(false)
|
||||
Settings.putGallerySite(EhUrl.SITE_E)
|
||||
navController.navigate(SELECT_SITE_ROUTE_NAME)
|
||||
},
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.tourist_mode))
|
||||
}
|
||||
}
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||
contentDescription = null,
|
||||
Modifier.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
}
|
||||
}
|
||||
if (isProgressIndicatorVisible) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showErrorDialog = false
|
||||
}) {
|
||||
Text(text = stringResource(id = R.string.get_it))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.sign_in_failed))
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
${ExceptionUtils.getReadableString(loginErrorException!!)}
|
||||
${stringResource(R.string.sign_in_failed_tip)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
ScreenDimension.ScreenRotationLandscape -> Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column( Modifier
|
||||
.width(dimensionResource(id = R.dimen.signinscreen_landscape_caption_frame_width))
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin)),
|
||||
horizontalAlignment = Alignment.CenterHorizontally){
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||
contentDescription = null,
|
||||
alignment = Alignment.Center,
|
||||
modifier = Modifier.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_waring),
|
||||
Modifier
|
||||
.widthIn(max = 480.dp)
|
||||
.padding(top = 24.dp),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)}
|
||||
|
||||
Column (Modifier.fillMaxWidth()){
|
||||
OutlinedTextField(
|
||||
OutlinedTextField(
|
||||
value = username,
|
||||
onValueChange = { username = it },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
@@ -347,18 +156,18 @@ fun SignInScreen(currentScreenDimension : ScreenDimension) {
|
||||
supportingText = { if (showUsernameError) Text(stringResource(R.string.error_username_cannot_empty)) },
|
||||
trailingIcon = {
|
||||
if (showUsernameError) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
singleLine = true,
|
||||
isError = showUsernameError
|
||||
)
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
OutlinedTextField(
|
||||
value = password,
|
||||
onValueChange = { password = it },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
@@ -367,7 +176,7 @@ fun SignInScreen(currentScreenDimension : ScreenDimension) {
|
||||
supportingText = { if (showPasswordError) Text(stringResource(R.string.error_password_cannot_empty)) },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { signIn() }
|
||||
onDone = { signIn() }
|
||||
),
|
||||
trailingIcon = {
|
||||
if (showPasswordError)
|
||||
@@ -375,120 +184,315 @@ fun SignInScreen(currentScreenDimension : ScreenDimension) {
|
||||
else
|
||||
IconButton(onClick = { passwordHidden = !passwordHidden }) {
|
||||
val visibilityIcon =
|
||||
if (passwordHidden) Icons.Filled.Visibility else Icons.Filled.VisibilityOff
|
||||
if (passwordHidden) Icons.Filled.Visibility else Icons.Filled.VisibilityOff
|
||||
Icon(imageVector = visibilityIcon, contentDescription = null)
|
||||
}
|
||||
},
|
||||
singleLine = true,
|
||||
isError = showPasswordError
|
||||
)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Button(
|
||||
onClick = { signIn() },
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_waring),
|
||||
Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.width(128.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.sign_in))
|
||||
}
|
||||
FilledTonalButton(
|
||||
.widthIn(max = dimensionResource(id = R.dimen.single_max_width))
|
||||
.padding(top = 24.dp),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Row {
|
||||
FilledTonalButton(
|
||||
onClick = {
|
||||
UrlOpener.openUrl(
|
||||
requireActivity(context),
|
||||
EhUrl.URL_REGISTER,
|
||||
false
|
||||
requireActivity(context),
|
||||
EhUrl.URL_REGISTER,
|
||||
false
|
||||
)
|
||||
},
|
||||
Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.width(128.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.register))
|
||||
.weight(1f)
|
||||
.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.register))
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { signIn() },
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.sign_in))
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
TextButton(
|
||||
onClick = { navController.navigate(COOKIE_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_cookies))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
TextButton(
|
||||
onClick = { navController.navigate(WEBVIEW_SIGN_IN_ROUTE_NAME) },
|
||||
Row(
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
) {
|
||||
TextButton(
|
||||
onClick = { navController.navigate(WEBVIEW_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_webview))
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_webview))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
TextButton(
|
||||
TextButton(
|
||||
onClick = { navController.navigate(COOKIE_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_cookies))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
Settings.putSelectSite(false)
|
||||
Settings.putGallerySite(EhUrl.SITE_E)
|
||||
navController.navigate(SELECT_SITE_ROUTE_NAME)
|
||||
},
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.tourist_mode))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (isProgressIndicatorVisible) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showErrorDialog = false
|
||||
}) {
|
||||
Text(text = stringResource(id = R.string.get_it))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.sign_in_failed))
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
${ExceptionUtils.getReadableString(loginErrorException!!)}
|
||||
${stringResource(R.string.sign_in_failed_tip)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (isProgressIndicatorVisible) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showErrorDialog = false
|
||||
}) {
|
||||
Text(text = stringResource(id = R.string.get_it))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.sign_in_failed))
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
ScreenDimension.ScreenRotationLandscape -> Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.width(dimensionResource(id = R.dimen.signinscreen_landscape_caption_frame_width))
|
||||
.padding(dimensionResource(id = R.dimen.keyline_margin)),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||
contentDescription = null,
|
||||
alignment = Alignment.Center,
|
||||
modifier = Modifier.padding(dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_waring),
|
||||
Modifier
|
||||
.widthIn(max = 480.dp)
|
||||
.padding(top = 24.dp),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
}
|
||||
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
OutlinedTextField(
|
||||
value = username,
|
||||
onValueChange = { username = it },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(stringResource(R.string.username)) },
|
||||
supportingText = { if (showUsernameError) Text(stringResource(R.string.error_username_cannot_empty)) },
|
||||
trailingIcon = {
|
||||
if (showUsernameError) Icon(
|
||||
imageVector = Icons.Filled.Info,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
singleLine = true,
|
||||
isError = showUsernameError
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = password,
|
||||
onValueChange = { password = it },
|
||||
Modifier.width(dimensionResource(id = R.dimen.single_max_width)),
|
||||
label = { Text(stringResource(R.string.password)) },
|
||||
visualTransformation = if (passwordHidden) PasswordVisualTransformation() else VisualTransformation.None,
|
||||
supportingText = { if (showPasswordError) Text(stringResource(R.string.error_password_cannot_empty)) },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { signIn() }
|
||||
),
|
||||
trailingIcon = {
|
||||
if (showPasswordError)
|
||||
Icon(imageVector = Icons.Filled.Info, contentDescription = null)
|
||||
else
|
||||
IconButton(onClick = { passwordHidden = !passwordHidden }) {
|
||||
val visibilityIcon =
|
||||
if (passwordHidden) Icons.Filled.Visibility else Icons.Filled.VisibilityOff
|
||||
Icon(imageVector = visibilityIcon, contentDescription = null)
|
||||
}
|
||||
},
|
||||
singleLine = true,
|
||||
isError = showPasswordError
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Button(
|
||||
onClick = { signIn() },
|
||||
Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.width(128.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.sign_in))
|
||||
}
|
||||
FilledTonalButton(
|
||||
onClick = {
|
||||
UrlOpener.openUrl(
|
||||
requireActivity(context),
|
||||
EhUrl.URL_REGISTER,
|
||||
false
|
||||
)
|
||||
},
|
||||
Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.width(128.dp)
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.register))
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
TextButton(
|
||||
onClick = { navController.navigate(COOKIE_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_cookies))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
TextButton(
|
||||
onClick = { navController.navigate(WEBVIEW_SIGN_IN_ROUTE_NAME) },
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.sign_in_via_webview))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
Settings.putSelectSite(false)
|
||||
Settings.putGallerySite(EhUrl.SITE_E)
|
||||
navController.navigate(SELECT_SITE_ROUTE_NAME)
|
||||
},
|
||||
Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buildAnnotatedString {
|
||||
withStyle(
|
||||
style = SpanStyle(textDecoration = TextDecoration.Underline)
|
||||
) {
|
||||
append(stringResource(id = R.string.tourist_mode))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (isProgressIndicatorVisible) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
if (showErrorDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
showErrorDialog = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showErrorDialog = false
|
||||
}) {
|
||||
Text(text = stringResource(id = R.string.get_it))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.sign_in_failed))
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text =
|
||||
"""
|
||||
${ExceptionUtils.getReadableString(loginErrorException!!)}
|
||||
${stringResource(R.string.sign_in_failed_tip)}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,7 @@ abstract class BaseScene : Fragment() {
|
||||
.build()
|
||||
NavHostFragment.findNavController(this).navigate(id, args, options)
|
||||
}
|
||||
|
||||
fun getScreenDimension(): ScreenDimension {
|
||||
|
||||
var dm = context?.resources?.displayMetrics
|
||||
@@ -244,14 +245,15 @@ abstract class BaseScene : Fragment() {
|
||||
var screenDimensionStatus = ScreenDimension.ScreenRotationLandscape
|
||||
|
||||
if (screenWidth != null) {
|
||||
screenDimensionStatus = if(screenWidth > screenHeight!!)
|
||||
screenDimensionStatus = if (screenWidth > screenHeight!!)
|
||||
ScreenDimension.ScreenRotationLandscape
|
||||
else{
|
||||
else {
|
||||
ScreenDimension.ScreenRotationPortrait
|
||||
}
|
||||
}
|
||||
return screenDimensionStatus
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LENGTH_SHORT = 0
|
||||
const val LENGTH_LONG = 1
|
||||
|
||||
@@ -77,12 +77,12 @@ import com.hippo.ehviewer.dao.Filter
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
|
||||
import com.hippo.text.URLImageGetter
|
||||
import com.hippo.util.toBBCode
|
||||
import com.hippo.util.ExceptionUtils
|
||||
import com.hippo.util.ReadableTime
|
||||
import com.hippo.util.TextUrl
|
||||
import com.hippo.util.addTextToClipboard
|
||||
import com.hippo.util.getParcelableCompat
|
||||
import com.hippo.util.toBBCode
|
||||
import com.hippo.view.ViewTransition
|
||||
import com.hippo.widget.FabLayout
|
||||
import com.hippo.widget.LinkifyTextView
|
||||
|
||||
@@ -153,12 +153,12 @@ import com.hippo.ehviewer.spider.SpiderQueen.Companion.MODE_READ
|
||||
import com.hippo.ehviewer.ui.CommonOperations
|
||||
import com.hippo.ehviewer.ui.GalleryInfoBottomSheet
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
import com.hippo.ehviewer.ui.ScreenDimension
|
||||
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
|
||||
import com.hippo.ehviewer.ui.widget.CrystalCard
|
||||
import com.hippo.ehviewer.ui.widget.EhAsyncPreview
|
||||
import com.hippo.ehviewer.ui.widget.GalleryDetailHeaderCard
|
||||
import com.hippo.ehviewer.ui.widget.GalleryDetailRating
|
||||
import com.hippo.ehviewer.ui.ScreenDimension
|
||||
import com.hippo.ehviewer.widget.GalleryRatingBar
|
||||
import com.hippo.ehviewer.widget.GalleryRatingBar.OnUserRateListener
|
||||
import com.hippo.text.URLImageGetter
|
||||
@@ -508,69 +508,15 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
contentPadding: PaddingValues,
|
||||
modifier: Modifier
|
||||
) {
|
||||
when(getScreenDimension()){
|
||||
ScreenDimension.ScreenRotationPortrait ->LazyVerticalGrid(
|
||||
columns = GridCells.Adaptive(Settings.thumbSizeDp),
|
||||
contentPadding = contentPadding,
|
||||
modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin))
|
||||
) {
|
||||
item(span = { GridItemSpan(maxCurrentLineSpan) }) {
|
||||
Column {
|
||||
GalleryDetailHeaderCard(
|
||||
galleryInfo = galleryInfo,
|
||||
galleryDetail = galleryDetail,
|
||||
onInfoCardClick = ::onGalleryInfoCardClick,
|
||||
onCategoryChipClick = ::onCategoryChipClick,
|
||||
onUploaderChipClick = ::onUploaderChipClick,
|
||||
onBlockUploaderIconClick = ::showFilterUploaderDialog,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
Row {
|
||||
FilledTonalButton(
|
||||
onClick = ::onDownloadButtonClick,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.weight(1F)
|
||||
) {
|
||||
Text(text = downloadButtonText)
|
||||
}
|
||||
Button(
|
||||
onClick = ::onReadButtonClick,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.weight(1F)
|
||||
) {
|
||||
Text(text = readButtonText)
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
BelowHeader(galleryDetail)
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
galleryDetailPreview(galleryDetail)
|
||||
}
|
||||
}
|
||||
ScreenDimension.ScreenRotationLandscape -> LazyVerticalGrid(
|
||||
when (getScreenDimension()) {
|
||||
ScreenDimension.ScreenRotationPortrait -> LazyVerticalGrid(
|
||||
columns = GridCells.Adaptive(Settings.thumbSizeDp),
|
||||
contentPadding = contentPadding,
|
||||
modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin))
|
||||
) {
|
||||
item(span = { GridItemSpan(maxCurrentLineSpan) }) {
|
||||
Column {
|
||||
Row(modifier = Modifier.fillMaxWidth()
|
||||
){
|
||||
GalleryDetailHeaderCard(
|
||||
) {
|
||||
item(span = { GridItemSpan(maxCurrentLineSpan) }) {
|
||||
Column {
|
||||
GalleryDetailHeaderCard(
|
||||
galleryInfo = galleryInfo,
|
||||
galleryDetail = galleryDetail,
|
||||
onInfoCardClick = ::onGalleryInfoCardClick,
|
||||
@@ -578,50 +524,108 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
onUploaderChipClick = ::onUploaderChipClick,
|
||||
onBlockUploaderIconClick = ::showFilterUploaderDialog,
|
||||
modifier = Modifier
|
||||
.width(dimensionResource(id = R.dimen.gallery_detail_card_landscape_width))
|
||||
.padding(vertical = dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
Column(modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Spacer(modifier = modifier.height(16.dp))
|
||||
Button(
|
||||
onClick = ::onReadButtonClick,
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.padding(horizontal = 16.dp)
|
||||
.width(192.dp)
|
||||
) {
|
||||
Text(text = readButtonText)
|
||||
}
|
||||
Spacer(modifier = modifier.height(24.dp))
|
||||
FilledTonalButton(
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
Row {
|
||||
FilledTonalButton(
|
||||
onClick = ::onDownloadButtonClick,
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.padding(horizontal = 16.dp)
|
||||
.width(192.dp)
|
||||
) {
|
||||
Text(text = downloadButtonText)
|
||||
.padding(horizontal = 4.dp)
|
||||
.weight(1F)
|
||||
) {
|
||||
Text(text = downloadButtonText)
|
||||
}
|
||||
Button(
|
||||
onClick = ::onReadButtonClick,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 4.dp)
|
||||
.weight(1F)
|
||||
) {
|
||||
Text(text = readButtonText)
|
||||
}
|
||||
}
|
||||
}}
|
||||
if (galleryDetail != null) {
|
||||
BelowHeader(galleryDetail)
|
||||
} else {
|
||||
Box(
|
||||
if (galleryDetail != null) {
|
||||
BelowHeader(galleryDetail)
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
galleryDetailPreview(galleryDetail)
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
galleryDetailPreview(galleryDetail)
|
||||
|
||||
ScreenDimension.ScreenRotationLandscape -> LazyVerticalGrid(
|
||||
columns = GridCells.Adaptive(Settings.thumbSizeDp),
|
||||
contentPadding = contentPadding,
|
||||
modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin))
|
||||
) {
|
||||
item(span = { GridItemSpan(maxCurrentLineSpan) }) {
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
GalleryDetailHeaderCard(
|
||||
galleryInfo = galleryInfo,
|
||||
galleryDetail = galleryDetail,
|
||||
onInfoCardClick = ::onGalleryInfoCardClick,
|
||||
onCategoryChipClick = ::onCategoryChipClick,
|
||||
onUploaderChipClick = ::onUploaderChipClick,
|
||||
onBlockUploaderIconClick = ::showFilterUploaderDialog,
|
||||
modifier = Modifier
|
||||
.width(dimensionResource(id = R.dimen.gallery_detail_card_landscape_width))
|
||||
.padding(vertical = dimensionResource(id = R.dimen.keyline_margin))
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Spacer(modifier = modifier.height(16.dp))
|
||||
Button(
|
||||
onClick = ::onReadButtonClick,
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.padding(horizontal = 16.dp)
|
||||
.width(192.dp)
|
||||
) {
|
||||
Text(text = readButtonText)
|
||||
}
|
||||
Spacer(modifier = modifier.height(24.dp))
|
||||
FilledTonalButton(
|
||||
onClick = ::onDownloadButtonClick,
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.padding(horizontal = 16.dp)
|
||||
.width(192.dp)
|
||||
) {
|
||||
Text(text = downloadButtonText)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
BelowHeader(galleryDetail)
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
galleryDetailPreview(galleryDetail)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun LazyGridScope.galleryDetailPreview(gd: GalleryDetail) {
|
||||
@@ -636,8 +640,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
CrystalCard(
|
||||
onClick = ::navigateToPreview,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(0.6666667F)
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(0.6666667F)
|
||||
) {}
|
||||
Text(stringResource(R.string.more_previews))
|
||||
}
|
||||
@@ -655,8 +659,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
mainActivity?.startReaderActivity(gd, it.position)
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(0.6666667F)
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(0.6666667F)
|
||||
) {
|
||||
EhAsyncPreview(
|
||||
model = it,
|
||||
@@ -730,8 +734,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
CrystalCard(
|
||||
onClick = ::showNewerVersionDialog,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(32.dp),
|
||||
.fillMaxWidth()
|
||||
.height(32.dp),
|
||||
) {}
|
||||
Text(text = stringResource(id = R.string.newer_version_avaliable))
|
||||
}
|
||||
@@ -783,8 +787,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(8.dp)
|
||||
.fillMaxWidth(),
|
||||
.padding(8.dp)
|
||||
.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
GalleryDetailRating(rating = galleryDetail.rating)
|
||||
|
||||
Reference in new issue
Block a user