Skip to content

Commit

Permalink
deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldrudell committed Jul 16, 2023
1 parent dd0011e commit c01f13e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
13 changes: 6 additions & 7 deletions app/src/main/java/com/dimowner/audiorecorder/ARApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class ARApplication : Application() {
applicationContext
)
)
injector = Injector()
val prefs = injector!!.providePrefs(applicationContext)
val prefs = injector.providePrefs(applicationContext)
if (!prefs.isMigratedSettings) {
prefs.migrateSettings()
}
Expand All @@ -79,14 +78,14 @@ class ARApplication : Application() {
override fun onTerminate() {
super.onTerminate()
//This method is never called on real Android devices
injector!!.releaseMainPresenter()
injector!!.closeTasks()
injector.releaseMainPresenter()
injector.closeTasks()
unregisterReceiver(audioOutputChangeReceiver)
}

fun pausePlayback() {
//Pause playback when incoming call or on hold
val player = injector!!.provideAudioPlayer()
val player = injector.provideAudioPlayer()
player.pause()
}

Expand Down Expand Up @@ -118,7 +117,7 @@ class ARApplication : Application() {
override fun onReceive(context: Context, intent: Intent) {
val actionOfIntent = intent.action
if (actionOfIntent != null && actionOfIntent == AUDIO_BECOMING_NOISY) {
val player = injector!!.provideAudioPlayer()
val player = injector.provideAudioPlayer()
player.pause()
}
}
Expand Down Expand Up @@ -150,7 +149,7 @@ class ARApplication : Application() {
/** Screen width in dp */
private var screenWidthDp = 0f
@JvmStatic
var injector: Injector? = null
var injector = Injector()
@JvmStatic
fun appPackage(): String? {
return PACKAGE_NAME
Expand Down
17 changes: 11 additions & 6 deletions app/src/main/java/com/dimowner/audiorecorder/app/DecodeService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class DecodeService : Service() {

override fun onCreate() {
super.onCreate()
colorMap = ARApplication.injector!!.provideColorMap(applicationContext)
processingTasks = ARApplication.injector!!.provideProcessingTasksQueue()
recordingsTasks = ARApplication.injector!!.provideRecordingTasksQueue()
localRepository = ARApplication.injector!!.provideLocalRepository(applicationContext)
waveformVisualization = ARApplication.injector!!.provideAudioWaveformVisualization()
colorMap = ARApplication.injector.provideColorMap(applicationContext)
processingTasks = ARApplication.injector.provideProcessingTasksQueue()
recordingsTasks = ARApplication.injector.provideRecordingTasksQueue()
localRepository = ARApplication.injector.provideLocalRepository(applicationContext)
waveformVisualization = ARApplication.injector.provideAudioWaveformVisualization()
}

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Expand Down Expand Up @@ -230,7 +230,12 @@ class DecodeService : Service() {
}

fun stopService() {
stopForeground(true)
if (Build.VERSION.SDK_INT>Build.VERSION_CODES.S_V2) {
stopForeground(STOP_FOREGROUND_REMOVE)
}else {
@Suppress("DEPRECATION")
stopForeground(true)
}
stopSelf()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.dimowner.audiorecorder.app.settings;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
Expand Down Expand Up @@ -281,8 +282,8 @@ private void initNameFormatSelector() {
values[2] = getResources().getString(R.string.naming) + " " + FileUtil.generateRecordNameDateUS() + ".m4a";
values[3] = getResources().getString(R.string.naming) + " " + FileUtil.generateRecordNameDateISO8601() + ".m4a";
values[4] = getResources().getString(R.string.naming) + " " + FileUtil.generateRecordNameMills() + ".m4a";
for (int i = 0; i < values.length; i++) {
items.add(new AppSpinnerAdapter.ThemeItem(values[i],
for (String value : values) {
items.add(new AppSpinnerAdapter.ThemeItem(value,
getApplicationContext().getResources().getColor(colorMap.getPrimaryColorRes())));
}
AppSpinnerAdapter adapter = new AppSpinnerAdapter(SettingsActivity.this,
Expand Down Expand Up @@ -323,6 +324,7 @@ protected void onDestroy() {
colorMap.removeOnThemeColorChangeListener(onThemeColorChangeListener);
}

@SuppressLint("UnsafeOptInUsageWarning")
@Override
public void onClick(View v) {
int id = v.getId();
Expand Down Expand Up @@ -384,11 +386,7 @@ private void requestFeature() {
private Intent rateIntentForUrl(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("%s?id=%s", url, getApplicationContext().getPackageName())));
int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
if (Build.VERSION.SDK_INT >= 21) {
flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
} else {
flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
}
intent.addFlags(flags);
return intent;
}
Expand Down

0 comments on commit c01f13e

Please sign in to comment.