Merge branch 'audiorecorder-3.3.5'

This commit is contained in:
Alexey Kuznetsov 2019-07-18 10:59:12 +03:00
commit 46d8711d76
5 changed files with 131 additions and 128 deletions

15
CONTRIBUTORS.md Normal file
View file

@ -0,0 +1,15 @@
# Translations
* japanese translation thanks to @naofumi
* german translation thanks to @s72785
* brazilian translation thanks to @vrozsas
* itallian tralslation thanks to @Agno94
* slovak translation thanks to @pvagner
* french thanks to @Nonot
* turkish thanks to @tneonflo
* spanish thanks to @sguinetti
* greek tanks to @cryoranger
* Indonesian thanks to @ditokp
* polish thanks to @krkk
* Chinese thanks to @itoy
* Chinese (Taiwan) translation thanks to @cges30901

View file

@ -17,19 +17,3 @@ If you want to translate 'Audio Recorder' to your language please read this:
# Screenshots
![shot](/docs/shot.png)
# Contributors
* japanese translation thanks to @naofumi
* german translation thanks to @vv01f
* brazilian translation thanks to @vrozsas
* itallian tralslation thanks to @Agno94
* slovak translation thanks to @pvagner
* french thanks to @Nonot
* turkish thanks to @tneonflo
* spanish thanks to @sguinetti
* greek tanks to @sjjj15
* Indonesian thanks to @ditokp
* polish thanks to @krkk
* Chinese thanks to @itoy
* Chinese (Taiwan) translation thanks to @cges30901

View file

@ -9,8 +9,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 9
targetSdkVersion 26
versionCode 329
versionName "3.3.4"
versionCode 330
versionName "3.3.5"
}
signingConfigs {
release {
@ -53,6 +53,6 @@ android {
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.github.axet:android-audio-library:1.0.166' // implementation project(':android-audio-library')
implementation 'com.github.axet:android-audio-library:1.0.168' // implementation project(':android-audio-library')
assets('com.google.android.exoplayer:exoplayer:2.7.3') { exclude group: 'com.android.support' }
}

View file

@ -3,6 +3,7 @@ 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;
@ -17,9 +18,9 @@ import android.view.View;
import android.widget.RemoteViews;
import com.github.axet.androidlibrary.app.AlarmManager;
import com.github.axet.androidlibrary.app.ProximityShader;
import com.github.axet.androidlibrary.services.PersistentService;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.androidlibrary.app.ProximityShader;
import com.github.axet.androidlibrary.widgets.RemoteNotificationCompat;
import com.github.axet.androidlibrary.widgets.RemoteViewsCompat;
import com.github.axet.audiolibrary.app.Storage;
@ -46,12 +47,7 @@ public class RecordingService extends PersistentService {
OptimizationPreferenceCompat.REFRESH = AlarmManager.MIN1;
}
{
id = NOTIFICATION_RECORDING_ICON;
}
Storage storage; // for storage path
Intent notificationIntent;
public static void startIfEnabled(Context context) {
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
@ -119,21 +115,128 @@ public class RecordingService extends PersistentService {
@Override
public void onCreateOptimization() {
optimization = new PersistentService.ServiceReceiver(null, AudioApplication.PREFERENCE_NEXT) {
storage = new Storage(this);
optimization = new OptimizationPreferenceCompat.ServiceReceiver(this, NOTIFICATION_RECORDING_ICON, null, AudioApplication.PREFERENCE_NEXT) {
Intent notificationIntent;
@Override
public void onCreateIcon(Service service, int id) {
icon = new OptimizationPreferenceCompat.OptimizationIcon(service, id, key) {
@Override
public void updateIcon() {
icon.updateIcon(new Intent());
}
@Override
public void updateIcon(Intent intent) {
super.updateIcon(intent);
notificationIntent = intent;
}
@SuppressLint("RestrictedApi")
public Notification build(Intent intent) {
String targetFile = intent.getStringExtra("targetFile");
boolean recording = intent.getBooleanExtra("recording", false);
boolean encoding = intent.getBooleanExtra("encoding", false);
String duration = intent.getStringExtra("duration");
PendingIntent main;
RemoteNotificationCompat.Builder builder;
String title;
String text;
if (targetFile == null) {
title = getString(R.string.app_name);
Uri f = storage.getStoragePath();
long free = Storage.getFree(context, f);
long sec = Storage.average(context, free);
text = AudioApplication.formatFree(context, free, sec);
builder = new RemoteNotificationCompat.Low(context, R.layout.notifictaion);
builder.setViewVisibility(R.id.notification_record, View.VISIBLE);
builder.setViewVisibility(R.id.notification_pause, View.GONE);
main = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
} else {
if (recording)
title = getString(R.string.recording_title);
else
title = getString(R.string.pause_title);
if (duration != null) {
title += " (" + duration + ")";
if (recording && notificationIntent != null && notificationIntent.hasExtra("duration") && notificationIntent.getBooleanExtra("recording", false)) { // speed up
try {
RemoteViews a = new RemoteViews(getPackageName(), icon.notification.contentView.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);
}
}
}
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),
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent re = PendingIntent.getService(context, 0,
new Intent(context, RecordingService.class).setAction(RECORD_BUTTON),
PendingIntent.FLAG_UPDATE_CURRENT);
if (encoding) {
builder.setViewVisibility(R.id.notification_pause, View.GONE);
title = getString(R.string.encoding_title);
}
builder.setOnClickPendingIntent(R.id.notification_pause, pe);
builder.setOnClickPendingIntent(R.id.notification_record, re);
builder.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.ic_play_arrow_black_24dp : R.drawable.ic_pause_black_24dp);
builder.setContentDescription(R.id.notification_pause, getString(!recording ? R.string.record_button : R.string.pause_button));
builder.setTheme(AudioApplication.getTheme(context, R.style.RecThemeLight, R.style.RecThemeDark))
.setChannel(AudioApplication.from(context).channelStatus)
.setImageViewTint(R.id.icon_circle, builder.getThemeColor(R.attr.colorButtonNormal))
.setTitle(title)
.setText(text)
.setWhen(icon.notification)
.setMainIntent(main)
.setAdaptiveIcon(R.drawable.ic_launcher_foreground)
.setSmallIcon(R.drawable.ic_launcher_notification)
.setOngoing(true);
return builder.build();
}
};
icon.create();
}
@Override
public boolean isOptimization() {
return true; // we not using optimization preference
}
};
optimization.create();
storage = new Storage(this);
}
@Override
public void onStartCommand(Intent intent) {
String a = intent.getAction();
if (a == null) {
updateIcon(intent);
optimization.icon.updateIcon(intent);
} else if (a.equals(PAUSE_BUTTON)) {
Intent i = new Intent(RecordingActivity.PAUSE_BUTTON);
sendBroadcast(i);
@ -158,103 +261,4 @@ public class RecordingService extends PersistentService {
public void onDestroy() {
super.onDestroy();
}
@SuppressLint("RestrictedApi")
public Notification build(Intent intent) {
String targetFile = intent.getStringExtra("targetFile");
boolean recording = intent.getBooleanExtra("recording", false);
boolean encoding = intent.getBooleanExtra("encoding", false);
String duration = intent.getStringExtra("duration");
PendingIntent main;
RemoteNotificationCompat.Builder builder;
String title;
String text;
if (targetFile == null) {
title = getString(R.string.app_name);
Uri f = storage.getStoragePath();
long free = Storage.getFree(this, f);
long sec = Storage.average(this, free);
text = AudioApplication.formatFree(this, free, sec);
builder = new RemoteNotificationCompat.Low(this, R.layout.notifictaion);
builder.setViewVisibility(R.id.notification_record, View.VISIBLE);
builder.setViewVisibility(R.id.notification_pause, View.GONE);
main = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
} else {
if (recording)
title = getString(R.string.recording_title);
else
title = getString(R.string.pause_title);
if (duration != null) {
title += " (" + duration + ")";
if (recording && notificationIntent != null && notificationIntent.hasExtra("duration") && notificationIntent.getBooleanExtra("recording", false)) { // speed up
try {
RemoteViews a = new RemoteViews(getPackageName(), notification.contentView.getLayoutId());
a.setTextViewText(R.id.title, title);
RemoteViewsCompat.mergeRemoteViews(notification.contentView, a);
if (Build.VERSION.SDK_INT >= 16 && notification.bigContentView != null) {
a = new RemoteViews(getPackageName(), notification.bigContentView.getLayoutId());
a.setTextViewText(R.id.title, title);
RemoteViewsCompat.mergeRemoteViews(notification.bigContentView, a);
}
return notification;
} catch (RuntimeException e) {
Log.d(TAG, "merge failed", e);
}
}
}
text = ".../" + targetFile;
builder = new RemoteNotificationCompat.Builder(this, R.layout.notifictaion);
builder.setViewVisibility(R.id.notification_record, View.GONE);
builder.setViewVisibility(R.id.notification_pause, View.VISIBLE);
main = PendingIntent.getService(this, 0, new Intent(this, RecordingService.class)
.setAction(SHOW_ACTIVITY)
.putExtra("targetFile", targetFile)
.putExtra("recording", recording), PendingIntent.FLAG_UPDATE_CURRENT);
}
PendingIntent pe = PendingIntent.getService(this, 0,
new Intent(this, RecordingService.class).setAction(PAUSE_BUTTON),
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent re = PendingIntent.getService(this, 0,
new Intent(this, RecordingService.class).setAction(RECORD_BUTTON),
PendingIntent.FLAG_UPDATE_CURRENT);
if (encoding) {
builder.setViewVisibility(R.id.notification_pause, View.GONE);
title = getString(R.string.encoding_title);
}
builder.setOnClickPendingIntent(R.id.notification_pause, pe);
builder.setOnClickPendingIntent(R.id.notification_record, re);
builder.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.ic_play_arrow_black_24dp : R.drawable.ic_pause_black_24dp);
builder.setContentDescription(R.id.notification_pause, getString(!recording ? R.string.record_button : R.string.pause_button));
builder.setTheme(AudioApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark))
.setChannel(AudioApplication.from(this).channelStatus)
.setImageViewTint(R.id.icon_circle, builder.getThemeColor(R.attr.colorButtonNormal))
.setTitle(title)
.setText(text)
.setWhen(notification)
.setMainIntent(main)
.setAdaptiveIcon(R.drawable.ic_launcher_foreground)
.setSmallIcon(R.drawable.ic_launcher_notification)
.setOngoing(true);
return builder.build();
}
@Override
public void updateIcon() {
updateIcon(new Intent());
}
@Override
public void updateIcon(Intent intent) {
super.updateIcon(intent);
notificationIntent = intent;
}
}

View file

@ -5,7 +5,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.github.axet:gradle-android-dx:0.0.4'
}
}