Merge branch 'audiorecorder-3.2.63'

This commit is contained in:
Alexey Kuznetsov 2019-05-22 17:44:20 +03:00
commit 50e6ffda9b
19 changed files with 75 additions and 77 deletions

View file

@ -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' }
}

View file

@ -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">
<service android:name=".services.RecordingService" />
<service
android:name=".services.TileService"
android:label="@string/tile_start_recording"
android:icon="@drawable/ic_mic_24dp"
android:label="@string/tile_start_recording"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />

View file

@ -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();

View file

@ -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());
}

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 395 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 427 B

After

Width:  |  Height:  |  Size: 427 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 511 B

After

Width:  |  Height:  |  Size: 511 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 551 B

After

Width:  |  Height:  |  Size: 551 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 788 B

After

Width:  |  Height:  |  Size: 788 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 823 B

After

Width:  |  Height:  |  Size: 823 B

Before After
Before After

View file

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<group
android:pivotX="12"
android:pivotY="12"
android:scaleX="0.6"
android:scaleY="0.6">
<path
android:fillColor="#000"
android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zm5.3,-3c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11H5c0,3.41 2.72,6.23 6,6.72V21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
</group>
</vector>

View file

@ -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" />
<ImageView
@ -126,8 +127,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:contentDescription=""
android:padding="10dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_fiber_manual_record_black_24dp"
android:tint="#ff0000"

View file

@ -7,7 +7,7 @@
android:icon="@drawable/ic_search_white_24dp"
android:title="@string/menu_search"
app:actionViewClass="com.github.axet.androidlibrary.widgets.SearchView"
app:showAsAction="collapseActionView|ifRoom" />
app:showAsAction="collapseActionView|always" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_circle_white_24dp" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View file

@ -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'
}
}