Skip to content

Commit

Permalink
Merge pull request #98 from Myzel394/feat/0.5.0
Browse files Browse the repository at this point in the history
Version 0.5.0
  • Loading branch information
Myzel394 authored Apr 3, 2024
2 parents 5cdbb60 + 6aff6c8 commit df9443e
Show file tree
Hide file tree
Showing 38 changed files with 1,438 additions and 379 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ jobs:
debug-builds:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: gradle/wrapper-validation-action@v1
- uses: gradle/wrapper-validation-action@v2

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: "adopt"
java-version: 19
java-version: 21
cache: "gradle"

- name: Compile
run: |
./gradlew assembleDebug
- name: Upload APK
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: alibi-app-debug-apks
path: app/build/outputs/apk/debug/app-*-debug.apk
8 changes: 5 additions & 3 deletions .github/workflows/release-app-github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: gradle/wrapper-validation-action@v2

- name: Write KeyStore 🗝️
uses: ./.github/actions/prepare-keystore
Expand All @@ -21,10 +23,10 @@ jobs:
keyStoreBase64: ${{ secrets.KEYSTORE }}

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: "17.x"
java-version: 21
cache: 'gradle'

- name: Build APKs 📱
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/release-app-google-play.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: gradle/wrapper-validation-action@v2

- name: Write KeyStore 🗝️
uses: ./.github/actions/prepare-keystore
Expand All @@ -21,10 +23,10 @@ jobs:
keyStoreBase64: ${{ secrets.KEYSTORE }}

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: "17.x"
java-version: 21
cache: 'gradle'

- name: Build APKs 📱
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
minSdk 24
targetSdk 34
versionCode 13
versionName "0.4.1"
versionName "0.5.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -97,20 +97,20 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.activity:activity-ktx:1.8.2'
implementation platform('androidx.compose:compose-bom:2024.02.02')
implementation platform('androidx.compose:compose-bom:2024.03.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3:1.2.1'
implementation "androidx.compose.material:material-icons-extended:1.6.3"
implementation "androidx.compose.material:material-icons-extended:1.6.4"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.lifecycle:lifecycle-service:2.7.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2024.02.02')
androidTestImplementation platform('androidx.compose:compose-bom:2024.03.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/app/myzel394/alibi/db/AppSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data class AppSettings(

/// Recording information
// 30 minutes
val maxDuration: Long = 30 * 60 * 1000L,
val maxDuration: Long = 15 * 60 * 1000L,
// 60 seconds
val intervalDuration: Long = 60 * 1000L,

Expand Down Expand Up @@ -308,14 +308,15 @@ data class AudioRecorderSettings(
companion object {
fun getDefaultInstance(): AudioRecorderSettings = AudioRecorderSettings()
val EXAMPLE_MAX_DURATIONS = listOf(
1 * 60 * 1000L,
5 * 60 * 1000L,
15 * 60 * 1000L,
30 * 60 * 1000L,
60 * 60 * 1000L,
2 * 60 * 60 * 1000L,
3 * 60 * 60 * 1000L,
)
val EXAMPLE_DURATION_TIMES = listOf(
60 * 1000L,
60 * 2 * 1000L,
60 * 5 * 1000L,
60 * 10 * 1000L,
60 * 15 * 1000L,
Expand Down
48 changes: 43 additions & 5 deletions app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.os.ParcelFileDescriptor
import android.os.storage.StorageManager
import android.provider.MediaStore
import android.provider.MediaStore.Video.Media
import android.system.Os
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.net.toFile
import androidx.core.net.toUri
import androidx.documentfile.provider.DocumentFile
import app.myzel394.alibi.db.AppSettings
Expand All @@ -28,6 +30,7 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.reflect.KFunction4


abstract class BatchesFolder(
open val context: Context,
open val type: BatchType,
Expand Down Expand Up @@ -523,11 +526,46 @@ abstract class BatchesFolder(
}

fun getAvailableBytes(): Long? {
if (type == BatchType.CUSTOM) {
var fileDescriptor: ParcelFileDescriptor? = null

try {
fileDescriptor =
context.contentResolver.openFileDescriptor(customFolder!!.uri, "r")!!
val stats = Os.fstatvfs(fileDescriptor.fileDescriptor)

val available = stats.f_bavail * stats.f_bsize

runCatching {
fileDescriptor.close()
}

return available
} catch (e: Exception) {
runCatching {
fileDescriptor?.close();
}

return null
}
}

val storageManager = context.getSystemService(StorageManager::class.java) ?: return null
val file = when (type) {
BatchType.INTERNAL -> context.filesDir
BatchType.CUSTOM -> customFolder!!.uri.toFile()
BatchType.MEDIA -> scopedMediaContentUri.toFile()
BatchType.MEDIA ->
if (SUPPORTS_SCOPED_STORAGE)
File(
Environment.getExternalStoragePublicDirectory(VideoBatchesFolder.BASE_SCOPED_STORAGE_RELATIVE_PATH),
Media.EXTERNAL_CONTENT_URI.toString(),
)
else
File(
Environment.getExternalStoragePublicDirectory(VideoBatchesFolder.BASE_LEGACY_STORAGE_FOLDER),
VideoBatchesFolder.MEDIA_RECORDINGS_SUBFOLDER,
)

BatchType.CUSTOM -> throw IllegalArgumentException("This code should not be reachable")
}

return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand All @@ -545,8 +583,8 @@ abstract class BatchesFolder(

companion object {
fun requiredBytesForOneMinuteOfRecording(appSettings: AppSettings): Long {
// 250 MiB sounds like a good default
return 250 * 1024 * 1024
// 350 MiB sounds like a good default
return 350 * 1024 * 1024
}
}
}
Expand Down
12 changes: 3 additions & 9 deletions app/src/main/java/app/myzel394/alibi/helpers/MediaConverter.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package app.myzel394.alibi.helpers

import android.content.Context
import android.net.Uri
import android.util.Log
import androidx.documentfile.provider.DocumentFile
import com.arthenica.ffmpegkit.FFmpegKit
import com.arthenica.ffmpegkit.FFmpegKitConfig
import com.arthenica.ffmpegkit.ReturnCode
import kotlinx.coroutines.CompletableDeferred
import java.io.File
import java.lang.Compiler.command
import java.util.UUID
import kotlin.math.log

// Abstract class for concatenating audio and video files
// The concatenator runs in its own thread to avoid unresponsiveness.
Expand Down Expand Up @@ -56,7 +50,7 @@ data class AudioConcatenator(
command
) { session ->
if (!ReturnCode.isSuccess(session!!.returnCode)) {
Log.d(
Log.i(
"Audio Concatenation",
String.format(
"Command failed with state %s and rc %s.%s",
Expand Down Expand Up @@ -100,7 +94,7 @@ class MediaConverter {
command,
{ session ->
if (!ReturnCode.isSuccess(session!!.returnCode)) {
Log.d(
Log.i(
"Audio Concatenation",
String.format(
"Command failed with state %s and rc %s.%s",
Expand Down Expand Up @@ -162,7 +156,7 @@ class MediaConverter {
if (ReturnCode.isSuccess(session!!.returnCode)) {
completer.complete(Unit)
} else {
Log.d(
Log.i(
"Video Concatenation",
String.format(
"Command failed with state %s and rc %s.%s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class VideoRecorderService :
_videoFinalizerListener = CompletableDeferred()

activeRecording = newRecording.start(ContextCompat.getMainExecutor(this)) { event ->
if (event is VideoRecordEvent.Finalize && this@VideoRecorderService.state == RecorderState.STOPPED || this@VideoRecorderService.state == RecorderState.PAUSED) {
if (event is VideoRecordEvent.Finalize && (this@VideoRecorderService.state == RecorderState.STOPPED || this@VideoRecorderService.state == RecorderState.PAUSED)) {
_videoFinalizerListener.complete(Unit)
}
}
Expand Down Expand Up @@ -191,17 +191,22 @@ class VideoRecorderService :
videoCapture = buildVideoCapture(recorder)

runOnMain {
camera = cameraProvider!!.bindToLifecycle(
this,
selectedCamera,
videoCapture
)
cameraControl = CameraControl(camera!!).also {
it.init()
}
onCameraControlAvailable()
try {
camera = cameraProvider!!.bindToLifecycle(
this,
selectedCamera,
videoCapture
)

cameraControl = CameraControl(camera!!).also {
it.init()
}
onCameraControlAvailable()

_cameraAvailableListener.complete(Unit)
_cameraAvailableListener.complete(Unit)
} catch (error: IllegalArgumentException) {
onError()
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/app/myzel394/alibi/ui/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app.myzel394.alibi.ui

import android.os.Build
import androidx.compose.ui.unit.dp
import java.util.Base64

val BIG_PRIMARY_BUTTON_SIZE = 64.dp
val BIG_PRIMARY_BUTTON_MAX_WIDTH = 450.dp
Expand Down Expand Up @@ -63,3 +64,17 @@ val CRYPTO_DONATIONS = mapOf(
"Litecoin" to "LZayhTosZ9ToRvcbeR1gEDgb76Z7ZA2drN",
"Filecoin" to "f1j6pm3chzhgadpf6iwmtux33jb5gccj5arkg4dsq",
)

// Base64encoding these values so that bots can't easily scrape them.
val b64d = Base64.getDecoder()
val CONTACT_METHODS = mapOf<String, String>(
"E-Mail" to String(b64d.decode("Z2" + "9vZ2xlLXBsYX" + "k" + "uMjlrMWFAYWxlZWFzL" + "mNvbQo=")).trim(),
"GitHub" to String(
b64d.decode(
"aHR" +
"0cHM6Ly9n" + "a" + "XRodWIuY29t" + "L015emVsMzk0L2NvbnRhY3QtbWUK"
)
).trim(),
"Mastodon" to String(b64d.decode("T" + "X" + "l6Z" + "WwzOTRAbWFzdG9kb24uc29" + "jaWFsCg" + "==")).trim(),
"Reddit" to "https://reddit.com/u/Myzel394"
)
14 changes: 12 additions & 2 deletions app/src/main/java/app/myzel394/alibi/ui/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
Expand All @@ -29,6 +30,7 @@ import app.myzel394.alibi.ui.screens.SettingsScreen
import app.myzel394.alibi.ui.screens.WelcomeScreen

const val SCALE_IN = 1.25f
const val DEBUG_SKIP_WELCOME = false;

@Composable
fun Navigation(
Expand Down Expand Up @@ -57,10 +59,18 @@ fun Navigation(
modifier = Modifier
.background(MaterialTheme.colorScheme.background),
navController = navController,
startDestination = if (settings.hasSeenOnboarding) Screen.AudioRecorder.route else Screen.Welcome.route,
startDestination = if (settings.hasSeenOnboarding || DEBUG_SKIP_WELCOME) Screen.AudioRecorder.route else Screen.Welcome.route,
) {
composable(Screen.Welcome.route) {
WelcomeScreen(onNavigateToAudioRecorderScreen = { navController.navigate(Screen.AudioRecorder.route) })
WelcomeScreen(
onNavigateToAudioRecorderScreen = {
val mainHandler = ContextCompat.getMainExecutor(context)

mainHandler.execute {
navController.navigate(Screen.AudioRecorder.route)
}
},
)
}
composable(
Screen.AudioRecorder.route,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ fun BigButton(
description: String? = null,
onClick: () -> Unit,
onLongClick: () -> Unit = {},
isBig: Boolean? = null,
) {
val orientation = LocalConfiguration.current.orientation

BoxWithConstraints {
val isLarge = maxWidth > 500.dp && orientation == Configuration.ORIENTATION_PORTRAIT
val isLarge = if (isBig == null)
maxWidth > 250.dp && maxHeight > 600.dp && orientation == Configuration.ORIENTATION_PORTRAIT else isBig

Column(
modifier = Modifier
.size(if (isLarge) 250.dp else 200.dp)
.size(if (isLarge) 250.dp else 190.dp)
.clip(CircleShape)
.semantics {
contentDescription = label
Expand Down
Loading

0 comments on commit df9443e

Please sign in to comment.