diff --git a/app/build.gradle b/app/build.gradle index 99df9c5..7f5f1a1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.github.axet.audiorecorder" minSdkVersion 9 targetSdkVersion 26 - versionCode 320 - versionName "3.2.62" + versionCode 321 + versionName "3.2.63" } signingConfigs { release { @@ -53,6 +53,6 @@ android { dependencies { testImplementation 'junit:junit:4.12' - implementation 'com.github.axet:android-audio-library:1.0.152' // implementation project(':android-audio-library') - assets('com.google.android.exoplayer:exoplayer:2.7.3') { exclude group: 'com.android.support' } + implementation 'com.github.axet:android-audio-library:1.0.153' // implementation project(':android-audio-library') + assets('com.google.android.exoplayer:exoplayer:2.8.4') { exclude group: 'com.android.support' } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8b35467..f96d923 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,13 +19,14 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/RecThemeLight"> diff --git a/app/src/main/java/com/github/axet/audiorecorder/activities/MainActivity.java b/app/src/main/java/com/github/axet/audiorecorder/activities/MainActivity.java index 96798b6..3f56fe9 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/activities/MainActivity.java +++ b/app/src/main/java/com/github/axet/audiorecorder/activities/MainActivity.java @@ -152,7 +152,7 @@ public class MainActivity extends AppCompatThemeActivity { MenuItem search = menu.findItem(R.id.action_search); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(search); - searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() { + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchView.clearFocus(); diff --git a/app/src/main/java/com/github/axet/audiorecorder/app/AudioApplication.java b/app/src/main/java/com/github/axet/audiorecorder/app/AudioApplication.java index e0b9d5d..5d521a3 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/app/AudioApplication.java +++ b/app/src/main/java/com/github/axet/audiorecorder/app/AudioApplication.java @@ -437,7 +437,7 @@ public class AudioApplication extends com.github.axet.audiolibrary.app.MainAppli .setText(text) .setMainIntent(main) .setChannel(channelStatus) - .setSmallIcon(R.drawable.ic_mic); + .setSmallIcon(R.drawable.ic_launcher_notification); NotificationManagerCompat nm = NotificationManagerCompat.from(this); nm.notify((int) System.currentTimeMillis(), builder.build()); } diff --git a/app/src/main/java/com/github/axet/audiorecorder/services/RecordingService.java b/app/src/main/java/com/github/axet/audiorecorder/services/RecordingService.java index b0df5d0..ee84eda 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/services/RecordingService.java +++ b/app/src/main/java/com/github/axet/audiorecorder/services/RecordingService.java @@ -3,7 +3,6 @@ package com.github.axet.audiorecorder.services; import android.annotation.SuppressLint; import android.app.Notification; import android.app.PendingIntent; -import android.app.Service; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; @@ -18,7 +17,7 @@ import android.view.View; import android.widget.RemoteViews; import com.github.axet.androidlibrary.app.AlarmManager; -import com.github.axet.androidlibrary.app.NotificationManagerCompat; +import com.github.axet.androidlibrary.services.PersistentService; import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat; import com.github.axet.androidlibrary.widgets.ProximityShader; import com.github.axet.androidlibrary.widgets.RemoteNotificationCompat; @@ -34,7 +33,7 @@ import java.io.File; /** * Sometimes RecordingActivity started twice when launched from lockscreen. We need service and move recording into Application object. */ -public class RecordingService extends Service { +public class RecordingService extends PersistentService { public static final String TAG = RecordingService.class.getSimpleName(); public static final int NOTIFICATION_RECORDING_ICON = 1; @@ -43,10 +42,15 @@ public class RecordingService extends Service { public static String PAUSE_BUTTON = RecordingService.class.getCanonicalName() + ".PAUSE_BUTTON"; public static String RECORD_BUTTON = RecordingService.class.getCanonicalName() + ".RECORD_BUTTON"; + static { + OptimizationPreferenceCompat.REFRESH = AlarmManager.MIN1; + NOTIFICATION_PERSISTENT_ICON = NOTIFICATION_RECORDING_ICON; + PREFERENCE_OPTIMIZATION = AudioApplication.PREFERENCE_OPTIMIZATION; + PREFERENCE_NEXT = AudioApplication.PREFERENCE_NEXT; + } + Storage storage; // for storage path - Notification notification; Intent notificationIntent; - OptimizationPreferenceCompat.ServiceReceiver optimization; public static void startIfEnabled(Context context) { SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context); @@ -79,11 +83,11 @@ public class RecordingService extends Service { } public static void start(Context context) { - OptimizationPreferenceCompat.startService(context, new Intent(context, RecordingService.class)); + start(context, new Intent(context, RecordingService.class)); } public static void startService(Context context, String targetFile, boolean recording, boolean encoding, String duration) { - OptimizationPreferenceCompat.startService(context, new Intent(context, RecordingService.class) + start(context, new Intent(context, RecordingService.class) .putExtra("targetFile", targetFile) .putExtra("recording", recording) .putExtra("encoding", encoding) @@ -101,7 +105,7 @@ public class RecordingService extends Service { } public static void stopService(Context context) { - context.stopService(new Intent(context, RecordingService.class)); + stop(context, new Intent(context, RecordingService.class)); } public RecordingService() { @@ -111,10 +115,11 @@ public class RecordingService extends Service { public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate"); - storage = new Storage(this); - showNotification(new Intent()); - OptimizationPreferenceCompat.REFRESH = AlarmManager.MIN1; - optimization = new OptimizationPreferenceCompat.ServiceReceiver(this, getClass(), AudioApplication.PREFERENCE_OPTIMIZATION) { + } + + @Override + public void onCreateOptimization() { + optimization = new PersistentService.ServiceReceiver(this, getClass(), AudioApplication.PREFERENCE_OPTIMIZATION) { @Override public void register() { // do not call super next(); @@ -129,35 +134,27 @@ public class RecordingService extends Service { } }; optimization.create(); + + storage = new Storage(this); } @Override - public int onStartCommand(Intent intent, int flags, int startId) { - Log.d(TAG, "onStartCommand"); - - if (optimization.onStartCommand(intent, flags, startId)) { - Log.d(TAG, "onStartCommand restart"); + public void onStartCommand(Intent intent) { + String a = intent.getAction(); + if (a == null) { + updateIcon(intent); + } else if (a.equals(PAUSE_BUTTON)) { + Intent i = new Intent(RecordingActivity.PAUSE_BUTTON); + sendBroadcast(i); + } else if (a.equals(RECORD_BUTTON)) { + RecordingActivity.startActivity(this, false); + } else if (a.equals(SHOW_ACTIVITY)) { + ProximityShader.closeSystemDialogs(this); + if (intent.getStringExtra("targetFile") == null) + MainActivity.startActivity(this); + else + RecordingActivity.startActivity(this, !intent.getBooleanExtra("recording", false)); } - - if (intent != null) { - String a = intent.getAction(); - if (a == null) { - showNotification(intent); - } else if (a.equals(PAUSE_BUTTON)) { - Intent i = new Intent(RecordingActivity.PAUSE_BUTTON); - sendBroadcast(i); - } else if (a.equals(RECORD_BUTTON)) { - RecordingActivity.startActivity(this, false); - } else if (a.equals(SHOW_ACTIVITY)) { - ProximityShader.closeSystemDialogs(this); - if (intent.getStringExtra("targetFile") == null) - MainActivity.startActivity(this); - else - RecordingActivity.startActivity(this, !intent.getBooleanExtra("recording", false)); - } - } - - return super.onStartCommand(intent, flags, startId); } @Nullable @@ -169,13 +166,6 @@ public class RecordingService extends Service { @Override public void onDestroy() { super.onDestroy(); - Log.d(TAG, "onDestroy"); - showNotification(null); - - if (optimization != null) { - optimization.close(); - optimization = null; - } } @SuppressLint("RestrictedApi") @@ -259,35 +249,21 @@ public class RecordingService extends Service { .setText(text) .setWhen(notification) .setMainIntent(main) - .setOngoing(true) - .setSmallIcon(R.drawable.ic_mic); + .setAdaptiveIcon(R.drawable.ic_launcher_foreground) + .setSmallIcon(R.drawable.ic_launcher_notification) + .setOngoing(true); return builder.build(); } - public void showNotification(Intent intent) { - NotificationManagerCompat nm = NotificationManagerCompat.from(this); - if (intent == null) { - stopForeground(false); - nm.cancel(NOTIFICATION_RECORDING_ICON); - notification = null; - notificationIntent = null; - } else { - Notification n = build(intent); - if (notification == null) { - startForeground(NOTIFICATION_RECORDING_ICON, n); - } else { - nm.notify(NOTIFICATION_RECORDING_ICON, n); - } - notification = n; - notificationIntent = intent; - } + @Override + public void updateIcon() { + updateIcon(new Intent()); } @Override - public void onTaskRemoved(Intent rootIntent) { - super.onTaskRemoved(rootIntent); - Log.d(TAG, "onTaskRemoved"); - optimization.onTaskRemoved(rootIntent); + public void updateIcon(Intent intent) { + super.updateIcon(intent); + notificationIntent = intent; } } diff --git a/app/src/main/res/drawable-hdpi-v11/ic_mic.png b/app/src/main/res/drawable-hdpi-v11/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-hdpi-v11/ic_mic.png rename to app/src/main/res/drawable-hdpi-v11/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-hdpi/ic_mic.png b/app/src/main/res/drawable-hdpi/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-hdpi/ic_mic.png rename to app/src/main/res/drawable-hdpi/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-mdpi-v11/ic_mic.png b/app/src/main/res/drawable-mdpi-v11/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-mdpi-v11/ic_mic.png rename to app/src/main/res/drawable-mdpi-v11/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-mdpi/ic_mic.png b/app/src/main/res/drawable-mdpi/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-mdpi/ic_mic.png rename to app/src/main/res/drawable-mdpi/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-xhdpi-v11/ic_mic.png b/app/src/main/res/drawable-xhdpi-v11/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-xhdpi-v11/ic_mic.png rename to app/src/main/res/drawable-xhdpi-v11/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-xhdpi/ic_mic.png b/app/src/main/res/drawable-xhdpi/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-xhdpi/ic_mic.png rename to app/src/main/res/drawable-xhdpi/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-xxhdpi-v11/ic_mic.png b/app/src/main/res/drawable-xxhdpi-v11/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-xxhdpi-v11/ic_mic.png rename to app/src/main/res/drawable-xxhdpi-v11/ic_launcher_notification.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_mic.png b/app/src/main/res/drawable-xxhdpi/ic_launcher_notification.png similarity index 100% rename from app/src/main/res/drawable-xxhdpi/ic_mic.png rename to app/src/main/res/drawable-xxhdpi/ic_launcher_notification.png diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..1cd0dd2 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/remoteview_header.xml b/app/src/main/res/layout/remoteview_header.xml index 9abe339..6e4ee3f 100644 --- a/app/src/main/res/layout/remoteview_header.xml +++ b/app/src/main/res/layout/remoteview_header.xml @@ -18,6 +18,7 @@ android:id="@+id/icon_circle" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_gravity="center" android:src="@drawable/ic_circle" /> + app:showAsAction="collapseActionView|always" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCH/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml similarity index 100% rename from app/src/main/res/values-zh-rCH/strings.xml rename to app/src/main/res/values-zh-rCN/strings.xml diff --git a/build.gradle b/build.gradle index 6345f44..c2fb838 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.android.tools.build:gradle:3.4.1' classpath 'com.github.axet:gradle-android-dx:0.0.4' } }