remove unused code
This commit is contained in:
@ -2,15 +2,11 @@ package app.omnivore.omnivore
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.dataStore
|
||||
import androidx.datastore.preferences.core.*
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import androidx.lifecycle.asLiveData
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
interface DatastoreRepository {
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package app.omnivore.omnivore
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
|
||||
@ -12,7 +12,6 @@ import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
//import androidx.compose.material.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
|
||||
@ -7,7 +7,6 @@ import retrofit2.http.Body
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.POST
|
||||
|
||||
|
||||
data class EmailAuthPayload(
|
||||
val authCookieString: String?,
|
||||
val authToken: String?,
|
||||
|
||||
@ -1,154 +0,0 @@
|
||||
package app.omnivore.omnivore
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.omnivore.omnivore.ui.theme.OmnivoreTheme
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SaveActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val viewModel: SaveViewModel by viewModels()
|
||||
var extractedText: String? = null
|
||||
val authToken = viewModel.getAuthToken()
|
||||
|
||||
when (intent?.action) {
|
||||
Intent.ACTION_SEND -> {
|
||||
if (intent.type?.startsWith("text/plain") == true) {
|
||||
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
|
||||
extractedText = it
|
||||
viewModel.saveURL(it)
|
||||
}
|
||||
}
|
||||
|
||||
if (intent.type?.startsWith("text/html") == true) {
|
||||
intent.getStringExtra(Intent.EXTRA_HTML_TEXT)?.let {
|
||||
extractedText = it
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
// Handle other intents, such as being started from the home screen
|
||||
}
|
||||
}
|
||||
|
||||
setContent {
|
||||
OmnivoreTheme {
|
||||
//dialog()
|
||||
// saveBottomModal()
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colors.background)
|
||||
.fillMaxSize()
|
||||
) {
|
||||
Text(text = extractedText ?: "no text extracted")
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(text = authToken ?: "no auth token")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun dialog() {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
// Dismiss the dialog when the user clicks outside the dialog or on the back
|
||||
// button. If you want to disable that functionality, simply use an empty
|
||||
// onCloseRequest.
|
||||
// openDialog.value = false
|
||||
},
|
||||
title = {
|
||||
Text(text = "Dialog Title")
|
||||
},
|
||||
text = {
|
||||
Text("Here is a text ")
|
||||
},
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = {
|
||||
// openDialog.value = false
|
||||
}) {
|
||||
Text("This is the Confirm Button")
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
Button(
|
||||
onClick = {
|
||||
// openDialog.value = false
|
||||
}) {
|
||||
Text("This is the dismiss Button")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun saveBottomModal() {
|
||||
val scaffoldState = rememberScaffoldState()
|
||||
val modalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.HalfExpanded)
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
Scaffold(
|
||||
scaffoldState = scaffoldState,
|
||||
) { innerPadding ->
|
||||
Box(modifier = Modifier.padding(innerPadding)) {
|
||||
Button(onClick = {
|
||||
coroutineScope.launch {
|
||||
modalBottomSheetState.show()
|
||||
}
|
||||
}) {
|
||||
Text(text = "Show")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModalBottomSheetLayout(
|
||||
sheetState = modalBottomSheetState,
|
||||
sheetContent = {
|
||||
LazyColumn {
|
||||
item {
|
||||
TextButton(modifier = Modifier.fillMaxWidth(), onClick = {
|
||||
// do something
|
||||
}) {
|
||||
Row {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Add,
|
||||
// painterResource(id = R.drawable.ic_baseline_add_24),
|
||||
contentDescription = "New Album"
|
||||
)
|
||||
Text("New Album")
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ abstract class SaveSheetActivity: AppCompatActivity() {
|
||||
|
||||
val viewModel: SaveViewModel by viewModels()
|
||||
var extractedText: String? = null
|
||||
val authToken = viewModel.getAuthToken()
|
||||
|
||||
when (intent?.action) {
|
||||
Intent.ACTION_SEND -> {
|
||||
@ -64,10 +63,8 @@ abstract class SaveSheetActivity: AppCompatActivity() {
|
||||
sheetBackgroundColor = Color.Transparent,
|
||||
sheetState = modalBottomSheetState,
|
||||
sheetContent = {
|
||||
BottomSheetUI(coroutineScope, modalBottomSheetState) {
|
||||
ScreenContent(viewModel, coroutineScope, modalBottomSheetState) {
|
||||
onFinish(coroutineScope, modalBottomSheetState)
|
||||
}
|
||||
BottomSheetUI {
|
||||
ScreenContent(viewModel, modalBottomSheetState)
|
||||
}
|
||||
}
|
||||
) {}
|
||||
@ -94,11 +91,7 @@ abstract class SaveSheetActivity: AppCompatActivity() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BottomSheetUI(
|
||||
coroutineScope: CoroutineScope,
|
||||
modalBottomSheetState: ModalBottomSheetState,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
private fun BottomSheetUI(content: @Composable () -> Unit) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
@ -158,9 +151,7 @@ abstract class SaveSheetActivity: AppCompatActivity() {
|
||||
@Composable
|
||||
fun ScreenContent(
|
||||
viewModel: SaveViewModel,
|
||||
coroutineScope: CoroutineScope,
|
||||
modalBottomSheetState: ModalBottomSheetState,
|
||||
onExit: () -> Unit?
|
||||
modalBottomSheetState: ModalBottomSheetState
|
||||
) {
|
||||
Box(modifier = Modifier.height(300.dp).background(Color.White)) {
|
||||
SaveContent(viewModel, modalBottomSheetState, modifier = Modifier.fillMaxSize())
|
||||
|
||||
@ -26,7 +26,7 @@ class SaveViewModel @Inject constructor(
|
||||
var message by mutableStateOf<String?>(null)
|
||||
private set
|
||||
|
||||
fun getAuthToken(): String? = runBlocking {
|
||||
private fun getAuthToken(): String? = runBlocking {
|
||||
datastoreRepo.getString(DatastoreKeys.omnivoreAuthToken)
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package app.omnivore.omnivore.ui.theme
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
private val LightColors = lightColorScheme(
|
||||
primary = md_theme_light_primary,
|
||||
@ -68,11 +68,16 @@ private val DarkColors = darkColorScheme(
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun OmnivoreTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
||||
val colorScheme = if (darkTheme) {
|
||||
DarkColors
|
||||
fun OmnivoreTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
useDynamicTheme: Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colorScheme = if (useDynamicTheme) {
|
||||
val context = LocalContext.current
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
} else {
|
||||
LightColors
|
||||
if (darkTheme) DarkColors else LightColors
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
|
||||
Reference in New Issue
Block a user