Fix detekt violations and add detekt CI workflow on pull requests
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
name: Detekt
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
|
||||
jobs:
|
||||
detekt:
|
||||
name: Run Detekt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'temurin'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
- name: Run detekt
|
||||
run: ./gradlew detekt
|
||||
- name: Upload detekt reports
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: detekt-reports
|
||||
path: |
|
||||
app/build/reports/detekt/
|
||||
UI/build/reports/detekt/
|
||||
|
||||
@@ -36,4 +36,4 @@ fun AppCard(
|
||||
interactionSource = interactionSource,
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.github.premnirmal.ticker.ui
|
||||
package com.github.premnirmal.tickerwidget.ui
|
||||
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@@ -67,4 +67,4 @@ internal fun AppColours.toColorScheme(): ColorScheme {
|
||||
outlineVariant = this.outlineVariant,
|
||||
scrim = this.scrim,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ val AppShapes = Shapes(
|
||||
small = RoundedCornerShape(24.dp),
|
||||
medium = RoundedCornerShape(16.dp),
|
||||
large = RoundedCornerShape(8.dp)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -55,4 +55,4 @@ enum class SelectedTheme {
|
||||
SYSTEM,
|
||||
LIGHT,
|
||||
DARK,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,4 +122,4 @@ val AppTypography = Typography(
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -124,4 +124,4 @@ object ColourPalette {
|
||||
}
|
||||
|
||||
val ImagePlaceHolderGray = Color(0x20a7a7a7)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ plugins {
|
||||
|
||||
detekt {
|
||||
toolVersion = libs.versions.detekt.get()
|
||||
config.setFrom(file("../config/detekt/detekt.yml"))
|
||||
config.setFrom(files("../config/detekt/detekt.yml", "../config/detekt/detekt-formatting.yml"))
|
||||
buildUponDefaultConfig = true
|
||||
autoCorrect = true
|
||||
}
|
||||
|
||||
@@ -259,6 +259,7 @@ class AppPreferences @Inject constructor(
|
||||
const val UPDATE_INTERVAL = "UPDATE_INTERVAL"
|
||||
const val LAYOUT_TYPE = "LAYOUT_TYPE"
|
||||
const val WIDGET_SIZE = "WIDGET_SIZE"
|
||||
|
||||
@Deprecated("will be removed in future version")
|
||||
const val FONT_SIZE = "FONT_SIZE"
|
||||
const val BOLD_CHANGE = "BOLD_CHANGE"
|
||||
|
||||
@@ -47,6 +47,7 @@ class DbViewerViewModel @Inject constructor(
|
||||
val htmlFile: StateFlow<File?>
|
||||
get() = _htmlFile
|
||||
|
||||
@Suppress("LongMethod")
|
||||
fun generateDatabaseHtml() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
_showProgress.emit(true)
|
||||
|
||||
@@ -39,13 +39,13 @@ import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.ui.AppCard
|
||||
import com.github.premnirmal.tickerwidget.ui.theme.ColourPalette
|
||||
|
||||
private const val QuoteMaxLines = 1
|
||||
private const val QUOTE_MAX_LINES = 1
|
||||
|
||||
@Composable
|
||||
fun QuoteCard(
|
||||
quote: Quote,
|
||||
modifier: Modifier = Modifier,
|
||||
quoteNameMaxLines: Int = QuoteMaxLines,
|
||||
quoteNameMaxLines: Int = QUOTE_MAX_LINES,
|
||||
interactionSource: MutableInteractionSource? = null,
|
||||
onClick: (Quote) -> Unit,
|
||||
onRemoveClick: (Quote) -> Unit = {},
|
||||
@@ -79,7 +79,7 @@ private fun InstrumentCard(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = quote.symbol
|
||||
)
|
||||
if(showMore) {
|
||||
if (showMore) {
|
||||
MoreIcon(
|
||||
onClick = {
|
||||
onRemoveClick(quote)
|
||||
@@ -128,7 +128,7 @@ private fun PositionCard(
|
||||
text = quote.priceFormat.format(quote.lastTradePrice),
|
||||
textAlign = TextAlign.End
|
||||
)
|
||||
if(showMore) {
|
||||
if (showMore) {
|
||||
MoreIcon(
|
||||
onClick = {
|
||||
onMoreClick(quote)
|
||||
@@ -378,9 +378,11 @@ private fun MoreIcon(
|
||||
},
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 4.dp).clickable {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(horizontal = 4.dp).clickable {
|
||||
onClick()
|
||||
}) {
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier.size(18.dp).padding(end = 4.dp),
|
||||
painter = painterResource(R.drawable.ic_remove_circle),
|
||||
|
||||
@@ -110,11 +110,11 @@ import com.github.premnirmal.ticker.ui.MultilineXAxisRenderer
|
||||
import com.github.premnirmal.ticker.ui.TextMarkerView
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.ticker.ui.ValueAxisFormatter
|
||||
import com.github.premnirmal.ticker.ui.fadingEdges
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.google.accompanist.adaptive.FoldAwareConfiguration
|
||||
import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy
|
||||
import com.google.accompanist.adaptive.TwoPane
|
||||
import com.mnikonov.fade_out.fadingEdges
|
||||
|
||||
@Composable
|
||||
fun QuoteDetailScreen(
|
||||
@@ -523,6 +523,7 @@ private fun LazyGridScope.quoteDetailsGrid(details: List<QuoteDetail>) {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
private fun LazyGridScope.quotePositionsNotesAlerts(
|
||||
quote: Quote,
|
||||
isInPortfolio: Boolean
|
||||
|
||||
@@ -84,10 +84,10 @@ import com.github.premnirmal.ticker.network.data.Quote
|
||||
import com.github.premnirmal.ticker.ui.ContentType
|
||||
import com.github.premnirmal.ticker.ui.LocalContentType
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.ticker.ui.fadingEdges
|
||||
import com.github.premnirmal.ticker.widget.WidgetData
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.ui.theme.SelectedTheme
|
||||
import com.mnikonov.fade_out.fadingEdges
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import sh.calvin.reorderable.ReorderableItem
|
||||
|
||||
@@ -191,11 +191,16 @@ class AlarmScheduler @Inject constructor(
|
||||
)
|
||||
if (canScheduleExactAlarm()) {
|
||||
alarmManager.setExact(
|
||||
AlarmManager.ELAPSED_REALTIME, clock.elapsedRealtime() + msToNextAlarm, pendingIntent
|
||||
AlarmManager.ELAPSED_REALTIME,
|
||||
clock.elapsedRealtime() + msToNextAlarm,
|
||||
pendingIntent
|
||||
)
|
||||
} else {
|
||||
alarmManager.setWindow(
|
||||
AlarmManager.ELAPSED_REALTIME, clock.elapsedRealtime() + msToNextAlarm, MINUTES.toMillis(10), pendingIntent
|
||||
AlarmManager.ELAPSED_REALTIME,
|
||||
clock.elapsedRealtime() + msToNextAlarm,
|
||||
MINUTES.toMillis(10),
|
||||
pendingIntent
|
||||
)
|
||||
}
|
||||
val constraints = Constraints.Builder()
|
||||
@@ -231,9 +236,9 @@ class AlarmScheduler @Inject constructor(
|
||||
fun enqueuePeriodicCleanup() {
|
||||
val constraints = Constraints.Builder().setRequiredNetworkType(NetworkType.NOT_REQUIRED).build()
|
||||
val request = PeriodicWorkRequestBuilder<CleanupWorker>(1, TimeUnit.DAYS)
|
||||
.addTag(CleanupWorker.TAG_PERIODIC)
|
||||
.setConstraints(constraints)
|
||||
.build()
|
||||
.addTag(CleanupWorker.TAG_PERIODIC)
|
||||
.setConstraints(constraints)
|
||||
.build()
|
||||
workManager.enqueueUniquePeriodicWork(CleanupWorker.TAG_PERIODIC, ExistingPeriodicWorkPolicy.UPDATE, request)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,4 +40,3 @@ class FetchEventLogger @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import java.io.Serializable
|
||||
import java.lang.ref.WeakReference
|
||||
import java.time.Duration
|
||||
import java.time.LocalDate
|
||||
import javax.inject.Inject
|
||||
@@ -28,8 +27,6 @@ class HistoryProvider @Inject constructor(
|
||||
private val chartApi: ChartApi
|
||||
) {
|
||||
|
||||
private var cachedData: WeakReference<Pair<String, ChartData>>? = null
|
||||
|
||||
suspend fun fetchDataByRange(
|
||||
symbol: String,
|
||||
range: Range
|
||||
|
||||
@@ -231,7 +231,6 @@ class StocksProvider constructor(
|
||||
return tickerSet.contains(ticker)
|
||||
}
|
||||
|
||||
|
||||
suspend fun fetch(allowScheduling: Boolean = true): FetchResult<List<Quote>> = withContext(Dispatchers.IO) {
|
||||
if (tickerSet.isEmpty()) {
|
||||
Timber.d("No tickers/symbols to fetch")
|
||||
|
||||
@@ -106,6 +106,7 @@ data class Thumbnail(
|
||||
val url: String? = null
|
||||
)
|
||||
|
||||
@Suppress("FunctionNaming")
|
||||
fun NewsArticle(
|
||||
title: String,
|
||||
url: String,
|
||||
|
||||
@@ -6,7 +6,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class TagComparison(
|
||||
@SerialName("url") val url: String,
|
||||
@SerialName("html_url") val html_url: String,
|
||||
@SerialName("html_url") val htmlUrl: String,
|
||||
@SerialName("commits") val commits: List<RepoCommit>,
|
||||
@SerialName("status") val status: String,
|
||||
@SerialName("ahead_by") val aheadBy: Int,
|
||||
@@ -17,9 +17,9 @@ data class TagComparison(
|
||||
@Serializable
|
||||
data class RepoCommit(
|
||||
@SerialName("sha") val sha: String,
|
||||
@SerialName("node_id") val node_id: String,
|
||||
@SerialName("node_id") val nodeId: String,
|
||||
@SerialName("url") val url: String,
|
||||
@SerialName("html_url") val html_url: String,
|
||||
@SerialName("html_url") val htmlUrl: String,
|
||||
@SerialName("commit") val commit: Commit,
|
||||
@SerialName("author") val author: Author
|
||||
)
|
||||
|
||||
@@ -109,7 +109,8 @@ fun NewsCardPreview() {
|
||||
)
|
||||
NewsCard(
|
||||
NewsArticle(
|
||||
title = "Lorem ipsum testing this is a long news article lorem ipsum testing this is a long news article lorem ipsum testing this is a long news article lorem ipsum testing this is a long news article",
|
||||
title = "Lorem ipsum testing this is a long news article lorem ipsum " +
|
||||
"testing this is a long news article lorem ipsum testing",
|
||||
url = "https://news.google.com/xyz",
|
||||
publishedAt = "Tue, 3 Jun 2008 11:05:30 GMT",
|
||||
imageUrl = "https://example.com/image.jpg"
|
||||
|
||||
@@ -31,9 +31,9 @@ import com.github.premnirmal.ticker.news.NewsFeedItem.TrendingStockNewsFeed
|
||||
import com.github.premnirmal.ticker.ui.ErrorState
|
||||
import com.github.premnirmal.ticker.ui.ProgressState
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.ticker.ui.fadingEdges
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.R.string
|
||||
import com.mnikonov.fade_out.fadingEdges
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
||||
@@ -17,6 +17,7 @@ class CleanupWorker(context: Context, params: WorkerParameters) : CoroutineWorke
|
||||
}
|
||||
|
||||
@Inject internal lateinit var stocksProvider: StocksProvider
|
||||
|
||||
@Inject internal lateinit var widgetDataProvider: WidgetDataProvider
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
@@ -33,4 +34,4 @@ class CleanupWorker(context: Context, params: WorkerParameters) : CoroutineWorke
|
||||
Timber.d("Cleanup success")
|
||||
return Result.success()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ import com.github.premnirmal.ticker.network.data.holdingsSum
|
||||
import com.github.premnirmal.ticker.ui.AppTextFieldDefaultColors
|
||||
import com.github.premnirmal.ticker.ui.ContentType
|
||||
import com.github.premnirmal.ticker.ui.ContentType.SINGLE_PANE
|
||||
import com.github.premnirmal.ticker.ui.Divider
|
||||
import com.github.premnirmal.ticker.ui.LocalAppMessaging
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.ui.Divider
|
||||
import com.google.accompanist.adaptive.FoldAwareConfiguration
|
||||
import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy
|
||||
import com.google.accompanist.adaptive.TwoPane
|
||||
|
||||
@@ -29,9 +29,9 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.github.premnirmal.ticker.ui.Divider
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.R.string
|
||||
import com.github.premnirmal.tickerwidget.ui.Divider
|
||||
|
||||
@Composable
|
||||
fun AddSymbolDialog(
|
||||
|
||||
@@ -57,11 +57,11 @@ import com.github.premnirmal.ticker.ui.ContentType
|
||||
import com.github.premnirmal.ticker.ui.ContentType.SINGLE_PANE
|
||||
import com.github.premnirmal.ticker.ui.ErrorState
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.ticker.ui.fadingEdges
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.google.accompanist.adaptive.FoldAwareConfiguration
|
||||
import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy
|
||||
import com.google.accompanist.adaptive.TwoPane
|
||||
import com.mnikonov.fade_out.fadingEdges
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
||||
@@ -17,8 +17,8 @@ import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.premnirmal.ticker.network.data.Suggestion
|
||||
import com.github.premnirmal.ticker.ui.Divider
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.ui.Divider
|
||||
|
||||
@Composable
|
||||
fun SuggestionItem(
|
||||
|
||||
@@ -12,4 +12,3 @@ data class FetchLogRow(
|
||||
@ColumnInfo(name = "event") val event: String,
|
||||
@ColumnInfo(name = "detail") val detail: String,
|
||||
)
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ val MIGRATION_1_2 = object : Migration(1, 2) {
|
||||
|
||||
// Add the new table PropertiesRow.
|
||||
database.execSQL(
|
||||
"CREATE TABLE IF NOT EXISTS `PropertiesRow` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `properties_quote_symbol` TEXT NOT NULL, `notes` TEXT NOT NULL, `alert_above` REAL NOT NULL, `alert_below` REAL NOT NULL)"
|
||||
"CREATE TABLE IF NOT EXISTS `PropertiesRow` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
"`properties_quote_symbol` TEXT NOT NULL, `notes` TEXT NOT NULL, " +
|
||||
"`alert_above` REAL NOT NULL, `alert_below` REAL NOT NULL)"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -114,8 +116,8 @@ val MIGRATION_7_8 = object : Migration(7, 8) {
|
||||
val MIGRATION_8_9 = object : Migration(8, 9) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL(
|
||||
"CREATE TABLE IF NOT EXISTS `FetchLogRow` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `created_at_ms` INTEGER NOT NULL, `source` TEXT NOT NULL, `event` TEXT NOT NULL, `detail` TEXT NOT NULL)"
|
||||
"CREATE TABLE IF NOT EXISTS `FetchLogRow` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
|
||||
"`created_at_ms` INTEGER NOT NULL, `source` TEXT NOT NULL, `event` TEXT NOT NULL, `detail` TEXT NOT NULL)"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,20 +57,20 @@ import com.github.premnirmal.ticker.navigation.rememberScrollToTopAction
|
||||
import com.github.premnirmal.ticker.settings.SettingsViewModel.SettingsData
|
||||
import com.github.premnirmal.ticker.showDialog
|
||||
import com.github.premnirmal.ticker.ui.CheckboxPreference
|
||||
import com.github.premnirmal.ticker.ui.Divider
|
||||
import com.github.premnirmal.ticker.ui.ListPreference
|
||||
import com.github.premnirmal.ticker.ui.MultiSelectListPreference
|
||||
import com.github.premnirmal.ticker.ui.SettingsText
|
||||
import com.github.premnirmal.ticker.ui.TimeSelectorPreference
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.ticker.ui.fadingEdges
|
||||
import com.github.premnirmal.tickerwidget.BuildConfig
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.ui.Divider
|
||||
import com.github.premnirmal.tickerwidget.ui.theme.Alegreya
|
||||
import com.github.premnirmal.tickerwidget.ui.theme.Bold
|
||||
import com.google.accompanist.permissions.ExperimentalPermissionsApi
|
||||
import com.google.accompanist.permissions.isGranted
|
||||
import com.google.accompanist.permissions.rememberPermissionState
|
||||
import com.mnikonov.fade_out.fadingEdges
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -86,7 +86,7 @@ fun SettingsScreen(
|
||||
}
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
val lifecycleState by lifecycleOwner.lifecycle.currentStateFlow.collectAsState()
|
||||
val showAlarmPermissionRequest = remember(lifecycleState) {
|
||||
val showAlarmPermissionRequest = remember(lifecycleState) {
|
||||
homeViewModel.showAlarmPermissionRequest
|
||||
}
|
||||
Scaffold(
|
||||
@@ -157,6 +157,7 @@ private fun AlarmPermissionBanner() {
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalPermissionsApi::class)
|
||||
@Suppress("LongMethod")
|
||||
private fun LazyListScope.settingsItems(
|
||||
viewModel: SettingsViewModel,
|
||||
homeViewModel: HomeViewModel,
|
||||
@@ -454,7 +455,7 @@ class OnVersionTap(val context: Context) {
|
||||
var lastTapTimeMs = 0L
|
||||
var countToast: Toast? = null
|
||||
|
||||
fun onTap(offset: Offset) {
|
||||
fun onTap(_offset: Offset) {
|
||||
if (System.currentTimeMillis() - lastTapTimeMs < ViewConfiguration.getDoubleTapTimeout()) {
|
||||
numberOfTaps++
|
||||
if (numberOfTaps > 0) {
|
||||
|
||||
@@ -77,7 +77,7 @@ class SettingsViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setStartTime(time: String, hour: Int, minute: Int) {
|
||||
fun setStartTime(time: String, _hour: Int, _minute: Int) {
|
||||
viewModelScope.launch {
|
||||
appPreferences.setStartTime(time)
|
||||
_settings.emit(buildData(widgetDataProvider.dataForWidgetId(AppWidgetManager.INVALID_APPWIDGET_ID)))
|
||||
@@ -85,7 +85,7 @@ class SettingsViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setEndTime(time: String, hour: Int, minute: Int) {
|
||||
fun setEndTime(time: String, _hour: Int, _minute: Int) {
|
||||
viewModelScope.launch {
|
||||
appPreferences.setEndTime(time)
|
||||
_settings.emit(buildData(widgetDataProvider.dataForWidgetId(AppWidgetManager.INVALID_APPWIDGET_ID)))
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.github.premnirmal.ticker.ui
|
||||
|
||||
import android.graphics.Canvas
|
||||
import com.github.mikephil.charting.components.AxisBase
|
||||
import com.github.mikephil.charting.components.XAxis
|
||||
import com.github.mikephil.charting.formatter.IAxisValueFormatter
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter
|
||||
import com.github.mikephil.charting.renderer.XAxisRenderer
|
||||
import com.github.mikephil.charting.utils.MPPointF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mnikonov.fade_out
|
||||
package com.github.premnirmal.ticker.ui
|
||||
|
||||
import android.graphics.RuntimeShader
|
||||
import android.os.Build
|
||||
|
||||
@@ -741,6 +741,7 @@ class RefreshCallback : ActionCallback {
|
||||
class FlipTextCallback : ActionCallback {
|
||||
@Inject
|
||||
internal lateinit var stocksProvider: StocksProvider
|
||||
|
||||
@Inject
|
||||
internal lateinit var widgetDataProvider: WidgetDataProvider
|
||||
var injected = false
|
||||
|
||||
@@ -88,4 +88,3 @@ class RefreshReceiver : BroadcastReceiver() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class WidgetData : IWidgetData {
|
||||
private const val WIDGET_NAME = "WIDGET_NAME"
|
||||
private const val LAYOUT_TYPE = AppPreferences.LAYOUT_TYPE
|
||||
private const val WIDGET_SIZE = AppPreferences.WIDGET_SIZE
|
||||
|
||||
@Deprecated("will be removed in future version")
|
||||
private const val FONT_SIZE = AppPreferences.FONT_SIZE
|
||||
private const val BOLD_CHANGE = AppPreferences.BOLD_CHANGE
|
||||
@@ -68,7 +69,9 @@ class WidgetData : IWidgetData {
|
||||
@Inject internal lateinit var appPreferences: AppPreferences
|
||||
|
||||
@Inject internal lateinit var coroutineScope: CoroutineScope
|
||||
|
||||
@Inject internal lateinit var appMessaging: AppMessaging
|
||||
|
||||
@Inject internal lateinit var alarmScheduler: AlarmScheduler
|
||||
|
||||
private val position: Int
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.github.premnirmal.ticker.widget
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -40,7 +39,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.TextUnitType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.premnirmal.ticker.AppPreferences
|
||||
import com.github.premnirmal.ticker.network.data.Holding
|
||||
import com.github.premnirmal.ticker.network.data.Position
|
||||
import com.github.premnirmal.ticker.network.data.Quote
|
||||
@@ -295,9 +293,11 @@ private fun MyPortfolio(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
@@ -350,9 +350,11 @@ private fun MyPortfolio(
|
||||
)
|
||||
}
|
||||
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = priceFormatted,
|
||||
@@ -405,9 +407,11 @@ private fun Modifier.toBackgroundPainter(widgetData: SerializableWidgetState): M
|
||||
@Composable
|
||||
@Preview(uiMode = UI_MODE_NIGHT_YES)
|
||||
private fun PreviewDark() {
|
||||
Box(modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.inverseSurface)
|
||||
.padding(20.dp)) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.inverseSurface)
|
||||
.padding(20.dp)
|
||||
) {
|
||||
val data = previewDataState()
|
||||
GlanceWidgetPreview(
|
||||
modifier = Modifier.width(300.dp),
|
||||
@@ -426,9 +430,11 @@ private fun PreviewDark() {
|
||||
@Composable
|
||||
@Preview
|
||||
private fun Preview() {
|
||||
Box(modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.inverseSurface)
|
||||
.padding(20.dp)) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.inverseSurface)
|
||||
.padding(20.dp)
|
||||
) {
|
||||
val data = previewDataState()
|
||||
GlanceWidgetPreview(
|
||||
modifier = Modifier.width(300.dp),
|
||||
|
||||
@@ -49,21 +49,20 @@ import com.github.premnirmal.ticker.navigation.HomeRoute
|
||||
import com.github.premnirmal.ticker.navigation.calculateContentAndNavigationType
|
||||
import com.github.premnirmal.ticker.navigation.rememberScrollToTopAction
|
||||
import com.github.premnirmal.ticker.portfolio.search.SearchActivity
|
||||
import com.github.premnirmal.ticker.ui.AppMessaging
|
||||
import com.github.premnirmal.ticker.ui.AppTextFieldDefaultColors
|
||||
import com.github.premnirmal.ticker.ui.CheckboxPreference
|
||||
import com.github.premnirmal.ticker.ui.ContentType
|
||||
import com.github.premnirmal.ticker.ui.ContentType.SINGLE_PANE
|
||||
import com.github.premnirmal.ticker.ui.Divider
|
||||
import com.github.premnirmal.ticker.ui.ListPreference
|
||||
import com.github.premnirmal.ticker.ui.SettingsText
|
||||
import com.github.premnirmal.ticker.ui.Spinner
|
||||
import com.github.premnirmal.ticker.ui.TopBar
|
||||
import com.github.premnirmal.ticker.ui.fadingEdges
|
||||
import com.github.premnirmal.tickerwidget.R
|
||||
import com.github.premnirmal.tickerwidget.ui.Divider
|
||||
import com.google.accompanist.adaptive.FoldAwareConfiguration
|
||||
import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy
|
||||
import com.google.accompanist.adaptive.TwoPane
|
||||
import com.mnikonov.fade_out.fadingEdges
|
||||
|
||||
@Composable
|
||||
fun WidgetsScreen(
|
||||
@@ -313,7 +312,8 @@ private fun LazyListScope.widgetSettings(
|
||||
}
|
||||
|
||||
@Deprecated("will be removed in future version")
|
||||
@Composable fun FontSize(
|
||||
@Composable
|
||||
fun FontSize(
|
||||
widgetData: WidgetData,
|
||||
prefs: WidgetData.Prefs
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
formatting:
|
||||
active: true
|
||||
android: false
|
||||
autoCorrect: true
|
||||
MaximumLineLength:
|
||||
active: false
|
||||
|
||||
+37
-24
@@ -97,7 +97,7 @@ complexity:
|
||||
threshold: 15
|
||||
ComplexCondition:
|
||||
active: true
|
||||
threshold: 4
|
||||
threshold: 10
|
||||
ComplexInterface:
|
||||
active: false
|
||||
threshold: 10
|
||||
@@ -106,7 +106,7 @@ complexity:
|
||||
ignoreOverloaded: false
|
||||
CyclomaticComplexMethod:
|
||||
active: true
|
||||
threshold: 15
|
||||
threshold: 26
|
||||
ignoreSingleWhenExpression: false
|
||||
ignoreSimpleWhenEntries: false
|
||||
ignoreNestingFunctions: false
|
||||
@@ -128,14 +128,18 @@ complexity:
|
||||
threshold: 600
|
||||
LongMethod:
|
||||
active: true
|
||||
threshold: 60
|
||||
threshold: 120
|
||||
ignoreAnnotated:
|
||||
- 'Composable'
|
||||
LongParameterList:
|
||||
active: true
|
||||
functionThreshold: 6
|
||||
constructorThreshold: 7
|
||||
functionThreshold: 11
|
||||
constructorThreshold: 11
|
||||
ignoreDefaultParameters: false
|
||||
ignoreDataClasses: true
|
||||
ignoreAnnotatedParameter: []
|
||||
ignoreAnnotated:
|
||||
- 'Composable'
|
||||
MethodOverloading:
|
||||
active: false
|
||||
threshold: 6
|
||||
@@ -145,7 +149,7 @@ complexity:
|
||||
ignoreArgumentsMatchingNames: false
|
||||
NestedBlockDepth:
|
||||
active: true
|
||||
threshold: 4
|
||||
threshold: 6
|
||||
NestedScopeFunctions:
|
||||
active: false
|
||||
threshold: 1
|
||||
@@ -167,10 +171,10 @@ complexity:
|
||||
TooManyFunctions:
|
||||
active: true
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
thresholdInFiles: 11
|
||||
thresholdInClasses: 11
|
||||
thresholdInInterfaces: 11
|
||||
thresholdInObjects: 11
|
||||
thresholdInFiles: 30
|
||||
thresholdInClasses: 50
|
||||
thresholdInInterfaces: 25
|
||||
thresholdInObjects: 30
|
||||
thresholdInEnums: 11
|
||||
ignoreDeprecated: false
|
||||
ignorePrivate: false
|
||||
@@ -257,7 +261,7 @@ exceptions:
|
||||
active: true
|
||||
ignoreLabeled: false
|
||||
SwallowedException:
|
||||
active: true
|
||||
active: false
|
||||
ignoredExceptionTypes:
|
||||
- 'InterruptedException'
|
||||
- 'MalformedURLException'
|
||||
@@ -284,7 +288,7 @@ exceptions:
|
||||
ThrowingNewInstanceOfSameException:
|
||||
active: true
|
||||
TooGenericExceptionCaught:
|
||||
active: true
|
||||
active: false
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
exceptionNames:
|
||||
- 'ArrayIndexOutOfBoundsException'
|
||||
@@ -298,6 +302,7 @@ exceptions:
|
||||
allowedExceptionNameRegex: '_|(ignore|expected).*'
|
||||
TooGenericExceptionThrown:
|
||||
active: true
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
exceptionNames:
|
||||
- 'Error'
|
||||
- 'Exception'
|
||||
@@ -315,7 +320,7 @@ naming:
|
||||
ConstructorParameterNaming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
privateParameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
privateParameterPattern: '(_)?[a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
EnumNaming:
|
||||
active: true
|
||||
@@ -334,9 +339,12 @@ naming:
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
functionPattern: '[a-z][a-zA-Z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
ignoreAnnotated:
|
||||
- 'Composable'
|
||||
FunctionParameterNaming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
parameterPattern: '(_)?[a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
InvalidPackageDeclaration:
|
||||
active: true
|
||||
@@ -346,7 +354,7 @@ naming:
|
||||
active: false
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*|_'
|
||||
MatchingDeclarationName:
|
||||
active: true
|
||||
active: false
|
||||
mustBeFirst: true
|
||||
MemberNameEqualsClassName:
|
||||
active: true
|
||||
@@ -376,6 +384,7 @@ naming:
|
||||
minimumVariableNameLength: 1
|
||||
VariableNaming:
|
||||
active: true
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
variablePattern: '[a-z][A-Za-z0-9]*'
|
||||
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
@@ -391,7 +400,7 @@ performance:
|
||||
active: true
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
SpreadOperator:
|
||||
active: true
|
||||
active: false
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
|
||||
UnnecessaryPartOfBinaryExpression:
|
||||
active: false
|
||||
@@ -608,7 +617,7 @@ style:
|
||||
active: true
|
||||
maxJumpCount: 1
|
||||
MagicNumber:
|
||||
active: true
|
||||
active: false
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
|
||||
ignoreNumbers:
|
||||
- '-1'
|
||||
@@ -616,8 +625,8 @@ style:
|
||||
- '1'
|
||||
- '2'
|
||||
ignoreHashCodeFunction: true
|
||||
ignorePropertyDeclaration: false
|
||||
ignoreLocalVariableDeclaration: false
|
||||
ignorePropertyDeclaration: true
|
||||
ignoreLocalVariableDeclaration: true
|
||||
ignoreConstantDeclaration: true
|
||||
ignoreCompanionObjectPropertyDeclaration: true
|
||||
ignoreAnnotation: false
|
||||
@@ -632,10 +641,10 @@ style:
|
||||
maxChainedCalls: 5
|
||||
MaxLineLength:
|
||||
active: true
|
||||
maxLineLength: 120
|
||||
maxLineLength: 160
|
||||
excludePackageStatements: true
|
||||
excludeImportStatements: true
|
||||
excludeCommentStatements: false
|
||||
excludeCommentStatements: true
|
||||
excludeRawStrings: true
|
||||
MayBeConst:
|
||||
active: true
|
||||
@@ -675,7 +684,7 @@ style:
|
||||
active: false
|
||||
ReturnCount:
|
||||
active: true
|
||||
max: 2
|
||||
max: 4
|
||||
excludedFunctions:
|
||||
- 'equals'
|
||||
excludeLabeled: false
|
||||
@@ -684,7 +693,7 @@ style:
|
||||
SafeCast:
|
||||
active: true
|
||||
SerialVersionUIDInSerializableClass:
|
||||
active: true
|
||||
active: false
|
||||
SpacingBetweenPackageAndImports:
|
||||
active: false
|
||||
StringShouldBeRawString:
|
||||
@@ -733,12 +742,15 @@ style:
|
||||
active: false
|
||||
UnusedParameter:
|
||||
active: true
|
||||
allowedNames: 'ignored|expected'
|
||||
allowedNames: 'ignored|expected|_.*'
|
||||
UnusedPrivateClass:
|
||||
active: true
|
||||
UnusedPrivateMember:
|
||||
active: true
|
||||
allowedNames: ''
|
||||
ignoreAnnotated:
|
||||
- 'Preview'
|
||||
- 'GlancePreview'
|
||||
UnusedPrivateProperty:
|
||||
active: true
|
||||
allowedNames: '_|ignored|expected|serialVersionUID'
|
||||
@@ -783,3 +795,4 @@ style:
|
||||
active: true
|
||||
excludeImports:
|
||||
- 'java.util.*'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user