From 15b02de00490b8edfa974b163877f672c2e9713a Mon Sep 17 00:00:00 2001 From: Tim Schneeberger Date: Thu, 9 Mar 2023 01:01:02 +0100 Subject: [PATCH] refactor: cleanup & sort extension methods --- .../rootlessjamesdsp/MainApplication.kt | 2 +- .../activity/AeqSelectorActivity.kt | 4 +- .../activity/AppCompatibilityActivity.kt | 2 +- .../activity/LiveprogEditorActivity.kt | 16 ++-- .../rootlessjamesdsp/activity/MainActivity.kt | 28 +++--- .../activity/OnboardingActivity.kt | 2 +- .../adapter/ThemesPreferenceAdapter.kt | 2 +- .../fragment/AppCompatibilityFragment.kt | 8 +- .../fragment/AppsListFragment.kt | 2 +- .../fragment/BlocklistFragment.kt | 12 +-- .../fragment/FileLibraryDialogFragment.kt | 6 +- .../fragment/GraphicEqualizerFragment.kt | 6 +- .../fragment/LibraryLoadErrorFragment.kt | 2 +- .../fragment/LimitationsFragment.kt | 2 +- .../fragment/LiveprogParamsFragment.kt | 4 +- .../fragment/OnboardingFragment.kt | 16 ++-- .../fragment/PreferenceGroupFragment.kt | 6 +- .../fragment/SettingsAboutFragment.kt | 2 +- .../fragment/SettingsAppearanceFragment.kt | 4 +- .../fragment/SettingsAudioFormatFragment.kt | 10 +- .../fragment/SettingsMiscFragment.kt | 8 +- .../SettingsTroubleshootingFragment.kt | 23 ++++- .../interop/JamesDspBaseEngine.kt | 2 +- .../interop/JamesDspLocalEngine.kt | 2 +- .../interop/JamesDspRemoteEngine.kt | 18 ++-- .../interop/ProcessorMessageHandler.kt | 2 +- .../rootlessjamesdsp/liveprog/EelParser.kt | 2 +- .../model/GraphicEqNodeList.kt | 2 +- .../rootlessjamesdsp/model/Preset.kt | 4 +- .../preference/AppIconPreference.kt | 2 +- .../preference/FileLibraryPreference.kt | 2 +- .../preference/GraphicEqualizerPreference.kt | 4 +- .../preference/MaterialSeekbarPreference.kt | 4 +- .../preference/ThemesPreference.kt | 2 +- .../receiver/SessionReceiver.kt | 2 +- .../service/QuickTileService.kt | 6 +- .../service/RootAudioProcessorService.kt | 2 +- .../service/RootlessAudioProcessorService.kt | 19 ++-- .../AudioPolicyServiceDumpProvider.kt | 2 +- .../dump/provider/AudioServiceDumpProvider.kt | 2 +- .../session/dump/utils/DumpUtils.kt | 2 +- .../session/root/RootSessionDatabase.kt | 4 +- .../rootless/SessionRecordingPolicyManager.kt | 2 +- .../session/shared/BaseSessionManager.kt | 4 +- .../utils/ApplicationUtils.kt | 33 ------- .../rootlessjamesdsp/utils/Cache.kt | 17 +--- .../rootlessjamesdsp/utils/DeviceUtil.kt | 31 ------ .../rootlessjamesdsp/utils/SdkCheck.kt | 11 ++- .../utils/ServiceNotificationHelper.kt | 4 +- .../rootlessjamesdsp/utils/Utils.kt | 94 ------------------- .../utils/{ => extensions}/ApiExtensions.kt | 2 +- .../AssetManagerExtensions.kt | 2 +- .../{ => extensions}/AudioEffectExtensions.kt | 2 +- .../utils/extensions/CompatExtensions.kt | 54 +++++++++++ .../{ => extensions}/ContextExtensions.kt | 14 +-- .../utils/extensions/MiscUtils.kt | 58 ++++++++++++ .../{ => extensions}/PermissionExtensions.kt | 5 +- .../rootlessjamesdsp/view/Card.kt | 8 +- .../rootlessjamesdsp/view/EqualizerSurface.kt | 6 +- .../view/GraphicEqualizerSurface.kt | 8 +- 60 files changed, 289 insertions(+), 318 deletions(-) delete mode 100644 app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApplicationUtils.kt delete mode 100644 app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/DeviceUtil.kt delete mode 100644 app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Utils.kt rename app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/{ => extensions}/ApiExtensions.kt (97%) rename app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/{ => extensions}/AssetManagerExtensions.kt (96%) rename app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/{ => extensions}/AudioEffectExtensions.kt (98%) create mode 100644 app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/CompatExtensions.kt rename app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/{ => extensions}/ContextExtensions.kt (95%) create mode 100644 app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/MiscUtils.kt rename app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/{ => extensions}/PermissionExtensions.kt (83%) diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt index 62f7cebe1..aa45546bf 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt @@ -18,7 +18,7 @@ import me.timschneeberger.rootlessjamesdsp.flavor.UpdateManager import me.timschneeberger.rootlessjamesdsp.service.RootAudioProcessorService import me.timschneeberger.rootlessjamesdsp.session.root.RootSessionDatabase import me.timschneeberger.rootlessjamesdsp.utils.Cache -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver import me.timschneeberger.rootlessjamesdsp.utils.Preferences import org.koin.android.ext.android.inject import org.koin.android.ext.koin.androidContext diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AeqSelectorActivity.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AeqSelectorActivity.kt index 0858a8455..21e1a073d 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AeqSelectorActivity.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AeqSelectorActivity.kt @@ -15,8 +15,8 @@ import me.timschneeberger.rootlessjamesdsp.api.AutoEqClient import me.timschneeberger.rootlessjamesdsp.contract.AutoEqSelectorContract import me.timschneeberger.rootlessjamesdsp.databinding.ActivityAeqSelectorBinding import me.timschneeberger.rootlessjamesdsp.model.api.AeqSearchResult -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.hideKeyboardFrom -import me.timschneeberger.rootlessjamesdsp.utils.getSerializableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getSerializableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.hideKeyboardFrom class AeqSelectorActivity : BaseActivity() { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AppCompatibilityActivity.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AppCompatibilityActivity.kt index f0535ba4c..08af9bed2 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AppCompatibilityActivity.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/AppCompatibilityActivity.kt @@ -7,7 +7,7 @@ import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.ActivityAppCompatibilityBinding import me.timschneeberger.rootlessjamesdsp.fragment.AppCompatibilityFragment import me.timschneeberger.rootlessjamesdsp.service.RootlessAudioProcessorService -import me.timschneeberger.rootlessjamesdsp.utils.getParcelableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getParcelableAs class AppCompatibilityActivity : BaseActivity() { @SuppressLint("InlinedApi") diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/LiveprogEditorActivity.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/LiveprogEditorActivity.kt index 4b553125c..32508330d 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/LiveprogEditorActivity.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/LiveprogEditorActivity.kt @@ -36,14 +36,14 @@ import me.timschneeberger.rootlessjamesdsp.liveprog.EelParser import me.timschneeberger.rootlessjamesdsp.model.ProcessorMessage import me.timschneeberger.rootlessjamesdsp.service.BaseAudioProcessorService import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.resolveColorAttribute -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showInputAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showYesNoAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.resolveColorAttribute +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showInputAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showYesNoAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver import timber.log.Timber import java.util.Locale import java.util.regex.Pattern diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt index ea47fb2c5..cb197eefd 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/MainActivity.kt @@ -43,20 +43,20 @@ import me.timschneeberger.rootlessjamesdsp.preference.FileLibraryPreference import me.timschneeberger.rootlessjamesdsp.service.BaseAudioProcessorService import me.timschneeberger.rootlessjamesdsp.service.RootAudioProcessorService import me.timschneeberger.rootlessjamesdsp.service.RootlessAudioProcessorService -import me.timschneeberger.rootlessjamesdsp.utils.ApplicationUtils -import me.timschneeberger.rootlessjamesdsp.utils.AssetManagerExtensions.installPrivateAssets +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AssetManagerExtensions.installPrivateAssets import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.check -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.requestIgnoreBatteryOptimizations -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showSingleChoiceAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showYesNoAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasDumpPermission -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasRecordPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.check +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppName +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.requestIgnoreBatteryOptimizations +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showSingleChoiceAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showYesNoAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasDumpPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasRecordPermission import me.timschneeberger.rootlessjamesdsp.utils.Result import me.timschneeberger.rootlessjamesdsp.utils.StorageUtils import me.timschneeberger.rootlessjamesdsp.utils.SystemServices @@ -140,7 +140,7 @@ class MainActivity : BaseActivity() { val check = applicationContext.check() if(check != 0) { toast("($check) Cannot launch application. Please re-download the latest version from the Google Play or the official GitHub project site.") - Timber.wtf(UnsupportedOperationException("Launch error $check; ${ApplicationUtils.describe(this)}")) + Timber.e(UnsupportedOperationException("Launch error $check; package=${packageName}; app_name=${getAppName()}")) quitGracefully() return } diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/OnboardingActivity.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/OnboardingActivity.kt index 6c78afc28..fdb7638be 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/OnboardingActivity.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/activity/OnboardingActivity.kt @@ -6,7 +6,7 @@ import me.timschneeberger.rootlessjamesdsp.BuildConfig import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.ActivityOnboardingBinding import me.timschneeberger.rootlessjamesdsp.fragment.OnboardingFragment -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert class OnboardingActivity : BaseActivity(){ diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/adapter/ThemesPreferenceAdapter.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/adapter/ThemesPreferenceAdapter.kt index 71ef30f08..7ce0f07b2 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/adapter/ThemesPreferenceAdapter.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/adapter/ThemesPreferenceAdapter.kt @@ -10,7 +10,7 @@ import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.PreferenceThemeItemBinding import me.timschneeberger.rootlessjamesdsp.delegates.ThemingDelegate import me.timschneeberger.rootlessjamesdsp.model.preference.AppTheme -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getResourceColor +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getResourceColor import me.timschneeberger.rootlessjamesdsp.utils.Preferences import org.koin.core.component.KoinComponent import org.koin.core.component.inject diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppCompatibilityFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppCompatibilityFragment.kt index 6aba3a09b..39e7a2c31 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppCompatibilityFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppCompatibilityFragment.kt @@ -21,11 +21,11 @@ import me.timschneeberger.rootlessjamesdsp.model.room.AppBlocklistViewModelFacto import me.timschneeberger.rootlessjamesdsp.model.room.BlockedApp import me.timschneeberger.rootlessjamesdsp.service.RootlessAudioProcessorService import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppIcon -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppNameFromUidSafe -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getPackageNameFromUid +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppIcon +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppNameFromUidSafe +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getPackageNameFromUid import me.timschneeberger.rootlessjamesdsp.utils.SystemServices -import me.timschneeberger.rootlessjamesdsp.utils.getParcelableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getParcelableAs import timber.log.Timber import java.util.* import kotlin.concurrent.schedule diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppsListFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppsListFragment.kt index 44ff8eefe..c68bb8f35 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppsListFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/AppsListFragment.kt @@ -18,7 +18,7 @@ import me.timschneeberger.rootlessjamesdsp.adapter.AppsListAdapter import me.timschneeberger.rootlessjamesdsp.databinding.FragmentApplistSheetBinding import me.timschneeberger.rootlessjamesdsp.model.AppInfo import me.timschneeberger.rootlessjamesdsp.model.ItemViewModel -import me.timschneeberger.rootlessjamesdsp.utils.getInstalledApplicationsCompat +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getInstalledApplicationsCompat class AppsListFragment : BottomSheetDialogFragment() { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/BlocklistFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/BlocklistFragment.kt index cfafdc87d..6fc100fa1 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/BlocklistFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/BlocklistFragment.kt @@ -24,12 +24,12 @@ import me.timschneeberger.rootlessjamesdsp.model.room.AppBlocklistViewModelFacto import me.timschneeberger.rootlessjamesdsp.model.room.BlockedApp import me.timschneeberger.rootlessjamesdsp.session.dump.DumpManager import me.timschneeberger.rootlessjamesdsp.session.rootless.SessionRecordingPolicyManager -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppIcon -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppNameFromUidSafe -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showYesNoAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppIcon +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppNameFromUidSafe +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showYesNoAlert import me.timschneeberger.rootlessjamesdsp.utils.Preferences -import me.timschneeberger.rootlessjamesdsp.utils.loadHtml +import me.timschneeberger.rootlessjamesdsp.utils.extensions.asHtml import org.koin.android.ext.android.inject class BlocklistFragment : Fragment() { @@ -82,7 +82,7 @@ class BlocklistFragment : Fragment() { binding.notice.setOnClickListener { requireContext().showAlert( getString(R.string.blocklist_unsupported_apps), - loadHtml(getString(R.string.blocklist_unsupported_apps_message, restrictedApps.joinToString("
"))) + getString(R.string.blocklist_unsupported_apps_message, restrictedApps.joinToString("
")).asHtml() ) } updateUnsupportedApps() diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/FileLibraryDialogFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/FileLibraryDialogFragment.kt index 258824db6..b9ef8c258 100755 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/FileLibraryDialogFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/FileLibraryDialogFragment.kt @@ -37,9 +37,9 @@ import me.timschneeberger.rootlessjamesdsp.interop.JdspImpResToolbox import me.timschneeberger.rootlessjamesdsp.liveprog.EelParser import me.timschneeberger.rootlessjamesdsp.model.Preset import me.timschneeberger.rootlessjamesdsp.preference.FileLibraryPreference -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showInputAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showInputAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import me.timschneeberger.rootlessjamesdsp.utils.StorageUtils import me.timschneeberger.rootlessjamesdsp.utils.SystemServices import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/GraphicEqualizerFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/GraphicEqualizerFragment.kt index 527de99f0..9d7121799 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/GraphicEqualizerFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/GraphicEqualizerFragment.kt @@ -19,9 +19,9 @@ import me.timschneeberger.rootlessjamesdsp.databinding.FragmentGraphicEqBinding import me.timschneeberger.rootlessjamesdsp.model.GraphicEqNode import me.timschneeberger.rootlessjamesdsp.model.GraphicEqNodeList import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showInputAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showYesNoAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showInputAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showYesNoAlert import timber.log.Timber import java.util.UUID diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LibraryLoadErrorFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LibraryLoadErrorFragment.kt index deac7bc71..9ac2bdb56 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LibraryLoadErrorFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LibraryLoadErrorFragment.kt @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import me.timschneeberger.rootlessjamesdsp.databinding.FragmentLibraryLoadErrorBinding -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.openPlayStoreApp +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.openPlayStoreApp class LibraryLoadErrorFragment : Fragment() { private lateinit var binding: FragmentLibraryLoadErrorBinding diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LimitationsFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LimitationsFragment.kt index ba7de5628..50febac7c 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LimitationsFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LimitationsFragment.kt @@ -7,7 +7,7 @@ import android.view.ViewGroup import androidx.core.view.isVisible import androidx.fragment.app.Fragment import me.timschneeberger.rootlessjamesdsp.databinding.OnboardingPage2Binding -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.dpToPx +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.dpToPx class LimitationsFragment : Fragment() { private lateinit var binding: OnboardingPage2Binding diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LiveprogParamsFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LiveprogParamsFragment.kt index a960999e3..b05c1d504 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LiveprogParamsFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/LiveprogParamsFragment.kt @@ -15,8 +15,8 @@ import me.timschneeberger.rootlessjamesdsp.liveprog.EelParser import me.timschneeberger.rootlessjamesdsp.preference.DropDownPreference import me.timschneeberger.rootlessjamesdsp.preference.MaterialSeekbarPreference import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import me.timschneeberger.rootlessjamesdsp.utils.NonPersistentDatastore import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/OnboardingFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/OnboardingFragment.kt index b5558d1c8..b19a893e5 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/OnboardingFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/OnboardingFragment.kt @@ -27,14 +27,14 @@ import me.timschneeberger.rootlessjamesdsp.activity.OnboardingActivity.Companion import me.timschneeberger.rootlessjamesdsp.databinding.OnboardingFragmentBinding import me.timschneeberger.rootlessjamesdsp.flavor.RootShellImpl import me.timschneeberger.rootlessjamesdsp.service.RootAudioProcessorService -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.isPackageInstalled -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.launchApp -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.openPlayStoreApp -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasDumpPermission -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasNotificationPermission -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasRecordPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.isPackageInstalled +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.launchApp +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.openPlayStoreApp +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasDumpPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasNotificationPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasRecordPermission import me.timschneeberger.rootlessjamesdsp.utils.Preferences import me.timschneeberger.rootlessjamesdsp.utils.sdkAbove import org.koin.android.ext.android.inject diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/PreferenceGroupFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/PreferenceGroupFragment.kt index 27a98ed90..5a68b1e20 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/PreferenceGroupFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/PreferenceGroupFragment.kt @@ -18,9 +18,9 @@ import me.timschneeberger.rootlessjamesdsp.preference.EqualizerPreference import me.timschneeberger.rootlessjamesdsp.preference.FileLibraryPreference import me.timschneeberger.rootlessjamesdsp.preference.MaterialSeekbarPreference import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAboutFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAboutFragment.kt index 2882dc13f..b4dadef60 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAboutFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAboutFragment.kt @@ -21,7 +21,7 @@ import me.timschneeberger.rootlessjamesdsp.BuildConfig import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.flavor.UpdateManager import me.timschneeberger.rootlessjamesdsp.model.Translator -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import me.timschneeberger.rootlessjamesdsp.utils.Result import org.koin.android.ext.android.inject import java.util.Locale diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAppearanceFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAppearanceFragment.kt index 102bc3fc8..989bb2adb 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAppearanceFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAppearanceFragment.kt @@ -13,7 +13,7 @@ import me.timschneeberger.rootlessjamesdsp.model.preference.AppTheme import me.timschneeberger.rootlessjamesdsp.model.preference.ThemeMode import me.timschneeberger.rootlessjamesdsp.preference.ThemesPreference import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.DeviceUtil +import me.timschneeberger.rootlessjamesdsp.utils.extensions.isDynamicColorAvailable class SettingsAppearanceFragment : PreferenceFragmentCompat() { @@ -27,7 +27,7 @@ class SettingsAppearanceFragment : PreferenceFragmentCompat() { val appThemes = AppTheme.values().filter { val monetFilter = if (it == AppTheme.MONET) { - DeviceUtil.isDynamicColorAvailable + isDynamicColorAvailable } else { true } diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAudioFormatFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAudioFormatFragment.kt index 2bccfde38..6ec08db69 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAudioFormatFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsAudioFormatFragment.kt @@ -18,11 +18,11 @@ import me.timschneeberger.rootlessjamesdsp.preference.MaterialSeekbarPreference import me.timschneeberger.rootlessjamesdsp.preference.MaterialSwitchPreference import me.timschneeberger.rootlessjamesdsp.service.RootAudioProcessorService import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.requestIgnoreBatteryOptimizations -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasDumpPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.requestIgnoreBatteryOptimizations +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasDumpPermission import me.timschneeberger.rootlessjamesdsp.utils.Preferences import org.koin.android.ext.android.inject import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsMiscFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsMiscFragment.kt index 85aa1d304..ad3a603bf 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsMiscFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsMiscFragment.kt @@ -15,11 +15,11 @@ import me.timschneeberger.rootlessjamesdsp.BuildConfig import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.api.AutoEqClient import me.timschneeberger.rootlessjamesdsp.flavor.CrashlyticsImpl -import me.timschneeberger.rootlessjamesdsp.utils.AssetManagerExtensions.installPrivateAssets +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AssetManagerExtensions.installPrivateAssets import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showYesNoAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showYesNoAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import me.timschneeberger.rootlessjamesdsp.utils.Preferences import org.koin.android.ext.android.inject import java.util.Locale diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsTroubleshootingFragment.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsTroubleshootingFragment.kt index c4b8b0ba7..5e8879a72 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsTroubleshootingFragment.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/fragment/SettingsTroubleshootingFragment.kt @@ -1,8 +1,10 @@ package me.timschneeberger.rootlessjamesdsp.fragment +import android.content.ComponentName import android.content.Intent import android.os.Build import android.os.Bundle +import android.provider.Settings import android.text.InputType import android.util.TypedValue import android.view.LayoutInflater @@ -18,10 +20,10 @@ import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.preference.MaterialSwitchPreference import me.timschneeberger.rootlessjamesdsp.service.NotificationListenerService import me.timschneeberger.rootlessjamesdsp.session.dump.DumpManager -import me.timschneeberger.rootlessjamesdsp.utils.ApplicationUtils import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.sdkAbove import org.koin.android.ext.android.inject import java.io.File import java.io.FileOutputStream @@ -78,7 +80,20 @@ class SettingsTroubleshootingFragment : PreferenceFragmentCompat() { true } findPreference(getString(R.string.key_troubleshooting_notification_access))?.setOnPreferenceClickListener { - val intent = ApplicationUtils.getIntentForNotificationAccess(requireContext().packageName, NotificationListenerService::class.java) + val serviceClassName = NotificationListenerService::class.java.name + val intent = sdkAbove(Build.VERSION_CODES.R) { + Intent(Settings.ACTION_NOTIFICATION_LISTENER_DETAIL_SETTINGS) + .putExtra(Settings.EXTRA_NOTIFICATION_LISTENER_COMPONENT_NAME, ComponentName(requireContext().packageName, serviceClassName).flattenToString()) + }.below { + Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS) + .apply { + val value = "${requireContext().packageName}/$serviceClassName" + val key = ":settings:fragment_args_key" + putExtra(":settings:show_fragment_args", Bundle().also { it.putString(key, value) }) + putExtra(":settings:fragment_args_key", "${requireContext().packageName}/$serviceClassName") + } + } + // TVs, smart-watches and some other weird devices do not have these settings try { requireActivity().startActivity(intent) diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspBaseEngine.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspBaseEngine.kt index 73caa4dd9..d62069ee4 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspBaseEngine.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspBaseEngine.kt @@ -12,7 +12,7 @@ import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.utils.Constants import me.timschneeberger.rootlessjamesdsp.interop.structure.EelVmVariable import me.timschneeberger.rootlessjamesdsp.model.ProcessorMessage -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast import timber.log.Timber import java.io.File import java.io.FileReader diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspLocalEngine.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspLocalEngine.kt index e6ea1e4aa..64a2bd7f7 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspLocalEngine.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspLocalEngine.kt @@ -4,7 +4,7 @@ import android.content.Context import android.content.Intent import me.timschneeberger.rootlessjamesdsp.interop.structure.EelVmVariable import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast import timber.log.Timber import java.util.Timer import kotlin.concurrent.schedule diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspRemoteEngine.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspRemoteEngine.kt index 2d15f56ad..ae3f0a8b2 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspRemoteEngine.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/JamesDspRemoteEngine.kt @@ -7,16 +7,16 @@ import android.content.IntentFilter import android.media.audiofx.AudioEffect import android.media.audiofx.AudioEffectHidden import me.timschneeberger.rootlessjamesdsp.interop.structure.EelVmVariable -import me.timschneeberger.rootlessjamesdsp.utils.AudioEffectExtensions.getParameterInt -import me.timschneeberger.rootlessjamesdsp.utils.AudioEffectExtensions.setParameter -import me.timschneeberger.rootlessjamesdsp.utils.AudioEffectExtensions.setParameterCharBuffer -import me.timschneeberger.rootlessjamesdsp.utils.AudioEffectExtensions.setParameterFloatArray -import me.timschneeberger.rootlessjamesdsp.utils.AudioEffectExtensions.setParameterImpulseResponseBuffer +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AudioEffectExtensions.getParameterInt +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AudioEffectExtensions.setParameter +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AudioEffectExtensions.setParameterCharBuffer +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AudioEffectExtensions.setParameterFloatArray +import me.timschneeberger.rootlessjamesdsp.utils.extensions.AudioEffectExtensions.setParameterImpulseResponseBuffer import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.toShort +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.toShort import timber.log.Timber import java.util.UUID import kotlin.math.roundToInt diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/ProcessorMessageHandler.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/ProcessorMessageHandler.kt index 1d0bc5a79..8e4e6a923 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/ProcessorMessageHandler.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/interop/ProcessorMessageHandler.kt @@ -4,7 +4,7 @@ import android.content.Context import android.content.Intent import me.timschneeberger.rootlessjamesdsp.model.ProcessorMessage import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast import org.koin.core.component.KoinComponent import org.koin.core.component.inject import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/liveprog/EelParser.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/liveprog/EelParser.kt index d5d8a1801..7714a4507 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/liveprog/EelParser.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/liveprog/EelParser.kt @@ -1,6 +1,6 @@ package me.timschneeberger.rootlessjamesdsp.liveprog -import me.timschneeberger.rootlessjamesdsp.utils.md5 +import me.timschneeberger.rootlessjamesdsp.utils.extensions.md5 import timber.log.Timber import java.io.File import java.io.FileNotFoundException diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/GraphicEqNodeList.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/GraphicEqNodeList.kt index 7082c5fd4..1b4cc4add 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/GraphicEqNodeList.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/GraphicEqNodeList.kt @@ -2,7 +2,7 @@ package me.timschneeberger.rootlessjamesdsp.model import android.os.Bundle import androidx.databinding.ObservableArrayList -import me.timschneeberger.rootlessjamesdsp.utils.getSerializableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getSerializableAs import timber.log.Timber import java.text.DecimalFormat import java.text.DecimalFormatSymbols diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/Preset.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/Preset.kt index a6da14ddf..e69e53e04 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/Preset.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/model/Preset.kt @@ -7,8 +7,8 @@ import me.timschneeberger.rootlessjamesdsp.BuildConfig import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.liveprog.EelParser import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import org.kamranzafar.jtar.TarEntry import org.kamranzafar.jtar.TarInputStream import org.kamranzafar.jtar.TarOutputStream diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/AppIconPreference.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/AppIconPreference.kt index 534dd575b..912465ddd 100755 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/AppIconPreference.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/AppIconPreference.kt @@ -6,7 +6,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceViewHolder import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.PreferenceAppiconBinding -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppName +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppName class AppIconPreference : Preference { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/FileLibraryPreference.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/FileLibraryPreference.kt index b2dc1205a..861304780 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/FileLibraryPreference.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/FileLibraryPreference.kt @@ -7,7 +7,7 @@ import androidx.preference.ListPreference import androidx.preference.Preference.SummaryProvider import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.model.Preset -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import java.io.File import java.io.InputStream diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/GraphicEqualizerPreference.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/GraphicEqualizerPreference.kt index ebe17fcfa..e188859d9 100755 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/GraphicEqualizerPreference.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/GraphicEqualizerPreference.kt @@ -12,8 +12,8 @@ import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.PreferenceGraphicEqualizerBinding import me.timschneeberger.rootlessjamesdsp.model.GraphicEqNodeList import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver class GraphicEqualizerPreference : Preference { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/MaterialSeekbarPreference.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/MaterialSeekbarPreference.kt index 96709c91e..f6d7f9057 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/MaterialSeekbarPreference.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/MaterialSeekbarPreference.kt @@ -13,8 +13,8 @@ import androidx.preference.PreferenceViewHolder import androidx.preference.SeekBarPreference import com.google.android.material.slider.Slider import me.timschneeberger.rootlessjamesdsp.R -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.showInputAlert -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.showInputAlert +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import timber.log.Timber import java.math.BigDecimal import java.math.MathContext diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/ThemesPreference.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/ThemesPreference.kt index f071995b5..4352f7a46 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/ThemesPreference.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/preference/ThemesPreference.kt @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.adapter.ThemesPreferenceAdapter import me.timschneeberger.rootlessjamesdsp.model.preference.AppTheme -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.dpToPx +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.dpToPx class ThemesPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ListPreference(context, attrs), diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/receiver/SessionReceiver.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/receiver/SessionReceiver.kt index cbf32f7af..9f09c3380 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/receiver/SessionReceiver.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/receiver/SessionReceiver.kt @@ -9,7 +9,7 @@ import me.timschneeberger.rootlessjamesdsp.BuildConfig import me.timschneeberger.rootlessjamesdsp.service.RootAudioProcessorService import me.timschneeberger.rootlessjamesdsp.session.rootless.RootlessSessionDatabase import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast import timber.log.Timber class SessionReceiver : BroadcastReceiver() { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/QuickTileService.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/QuickTileService.kt index fac8450d6..310d2c4a2 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/QuickTileService.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/QuickTileService.kt @@ -13,9 +13,9 @@ import me.timschneeberger.rootlessjamesdsp.MainApplication import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.activity.EngineLauncherActivity import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasProjectMediaAppOp +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasProjectMediaAppOp import me.timschneeberger.rootlessjamesdsp.utils.Preferences import org.koin.android.ext.android.inject import org.koin.core.component.KoinComponent diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootAudioProcessorService.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootAudioProcessorService.kt index 1a07dfefa..efca0eae6 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootAudioProcessorService.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootAudioProcessorService.kt @@ -29,7 +29,7 @@ import me.timschneeberger.rootlessjamesdsp.session.root.RootSessionDumpManager import me.timschneeberger.rootlessjamesdsp.utils.Constants import me.timschneeberger.rootlessjamesdsp.utils.Constants.CHANNEL_ID_SERVICE import me.timschneeberger.rootlessjamesdsp.utils.Constants.NOTIFICATION_ID_SERVICE -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast import me.timschneeberger.rootlessjamesdsp.utils.Preferences import me.timschneeberger.rootlessjamesdsp.utils.ServiceNotificationHelper import me.timschneeberger.rootlessjamesdsp.utils.SystemServices diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootlessAudioProcessorService.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootlessAudioProcessorService.kt index b0d87a3d8..a06f0acaa 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootlessAudioProcessorService.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/service/RootlessAudioProcessorService.kt @@ -41,16 +41,15 @@ import me.timschneeberger.rootlessjamesdsp.utils.Constants.NOTIFICATION_ID_APP_I import me.timschneeberger.rootlessjamesdsp.utils.Constants.NOTIFICATION_ID_PERMISSION_PROMPT import me.timschneeberger.rootlessjamesdsp.utils.Constants.NOTIFICATION_ID_SERVICE import me.timschneeberger.rootlessjamesdsp.utils.Constants.NOTIFICATION_ID_SESSION_LOSS -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.sendLocalBroadcast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasRecordPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.sendLocalBroadcast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasRecordPermission import me.timschneeberger.rootlessjamesdsp.utils.Preferences import me.timschneeberger.rootlessjamesdsp.utils.ServiceNotificationHelper import me.timschneeberger.rootlessjamesdsp.utils.SystemServices -import me.timschneeberger.rootlessjamesdsp.utils.concatenate -import me.timschneeberger.rootlessjamesdsp.utils.getParcelableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getParcelableAs import org.koin.android.ext.android.inject import timber.log.Timber import java.io.IOException @@ -627,15 +626,15 @@ class RootlessAudioProcessorService : BaseAudioProcessorService() { .addMatchingUsage(AudioAttributes.USAGE_GAME) .addMatchingUsage(AudioAttributes.USAGE_UNKNOWN) - var excluded = if(excludeRestrictedSessions) + val excluded = (if(excludeRestrictedSessions) sessionManager.sessionPolicyDatabase.getRestrictedUids().toList() else { sessionManager.pollOnce(false) emptyList() - } + }).toMutableList() blockedApps.value?.map { it.uid }?.let { - excluded = concatenate(excluded, it) + excluded += it } excluded.forEach { configBuilder.excludeUid(it) } diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioPolicyServiceDumpProvider.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioPolicyServiceDumpProvider.kt index 30ae73eee..023bcb471 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioPolicyServiceDumpProvider.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioPolicyServiceDumpProvider.kt @@ -6,7 +6,7 @@ import me.timschneeberger.rootlessjamesdsp.session.dump.data.AudioPolicyServiceD import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionInfoDump import me.timschneeberger.rootlessjamesdsp.session.dump.utils.DumpUtils import me.timschneeberger.rootlessjamesdsp.model.AudioSessionDumpEntry -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getPackageNameFromUid +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getPackageNameFromUid import timber.log.Timber import java.util.* diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioServiceDumpProvider.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioServiceDumpProvider.kt index 19810a5e1..06d3f4365 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioServiceDumpProvider.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioServiceDumpProvider.kt @@ -6,7 +6,7 @@ import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionInfoDump import me.timschneeberger.rootlessjamesdsp.session.dump.utils.AudioFlingerServiceDumpUtils import me.timschneeberger.rootlessjamesdsp.session.dump.utils.DumpUtils import me.timschneeberger.rootlessjamesdsp.model.AudioSessionDumpEntry -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getPackageNameFromUid +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getPackageNameFromUid import timber.log.Timber import java.lang.Exception diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/utils/DumpUtils.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/utils/DumpUtils.kt index 995e9c018..e5136d55e 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/utils/DumpUtils.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/utils/DumpUtils.kt @@ -2,7 +2,7 @@ package me.timschneeberger.rootlessjamesdsp.session.dump.utils import android.content.Context import android.os.ParcelFileDescriptor -import me.timschneeberger.rootlessjamesdsp.utils.PermissionExtensions.hasDumpPermission +import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasDumpPermission import rikka.shizuku.SystemServiceHelper import timber.log.Timber import java.io.FileInputStream diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/root/RootSessionDatabase.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/root/RootSessionDatabase.kt index 1432b15bf..f6bb59ddc 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/root/RootSessionDatabase.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/root/RootSessionDatabase.kt @@ -11,8 +11,8 @@ import me.timschneeberger.rootlessjamesdsp.model.AudioSessionDumpEntry import me.timschneeberger.rootlessjamesdsp.model.IEffectSession import me.timschneeberger.rootlessjamesdsp.model.root.RemoteEffectSession import me.timschneeberger.rootlessjamesdsp.session.shared.BaseSessionDatabase -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getUidFromPackage -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.toast +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getUidFromPackage +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.toast import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/rootless/SessionRecordingPolicyManager.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/rootless/SessionRecordingPolicyManager.kt index 82ad4d200..38afe1388 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/rootless/SessionRecordingPolicyManager.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/rootless/SessionRecordingPolicyManager.kt @@ -4,7 +4,7 @@ import android.content.Context import android.content.pm.PackageManager import me.timschneeberger.rootlessjamesdsp.model.rootless.SessionRecordingPolicyEntry import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionPolicyInfoDump -import me.timschneeberger.rootlessjamesdsp.utils.getApplicationInfoCompat +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getApplicationInfoCompat import timber.log.Timber diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/shared/BaseSessionManager.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/shared/BaseSessionManager.kt index 1ff94d2c8..23f1378ba 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/shared/BaseSessionManager.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/session/shared/BaseSessionManager.kt @@ -21,8 +21,8 @@ import me.timschneeberger.rootlessjamesdsp.model.preference.SessionUpdateMode import me.timschneeberger.rootlessjamesdsp.service.NotificationListenerService import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionInfoDump import me.timschneeberger.rootlessjamesdsp.utils.Constants -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.registerLocalReceiver -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.unregisterLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.unregisterLocalReceiver import me.timschneeberger.rootlessjamesdsp.utils.Preferences import me.timschneeberger.rootlessjamesdsp.utils.SystemServices import org.koin.core.component.KoinComponent diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApplicationUtils.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApplicationUtils.kt deleted file mode 100644 index 4e4142b52..000000000 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApplicationUtils.kt +++ /dev/null @@ -1,33 +0,0 @@ -package me.timschneeberger.rootlessjamesdsp.utils - -import android.content.ComponentName -import android.content.Context -import android.content.Intent -import android.os.Build -import android.os.Bundle -import android.provider.Settings -import me.timschneeberger.rootlessjamesdsp.service.NotificationListenerService -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppName - - -object ApplicationUtils { - fun describe(ctx: Context): String { - return "package=${ctx.packageName}; app_name=${ctx.getAppName()}; label=${ctx.getAppName()}" - } - - fun getIntentForNotificationAccess(packageName: String, notificationAccessServiceClass: Class): Intent = - getIntentForNotificationAccess(packageName, notificationAccessServiceClass.name) - - private fun getIntentForNotificationAccess(packageName: String, notificationAccessServiceClassName: String): Intent { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - return Intent(Settings.ACTION_NOTIFICATION_LISTENER_DETAIL_SETTINGS) - .putExtra(Settings.EXTRA_NOTIFICATION_LISTENER_COMPONENT_NAME, ComponentName(packageName, notificationAccessServiceClassName).flattenToString()) - } - val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS) - val value = "$packageName/$notificationAccessServiceClassName" - val key = ":settings:fragment_args_key" - intent.putExtra(key, value) - intent.putExtra(":settings:show_fragment_args", Bundle().also { it.putString(key, value) }) - return intent - } -} \ No newline at end of file diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Cache.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Cache.kt index 67bc62be4..31bb14914 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Cache.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Cache.kt @@ -11,6 +11,7 @@ import android.os.Build import android.os.ParcelFileDescriptor import android.provider.OpenableColumns import android.system.Os +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getPackageInfoCompat import java.io.File import java.util.* import kotlin.concurrent.thread @@ -64,18 +65,10 @@ object Cache { val file = getReleaseFile(context, cacheFileName) val packageInfo = try { - if (SdkCheck.isTiramisu) { - context.packageManager.getPackageInfo( - context.packageName, - PackageManager.PackageInfoFlags.of(PackageManager.GET_PROVIDERS.toLong()) - ) - } else { - @Suppress("DEPRECATION") - context.packageManager.getPackageInfo( - context.packageName, - PackageManager.GET_PROVIDERS - ) - } + context.packageManager.getPackageInfoCompat( + context.packageName, + PackageManager.GET_PROVIDERS + ) } catch (e: Exception) { null } diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/DeviceUtil.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/DeviceUtil.kt deleted file mode 100644 index 024906609..000000000 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/DeviceUtil.kt +++ /dev/null @@ -1,31 +0,0 @@ -package me.timschneeberger.rootlessjamesdsp.utils - -import android.annotation.SuppressLint -import android.os.Build -import com.google.android.material.color.DynamicColors -import timber.log.Timber - -object DeviceUtil { - private val isSamsung by lazy { - Build.MANUFACTURER.equals("samsung", ignoreCase = true) - } - - @SuppressLint("PrivateApi") - private fun getSystemProperty(key: String?): String? { - return try { - Class.forName("android.os.SystemProperties") - .getDeclaredMethod("get", String::class.java) - .invoke(null, key) as String - } catch (e: Exception) { - Timber.w("Unable to use SystemProperties.get()") - Timber.d(e) - null - } - } - - - val isDynamicColorAvailable by lazy { - DynamicColors.isDynamicColorAvailable() || - (isSamsung && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) - } -} \ No newline at end of file diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/SdkCheck.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/SdkCheck.kt index a51a97493..b8ba925ac 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/SdkCheck.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/SdkCheck.kt @@ -3,9 +3,16 @@ package me.timschneeberger.rootlessjamesdsp.utils import android.os.Build import androidx.annotation.ChecksSdkIntAtLeast +class SdkCheckElseBranch(private val result: T?) { + fun valueOrNull(): T? = result + fun below(onFailure: () -> T): T = result ?: onFailure() +} + @ChecksSdkIntAtLeast(parameter = 0, lambda = 1) -inline fun sdkAbove(sdk: Int, onSuccessful: () -> Unit) { - if (Build.VERSION.SDK_INT >= sdk) onSuccessful() +inline fun sdkAbove(sdk: Int, onSuccessful: () -> T): SdkCheckElseBranch { + (Build.VERSION.SDK_INT >= sdk).let { + return SdkCheckElseBranch(if(it) onSuccessful() else null) + } } object SdkCheck { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ServiceNotificationHelper.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ServiceNotificationHelper.kt index 5c66d5a4b..fa59ef737 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ServiceNotificationHelper.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ServiceNotificationHelper.kt @@ -15,8 +15,8 @@ import me.timschneeberger.rootlessjamesdsp.activity.EngineLauncherActivity import me.timschneeberger.rootlessjamesdsp.activity.MainActivity import me.timschneeberger.rootlessjamesdsp.model.IEffectSession import me.timschneeberger.rootlessjamesdsp.service.RootlessAudioProcessorService -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppName -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.getAppNameFromUid +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppName +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.getAppNameFromUid import org.koin.core.component.KoinComponent import org.koin.core.component.inject diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Utils.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Utils.kt deleted file mode 100644 index aa8306a4d..000000000 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/Utils.kt +++ /dev/null @@ -1,94 +0,0 @@ -package me.timschneeberger.rootlessjamesdsp.utils - -import android.content.pm.ApplicationInfo -import android.content.pm.PackageManager -import android.os.Build -import android.os.Bundle -import android.os.Parcelable -import android.text.Html -import android.text.Spanned -import java.io.Serializable -import java.math.BigDecimal -import java.math.RoundingMode -import java.security.MessageDigest -import java.util.* -import kotlin.math.* - - -fun concatenate(vararg lists: List): List { - return listOf(*lists).flatten() -} - -fun loadHtml(html: String): Spanned = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY) - -fun prettyNumberFormat(input: Double): String { - if( input == 0.0 ) return "0" - - val prefix = if( input < 0 ) "-" else "" - val num = abs(input) - - // figure out what group of suffixes we are in and scale the number - val pow = floor(log10(num) /3).roundToInt() - val base = num / 10.0.pow(pow * 3) - - // Using consistent rounding behavior, always rounding down since you want - // 999999999 to show as 999.99M and not 1B - val roundedDown = floor(base*100) /100.0 - - // Convert the number to a string with up to 1 decimal place - var baseStr = BigDecimal(roundedDown) - .setScale(1, RoundingMode.HALF_EVEN) - .toString() - - // Drop trailing zeros, then drop any trailing '.' if present - baseStr = baseStr.dropLastWhile { it == '0' }.dropLastWhile { it == '.' } - - val suffixes = listOf("","k","M","B","T") - - return when { - pow < suffixes.size -> "$prefix$baseStr${suffixes[pow]}" - else -> "${prefix}∞" - } -} - -@Suppress("UNCHECKED_CAST") -fun Bundle.getSerializableAs(key: String, clazz: Class): T? { - return (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - this.getSerializable(key, clazz) - } else { - @Suppress("DEPRECATION") - this.getSerializable(key) - }) as? T -} - -inline fun Bundle.getParcelableAs(key: String): T? { - return (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - this.getParcelable(key, T::class.java) - } else { - @Suppress("DEPRECATION") - this.getParcelable(key) - }) -} - -fun PackageManager.getApplicationInfoCompat(packageName: String, flags: Int = 0): ApplicationInfo { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of(flags.toLong())) - } else { - @Suppress("DEPRECATION") getApplicationInfo(packageName, flags) - } -} - -fun PackageManager.getInstalledApplicationsCompat(flags: Int = 0): List { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - getInstalledApplications(PackageManager.ApplicationInfoFlags.of(flags.toLong())) - } else { - @Suppress("DEPRECATION") getInstalledApplications(flags) - } -} - -fun Boolean.toShort() = (if (this) 1 else 0).toShort() - -val String.md5: ByteArray - get() { - return MessageDigest.getInstance("MD5").digest(this.toByteArray()) - } \ No newline at end of file diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApiExtensions.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/ApiExtensions.kt similarity index 97% rename from app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApiExtensions.kt rename to app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/ApiExtensions.kt index 9f8ff34c8..c0b8fbeef 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ApiExtensions.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/ApiExtensions.kt @@ -1,4 +1,4 @@ -package me.timschneeberger.rootlessjamesdsp.utils +package me.timschneeberger.rootlessjamesdsp.utils.extensions import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/AssetManagerExtensions.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/AssetManagerExtensions.kt similarity index 96% rename from app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/AssetManagerExtensions.kt rename to app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/AssetManagerExtensions.kt index 0d05fca8c..35254dd0e 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/AssetManagerExtensions.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/AssetManagerExtensions.kt @@ -1,4 +1,4 @@ -package me.timschneeberger.rootlessjamesdsp.utils +package me.timschneeberger.rootlessjamesdsp.utils.extensions import android.content.Context import android.content.res.AssetManager diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/AudioEffectExtensions.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/AudioEffectExtensions.kt similarity index 98% rename from app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/AudioEffectExtensions.kt rename to app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/AudioEffectExtensions.kt index 5f2a11386..7e3736c5b 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/AudioEffectExtensions.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/AudioEffectExtensions.kt @@ -1,4 +1,4 @@ -package me.timschneeberger.rootlessjamesdsp.utils +package me.timschneeberger.rootlessjamesdsp.utils.extensions import android.media.audiofx.AudioEffect import android.media.audiofx.AudioEffectHidden diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/CompatExtensions.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/CompatExtensions.kt new file mode 100644 index 000000000..94bc51b68 --- /dev/null +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/CompatExtensions.kt @@ -0,0 +1,54 @@ +package me.timschneeberger.rootlessjamesdsp.utils.extensions + +import android.content.pm.ApplicationInfo +import android.content.pm.PackageInfo +import android.content.pm.PackageManager +import android.os.Build +import android.os.Bundle +import android.os.Parcelable +import java.io.Serializable + +object CompatExtensions { + @Suppress("UNCHECKED_CAST") + fun Bundle.getSerializableAs(key: String, clazz: Class): T? { + return (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + this.getSerializable(key, clazz) + } else { + @Suppress("DEPRECATION") + this.getSerializable(key) + }) as? T + } + + inline fun Bundle.getParcelableAs(key: String): T? { + return (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + this.getParcelable(key, T::class.java) + } else { + @Suppress("DEPRECATION") + this.getParcelable(key) + }) + } + + fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): PackageInfo { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(flags.toLong())) + } else { + @Suppress("DEPRECATION") getPackageInfo(packageName, flags) + } + } + + fun PackageManager.getApplicationInfoCompat(packageName: String, flags: Int = 0): ApplicationInfo { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of(flags.toLong())) + } else { + @Suppress("DEPRECATION") getApplicationInfo(packageName, flags) + } + } + + fun PackageManager.getInstalledApplicationsCompat(flags: Int = 0): List { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + getInstalledApplications(PackageManager.ApplicationInfoFlags.of(flags.toLong())) + } else { + @Suppress("DEPRECATION") getInstalledApplications(flags) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ContextExtensions.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/ContextExtensions.kt similarity index 95% rename from app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ContextExtensions.kt rename to app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/ContextExtensions.kt index e6bc2a439..4ee448484 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/ContextExtensions.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/ContextExtensions.kt @@ -1,4 +1,4 @@ -package me.timschneeberger.rootlessjamesdsp.utils +package me.timschneeberger.rootlessjamesdsp.utils.extensions import android.annotation.SuppressLint import android.content.* @@ -33,6 +33,9 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import me.timschneeberger.rootlessjamesdsp.BuildConfig import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.DialogTextinputBinding +import me.timschneeberger.rootlessjamesdsp.utils.SystemServices +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getApplicationInfoCompat +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getPackageInfoCompat import timber.log.Timber import java.io.File import kotlin.math.roundToInt @@ -93,10 +96,9 @@ object ContextExtensions { } } - @Suppress("DEPRECATION") fun Context.isPackageInstalled(packageName: String): Boolean { return try { - packageManager.getPackageInfo(packageName, 0) + packageManager.getPackageInfoCompat(packageName, 0) true } catch (e: PackageManager.NameNotFoundException) { false @@ -268,10 +270,9 @@ object ContextExtensions { fun Context.getAppName(): String = applicationInfo.loadLabel(packageManager).toString() - @Suppress("DEPRECATION") fun Context.getAppName(packageName: String): CharSequence? { return try { - packageManager.getApplicationInfo(packageName, 0) + packageManager.getApplicationInfoCompat(packageName, 0) } catch (e: Exception) { null }?.let { @@ -300,10 +301,9 @@ object ContextExtensions { return "UID $uid" } - @Suppress("DEPRECATION") fun Context.getUidFromPackage(packageName: String): Int { return try { - packageManager.getApplicationInfo(packageName, 0).uid + packageManager.getApplicationInfoCompat(packageName, 0).uid } catch (e: PackageManager.NameNotFoundException) { Timber.e("Cannot get UID. Package not found: $packageName") -1 diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/MiscUtils.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/MiscUtils.kt new file mode 100644 index 000000000..c584c44d1 --- /dev/null +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/MiscUtils.kt @@ -0,0 +1,58 @@ +package me.timschneeberger.rootlessjamesdsp.utils.extensions + +import android.os.Build +import android.text.Html +import android.text.Spanned +import com.google.android.material.color.DynamicColors +import java.math.BigDecimal +import java.math.RoundingMode +import java.security.MessageDigest +import kotlin.math.* + +fun String.asHtml(): Spanned = Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY) + +fun Double.prettyNumberFormat(): String { + if( this == 0.0 ) return "0" + + val prefix = if( this < 0 ) "-" else "" + val num = abs(this) + + // figure out what group of suffixes we are in and scale the number + val pow = floor(log10(num) /3).roundToInt() + val base = num / 10.0.pow(pow * 3) + + // Using consistent rounding behavior, always rounding down since you want + // 999999999 to show as 999.99M and not 1B + val roundedDown = floor(base*100) /100.0 + + // Convert the number to a string with up to 1 decimal place + var baseStr = BigDecimal(roundedDown) + .setScale(1, RoundingMode.HALF_EVEN) + .toString() + + // Drop trailing zeros, then drop any trailing '.' if present + baseStr = baseStr.dropLastWhile { it == '0' }.dropLastWhile { it == '.' } + + val suffixes = listOf("","k","M","B","T") + + return when { + pow < suffixes.size -> "$prefix$baseStr${suffixes[pow]}" + else -> "${prefix}∞" + } +} + +fun Boolean.toShort() = (if (this) 1 else 0).toShort() + +val String.md5: ByteArray + get() { + return MessageDigest.getInstance("MD5").digest(this.toByteArray()) + } + +private val isSamsung by lazy { + Build.MANUFACTURER.equals("samsung", ignoreCase = true) +} + +val isDynamicColorAvailable by lazy { + DynamicColors.isDynamicColorAvailable() || + (isSamsung && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) +} \ No newline at end of file diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/PermissionExtensions.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/PermissionExtensions.kt similarity index 83% rename from app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/PermissionExtensions.kt rename to app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/PermissionExtensions.kt index da3d5c9e9..b0fe51223 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/PermissionExtensions.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/utils/extensions/PermissionExtensions.kt @@ -1,10 +1,13 @@ -package me.timschneeberger.rootlessjamesdsp.utils +package me.timschneeberger.rootlessjamesdsp.utils.extensions import android.Manifest import android.app.AppOpsManager import android.content.Context import android.content.pm.PackageManager import android.os.Build +import me.timschneeberger.rootlessjamesdsp.utils.SystemServices +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getApplicationInfoCompat +import me.timschneeberger.rootlessjamesdsp.utils.sdkAbove import timber.log.Timber object PermissionExtensions { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/Card.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/Card.kt index e636a46f4..5797e83db 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/Card.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/Card.kt @@ -14,8 +14,8 @@ import androidx.core.view.isVisible import androidx.core.view.setMargins import me.timschneeberger.rootlessjamesdsp.R import me.timschneeberger.rootlessjamesdsp.databinding.ViewCardBinding -import me.timschneeberger.rootlessjamesdsp.utils.ContextExtensions.dpToPx -import me.timschneeberger.rootlessjamesdsp.utils.loadHtml +import me.timschneeberger.rootlessjamesdsp.utils.extensions.asHtml +import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.dpToPx class Card @JvmOverloads constructor( @@ -52,13 +52,13 @@ class Card @JvmOverloads constructor( field = value binding.title.isVisible = value != null if(value != null) { - binding.title.text = loadHtml(value) + binding.title.text = value.asHtml() } } var bodyText: String? = null set(value) { field = value - binding.text.text = loadHtml(value ?: "") + binding.text.text = value?.asHtml() ?: "" } @DrawableRes var iconSrc: Int = 0 set(value) { diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/EqualizerSurface.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/EqualizerSurface.kt index 423b8f628..306c31304 100755 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/EqualizerSurface.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/EqualizerSurface.kt @@ -14,8 +14,8 @@ import android.view.View import androidx.core.content.withStyledAttributes import androidx.core.os.bundleOf import me.timschneeberger.rootlessjamesdsp.interop.JdspImpResToolbox -import me.timschneeberger.rootlessjamesdsp.utils.getParcelableAs -import me.timschneeberger.rootlessjamesdsp.utils.prettyNumberFormat +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getParcelableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.prettyNumberFormat import java.util.Locale import kotlin.math.abs import kotlin.math.exp @@ -150,7 +150,7 @@ class EqualizerSurface(context: Context?, attrs: AttributeSet?) : View(context, { canvas.drawCircle(x, y, 16f, mControlBarKnob) } - canvas.drawText(prettyNumberFormat(FreqScale[i]), x, mHeight - 16, mControlBarText) + canvas.drawText(FreqScale[i].prettyNumberFormat(), x, mHeight - 16, mControlBarText) val gainText = String.format(Locale.ROOT, "%.1f", mLevels[i]) canvas.drawText(gainText, x, mControlBarText.textSize + 8, mControlBarText) } diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/GraphicEqualizerSurface.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/GraphicEqualizerSurface.kt index d521f985d..c2d814c2a 100755 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/GraphicEqualizerSurface.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/view/GraphicEqualizerSurface.kt @@ -10,8 +10,8 @@ import android.view.View import androidx.core.content.withStyledAttributes import androidx.core.os.bundleOf import me.timschneeberger.rootlessjamesdsp.model.GraphicEqNodeList -import me.timschneeberger.rootlessjamesdsp.utils.getParcelableAs -import me.timschneeberger.rootlessjamesdsp.utils.prettyNumberFormat +import me.timschneeberger.rootlessjamesdsp.utils.extensions.CompatExtensions.getParcelableAs +import me.timschneeberger.rootlessjamesdsp.utils.extensions.prettyNumberFormat import java.util.* import kotlin.math.* @@ -150,7 +150,7 @@ class GraphicEqualizerSurface(context: Context?, attrs: AttributeSet?) : View(co x > lastFreqTextBounds.right + lastFreqTextBounds.width() /* check for freq text overlap */ && x > lastGainTextBounds.right + lastGainTextBounds.width() /* check for gain text overlap */) { - val freqText = prettyNumberFormat(mFreqs[i]) + val freqText = mFreqs[i].prettyNumberFormat() val freqWidth = mControlBarText.measureText(freqText) val gainText = String.format(Locale.ROOT, "%.1f", mGains[i]) val gainWidth = mControlBarText.measureText(gainText) @@ -170,7 +170,7 @@ class GraphicEqualizerSurface(context: Context?, attrs: AttributeSet?) : View(co x = projectX(scale) * mWidth // UNUSED: y = projectY(gain.toFloat()) * mHeight - val freqText = prettyNumberFormat(scale) + val freqText = scale.prettyNumberFormat() val gainText = String.format(Locale.ROOT, "%.1f", gain) canvas.drawText(freqText, x, mHeight - 16, mControlBarText)