mirror of
https://github.com/owenlejeune/TVTime.git
synced 2025-11-08 12:42:44 -05:00
t
This commit is contained in:
@@ -29,6 +29,7 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
@@ -136,6 +137,8 @@ dependencies {
|
||||
|
||||
implementation 'de.charlex.compose:revealswipe:1.0.0'
|
||||
|
||||
implementation 'com.github.jeziellago:compose-markdown:0.3.3'
|
||||
|
||||
// testing
|
||||
def junit = "4.13.2"
|
||||
def androidx_junit = "1.1.3"
|
||||
|
||||
@@ -14,11 +14,10 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Drafts
|
||||
import androidx.compose.material.icons.outlined.Description
|
||||
import androidx.compose.material.icons.outlined.Drafts
|
||||
import androidx.compose.material.icons.outlined.FileCopy
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -29,7 +28,10 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
@@ -41,7 +43,8 @@ import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import com.owenlejeune.tvtime.BuildConfig
|
||||
import com.owenlejeune.tvtime.R
|
||||
import com.owenlejeune.tvtime.ui.navigation.MainNavItem
|
||||
import com.owenlejeune.tvtime.utils.FileUtils
|
||||
import dev.jeziellago.compose.markdowntext.MarkdownText
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -91,9 +94,15 @@ fun AboutView(
|
||||
}
|
||||
)
|
||||
|
||||
var showChangeLog by remember { mutableStateOf(false) }
|
||||
AboutItem(
|
||||
title = "Changelog",
|
||||
icon = Icons.Outlined.Description
|
||||
icon = Icons.Outlined.Description,
|
||||
onClick = { showChangeLog = true }
|
||||
)
|
||||
ChangeLogDialog(
|
||||
visible = showChangeLog,
|
||||
onDismissRequest = { showChangeLog = false }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -136,4 +145,28 @@ private fun AboutItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChangeLogDialog(
|
||||
visible: Boolean,
|
||||
onDismissRequest: () -> Unit
|
||||
) {
|
||||
if (visible) {
|
||||
val changeLog = FileUtils.getRawResourceFileAsString(LocalContext.current, R.raw.changelog)
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = onDismissRequest
|
||||
) {
|
||||
Text(text = "Close")
|
||||
}
|
||||
},
|
||||
text = {
|
||||
MarkdownText(markdown = changeLog)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
32
app/src/main/java/com/owenlejeune/tvtime/utils/FileUtils.kt
Normal file
32
app/src/main/java/com/owenlejeune/tvtime/utils/FileUtils.kt
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.owenlejeune.tvtime.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import java.io.BufferedInputStream
|
||||
|
||||
object FileUtils {
|
||||
|
||||
private const val TAG = "FileUtils"
|
||||
|
||||
fun getRawResourceFileAsString(context: Context, resourceId: Int): String {
|
||||
try {
|
||||
val fin = context.resources.openRawResource(resourceId)
|
||||
val bis = BufferedInputStream(fin)
|
||||
// Note that if a multi-byte character happens to cross this buffer boundary we can end up with a corrupted
|
||||
// char in that case. So we make it 4K to cover most, if not all, cases...
|
||||
val buffer = ByteArray(4096)
|
||||
val sb = java.lang.StringBuilder()
|
||||
var bytesRead = 0
|
||||
while (bis.read(buffer).also { bytesRead = it } > 0) {
|
||||
val text = String(buffer, 0, bytesRead)
|
||||
sb.append(text)
|
||||
}
|
||||
bis.close()
|
||||
return sb.toString()
|
||||
} catch (e: java.lang.Exception) {
|
||||
Log.e(TAG, "Could not write file: $resourceId", e)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
# Changelog
|
||||
Reference in New Issue
Block a user