Skip to content

Commit

Permalink
Drop legacy and unsupported Android 9, small reformating
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykMis committed Nov 6, 2022
1 parent 113a384 commit f15b5c0
Show file tree
Hide file tree
Showing 45 changed files with 54 additions and 61 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ BCR is a simple Android call recording app for rooted devices or devices running

### Features

* Supports Android 9 through 13
* Supports Android 10 through 13
* Supports output in various formats:
* OGG/Opus - Lossy, smallest files, default on Android 10+
* M4A/AAC - Lossy, smaller files, default on Android 9
* OGG/Opus - Lossy, smallest files, default
* M4A/AAC - Lossy, smaller files
* FLAC - Lossless, larger files
* WAV/PCM - Lossless, largest files, least CPU usage
* Supports Android's Storage Access Framework (can record to SD cards, USB devices, etc.)
Expand Down
2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/build
/build
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ android {

defaultConfig {
applicationId = "com.chiller3.bcr"
minSdk = 28
minSdk = 29
targetSdk = 33
versionCode = gitVersionCode
versionName = gitVersionName
Expand Down Expand Up @@ -311,4 +311,4 @@ android.applicationVariants.all {
}
}
}
}
}
2 changes: 1 addition & 1 deletion app/magisk/updates/release/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"changelog": "https://github.com/chenxiaolong/BCR/raw/master/app/magisk/updates/release/changelog.txt",
"version": "1.22",
"versionCode": 71168
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.chiller3.bcr", appContext.packageName)
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
</intent-filter>
</activity>
</application>
</manifest>
</manifest>
9 changes: 1 addition & 8 deletions app/src/main/java/com/chiller3/bcr/AudioFormatExtension.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package com.chiller3.bcr

import android.media.AudioFormat
import android.os.Build

val AudioFormat.frameSizeInBytesCompat: Int
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
frameSizeInBytes
} else{
// Hardcoded for Android 9 compatibility only
assert(encoding == AudioFormat.ENCODING_PCM_16BIT)
2 * channelCount
}
get() = frameSizeInBytes
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/ChipGroupCentered.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ class ChipGroupCentered(context: Context, attrs: AttributeSet?, defStyleAttr: In
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class LongClickablePreference(context: Context, attrs: AttributeSet?) : Preferen
interface OnPreferenceLongClickListener {
fun onPreferenceLongClick(preference: Preference): Boolean
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class OpenPersistentDocumentTree : ActivityResultContracts.OpenDocumentTree() {

return intent
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ class OutputDirectoryBottomSheetFragment : BottomSheetDialogFragment(), Slider.O
companion object {
val TAG: String = OutputDirectoryBottomSheetFragment::class.java.simpleName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ class OutputFormatBottomSheetFragment : BottomSheetDialogFragment(),
companion object {
val TAG: String = OutputFormatBottomSheetFragment::class.java.simpleName
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/Permissions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ object Permissions {
intent.data = Uri.fromParts("package", context.packageName, null)
return intent
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ class Preferences(private val context: Context) {
var sampleRate: SampleRate?
get() = getOptionalUint(PREF_SAMPLE_RATE)?.let { SampleRate(it) }
set(sampleRate) = setOptionalUint(PREF_SAMPLE_RATE, sampleRate?.value)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/RecorderApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ class RecorderApplication : Application() {
val notificationManager = getSystemService(NotificationManager::class.java)
notificationManager.createNotificationChannel(channel)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@ class RecorderInCallService : InCallService(), RecorderThread.OnRecordingComplet
notifyError(errorMsg, uri)
}
}
}
}
13 changes: 6 additions & 7 deletions app/src/main/java/com/chiller3/bcr/RecorderThread.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ class RecorderThread(
callTimestamp = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault())
append(FORMATTER.format(callTimestamp))

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
when (details.callDirection) {
Call.Details.DIRECTION_INCOMING -> append("_in")
Call.Details.DIRECTION_OUTGOING -> append("_out")
Call.Details.DIRECTION_UNKNOWN -> {}
}
when (details.callDirection) {
Call.Details.DIRECTION_INCOMING -> append("_in")
Call.Details.DIRECTION_OUTGOING -> append("_out")
Call.Details.DIRECTION_UNKNOWN -> {}
}
}

if (details.handle?.scheme == PhoneAccount.SCHEME_TEL) {
append('_')
Expand Down Expand Up @@ -624,4 +623,4 @@ class RecorderThread(
*/
fun onRecordingFailed(thread: RecorderThread, errorMsg: String?, uri: Uri?)
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/RecorderTileService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ class RecorderTileService : TileService(), SharedPreferences.OnSharedPreferenceC

tile.updateTile()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ class SettingsActivity : AppCompatActivity() {
}
}
}
}
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/chiller3/bcr/UriExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ val Uri.formattedString: String
}
}
else -> toString()
}
}

2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/AacFormat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ object AacFormat : Format() {

override fun getContainer(fd: FileDescriptor): Container =
MediaMuxerContainer(fd, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/Encoder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ abstract class Encoder(
* @param isEof No more data can be submitted after this method is called once with EOF == true.
*/
abstract fun encode(buffer: ByteBuffer, isEof: Boolean)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/FlacContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ class FlacContainer(private val fd: FileDescriptor) : Container {
private val TAG = FlacContainer::class.java.simpleName
private val FLAC_MAGIC = ubyteArrayOf(0x66u, 0x4cu, 0x61u, 0x43u) // fLaC
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/FlacFormat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ object FlacFormat : Format() {

override fun getContainer(fd: FileDescriptor): Container =
FlacContainer(fd)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/Format.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ sealed class Format {
return Pair(format, param)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ object NoParamInfo : FormatParamInfo(0u) {
override fun toNearest(param: UInt): UInt = param

override fun format(param: UInt): String = ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ class MediaCodecEncoder(
return codec
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class MediaMuxerContainer(
override fun writeSamples(trackIndex: Int, byteBuffer: ByteBuffer,
bufferInfo: MediaCodec.BufferInfo) =
muxer.writeSampleData(trackIndex, byteBuffer, bufferInfo)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/OpusFormat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ object OpusFormat : Format() {
@RequiresApi(Build.VERSION_CODES.Q)
override fun getContainer(fd: FileDescriptor): Container =
MediaMuxerContainer(fd, MediaMuxer.OutputFormat.MUXER_OUTPUT_OGG)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ class PassthroughEncoder(

numFrames += frames
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/SampleRate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ value class SampleRate(val value: UInt) {
return default
}
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/WaveContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ class WaveContainer(private val fd: FileDescriptor) : Container {
private val FMT_MAGIC = ubyteArrayOf(0x66u, 0x6du, 0x74u, 0x20u) // "fmt "
private val DATA_MAGIC = ubyteArrayOf(0x64u, 0x61u, 0x74u, 0x61u) // data
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/chiller3/bcr/format/WaveFormat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ object WaveFormat : Format() {

override fun getContainer(fd: FileDescriptor): Container =
WaveContainer(fd)
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/bottom_sheet_chip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<com.google.android.material.chip.Chip xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Widget.Material3.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content" />
2 changes: 1 addition & 1 deletion app/src/main/res/layout/output_directory_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
android:text="@string/bottom_sheet_reset"
style="?attr/materialButtonOutlinedStyle" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/output_format_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
android:text="@string/bottom_sheet_reset"
style="?attr/materialButtonOutlinedStyle" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/settings_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/mipmap-anydpi/ic_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
</adaptive-icon>
2 changes: 1 addition & 1 deletion app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
</adaptive-icon>
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<dimen name="bottom_sheet_overall_padding">28dp</dimen>
<dimen name="bottom_sheet_title_margin_bottom">16dp</dimen>
<dimen name="bottom_sheet_section_separation">28dp</dimen>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="windowActionModeOverlay">true</item>
</style>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
app:title="@string/pref_version_name"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>
2 changes: 1 addition & 1 deletion app/src/test/java/com/chiller3/bcr/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class ExampleUnitTest {
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ plugins {

task<Delete>("clean") {
delete(rootProject.buildDir)
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true

0 comments on commit f15b5c0

Please sign in to comment.