Merge pull request #209 from esensar/viewbinding-migration
Migrate to viewbinding and kotlin gradle scripts
This commit is contained in:
commit
a53d6985d7
24 changed files with 450 additions and 353 deletions
|
@ -1,74 +0,0 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.simplemobiletools.voicerecorder"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 34
|
||||
versionCode 38
|
||||
versionName "5.12.0"
|
||||
setProperty("archivesBaseName", "voice-recorder")
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "variants"
|
||||
productFlavors {
|
||||
core {}
|
||||
fdroid {}
|
||||
prepaid {}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0'
|
||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||
implementation 'com.github.Armen101:AudioRecordView:1.0.4'
|
||||
implementation 'androidx.documentfile:documentfile:1.0.1'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.github.naman14:TAndroidLame:1.1'
|
||||
implementation 'me.grantland:autofittextview:0.2.1'
|
||||
}
|
100
app/build.gradle.kts
Normal file
100
app/build.gradle.kts
Normal file
|
@ -0,0 +1,100 @@
|
|||
import java.io.FileInputStream
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.konan.properties.Properties
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android)
|
||||
alias(libs.plugins.kotlinAndroid)
|
||||
alias(libs.plugins.ksp)
|
||||
}
|
||||
|
||||
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
applicationId = libs.versions.app.version.appId.get()
|
||||
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
|
||||
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
|
||||
versionName = project.libs.versions.app.version.versionName.get()
|
||||
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
|
||||
setProperty("archivesBaseName", "voice-recorder")
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
register("release") {
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix = ".debug"
|
||||
}
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions.add("variants")
|
||||
productFlavors {
|
||||
register("core")
|
||||
register("fdroid")
|
||||
register("prepaid")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("main").java.srcDirs("src/main/kotlin")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
|
||||
sourceCompatibility = currentJavaVersionFromLibs
|
||||
targetCompatibility = currentJavaVersionFromLibs
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
|
||||
}
|
||||
|
||||
namespace = libs.versions.app.version.appId.get()
|
||||
|
||||
lint {
|
||||
checkReleaseBuilds = false
|
||||
abortOnError = false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.simple.tools.commons)
|
||||
implementation(libs.eventbus)
|
||||
implementation(libs.audiorecordview)
|
||||
implementation(libs.androidx.documentfile)
|
||||
implementation(libs.androidx.swiperefreshlayout)
|
||||
implementation(libs.androidx.constraintlayout)
|
||||
implementation(libs.tandroidlame)
|
||||
implementation(libs.autofittextview)
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.simplemobiletools.voicerecorder"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simplemobiletools.voicerecorder.activities
|
|||
import android.content.Intent
|
||||
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||
import com.simplemobiletools.commons.extensions.openNotificationSettings
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.services.RecorderService
|
||||
|
||||
class BackgroundRecordActivity : SimpleActivity() {
|
||||
|
@ -27,7 +26,7 @@ class BackgroundRecordActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
PermissionRequiredDialog(this, R.string.allow_notifications_voice_recorder, { openNotificationSettings() })
|
||||
PermissionRequiredDialog(this, com.simplemobiletools.commons.R.string.allow_notifications_voice_recorder, { openNotificationSettings() })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ import com.simplemobiletools.commons.models.FAQItem
|
|||
import com.simplemobiletools.voicerecorder.BuildConfig
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.adapters.ViewPagerAdapter
|
||||
import com.simplemobiletools.voicerecorder.databinding.ActivityMainBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.checkRecycleBinItems
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.helpers.STOP_AMPLITUDE_UPDATE
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.services.RecorderService
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.grantland.widget.AutofitHelper
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
|
@ -26,16 +26,18 @@ import org.greenrobot.eventbus.ThreadMode
|
|||
class MainActivity : SimpleActivity() {
|
||||
|
||||
private var bus: EventBus? = null
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
appLaunched(BuildConfig.APPLICATION_ID)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = true)
|
||||
updateMaterialActivityViews(binding.mainCoordinator, binding.mainHolder, useTransparentNavigation = false, useTopSearchMenu = true)
|
||||
|
||||
if (checkAppSideloading()) {
|
||||
return
|
||||
|
@ -49,7 +51,7 @@ class MainActivity : SimpleActivity() {
|
|||
if (it) {
|
||||
tryInitVoiceRecorder()
|
||||
} else {
|
||||
toast(R.string.no_audio_permissions)
|
||||
toast(com.simplemobiletools.commons.R.string.no_audio_permissions)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
config.lastUsedViewPagerPage = view_pager.currentItem
|
||||
config.lastUsedViewPagerPage = binding.viewPager.currentItem
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -96,8 +98,8 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (main_menu.isSearchOpen) {
|
||||
main_menu.closeSearch()
|
||||
if (binding.mainMenu.isSearchOpen) {
|
||||
binding.mainMenu.closeSearch()
|
||||
} else if (isThirdPartyIntent()) {
|
||||
setResult(Activity.RESULT_CANCELED, null)
|
||||
super.onBackPressed()
|
||||
|
@ -107,27 +109,27 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun refreshMenuItems() {
|
||||
main_menu.getToolbar().menu.apply {
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
||||
binding.mainMenu.getToolbar().menu.apply {
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
main_menu.getToolbar().inflateMenu(R.menu.menu)
|
||||
main_menu.toggleHideOnScroll(false)
|
||||
main_menu.setupMenu()
|
||||
binding.mainMenu.getToolbar().inflateMenu(R.menu.menu)
|
||||
binding.mainMenu.toggleHideOnScroll(false)
|
||||
binding.mainMenu.setupMenu()
|
||||
|
||||
main_menu.onSearchOpenListener = {
|
||||
if (view_pager.currentItem == 0) {
|
||||
view_pager.currentItem = 1
|
||||
binding.mainMenu.onSearchOpenListener = {
|
||||
if (binding.viewPager.currentItem == 0) {
|
||||
binding.viewPager.currentItem = 1
|
||||
}
|
||||
}
|
||||
|
||||
main_menu.onSearchTextChangedListener = { text ->
|
||||
binding.mainMenu.onSearchTextChangedListener = { text ->
|
||||
getPagerAdapter()?.searchTextChanged(text)
|
||||
}
|
||||
|
||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||
binding.mainMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||
R.id.settings -> launchSettings()
|
||||
|
@ -140,7 +142,7 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
private fun updateMenuColors() {
|
||||
updateStatusbarColor(getProperBackgroundColor())
|
||||
main_menu.updateColors()
|
||||
binding.mainMenu.updateColors()
|
||||
}
|
||||
|
||||
private fun tryInitVoiceRecorder() {
|
||||
|
@ -158,66 +160,66 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupViewPager() {
|
||||
main_tabs_holder.removeAllTabs()
|
||||
var tabDrawables = arrayOf(R.drawable.ic_microphone_vector, R.drawable.ic_headset_vector)
|
||||
binding.mainTabsHolder.removeAllTabs()
|
||||
var tabDrawables = arrayOf(com.simplemobiletools.commons.R.drawable.ic_microphone_vector, R.drawable.ic_headset_vector)
|
||||
var tabLabels = arrayOf(R.string.recorder, R.string.player)
|
||||
if (config.useRecycleBin) {
|
||||
tabDrawables += R.drawable.ic_delete_vector
|
||||
tabLabels += R.string.recycle_bin
|
||||
tabDrawables += com.simplemobiletools.commons.R.drawable.ic_delete_vector
|
||||
tabLabels += com.simplemobiletools.commons.R.string.recycle_bin
|
||||
}
|
||||
|
||||
tabDrawables.forEachIndexed { i, drawableId ->
|
||||
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(drawableId))
|
||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(tabLabels[i])
|
||||
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
||||
main_tabs_holder.addTab(this)
|
||||
binding.mainTabsHolder.newTab().setCustomView(com.simplemobiletools.commons.R.layout.bottom_tablayout_item).apply {
|
||||
customView?.findViewById<ImageView>(com.simplemobiletools.commons.R.id.tab_item_icon)?.setImageDrawable(getDrawable(drawableId))
|
||||
customView?.findViewById<TextView>(com.simplemobiletools.commons.R.id.tab_item_label)?.setText(tabLabels[i])
|
||||
AutofitHelper.create(customView?.findViewById(com.simplemobiletools.commons.R.id.tab_item_label))
|
||||
binding.mainTabsHolder.addTab(this)
|
||||
}
|
||||
}
|
||||
|
||||
main_tabs_holder.onTabSelectionChanged(
|
||||
binding.mainTabsHolder.onTabSelectionChanged(
|
||||
tabUnselectedAction = {
|
||||
updateBottomTabItemColors(it.customView, false)
|
||||
if (it.position == 1 || it.position == 2) {
|
||||
main_menu.closeSearch()
|
||||
binding.mainMenu.closeSearch()
|
||||
}
|
||||
},
|
||||
tabSelectedAction = {
|
||||
view_pager.currentItem = it.position
|
||||
binding.viewPager.currentItem = it.position
|
||||
updateBottomTabItemColors(it.customView, true)
|
||||
}
|
||||
)
|
||||
|
||||
view_pager.adapter = ViewPagerAdapter(this, config.useRecycleBin)
|
||||
view_pager.offscreenPageLimit = 2
|
||||
view_pager.onPageChangeListener {
|
||||
main_tabs_holder.getTabAt(it)?.select()
|
||||
(view_pager.adapter as ViewPagerAdapter).finishActMode()
|
||||
binding.viewPager.adapter = ViewPagerAdapter(this, config.useRecycleBin)
|
||||
binding.viewPager.offscreenPageLimit = 2
|
||||
binding.viewPager.onPageChangeListener {
|
||||
binding.mainTabsHolder.getTabAt(it)?.select()
|
||||
(binding.viewPager.adapter as ViewPagerAdapter).finishActMode()
|
||||
}
|
||||
|
||||
if (isThirdPartyIntent()) {
|
||||
view_pager.currentItem = 0
|
||||
binding.viewPager.currentItem = 0
|
||||
} else {
|
||||
view_pager.currentItem = config.lastUsedViewPagerPage
|
||||
main_tabs_holder.getTabAt(config.lastUsedViewPagerPage)?.select()
|
||||
binding.viewPager.currentItem = config.lastUsedViewPagerPage
|
||||
binding.mainTabsHolder.getTabAt(config.lastUsedViewPagerPage)?.select()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupTabColors() {
|
||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
||||
val inactiveView = main_tabs_holder.getTabAt(getInactiveTabIndex())?.customView
|
||||
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||
val inactiveView = binding.mainTabsHolder.getTabAt(getInactiveTabIndex())?.customView
|
||||
updateBottomTabItemColors(activeView, true)
|
||||
updateBottomTabItemColors(inactiveView, false)
|
||||
|
||||
main_tabs_holder.getTabAt(view_pager.currentItem)?.select()
|
||||
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.select()
|
||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
||||
binding.mainTabsHolder.setBackgroundColor(bottomBarColor)
|
||||
updateNavigationBarColor(bottomBarColor)
|
||||
}
|
||||
|
||||
private fun getInactiveTabIndex() = if (view_pager.currentItem == 0) 1 else 0
|
||||
private fun getInactiveTabIndex() = if (binding.viewPager.currentItem == 0) 1 else 0
|
||||
|
||||
private fun getPagerAdapter() = (view_pager.adapter as? ViewPagerAdapter)
|
||||
private fun getPagerAdapter() = (binding.viewPager.adapter as? ViewPagerAdapter)
|
||||
|
||||
private fun launchSettings() {
|
||||
hideKeyboard()
|
||||
|
@ -229,12 +231,12 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
val faqItems = arrayListOf(
|
||||
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
||||
FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons)
|
||||
FAQItem(com.simplemobiletools.commons.R.string.faq_9_title_commons, com.simplemobiletools.commons.R.string.faq_9_text_commons)
|
||||
)
|
||||
|
||||
if (!resources.getBoolean(R.bool.hide_google_relations)) {
|
||||
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
|
||||
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons))
|
||||
if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) {
|
||||
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_text_commons))
|
||||
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.commons.R.string.faq_6_text_commons))
|
||||
}
|
||||
|
||||
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.databinding.ActivitySettingsBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.extensions.emptyTheRecycleBin
|
||||
import com.simplemobiletools.voicerecorder.extensions.getAllRecordings
|
||||
|
@ -16,26 +17,27 @@ import com.simplemobiletools.voicerecorder.helpers.EXTENSION_M4A
|
|||
import com.simplemobiletools.voicerecorder.helpers.EXTENSION_MP3
|
||||
import com.simplemobiletools.voicerecorder.helpers.EXTENSION_OGG
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.Locale
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
private var recycleBinContentSize = 0
|
||||
private lateinit var binding: ActivitySettingsBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
||||
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||
|
||||
setupPurchaseThankYou()
|
||||
setupCustomizeColors()
|
||||
|
@ -51,29 +53,29 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupRecordAfterLaunch()
|
||||
setupUseRecycleBin()
|
||||
setupEmptyRecycleBin()
|
||||
updateTextColors(settings_nested_scrollview)
|
||||
updateTextColors(binding.settingsNestedScrollview)
|
||||
|
||||
arrayOf(settings_color_customization_section_label, settings_general_settings_label, settings_recycle_bin_label).forEach {
|
||||
arrayOf(binding.settingsColorCustomizationSectionLabel, binding.settingsGeneralSettingsLabel, binding.settingsRecycleBinLabel).forEach {
|
||||
it.setTextColor(getProperPrimaryColor())
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPurchaseThankYou() {
|
||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
||||
settings_purchase_thank_you_holder.setOnClickListener {
|
||||
binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||
binding.settingsPurchaseThankYouHolder.setOnClickListener {
|
||||
launchPurchaseThankYouIntent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCustomizeColors() {
|
||||
settings_color_customization_label.text = getCustomizeColorsString()
|
||||
settings_color_customization_holder.setOnClickListener {
|
||||
binding.settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||
handleCustomizeColorsClick()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCustomizeWidgetColors() {
|
||||
settings_widget_color_customization_holder.setOnClickListener {
|
||||
binding.settingsWidgetColorCustomizationHolder.setOnClickListener {
|
||||
Intent(this, WidgetRecordDisplayConfigureActivity::class.java).apply {
|
||||
putExtra(IS_CUSTOMIZING_COLORS, true)
|
||||
startActivity(this)
|
||||
|
@ -82,41 +84,41 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settings_use_english.isChecked = config.useEnglish
|
||||
settings_use_english_holder.setOnClickListener {
|
||||
settings_use_english.toggle()
|
||||
config.useEnglish = settings_use_english.isChecked
|
||||
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||
binding.settingsUseEnglish.toggle()
|
||||
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLanguage() {
|
||||
settings_language.text = Locale.getDefault().displayLanguage
|
||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
||||
settings_language_holder.setOnClickListener {
|
||||
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||
binding.settingsLanguageHolder.setOnClickListener {
|
||||
launchChangeAppLanguageIntent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupChangeDateTimeFormat() {
|
||||
settings_change_date_time_format_holder.setOnClickListener {
|
||||
binding.settingsChangeDateTimeFormatHolder.setOnClickListener {
|
||||
ChangeDateTimeFormatDialog(this) {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupHideNotification() {
|
||||
settings_hide_notification.isChecked = config.hideNotification
|
||||
settings_hide_notification_holder.setOnClickListener {
|
||||
settings_hide_notification.toggle()
|
||||
config.hideNotification = settings_hide_notification.isChecked
|
||||
binding.settingsHideNotification.isChecked = config.hideNotification
|
||||
binding.settingsHideNotificationHolder.setOnClickListener {
|
||||
binding.settingsHideNotification.toggle()
|
||||
config.hideNotification = binding.settingsHideNotification.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSaveRecordingsFolder() {
|
||||
settings_save_recordings_label.text = addLockedLabelIfNeeded(R.string.save_recordings_in)
|
||||
settings_save_recordings.text = humanizePath(config.saveRecordingsFolder)
|
||||
settings_save_recordings_holder.setOnClickListener {
|
||||
binding.settingsSaveRecordingsLabel.text = addLockedLabelIfNeeded(R.string.save_recordings_in)
|
||||
binding.settingsSaveRecordings.text = humanizePath(config.saveRecordingsFolder)
|
||||
binding.settingsAudioSourceHolder.setOnClickListener {
|
||||
if (isOrWasThankYouInstalled()) {
|
||||
FilePickerDialog(this, config.saveRecordingsFolder, false, showFAB = true) {
|
||||
val path = it
|
||||
|
@ -131,7 +133,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
config.saveRecordingsFolder = path
|
||||
settings_save_recordings.text = humanizePath(config.saveRecordingsFolder)
|
||||
binding.settingsSaveRecordings.text = humanizePath(config.saveRecordingsFolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +144,8 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupExtension() {
|
||||
settings_extension.text = config.getExtensionText()
|
||||
settings_extension_holder.setOnClickListener {
|
||||
binding.settingsExtension.text = config.getExtensionText()
|
||||
binding.settingsExtensionHolder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(EXTENSION_M4A, getString(R.string.m4a)),
|
||||
RadioItem(EXTENSION_MP3, getString(R.string.mp3))
|
||||
|
@ -155,19 +157,19 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.extension) {
|
||||
config.extension = it as Int
|
||||
settings_extension.text = config.getExtensionText()
|
||||
binding.settingsExtension.text = config.getExtensionText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupBitrate() {
|
||||
settings_bitrate.text = getBitrateText(config.bitrate)
|
||||
settings_bitrate_holder.setOnClickListener {
|
||||
binding.settingsBitrate.text = getBitrateText(config.bitrate)
|
||||
binding.settingsBitrateHolder.setOnClickListener {
|
||||
val items = BITRATES.map { RadioItem(it, getBitrateText(it)) } as ArrayList
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.bitrate) {
|
||||
config.bitrate = it as Int
|
||||
settings_bitrate.text = getBitrateText(config.bitrate)
|
||||
binding.settingsBitrate.text = getBitrateText(config.bitrate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,25 +177,25 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun getBitrateText(value: Int): String = getString(R.string.bitrate_value).format(value / 1000)
|
||||
|
||||
private fun setupRecordAfterLaunch() {
|
||||
settings_record_after_launch.isChecked = config.recordAfterLaunch
|
||||
settings_record_after_launch_holder.setOnClickListener {
|
||||
settings_record_after_launch.toggle()
|
||||
config.recordAfterLaunch = settings_record_after_launch.isChecked
|
||||
binding.settingsRecordAfterLaunch.isChecked = config.recordAfterLaunch
|
||||
binding.settingsRecordAfterLaunchHolder.setOnClickListener {
|
||||
binding.settingsRecordAfterLaunch.toggle()
|
||||
config.recordAfterLaunch = binding.settingsRecordAfterLaunch.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUseRecycleBin() {
|
||||
updateRecycleBinButtons()
|
||||
settings_use_recycle_bin.isChecked = config.useRecycleBin
|
||||
settings_use_recycle_bin_holder.setOnClickListener {
|
||||
settings_use_recycle_bin.toggle()
|
||||
config.useRecycleBin = settings_use_recycle_bin.isChecked
|
||||
binding.settingsUseRecycleBin.isChecked = config.useRecycleBin
|
||||
binding.settingsUseRecycleBinHolder.setOnClickListener {
|
||||
binding.settingsUseRecycleBin.toggle()
|
||||
config.useRecycleBin = binding.settingsUseRecycleBin.isChecked
|
||||
updateRecycleBinButtons()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRecycleBinButtons() {
|
||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
binding.settingsEmptyRecycleBinHolder.beVisibleIf(config.useRecycleBin)
|
||||
}
|
||||
|
||||
private fun setupEmptyRecycleBin() {
|
||||
|
@ -206,18 +208,18 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
runOnUiThread {
|
||||
settings_empty_recycle_bin_size.text = recycleBinContentSize.formatSize()
|
||||
binding.settingsEmptyRecycleBinSize.text = recycleBinContentSize.formatSize()
|
||||
}
|
||||
}
|
||||
|
||||
settings_empty_recycle_bin_holder.setOnClickListener {
|
||||
binding.settingsEmptyRecycleBinHolder.setOnClickListener {
|
||||
if (recycleBinContentSize == 0) {
|
||||
toast(R.string.recycle_bin_empty)
|
||||
toast(com.simplemobiletools.commons.R.string.recycle_bin_empty)
|
||||
} else {
|
||||
ConfirmationDialog(this, "", R.string.empty_recycle_bin_confirmation, R.string.yes, R.string.no) {
|
||||
ConfirmationDialog(this, "", com.simplemobiletools.commons.R.string.empty_recycle_bin_confirmation, com.simplemobiletools.commons.R.string.yes, com.simplemobiletools.commons.R.string.no) {
|
||||
emptyTheRecycleBin()
|
||||
recycleBinContentSize = 0
|
||||
settings_empty_recycle_bin_size.text = 0.formatSize()
|
||||
binding.settingsEmptyRecycleBinSize.text = 0.formatSize()
|
||||
EventBus.getDefault().post(Events.RecordingTrashUpdated())
|
||||
}
|
||||
}
|
||||
|
@ -225,13 +227,13 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupAudioSource() {
|
||||
settings_audio_source.text = config.getAudioSourceText(config.audioSource)
|
||||
settings_audio_source_holder.setOnClickListener {
|
||||
binding.settingsAudioSource.text = config.getAudioSourceText(config.audioSource)
|
||||
binding.settingsAudioSourceHolder.setOnClickListener {
|
||||
val items = getAudioSources().map { RadioItem(it, config.getAudioSourceText(it)) } as ArrayList
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.audioSource) {
|
||||
config.audioSource = it as Int
|
||||
settings_audio_source.text = config.getAudioSourceText(config.audioSource)
|
||||
binding.settingsAudioSource.text = config.getAudioSourceText(config.audioSource)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.databinding.WidgetRecordDisplayConfigBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.helpers.MyWidgetRecordDisplayProvider
|
||||
import kotlinx.android.synthetic.main.widget_record_display_config.*
|
||||
|
||||
class WidgetRecordDisplayConfigureActivity : SimpleActivity() {
|
||||
private var mWidgetAlpha = 0f
|
||||
|
@ -22,12 +22,14 @@ class WidgetRecordDisplayConfigureActivity : SimpleActivity() {
|
|||
private var mWidgetColor = 0
|
||||
private var mWidgetColorWithoutTransparency = 0
|
||||
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
||||
private lateinit var binding: WidgetRecordDisplayConfigBinding
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
useDynamicTheme = false
|
||||
super.onCreate(savedInstanceState)
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
setContentView(R.layout.widget_record_display_config)
|
||||
binding = WidgetRecordDisplayConfigBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
initVariables()
|
||||
|
||||
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
|
||||
|
@ -37,11 +39,11 @@ class WidgetRecordDisplayConfigureActivity : SimpleActivity() {
|
|||
finish()
|
||||
}
|
||||
|
||||
config_save.setOnClickListener { saveConfig() }
|
||||
config_widget_color.setOnClickListener { pickBackgroundColor() }
|
||||
binding.configSave.setOnClickListener { saveConfig() }
|
||||
binding.configWidgetColor.setOnClickListener { pickBackgroundColor() }
|
||||
|
||||
val primaryColor = getProperPrimaryColor()
|
||||
config_widget_seekbar.setColors(getProperTextColor(), primaryColor, primaryColor)
|
||||
binding.configWidgetSeekbar.setColors(getProperTextColor(), primaryColor, primaryColor)
|
||||
|
||||
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
||||
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
||||
|
@ -51,8 +53,8 @@ class WidgetRecordDisplayConfigureActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||
config_save.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
binding.configSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||
binding.configSave.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -67,14 +69,14 @@ class WidgetRecordDisplayConfigureActivity : SimpleActivity() {
|
|||
private fun initVariables() {
|
||||
mWidgetColor = config.widgetBgColor
|
||||
if (mWidgetColor == resources.getColor(R.color.default_widget_bg_color) && config.isUsingSystemTheme) {
|
||||
mWidgetColor = resources.getColor(R.color.you_primary_color, theme)
|
||||
mWidgetColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
|
||||
}
|
||||
|
||||
mWidgetAlpha = Color.alpha(mWidgetColor) / 255.toFloat()
|
||||
|
||||
mWidgetColorWithoutTransparency = Color.rgb(Color.red(mWidgetColor), Color.green(mWidgetColor), Color.blue(mWidgetColor))
|
||||
config_widget_seekbar.setOnSeekBarChangeListener(seekbarChangeListener)
|
||||
config_widget_seekbar.progress = (mWidgetAlpha * 100).toInt()
|
||||
binding.configWidgetSeekbar.setOnSeekBarChangeListener(seekbarChangeListener)
|
||||
binding.configWidgetSeekbar.progress = (mWidgetAlpha * 100).toInt()
|
||||
updateColors()
|
||||
}
|
||||
|
||||
|
@ -107,8 +109,8 @@ class WidgetRecordDisplayConfigureActivity : SimpleActivity() {
|
|||
|
||||
private fun updateColors() {
|
||||
mWidgetColor = mWidgetColorWithoutTransparency.adjustAlpha(mWidgetAlpha)
|
||||
config_widget_color.setFillWithStroke(mWidgetColor, mWidgetColor)
|
||||
config_image.background.mutate().applyColorFilter(mWidgetColor)
|
||||
binding.configWidgetColor.setFillWithStroke(mWidgetColor, mWidgetColor)
|
||||
binding.configImage.background.mutate().applyColorFilter(mWidgetColor)
|
||||
}
|
||||
|
||||
private val seekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||
import com.simplemobiletools.voicerecorder.BuildConfig
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||
import com.simplemobiletools.voicerecorder.databinding.ItemRecordingBinding
|
||||
import com.simplemobiletools.voicerecorder.dialogs.DeleteConfirmationDialog
|
||||
import com.simplemobiletools.voicerecorder.dialogs.RenameRecordingDialog
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
|
@ -21,7 +22,6 @@ import com.simplemobiletools.voicerecorder.helpers.getAudioFileContentUri
|
|||
import com.simplemobiletools.voicerecorder.interfaces.RefreshRecordingsListener
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.models.Recording
|
||||
import kotlinx.android.synthetic.main.item_recording.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class RecordingsAdapter(
|
||||
|
@ -74,7 +74,9 @@ class RecordingsAdapter(
|
|||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_recording, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return createViewHolder(ItemRecordingBinding.inflate(layoutInflater, parent, false).root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val recording = recordings[position]
|
||||
|
@ -136,7 +138,7 @@ class RecordingsAdapter(
|
|||
}
|
||||
|
||||
val baseString = if (activity.config.useRecycleBin) {
|
||||
R.string.move_to_recycle_bin_confirmation
|
||||
com.simplemobiletools.commons.R.string.move_to_recycle_bin_confirmation
|
||||
} else {
|
||||
R.string.delete_recordings_confirmation
|
||||
}
|
||||
|
@ -215,30 +217,30 @@ class RecordingsAdapter(
|
|||
private fun getSelectedItems() = recordings.filter { selectedKeys.contains(it.id) } as ArrayList<Recording>
|
||||
|
||||
private fun setupView(view: View, recording: Recording) {
|
||||
view.apply {
|
||||
setupViewBackground(activity)
|
||||
recording_frame?.isSelected = selectedKeys.contains(recording.id)
|
||||
ItemRecordingBinding.bind(view).apply {
|
||||
root.setupViewBackground(activity)
|
||||
recordingFrame.isSelected = selectedKeys.contains(recording.id)
|
||||
|
||||
arrayListOf<TextView>(recording_title, recording_date, recording_duration, recording_size).forEach {
|
||||
arrayListOf<TextView>(recordingTitle, recordingDate, recordingDuration, recordingSize).forEach {
|
||||
it.setTextColor(textColor)
|
||||
}
|
||||
|
||||
if (recording.id == currRecordingId) {
|
||||
recording_title.setTextColor(context.getProperPrimaryColor())
|
||||
recordingTitle.setTextColor(root.context.getProperPrimaryColor())
|
||||
}
|
||||
|
||||
recording_title.text = recording.title
|
||||
recording_date.text = recording.timestamp.formatDate(context)
|
||||
recording_duration.text = recording.duration.getFormattedDuration()
|
||||
recording_size.text = recording.size.formatSize()
|
||||
recordingTitle.text = recording.title
|
||||
recordingDate.text = recording.timestamp.formatDate(root.context)
|
||||
recordingDuration.text = recording.duration.getFormattedDuration()
|
||||
recordingSize.text = recording.size.formatSize()
|
||||
|
||||
overflow_menu_icon.drawable.apply {
|
||||
overflowMenuIcon.drawable.apply {
|
||||
mutate()
|
||||
setTint(activity.getProperTextColor())
|
||||
}
|
||||
|
||||
overflow_menu_icon.setOnClickListener {
|
||||
showPopupMenu(overflow_menu_anchor, recording)
|
||||
overflowMenuIcon.setOnClickListener {
|
||||
showPopupMenu(overflowMenuAnchor, recording)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||
import com.simplemobiletools.voicerecorder.databinding.ItemRecordingBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.deleteRecordings
|
||||
import com.simplemobiletools.voicerecorder.extensions.restoreRecordings
|
||||
import com.simplemobiletools.voicerecorder.interfaces.RefreshRecordingsListener
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.models.Recording
|
||||
import kotlinx.android.synthetic.main.item_recording.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class TrashAdapter(
|
||||
|
@ -59,7 +59,9 @@ class TrashAdapter(
|
|||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_recording, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return createViewHolder(ItemRecordingBinding.inflate(layoutInflater, parent, false).root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val recording = recordings[position]
|
||||
|
@ -147,26 +149,26 @@ class TrashAdapter(
|
|||
private fun getSelectedItems() = recordings.filter { selectedKeys.contains(it.id) } as ArrayList<Recording>
|
||||
|
||||
private fun setupView(view: View, recording: Recording) {
|
||||
view.apply {
|
||||
setupViewBackground(activity)
|
||||
recording_frame?.isSelected = selectedKeys.contains(recording.id)
|
||||
ItemRecordingBinding.bind(view).apply {
|
||||
root.setupViewBackground(activity)
|
||||
recordingFrame.isSelected = selectedKeys.contains(recording.id)
|
||||
|
||||
arrayListOf<TextView>(recording_title, recording_date, recording_duration, recording_size).forEach {
|
||||
arrayListOf<TextView>(recordingTitle, recordingDate, recordingDuration, recordingSize).forEach {
|
||||
it.setTextColor(textColor)
|
||||
}
|
||||
|
||||
recording_title.text = recording.title
|
||||
recording_date.text = recording.timestamp.formatDate(context)
|
||||
recording_duration.text = recording.duration.getFormattedDuration()
|
||||
recording_size.text = recording.size.formatSize()
|
||||
recordingTitle.text = recording.title
|
||||
recordingDate.text = recording.timestamp.formatDate(root.context)
|
||||
recordingDuration.text = recording.duration.getFormattedDuration()
|
||||
recordingSize.text = recording.size.formatSize()
|
||||
|
||||
overflow_menu_icon.drawable.apply {
|
||||
overflowMenuIcon.drawable.apply {
|
||||
mutate()
|
||||
setTint(activity.getProperTextColor())
|
||||
}
|
||||
|
||||
overflow_menu_icon.setOnClickListener {
|
||||
showPopupMenu(overflow_menu_anchor, recording)
|
||||
overflowMenuIcon.setOnClickListener {
|
||||
showPopupMenu(overflowMenuAnchor, recording)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +188,7 @@ class TrashAdapter(
|
|||
PopupMenu(contextTheme, view, Gravity.END).apply {
|
||||
inflate(getActionMenuId())
|
||||
menu.findItem(R.id.cab_select_all).isVisible = false
|
||||
menu.findItem(R.id.cab_restore).title = resources.getString(R.string.restore_this_file)
|
||||
menu.findItem(R.id.cab_restore).title = resources.getString(com.simplemobiletools.commons.R.string.restore_this_file)
|
||||
setOnMenuItemClickListener { item ->
|
||||
val recordingId = recording.id
|
||||
when (item.itemId) {
|
||||
|
|
|
@ -5,9 +5,7 @@ import androidx.appcompat.app.AlertDialog
|
|||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import kotlinx.android.synthetic.main.dialog_delete_confirmation.view.delete_remember_title
|
||||
import kotlinx.android.synthetic.main.dialog_delete_confirmation.view.skip_the_recycle_bin_checkbox
|
||||
import com.simplemobiletools.voicerecorder.databinding.DialogDeleteConfirmationBinding
|
||||
|
||||
class DeleteConfirmationDialog(
|
||||
private val activity: Activity,
|
||||
|
@ -17,14 +15,15 @@ class DeleteConfirmationDialog(
|
|||
) {
|
||||
|
||||
private var dialog: AlertDialog? = null
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_confirmation, null)!!
|
||||
val binding = DialogDeleteConfirmationBinding.inflate(activity.layoutInflater)
|
||||
val view = binding.root
|
||||
|
||||
init {
|
||||
view.delete_remember_title.text = message
|
||||
view.skip_the_recycle_bin_checkbox.beGoneIf(!showSkipRecycleBinOption)
|
||||
binding.deleteRememberTitle.text = message
|
||||
binding.skipTheRecycleBinCheckbox.beGoneIf(!showSkipRecycleBinOption)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.yes) { _, _ -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.yes) { _, _ -> dialogConfirmed() }
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.no, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
|
@ -34,6 +33,6 @@ class DeleteConfirmationDialog(
|
|||
|
||||
private fun dialogConfirmed() {
|
||||
dialog?.dismiss()
|
||||
callback(view.skip_the_recycle_bin_checkbox.isChecked)
|
||||
callback(binding.skipTheRecycleBinCheckbox.isChecked)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,36 +7,36 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.helpers.isRPlus
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.databinding.DialogRenameRecordingBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.helpers.getAudioFileContentUri
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.models.Recording
|
||||
import kotlinx.android.synthetic.main.dialog_rename_recording.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.io.File
|
||||
|
||||
class RenameRecordingDialog(val activity: BaseSimpleActivity, val recording: Recording, val callback: () -> Unit) {
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_recording, null).apply {
|
||||
rename_recording_title.setText(recording.title.substringBeforeLast('.'))
|
||||
val binding = DialogRenameRecordingBinding.inflate(activity.layoutInflater).apply {
|
||||
renameRecordingTitle.setText(recording.title.substringBeforeLast('.'))
|
||||
}
|
||||
val view = binding.root
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.rename) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.rename_recording_title)
|
||||
activity.setupDialogStuff(view, this, com.simplemobiletools.commons.R.string.rename) { alertDialog ->
|
||||
alertDialog.showKeyboard(binding.renameRecordingTitle)
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val newTitle = view.rename_recording_title.value
|
||||
val newTitle = binding.renameRecordingTitle.value
|
||||
if (newTitle.isEmpty()) {
|
||||
activity.toast(R.string.empty_name)
|
||||
activity.toast(com.simplemobiletools.commons.R.string.empty_name)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (!newTitle.isAValidFilename()) {
|
||||
activity.toast(R.string.invalid_name)
|
||||
activity.toast(com.simplemobiletools.commons.R.string.invalid_name)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ import com.simplemobiletools.commons.helpers.isQPlus
|
|||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||
import com.simplemobiletools.voicerecorder.adapters.RecordingsAdapter
|
||||
import com.simplemobiletools.voicerecorder.databinding.FragmentPlayerBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.extensions.getAllRecordings
|
||||
import com.simplemobiletools.voicerecorder.helpers.getAudioFileContentUri
|
||||
import com.simplemobiletools.voicerecorder.interfaces.RefreshRecordingsListener
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.models.Recording
|
||||
import kotlinx.android.synthetic.main.fragment_player.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
@ -42,6 +42,12 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
private var prevSavePath = ""
|
||||
private var prevRecycleBinState = context.config.useRecycleBin
|
||||
private var playOnPreparation = true
|
||||
private lateinit var binding: FragmentPlayerBinding
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
binding = FragmentPlayerBinding.bind(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
setupColors()
|
||||
|
@ -78,23 +84,23 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
}
|
||||
|
||||
private fun setupViews() {
|
||||
play_pause_btn.setOnClickListener {
|
||||
if (playedRecordingIDs.empty() || player_progressbar.max == 0) {
|
||||
next_btn.callOnClick()
|
||||
binding.playPauseBtn.setOnClickListener {
|
||||
if (playedRecordingIDs.empty() || binding.playerProgressbar.max == 0) {
|
||||
binding.nextBtn.callOnClick()
|
||||
} else {
|
||||
togglePlayPause()
|
||||
}
|
||||
}
|
||||
|
||||
player_progress_current.setOnClickListener {
|
||||
binding.playerProgressCurrent.setOnClickListener {
|
||||
skip(false)
|
||||
}
|
||||
|
||||
player_progress_max.setOnClickListener {
|
||||
binding.playerProgressMax.setOnClickListener {
|
||||
skip(true)
|
||||
}
|
||||
|
||||
previous_btn.setOnClickListener {
|
||||
binding.previousBtn.setOnClickListener {
|
||||
if (playedRecordingIDs.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
@ -110,14 +116,14 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
playRecording(prevRecording, true)
|
||||
}
|
||||
|
||||
player_title.setOnLongClickListener {
|
||||
if (player_title.value.isNotEmpty()) {
|
||||
context.copyToClipboard(player_title.value)
|
||||
binding.playerTitle.setOnLongClickListener {
|
||||
if (binding.playerTitle.value.isNotEmpty()) {
|
||||
context.copyToClipboard(binding.playerTitle.value)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
next_btn.setOnClickListener {
|
||||
binding.nextBtn.setOnClickListener {
|
||||
val adapter = getRecordingsAdapter()
|
||||
if (adapter == null || adapter.recordings.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
|
@ -137,8 +143,8 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
}
|
||||
|
||||
private fun setupAdapter(recordings: ArrayList<Recording>) {
|
||||
recordings_fastscroller.beVisibleIf(recordings.isNotEmpty())
|
||||
recordings_placeholder.beVisibleIf(recordings.isEmpty())
|
||||
binding.recordingsFastscroller.beVisibleIf(recordings.isNotEmpty())
|
||||
binding.recordingsPlaceholder.beVisibleIf(recordings.isEmpty())
|
||||
if (recordings.isEmpty()) {
|
||||
val stringId = if (lastSearchQuery.isEmpty()) {
|
||||
if (isQPlus()) {
|
||||
|
@ -147,27 +153,27 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
R.string.no_recordings_in_folder_found
|
||||
}
|
||||
} else {
|
||||
R.string.no_items_found
|
||||
com.simplemobiletools.commons.R.string.no_items_found
|
||||
}
|
||||
|
||||
recordings_placeholder.text = context.getString(stringId)
|
||||
binding.recordingsPlaceholder.text = context.getString(stringId)
|
||||
resetProgress(null)
|
||||
player?.stop()
|
||||
}
|
||||
|
||||
val adapter = getRecordingsAdapter()
|
||||
if (adapter == null) {
|
||||
RecordingsAdapter(context as SimpleActivity, recordings, this, recordings_list) {
|
||||
RecordingsAdapter(context as SimpleActivity, recordings, this, binding.recordingsList) {
|
||||
playRecording(it as Recording, true)
|
||||
if (playedRecordingIDs.isEmpty() || playedRecordingIDs.peek() != it.id) {
|
||||
playedRecordingIDs.push(it.id)
|
||||
}
|
||||
}.apply {
|
||||
recordings_list.adapter = this
|
||||
binding.recordingsList.adapter = this
|
||||
}
|
||||
|
||||
if (context.areSystemAnimationsEnabled) {
|
||||
recordings_list.scheduleLayoutAnimation()
|
||||
binding.recordingsList.scheduleLayoutAnimation()
|
||||
}
|
||||
} else {
|
||||
adapter.updateItems(recordings)
|
||||
|
@ -187,9 +193,9 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
setOnCompletionListener {
|
||||
progressTimer.cancel()
|
||||
player_progressbar.progress = player_progressbar.max
|
||||
player_progress_current.text = player_progress_max.text
|
||||
play_pause_btn.setImageDrawable(getToggleButtonIcon(false))
|
||||
binding.playerProgressbar.progress = binding.playerProgressbar.max
|
||||
binding.playerProgressCurrent.text = binding.playerProgressMax.text
|
||||
binding.playPauseBtn.setImageDrawable(getToggleButtonIcon(false))
|
||||
}
|
||||
|
||||
setOnPreparedListener {
|
||||
|
@ -205,7 +211,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
override fun playRecording(recording: Recording, playOnPrepared: Boolean) {
|
||||
resetProgress(recording)
|
||||
(recordings_list.adapter as RecordingsAdapter).updateCurrentRecording(recording.id)
|
||||
(binding.recordingsList.adapter as RecordingsAdapter).updateCurrentRecording(recording.id)
|
||||
playOnPreparation = playOnPrepared
|
||||
|
||||
player!!.apply {
|
||||
|
@ -239,12 +245,12 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
}
|
||||
}
|
||||
|
||||
play_pause_btn.setImageDrawable(getToggleButtonIcon(playOnPreparation))
|
||||
player_progressbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
binding.playPauseBtn.setImageDrawable(getToggleButtonIcon(playOnPreparation))
|
||||
binding.playerProgressbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser && !playedRecordingIDs.isEmpty()) {
|
||||
player?.seekTo(progress * 1000)
|
||||
player_progress_current.text = progress.getFormattedDuration()
|
||||
binding.playerProgressCurrent.text = progress.getFormattedDuration()
|
||||
resumePlayback()
|
||||
}
|
||||
}
|
||||
|
@ -267,22 +273,22 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
if (player != null) {
|
||||
val progress = Math.round(player!!.currentPosition / 1000.toDouble()).toInt()
|
||||
updateCurrentProgress(progress)
|
||||
player_progressbar.progress = progress
|
||||
binding.playerProgressbar.progress = progress
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCurrentProgress(seconds: Int) {
|
||||
player_progress_current.text = seconds.getFormattedDuration()
|
||||
binding.playerProgressCurrent.text = seconds.getFormattedDuration()
|
||||
}
|
||||
|
||||
private fun resetProgress(recording: Recording?) {
|
||||
updateCurrentProgress(0)
|
||||
player_progressbar.progress = 0
|
||||
player_progressbar.max = recording?.duration ?: 0
|
||||
player_title.text = recording?.title ?: ""
|
||||
player_progress_max.text = (recording?.duration ?: 0).getFormattedDuration()
|
||||
binding.playerProgressbar.progress = 0
|
||||
binding.playerProgressbar.max = recording?.duration ?: 0
|
||||
binding.playerTitle.text = recording?.title ?: ""
|
||||
binding.playerProgressMax.text = (recording?.duration ?: 0).getFormattedDuration()
|
||||
}
|
||||
|
||||
fun onSearchTextChanged(text: String) {
|
||||
|
@ -301,18 +307,18 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
private fun pausePlayback() {
|
||||
player?.pause()
|
||||
play_pause_btn.setImageDrawable(getToggleButtonIcon(false))
|
||||
binding.playPauseBtn.setImageDrawable(getToggleButtonIcon(false))
|
||||
progressTimer.cancel()
|
||||
}
|
||||
|
||||
private fun resumePlayback() {
|
||||
player?.start()
|
||||
play_pause_btn.setImageDrawable(getToggleButtonIcon(true))
|
||||
binding.playPauseBtn.setImageDrawable(getToggleButtonIcon(true))
|
||||
setupProgressTimer()
|
||||
}
|
||||
|
||||
private fun getToggleButtonIcon(isPlaying: Boolean): Drawable {
|
||||
val drawable = if (isPlaying) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
||||
val drawable = if (isPlaying) com.simplemobiletools.commons.R.drawable.ic_pause_vector else com.simplemobiletools.commons.R.drawable.ic_play_vector
|
||||
return resources.getColoredDrawableWithColor(drawable, context.getProperPrimaryColor().getContrastColor())
|
||||
}
|
||||
|
||||
|
@ -333,7 +339,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
private fun getIsPlaying() = player?.isPlaying == true
|
||||
|
||||
private fun getRecordingsAdapter() = recordings_list.adapter as? RecordingsAdapter
|
||||
private fun getRecordingsAdapter() = binding.recordingsList.adapter as? RecordingsAdapter
|
||||
|
||||
private fun storePrevState() {
|
||||
prevSavePath = context!!.config.saveRecordingsFolder
|
||||
|
@ -342,16 +348,16 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
private fun setupColors() {
|
||||
val properPrimaryColor = context.getProperPrimaryColor()
|
||||
recordings_fastscroller.updateColors(properPrimaryColor)
|
||||
context.updateTextColors(player_holder)
|
||||
binding.recordingsFastscroller.updateColors(properPrimaryColor)
|
||||
context.updateTextColors(binding.playerHolder)
|
||||
|
||||
val textColor = context.getProperTextColor()
|
||||
arrayListOf(previous_btn, next_btn).forEach {
|
||||
arrayListOf(binding.previousBtn, binding.nextBtn).forEach {
|
||||
it.applyColorFilter(textColor)
|
||||
}
|
||||
|
||||
play_pause_btn.background.applyColorFilter(properPrimaryColor)
|
||||
play_pause_btn.setImageDrawable(getToggleButtonIcon(false))
|
||||
binding.playPauseBtn.background.applyColorFilter(properPrimaryColor)
|
||||
binding.playPauseBtn.setImageDrawable(getToggleButtonIcon(false))
|
||||
}
|
||||
|
||||
fun finishActMode() = getRecordingsAdapter()?.finishActMode()
|
||||
|
|
|
@ -10,14 +10,10 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
|||
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.databinding.FragmentRecorderBinding
|
||||
import com.simplemobiletools.voicerecorder.helpers.*
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.services.RecorderService
|
||||
import kotlinx.android.synthetic.main.fragment_recorder.view.recorder_visualizer
|
||||
import kotlinx.android.synthetic.main.fragment_recorder.view.recording_duration
|
||||
import kotlinx.android.synthetic.main.fragment_recorder.view.toggle_pause_button
|
||||
import kotlinx.android.synthetic.main.fragment_recorder.view.toggle_recording_button
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
@ -28,6 +24,12 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
private var status = RECORDING_STOPPED
|
||||
private var pauseBlinkTimer = Timer()
|
||||
private var bus: EventBus? = null
|
||||
private lateinit var binding: FragmentRecorderBinding
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
binding = FragmentRecorderBinding.bind(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
setupColors()
|
||||
|
@ -46,24 +48,24 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
setupColors()
|
||||
recorder_visualizer.recreate()
|
||||
binding.recorderVisualizer.recreate()
|
||||
bus = EventBus.getDefault()
|
||||
bus!!.register(this)
|
||||
|
||||
updateRecordingDuration(0)
|
||||
toggle_recording_button.setOnClickListener {
|
||||
binding.toggleRecordingButton.setOnClickListener {
|
||||
(context as? BaseSimpleActivity)?.handleNotificationPermission { granted ->
|
||||
if (granted) {
|
||||
toggleRecording()
|
||||
} else {
|
||||
PermissionRequiredDialog(context as BaseSimpleActivity, R.string.allow_notifications_voice_recorder, {
|
||||
PermissionRequiredDialog(context as BaseSimpleActivity, com.simplemobiletools.commons.R.string.allow_notifications_voice_recorder, {
|
||||
(context as BaseSimpleActivity).openNotificationSettings()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toggle_pause_button.setOnClickListener {
|
||||
binding.togglePauseButton.setOnClickListener {
|
||||
Intent(context, RecorderService::class.java).apply {
|
||||
action = TOGGLE_PAUSE
|
||||
context.startService(this)
|
||||
|
@ -81,26 +83,27 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
|
||||
private fun setupColors() {
|
||||
val properPrimaryColor = context.getProperPrimaryColor()
|
||||
toggle_recording_button.apply {
|
||||
binding.toggleRecordingButton.apply {
|
||||
setImageDrawable(getToggleButtonIcon())
|
||||
background.applyColorFilter(properPrimaryColor)
|
||||
}
|
||||
|
||||
toggle_pause_button.apply {
|
||||
setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_pause_vector, properPrimaryColor.getContrastColor()))
|
||||
binding.togglePauseButton.apply {
|
||||
setImageDrawable(resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_pause_vector, properPrimaryColor.getContrastColor()))
|
||||
background.applyColorFilter(properPrimaryColor)
|
||||
}
|
||||
|
||||
recorder_visualizer.chunkColor = properPrimaryColor
|
||||
recording_duration.setTextColor(context.getProperTextColor())
|
||||
binding.recorderVisualizer.chunkColor = properPrimaryColor
|
||||
binding.recordingDuration.setTextColor(context.getProperTextColor())
|
||||
}
|
||||
|
||||
private fun updateRecordingDuration(duration: Int) {
|
||||
recording_duration.text = duration.getFormattedDuration()
|
||||
binding.recordingDuration.text = duration.getFormattedDuration()
|
||||
}
|
||||
|
||||
private fun getToggleButtonIcon(): Drawable {
|
||||
val drawable = if (status == RECORDING_RUNNING || status == RECORDING_PAUSED) R.drawable.ic_stop_vector else R.drawable.ic_microphone_vector
|
||||
val drawable =
|
||||
if (status == RECORDING_RUNNING || status == RECORDING_PAUSED) com.simplemobiletools.commons.R.drawable.ic_stop_vector else com.simplemobiletools.commons.R.drawable.ic_microphone_vector
|
||||
return resources.getColoredDrawableWithColor(drawable, context.getProperPrimaryColor().getContrastColor())
|
||||
}
|
||||
|
||||
|
@ -111,12 +114,12 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
RECORDING_RUNNING
|
||||
}
|
||||
|
||||
toggle_recording_button.setImageDrawable(getToggleButtonIcon())
|
||||
binding.toggleRecordingButton.setImageDrawable(getToggleButtonIcon())
|
||||
|
||||
if (status == RECORDING_RUNNING) {
|
||||
startRecording()
|
||||
} else {
|
||||
toggle_pause_button.beGone()
|
||||
binding.togglePauseButton.beGone()
|
||||
stopRecording()
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +128,7 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
Intent(context, RecorderService::class.java).apply {
|
||||
context.startService(this)
|
||||
}
|
||||
recorder_visualizer.recreate()
|
||||
binding.recorderVisualizer.recreate()
|
||||
}
|
||||
|
||||
private fun stopRecording() {
|
||||
|
@ -139,15 +142,15 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
if (status == RECORDING_PAUSED) {
|
||||
// update just the alpha so that it will always be clickable
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
toggle_pause_button.alpha = if (toggle_pause_button.alpha == 0f) 1f else 0f
|
||||
binding.togglePauseButton.alpha = if (binding.togglePauseButton.alpha == 0f) 1f else 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshView() {
|
||||
toggle_recording_button.setImageDrawable(getToggleButtonIcon())
|
||||
toggle_pause_button.beVisibleIf(status != RECORDING_STOPPED && isNougatPlus())
|
||||
binding.toggleRecordingButton.setImageDrawable(getToggleButtonIcon())
|
||||
binding.togglePauseButton.beVisibleIf(status != RECORDING_STOPPED && isNougatPlus())
|
||||
pauseBlinkTimer.cancel()
|
||||
|
||||
if (status == RECORDING_PAUSED) {
|
||||
|
@ -156,7 +159,7 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
}
|
||||
|
||||
if (status == RECORDING_RUNNING) {
|
||||
toggle_pause_button.alpha = 1f
|
||||
binding.togglePauseButton.alpha = 1f
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +178,7 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
fun gotAmplitudeEvent(event: Events.RecordingAmplitude) {
|
||||
val amplitude = event.amplitude
|
||||
if (status == RECORDING_RUNNING) {
|
||||
recorder_visualizer.update(amplitude)
|
||||
binding.recorderVisualizer.update(amplitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,14 @@ package com.simplemobiletools.voicerecorder.fragments
|
|||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||
import com.simplemobiletools.voicerecorder.adapters.TrashAdapter
|
||||
import com.simplemobiletools.voicerecorder.databinding.FragmentTrashBinding
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.extensions.getAllRecordings
|
||||
import com.simplemobiletools.voicerecorder.interfaces.RefreshRecordingsListener
|
||||
import com.simplemobiletools.voicerecorder.models.Events
|
||||
import com.simplemobiletools.voicerecorder.models.Recording
|
||||
import kotlinx.android.synthetic.main.fragment_trash.view.trash_fastscroller
|
||||
import kotlinx.android.synthetic.main.fragment_trash.view.trash_holder
|
||||
import kotlinx.android.synthetic.main.fragment_trash.view.trash_list
|
||||
import kotlinx.android.synthetic.main.fragment_trash.view.trash_placeholder
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
@ -24,6 +20,12 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
private var lastSearchQuery = ""
|
||||
private var bus: EventBus? = null
|
||||
private var prevSavePath = ""
|
||||
private lateinit var binding: FragmentTrashBinding
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
binding = FragmentTrashBinding.bind(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
setupColors()
|
||||
|
@ -60,26 +62,26 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
override fun playRecording(recording: Recording, playOnPrepared: Boolean) {}
|
||||
|
||||
private fun setupAdapter(recordings: ArrayList<Recording>) {
|
||||
trash_fastscroller.beVisibleIf(recordings.isNotEmpty())
|
||||
trash_placeholder.beVisibleIf(recordings.isEmpty())
|
||||
binding.trashFastscroller.beVisibleIf(recordings.isNotEmpty())
|
||||
binding.trashPlaceholder.beVisibleIf(recordings.isEmpty())
|
||||
if (recordings.isEmpty()) {
|
||||
val stringId = if (lastSearchQuery.isEmpty()) {
|
||||
R.string.recycle_bin_empty
|
||||
com.simplemobiletools.commons.R.string.recycle_bin_empty
|
||||
} else {
|
||||
R.string.no_items_found
|
||||
com.simplemobiletools.commons.R.string.no_items_found
|
||||
}
|
||||
|
||||
trash_placeholder.text = context.getString(stringId)
|
||||
binding.trashPlaceholder.text = context.getString(stringId)
|
||||
}
|
||||
|
||||
val adapter = getRecordingsAdapter()
|
||||
if (adapter == null) {
|
||||
TrashAdapter(context as SimpleActivity, recordings, this, trash_list).apply {
|
||||
trash_list.adapter = this
|
||||
TrashAdapter(context as SimpleActivity, recordings, this, binding.trashList).apply {
|
||||
binding.trashList.adapter = this
|
||||
}
|
||||
|
||||
if (context.areSystemAnimationsEnabled) {
|
||||
trash_list.scheduleLayoutAnimation()
|
||||
binding.trashList.scheduleLayoutAnimation()
|
||||
}
|
||||
} else {
|
||||
adapter.updateItems(recordings)
|
||||
|
@ -98,7 +100,7 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
setupAdapter(filtered)
|
||||
}
|
||||
|
||||
private fun getRecordingsAdapter() = trash_list.adapter as? TrashAdapter
|
||||
private fun getRecordingsAdapter() = binding.trashList.adapter as? TrashAdapter
|
||||
|
||||
private fun storePrevPath() {
|
||||
prevSavePath = context!!.config.saveRecordingsFolder
|
||||
|
@ -106,8 +108,8 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
|
||||
private fun setupColors() {
|
||||
val properPrimaryColor = context.getProperPrimaryColor()
|
||||
trash_fastscroller.updateColors(properPrimaryColor)
|
||||
context.updateTextColors(trash_holder)
|
||||
binding.trashFastscroller.updateColors(properPrimaryColor)
|
||||
context.updateTextColors(binding.trashHolder)
|
||||
}
|
||||
|
||||
fun finishActMode() = getRecordingsAdapter()?.finishActMode()
|
||||
|
|
|
@ -57,7 +57,7 @@ class MyWidgetRecordDisplayProvider : AppWidgetProvider() {
|
|||
}
|
||||
|
||||
private fun getColoredIcon(context: Context, color: Int, alpha: Int): Bitmap {
|
||||
val drawable = context.resources.getColoredDrawableWithColor(R.drawable.ic_microphone_vector, color, alpha)
|
||||
val drawable = context.resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_microphone_vector, color, alpha)
|
||||
return context.drawableToBitmap(drawable)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ class RecorderService : Service() {
|
|||
|
||||
val newUri = contentResolver.insert(audioCollection, newSongDetails)
|
||||
if (newUri == null) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ class RecorderService : Service() {
|
|||
}
|
||||
|
||||
var priority = Notification.PRIORITY_DEFAULT
|
||||
var icon = R.drawable.ic_microphone_vector
|
||||
var icon = com.simplemobiletools.commons.R.drawable.ic_microphone_vector
|
||||
var title = label
|
||||
var visibility = NotificationCompat.VISIBILITY_PUBLIC
|
||||
var text = getString(R.string.recording)
|
||||
|
|
29
build.gradle
29
build.gradle
|
@ -1,29 +0,0 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.7.10'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
5
build.gradle.kts
Normal file
5
build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
|||
plugins {
|
||||
alias(libs.plugins.android).apply(false)
|
||||
alias(libs.plugins.kotlinAndroid).apply(false)
|
||||
alias(libs.plugins.ksp).apply(false)
|
||||
}
|
|
@ -19,3 +19,4 @@ android.useAndroidX=true
|
|||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
android.nonTransitiveRClass=true
|
||||
|
|
61
gradle/libs.versions.toml
Normal file
61
gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,61 @@
|
|||
[versions]
|
||||
#jetbrains
|
||||
kotlin = "1.9.0"
|
||||
#KSP
|
||||
ksp = "1.9.0-1.0.12"
|
||||
#AndroidX
|
||||
androidx-constraintlayout = "2.1.4"
|
||||
androidx-documentfile = "1.0.1"
|
||||
androidx-swiperefreshlayout = "1.1.0"
|
||||
#Eventbus
|
||||
eventbus = "3.3.1"
|
||||
#Room
|
||||
room = "2.6.0-alpha02"
|
||||
#Simple tools
|
||||
simple-commons = "c5a32fb1f3"
|
||||
#AudioRecordView
|
||||
audiorecordview = "1.0.4"
|
||||
#TAndroidLame
|
||||
tandroidlame = "1.1"
|
||||
#AutofitTextView
|
||||
autofittextview = "0.2.1"
|
||||
#Gradle
|
||||
gradlePlugins-agp = "8.1.0"
|
||||
#build
|
||||
app-build-compileSDKVersion = "34"
|
||||
app-build-targetSDK = "34"
|
||||
app-build-minimumSDK = "23"
|
||||
app-build-javaVersion = "VERSION_17"
|
||||
app-build-kotlinJVMTarget = "17"
|
||||
#versioning
|
||||
app-version-appId = "com.simplemobiletools.voicerecorder"
|
||||
app-version-versionCode = "38"
|
||||
app-version-versionName = "5.12.0"
|
||||
[libraries]
|
||||
#AndroidX
|
||||
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }
|
||||
androidx-documentfile = { module = "androidx.documentfile:documentfile", version.ref = "androidx-documentfile" }
|
||||
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" }
|
||||
#Room
|
||||
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
||||
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
|
||||
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||
#Simple Mobile Tools
|
||||
simple-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" }
|
||||
#EventBus
|
||||
eventbus = { module = "org.greenrobot:eventbus", version.ref = "eventbus" }
|
||||
#AudioRecordView
|
||||
audiorecordview = { module = "com.github.Armen101:AudioRecordView", version.ref = "audiorecordview" }
|
||||
#TAndroidLame
|
||||
tandroidlame = { module = "com.github.naman14:TAndroidLame", version.ref = "tandroidlame" }
|
||||
#AutofitTextView
|
||||
autofittextview = { module = "me.grantland:autofittextview", version.ref = "autofittextview" }
|
||||
[bundles]
|
||||
room = [
|
||||
"androidx-room-ktx",
|
||||
"androidx-room-runtime",
|
||||
]
|
||||
[plugins]
|
||||
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
|
||||
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
include ':app'
|
16
settings.gradle.kts
Normal file
16
settings.gradle.kts
Normal file
|
@ -0,0 +1,16 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { setUrl("https://jitpack.io") }
|
||||
}
|
||||
}
|
||||
include(":app")
|
Loading…
Reference in a new issue