Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to select texts in reader #95

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app/src/main/java/com/starry/myne/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ class MainActivity : AppCompatActivity() {
settingsViewModel = ViewModelProvider(this)[SettingsViewModel::class.java]
mainViewModel = ViewModelProvider(this)[MainViewModel::class.java]

when (settingsViewModel.getThemeValue()) {
ThemeMode.Auto.ordinal -> settingsViewModel.setTheme(ThemeMode.Auto)
ThemeMode.Dark.ordinal -> settingsViewModel.setTheme(ThemeMode.Dark)
ThemeMode.Light.ordinal -> settingsViewModel.setTheme(ThemeMode.Light)
}

ThemeMode.entries.find { it.ordinal == settingsViewModel.getThemeValue()}
?.let { settingsViewModel.setTheme(it) }
settingsViewModel.setMaterialYou(settingsViewModel.getMaterialYouValue())

// Install splash screen before setting content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -82,10 +83,9 @@ class ReaderRVAdapter(
val chapter = allChapters[position]
composeView.setContent {
MyneTheme(settingsViewModel = activity.settingsViewModel) {
ReaderItem(
chapter = chapter,
viewModel = viewModel
)
SelectionContainer {
ReaderItem(chapter = chapter, viewModel = viewModel)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ class PreferenceUtil(context: Context) {
prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
}

fun keyExists(key: String): Boolean {
if (prefs.contains(key))
return true
return false
}
fun keyExists(key: String): Boolean = prefs.contains(key)

fun putString(key: String, value: String) {
val prefsEditor = prefs.edit()
Expand Down