Merge branch 'audiorecorder-3.2.20'

This commit is contained in:
Alexey Kuznetsov 2018-09-23 23:38:38 +03:00
commit 69edfadcaa
10 changed files with 190 additions and 70 deletions

View file

@ -10,8 +10,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 9
targetSdkVersion 23 // 24+ file:// unable to open
versionCode 277
versionName "3.2.19"
versionCode 278
versionName "3.2.20"
}
signingConfigs {
release {
@ -57,5 +57,5 @@ android {
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.github.axet:android-audio-library:1.0.118' // implementation project(':android-audio-library')
implementation 'com.github.axet:android-audio-library:1.0.121' // implementation project(':android-audio-library')
}

View file

@ -104,12 +104,12 @@ public class MainActivity extends AppCompatThemeActivity {
receiver = new ScreenReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
public void onScreenOff() {
boolean p = storage.recordingPending();
boolean c = shared.getBoolean(MainApplication.PREFERENCE_CONTROLS, false);
if (!p && !c)
return;
super.onReceive(context, intent);
super.onScreenOff();
}
};
receiver.registerReceiver(this);

View file

@ -727,17 +727,19 @@ public class RecordingActivity extends AppCompatThemeActivity {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
TreeMap<String, Integer> map = new TreeMap<>();
map.put(getString(R.string.source_mic), MediaRecorder.AudioSource.MIC);
map.put(getString(R.string.source_default), MediaRecorder.AudioSource.DEFAULT);
if (Sound.isUnprocessedSupported(this))
map.put(getString(R.string.source_raw), MediaRecorder.AudioSource.UNPROCESSED);
else
map.put(getString(R.string.source_raw), MediaRecorder.AudioSource.VOICE_RECOGNITION);
map.put(getString(R.string.source_bluetooth), MediaRecorder.AudioSource.MIC);
int user;
if (shared.getString(MainApplication.PREFERENCE_SOURCE, getString(R.string.source_mic)).equals(getString(R.string.source_raw))) {
if (Sound.isUnprocessedSupported(this))
user = MediaRecorder.AudioSource.UNPROCESSED;
else
user = MediaRecorder.AudioSource.VOICE_RECOGNITION;
} else {
user = MediaRecorder.AudioSource.MIC;
}
int[] ss = new int[]{
map.get(shared.getString(MainApplication.PREFERENCE_SOURCE, getString(R.string.source_mic))),
user,
MediaRecorder.AudioSource.MIC,
MediaRecorder.AudioSource.DEFAULT
};

View file

@ -3,8 +3,10 @@ package com.github.axet.audiorecorder.app;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v7.preference.PreferenceManager;
import com.github.axet.androidlibrary.widgets.NotificationChannelCompat;
import com.github.axet.audiolibrary.encoders.FormatFLAC;
import com.github.axet.audiolibrary.encoders.FormatM4A;
import com.github.axet.audiolibrary.encoders.FormatOGG;
@ -19,10 +21,18 @@ public class MainApplication extends com.github.axet.audiolibrary.app.MainApplic
public static final String PREFERENCE_VERSION = "version";
public NotificationChannelCompat channelStatus;
public int getUserTheme() {
return getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
channelStatus = new NotificationChannelCompat(this, "status", "Status", NotificationManagerCompat.IMPORTANCE_LOW);
}
@Override
public void onCreate() {
super.onCreate();

View file

@ -1,14 +1,11 @@
package com.github.axet.audiorecorder.services;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
@ -16,12 +13,15 @@ import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RemoteViews;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.androidlibrary.widgets.ProximityShader;
import com.github.axet.androidlibrary.widgets.RemoteViewsCompat;
import com.github.axet.androidlibrary.widgets.ThemeUtils;
import com.github.axet.audiolibrary.app.Storage;
import com.github.axet.audiorecorder.R;
import com.github.axet.audiorecorder.activities.MainActivity;
@ -48,6 +48,7 @@ public class RecordingService extends Service {
public static String RECORD_BUTTON = RecordingService.class.getCanonicalName() + ".RECORD_BUTTON";
Storage storage; // for storage path
Notification notification;
public static void startIfEnabled(Context context) {
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
@ -107,14 +108,20 @@ public class RecordingService extends Service {
public RecordingService() {
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
}
@Override
public void onCreate() {
setTheme(MainApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark));
super.onCreate();
Log.d(TAG, "onCreate");
storage = new Storage(this);
startForeground(NOTIFICATION_RECORDING_ICON, build(new Intent()));
showNotificationAlarm(true, new Intent());
}
@Override
@ -158,9 +165,6 @@ public class RecordingService extends Service {
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestory");
stopForeground(false);
showNotificationAlarm(false, null);
}
@ -181,9 +185,10 @@ public class RecordingService extends Service {
new Intent(this, RecordingService.class).setAction(RECORD_BUTTON),
PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews view = new RemoteViews(getPackageName(), MainApplication.getTheme(getBaseContext(),
R.layout.notifictaion_recording_light,
R.layout.notifictaion_recording_dark));
RemoteViews view = new RemoteViews(getPackageName(), MainApplication.getTheme(this, R.layout.notifictaion_recording_light, R.layout.notifictaion_recording_dark));
RemoteViewsCompat.setImageViewTint(view, R.id.icon_circle, ThemeUtils.getThemeColor(this, R.attr.colorButtonNormal)); // android:tint="?attr/colorButtonNormal" not working API16
RemoteViewsCompat.applyTheme(this, view);
String title;
String text;
@ -216,14 +221,14 @@ public class RecordingService extends Service {
view.setTextViewText(R.id.notification_text, text);
view.setOnClickPendingIntent(R.id.notification_pause, pe);
view.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.ic_play_arrow_black_24dp : R.drawable.ic_pause_black_24dp);
if (Build.VERSION.SDK_INT >= 15)
view.setContentDescription(R.id.notification_pause, getString(!recording ? R.string.record_button : R.string.pause_button));
RemoteViewsCompat.setContentDescription(view, R.id.notification_pause, getString(!recording ? R.string.record_button : R.string.pause_button));
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setOngoing(true)
.setContentTitle(title)
.setContentText(text)
.setTicker(title)
.setWhen(notification == null ? System.currentTimeMillis() : notification.when)
.setSmallIcon(R.drawable.ic_mic)
.setContent(view);
@ -234,16 +239,24 @@ public class RecordingService extends Service {
if (Build.VERSION.SDK_INT >= 21)
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
return builder.build();
Notification n = builder.build();
((MainApplication) getApplication()).channelStatus.apply(n);
return n;
}
// alarm dismiss button
public void showNotificationAlarm(boolean show, Intent intent) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationManagerCompat nm = NotificationManagerCompat.from(this);
if (!show) {
notificationManager.cancel(NOTIFICATION_RECORDING_ICON);
stopForeground(false);
nm.cancel(NOTIFICATION_RECORDING_ICON);
notification = null;
} else {
notificationManager.notify(NOTIFICATION_RECORDING_ICON, build(intent));
Notification n = build(intent);
if (notification == null)
startForeground(NOTIFICATION_RECORDING_ICON, n);
else
nm.notify(NOTIFICATION_RECORDING_ICON, n);
notification = n;
}
}

View file

@ -0,0 +1,24 @@
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="source" href="https://en.wikipedia.org/wiki/Binaural_beats"/>
<style>
a { white-space: pre-wrap; word-wrap:break-word; }
</style>
</head>
<body>
<h3>Tentang</h3>
<p>
Android ramah!
</p>
<p>Perekam Audio dengan folder rekaman kustom, indikator volume rekaman yang bagus, notifikasi rekaman, merekam aktivitas layar kunci.</p>
<dl>
<dt><b>Lisensi:</b></dt>
<dd>GPLv3</dd>
<dt><b>Kode Sumber:</b></dt>
<dd><a href="https://gitlab.com/axet/android-audio-recorder">https://gitlab.com/axet/android-audio-recorder</a></dd>
</dl>
</body>
</html>

View file

@ -0,0 +1,70 @@
<resources>
<string name="app_name">Audio Recorder</string>
<string-array name="sample_rate_text">
<item>48 kHz</item>
<item>44.1 kHz (CD)</item>
<item>32 kHz</item>
<item>22 kHz</item>
<item>16 kHz (bawaan)</item>
<item>11 kHz</item>
<item>8 kHz (telepon)</item>
</string-array>
<string-array name="source_text">
<item>Mik</item>
<item>Belum diproses</item>
<item>Bluetooth</item>
</string-array>
<string-array name="themes_text">
<item>Tema Terang</item>
<item>Tema Gelap</item>
</string-array>
<string-array name="channels_text">
<item>Mono (bawaan)</item>
<item>Stereo</item>
</string-array>
<string name="no_folder_app">Tak ada aplikasi penampil folder yang terpasang</string>
<string name="hold_by_call">jeda (menahan berdasarkan panggilan)</string>
<string name="recording_status_recording">merekan</string>
<string name="recording_status_encoding">encoding</string>
<string name="recording_status_pause">jeda</string>
<string name="recording_status_edit">sunting</string>
<string name="confirm_cancel">Konfirmasi batal</string>
<string name="encoding_title">Encoding...</string>
<string name="pause_title">Jeda...</string>
<string name="recording_title">Merekam</string>
<string name="open_recording_folder">Buka Folder Rekaman</string>
<string name="recording_list_is_empty">Daftar Rekaman Kosong\n\nKlik Rekam untuk Memulai Rekaman</string>
<string name="record_button">Rekam</string>
<string name="cut_button">Potong</string>
<string name="stop_button">Berhenti</string>
<string name="cancel_button">Batal</string>
<string name="pause_button">Jeda</string>
<string name="pref_storage_title">Jalur Penyimpanan</string>
<string name="pref_rate_title">Rasio Sampel</string>
<string name="pref_encoding_title">Encoding</string>
<string name="pref_encoding_summary">Format file output (.wav, .m4a, ...)</string>
<string name="pref_mode_title">Mode</string>
<string name="pref_mode_summary">Saluran rekaman</string>
<string name="pref_nameformat_title">Nama Format</string>
<string name="pref_pausecalls_title">Jeda Selama ada Panggilan</string>
<string name="pref_pausecalls_summary">Berhenti merekam saat menjawab dan lanjutkan saat menutup telepon</string>
<string name="pref_silence_title">Mode Senyap</string>
<string name="pref_silence_summary">Masukkan telepon dalam \'mode senyap\' saat rekaman</string>
<string name="pref_lockscreen_title">Kontrol Layar Lockscreen</string>
<string name="pref_lockscreen_summary">Perlihatkan kontrol saat telepon dikunci</string>
<string name="pref_theme_title">Tema Aplikasi</string>
<string name="pref_theme_summary">Setel tema aplikasi (gelap / terang)</string>
<string name="pref_application">Aplikasi</string>
<string name="pref_recordings">Rekaman</string>
<string name="pref_fly_title">Encoding on Fly</string>
<string name="pref_fly_summary">Mengaktifkan encoding on fly menonaktifkan pengeditan, dan pemulihan kerusakan</string>
<string name="hold_by_bluetooth">jeda (bluetooth terputus)</string>
<string name="menu_search">Cari</string>
<string name="save_as_wav">Simpan sebagai WAV</string>
</resources>

View file

@ -2,8 +2,47 @@
<resources>
<attr name="recColor" format="color" />
<attr name="cutColor" format="color" />
<string name="source_mic" translatable="false">mic</string>
<string name="source_default" translatable="false">default</string>
<string name="source_raw" translatable="false">raw</string>
<string name="source_bluetooth" translatable="false">bluetooth</string>
<string-array name="sample_rate_values" translatable="false">
<item>48000</item>
<item>44100</item>
<item>32000</item>
<item>22050</item>
<item>16000</item>
<item>11025</item>
<item>8000</item>
</string-array>
<string-array name="source_values" translatable="false">
<item>@string/source_mic</item>
<item>@string/source_raw</item>
<item>@string/source_bluetooth</item>
</string-array>
<string-array name="themes_values" translatable="false">
<item>@string/Theme_Light</item>
<item>@string/Theme_Dark</item>
</string-array>
<string-array name="channels_values" translatable="false">
<item>1</item>
<item>2</item>
</string-array>
<string-array name="format_text" translatable="false">
<item>2017-02-01 09.08.01.wav</item>
<item>1487926249.wav</item>
<item>20170528T043902.wav</item>
</string-array>
<string-array name="format_values" formatted="false" translatable="false">
<item>%s</item>
<item>%T</item>
<item>%I</item>
</string-array>
</resources>

View file

@ -11,60 +11,22 @@
<item>8 kHz (telephone)</item>
</string-array>
<string-array name="sample_rate_values" translatable="false">
<item>48000</item>
<item>44100</item>
<item>32000</item>
<item>22050</item>
<item>16000</item>
<item>11025</item>
<item>8000</item>
</string-array>
<string-array name="source_text">
<item>Mic</item>
<item>Unprocessed</item>
<item>Bluetooth</item>
</string-array>
<string-array name="source_values" translatable="false">
<item>@string/source_mic</item>
<item>@string/source_raw</item>
<item>@string/source_bluetooth</item>
</string-array>
<string-array name="themes_text">
<item>Theme White</item>
<item>Theme Dark</item>
</string-array>
<string-array name="themes_values" translatable="false">
<item>@string/Theme_Light</item>
<item>@string/Theme_Dark</item>
</string-array>
<string-array name="channels_text">
<item>Mono (default)</item>
<item>Stereo</item>
</string-array>
<string-array name="channels_values" translatable="false">
<item>1</item>
<item>2</item>
</string-array>
<string-array name="format_text" translatable="false">
<item>2017-02-01 09.08.01.wav</item>
<item>1487926249.wav</item>
<item>20170528T043902.wav</item>
</string-array>
<string-array name="format_values" formatted="false" translatable="false">
<item>%s</item>
<item>%T</item>
<item>%I</item>
</string-array>
<string name="no_folder_app">No folder view application installed</string>
<string name="hold_by_call">pause (hold by call)</string>
<string name="recording_status_recording">recording</string>