From 966e90339f2bb62c81baf2cda58877ee2183d9c5 Mon Sep 17 00:00:00 2001 From: Alexey Kuznetsov Date: Thu, 10 Dec 2020 23:11:10 +0300 Subject: [PATCH] lockscreen control only during lock screen --- app/src/main/AndroidManifest.xml | 1 + .../activities/MainActivity.java | 2 + .../activities/RecordingActivity.java | 3 + .../activities/SettingsActivity.java | 8 +- .../audiorecorder/app/AudioApplication.java | 2 + .../services/ControlsService.java | 236 ++++++++++++++++++ .../services/OnBootReceiver.java | 1 + .../services/OnExternalReceiver.java | 1 + .../services/OnUpgradeReceiver.java | 1 + .../services/RecordingService.java | 77 ++---- 10 files changed, 279 insertions(+), 53 deletions(-) create mode 100644 app/src/main/java/com/github/axet/audiorecorder/services/ControlsService.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c078dde..bd59451 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ android:theme="@style/RecThemeLight"> + = 16 && icon.notification.bigContentView != null) { + a = new RemoteViews(getPackageName(), icon.notification.bigContentView.getLayoutId()); a.setTextViewText(R.id.title, title); - RemoteViewsCompat.mergeRemoteViews(icon.notification.contentView, a); - if (Build.VERSION.SDK_INT >= 16 && icon.notification.bigContentView != null) { - a = new RemoteViews(getPackageName(), icon.notification.bigContentView.getLayoutId()); - a.setTextViewText(R.id.title, title); - RemoteViewsCompat.mergeRemoteViews(icon.notification.bigContentView, a); - } - return icon.notification; - } catch (RuntimeException e) { - Log.d(TAG, "merge failed", e); + RemoteViewsCompat.mergeRemoteViews(icon.notification.bigContentView, a); } + return icon.notification; + } catch (RuntimeException e) { + Log.d(TAG, "merge failed", e); } } - text = ".../" + targetFile; - builder = new RemoteNotificationCompat.Builder(context, R.layout.notifictaion); - builder.setViewVisibility(R.id.notification_record, View.GONE); - builder.setViewVisibility(R.id.notification_pause, View.VISIBLE); - main = PendingIntent.getService(context, 0, new Intent(context, RecordingService.class) - .setAction(SHOW_ACTIVITY) - .putExtra("targetFile", targetFile) - .putExtra("recording", recording), PendingIntent.FLAG_UPDATE_CURRENT); } + text = ".../" + targetFile; + builder = new RemoteNotificationCompat.Builder(context, R.layout.notifictaion); + builder.setViewVisibility(R.id.notification_record, View.GONE); + builder.setViewVisibility(R.id.notification_pause, View.VISIBLE); + main = PendingIntent.getService(context, 0, new Intent(context, RecordingService.class) + .setAction(SHOW_ACTIVITY) + .putExtra("targetFile", targetFile) + .putExtra("recording", recording), PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pe = PendingIntent.getService(context, 0, new Intent(context, RecordingService.class).setAction(PAUSE_BUTTON),