Skip to content

Commit

Permalink
4.44.0 move .kt into kotlin folder; prep compose theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshnsears committed Sep 3, 2024
1 parent 7622b46 commit dc020cf
Show file tree
Hide file tree
Showing 34 changed files with 159 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.jameshnsears.quoteunquote.cloud.transfer.restore

import com.github.jameshnsears.quoteunquote.cloud.transfer.TransferUtility
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.TransferBackup
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.restore.TransferRestore
import io.mockk.every
import io.mockk.mockkObject
import org.junit.Assert.assertTrue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.jameshnsears.quoteunquote.cloud.transfer.restore

import android.os.Build
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.TransferBackup
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.restore.TransferRestore
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.jameshnsears.quoteunquote.cloud.transfer.restore
import com.github.jameshnsears.quoteunquote.cloud.transfer.Transfer
import com.github.jameshnsears.quoteunquote.cloud.transfer.TransferUtility
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.TransferBackup
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.restore.TransferRestore
import com.github.jameshnsears.quoteunquote.database.quotation.QuotationEntity
import io.mockk.every
import io.mockk.mockkObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.jameshnsears.quoteunquote.configure.fragment.sync

import androidx.test.core.app.ApplicationProvider.getApplicationContext
import androidx.test.platform.app.InstrumentationRegistry
import com.github.jameshnsears.quoteunquote.sync.SyncJsonSchemaValidation
import com.github.jameshnsears.quoteunquote.utils.logging.MethodLineLoggingTree
import org.junit.Assert.assertTrue
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import com.github.jameshnsears.quoteunquote.database.history.FavouriteEntity;
import com.github.jameshnsears.quoteunquote.database.quotation.AuthorPOJO;
import com.github.jameshnsears.quoteunquote.database.quotation.QuotationEntity;
import com.github.jameshnsears.quoteunquote.scraper.Scraper;
import com.github.jameshnsears.quoteunquote.scraper.ScraperData;
import com.github.jameshnsears.quoteunquote.scraper.ScraperQuotationException;
import com.github.jameshnsears.quoteunquote.scraper.ScraperSourceException;
import com.github.jameshnsears.quoteunquote.scraper.ScraperUrlException;
import com.github.jameshnsears.quoteunquote.utils.ContentSelection;
import com.github.jameshnsears.quoteunquote.utils.ImportHelper;
import com.github.jameshnsears.quoteunquote.utils.scraper.Scraper;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperData;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperQuotationException;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperSourceException;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperUrlException;

import org.jsoup.nodes.Document;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.github.jameshnsears.quoteunquote.configure.fragment.quotations.QuotationsPreferences;
import com.github.jameshnsears.quoteunquote.database.quotation.QuotationEntity;
import com.github.jameshnsears.quoteunquote.listview.ListViewService;
import com.github.jameshnsears.quoteunquote.scraper.ScraperData;
import com.github.jameshnsears.quoteunquote.utils.ContentSelection;
import com.github.jameshnsears.quoteunquote.utils.ImportHelper;
import com.github.jameshnsears.quoteunquote.utils.IntentFactoryHelper;
Expand All @@ -44,7 +45,6 @@
import com.github.jameshnsears.quoteunquote.utils.notification.NotificationsDailyAlarm;
import com.github.jameshnsears.quoteunquote.utils.preference.PreferencesFacade;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperAlarm;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperData;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ExecutorService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.github.jameshnsears.quoteunquote.R;
import com.github.jameshnsears.quoteunquote.cloud.transfer.Transfer;
import com.github.jameshnsears.quoteunquote.cloud.transfer.TransferRestoreResponse;
import com.github.jameshnsears.quoteunquote.cloud.transfer.restore.TransferRestore;
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.restore.TransferRestore;
import com.github.jameshnsears.quoteunquote.configure.fragment.sync.SyncFragment;
import com.github.jameshnsears.quoteunquote.configure.fragment.sync.SyncPreferences;
import com.github.jameshnsears.quoteunquote.database.DatabaseRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import com.github.jameshnsears.quoteunquote.configure.fragment.quotations.QuotationsPreferences;
import com.github.jameshnsears.quoteunquote.database.DatabaseRepository;
import com.github.jameshnsears.quoteunquote.databinding.FragmentQuotationsTabDatabaseTabWebBinding;
import com.github.jameshnsears.quoteunquote.scraper.ScraperData;
import com.github.jameshnsears.quoteunquote.utils.ImportHelper;
import com.github.jameshnsears.quoteunquote.utils.scraper.ScraperData;

import timber.log.Timber;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
import com.github.jameshnsears.quoteunquote.cloud.CloudServiceRestore;
import com.github.jameshnsears.quoteunquote.cloud.CloudTransferHelper;
import com.github.jameshnsears.quoteunquote.cloud.transfer.Transfer;
import com.github.jameshnsears.quoteunquote.cloud.transfer.restore.TransferRestore;
import com.github.jameshnsears.quoteunquote.cloud.transfer.backup.restore.TransferRestore;
import com.github.jameshnsears.quoteunquote.configure.ConfigureActivity;
import com.github.jameshnsears.quoteunquote.configure.fragment.FragmentCommon;
import com.github.jameshnsears.quoteunquote.database.DatabaseRepository;
import com.github.jameshnsears.quoteunquote.databinding.FragmentSyncBinding;
import com.github.jameshnsears.quoteunquote.sync.SyncJsonSchemaValidation;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import com.google.gson.Gson;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jameshnsears.quoteunquote.cloud.transfer.restore
package com.github.jameshnsears.quoteunquote.cloud.transfer.backup.restore

import android.app.AlarmManager
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package com.github.jameshnsears.quoteunquote.configure.fragment.quotations.tabs.content.tabs

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Card
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -23,16 +27,26 @@ fun Greeting(
) {
val state = stateFlow.collectAsState()

if (state.value) {
ElevatedCard(
// if (state.value) {

Box(
modifier = Modifier
.padding(start = 5.dp, end = 5.dp)
) {
OutlinedCard(
elevation = CardDefaults.cardElevation(
defaultElevation = 6.dp
defaultElevation = 4.dp
),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant,
),
modifier = Modifier
.size(width = 240.dp, height = 100.dp)
.height(60.dp)
.fillMaxWidth()
.wrapContentHeight()
.clip(RoundedCornerShape(12.dp))
.padding(3.dp),
shape = RoundedCornerShape(12.dp)
) {
Text(
text = "Hello, $name!",
Expand All @@ -42,6 +56,9 @@ fun Greeting(
)
}
}


// }
}

@Preview(apiLevel = 34)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.github.jameshnsears.quoteunquote.R
import com.github.jameshnsears.quoteunquote.configure.ConfigureActivity
import com.github.jameshnsears.quoteunquote.configure.fragment.quotations.QuotationsPreferences
import com.github.jameshnsears.quoteunquote.database.DatabaseRepository
import com.github.jameshnsears.quoteunquote.databinding.FragmentQuotationsTabDatabaseTabCsvBinding
import com.github.jameshnsears.quoteunquote.theme.QuoteUnquoteTheme
import com.github.jameshnsears.quoteunquote.utils.ImportHelper
import com.github.jameshnsears.quoteunquote.utils.ImportHelper.ImportHelperException
import com.google.android.material.snackbar.BaseTransientBottomBar
Expand Down Expand Up @@ -62,7 +62,7 @@ class ContentCsvFragment(widgetId: Int) : ContentFragment(widgetId) {

_stateFlow.value = quotationsPreferences!!.databaseExternalCsv
setContent {
MaterialTheme {
QuoteUnquoteTheme {
Greeting(
stateFlow,
":-)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jameshnsears.quoteunquote.utils.scraper
package com.github.jameshnsears.quoteunquote.scraper

import okhttp3.OkHttpClient
import okhttp3.Request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jameshnsears.quoteunquote.utils.scraper
package com.github.jameshnsears.quoteunquote.scraper

data class ScraperData(
val scrapeResult: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jameshnsears.quoteunquote.utils.scraper
package com.github.jameshnsears.quoteunquote.scraper

open class ScraperException(message: String?) : java.lang.Exception(message)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jameshnsears.quoteunquote.configure.fragment.sync
package com.github.jameshnsears.quoteunquote.sync

import android.content.Context
import net.pwall.json.schema.JSONSchema
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.jameshnsears.quoteunquote.theme

import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.github.jameshnsears.quoteunquote.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
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.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80,
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40,

/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)

@Composable
fun QuoteUnquoteTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit,
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.jameshnsears.quoteunquote.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp,
),
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<string name="fragment_quotations_database_csv">CSV file</string>
<string name="fragment_quotations_database_button_import">Import</string>
<string name="fragment_quotations_database_external_instructions_1_info"></string>
<string name="fragment_quotations_database_external_instructions_1">\u2022 Export an Internal Database Source for an example</string>
<string name="fragment_quotations_database_external_instructions_1">\u2022 Export an Internal Database Source for an example CSV file</string>
<string name="fragment_quotations_database_external_instructions_2">\u2022 Expected format is <b>Source||Quotation</b> per line</string>
<string name="fragment_quotations_database_external_instructions_3">\u2022 File should be UTF-8 encoded</string>
<string name="fragment_quotations_database_import_contents_0">Invalid: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.github.jameshnsears.quoteunquote.utils.scraper

import com.github.jameshnsears.quoteunquote.scraper.Scraper
import com.github.jameshnsears.quoteunquote.scraper.ScraperQuotationException
import com.github.jameshnsears.quoteunquote.scraper.ScraperSourceException
import com.github.jameshnsears.quoteunquote.scraper.ScraperUrlException
import io.mockk.every
import io.mockk.spyk
import kotlinx.coroutines.test.runTest
Expand Down

0 comments on commit dc020cf

Please sign in to comment.