This commit is contained in:
Alexey Kuznetsov 2018-10-07 12:59:49 +03:00
commit da85241ae7
8 changed files with 85 additions and 100 deletions

View file

@ -14,7 +14,7 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:name=".app.MainApplication"
android:name=".app.AudioApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

View file

@ -30,7 +30,7 @@ import com.github.axet.androidlibrary.widgets.SearchView;
import com.github.axet.audiolibrary.app.Recordings;
import com.github.axet.audiolibrary.app.Storage;
import com.github.axet.audiorecorder.R;
import com.github.axet.audiorecorder.app.MainApplication;
import com.github.axet.audiorecorder.app.AudioApplication;
import com.github.axet.audiorecorder.services.RecordingService;
public class MainActivity extends AppCompatThemeActivity {
@ -56,7 +56,7 @@ public class MainActivity extends AppCompatThemeActivity {
@Override
public int getAppTheme() {
return MainApplication.getTheme(this, R.style.RecThemeLight_NoActionBar, R.style.RecThemeDark_NoActionBar);
return AudioApplication.getTheme(this, R.style.RecThemeLight_NoActionBar, R.style.RecThemeDark_NoActionBar);
}
@Override
@ -106,7 +106,7 @@ public class MainActivity extends AppCompatThemeActivity {
@Override
public void onScreenOff() {
boolean p = storage.recordingPending();
boolean c = shared.getBoolean(MainApplication.PREFERENCE_CONTROLS, false);
boolean c = shared.getBoolean(AudioApplication.PREFERENCE_CONTROLS, false);
if (!p && !c)
return;
super.onScreenOff();
@ -196,7 +196,7 @@ public class MainActivity extends AppCompatThemeActivity {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
if (shared.getBoolean(MainApplication.PREFERENCE_CONTROLS, false))
if (shared.getBoolean(AudioApplication.PREFERENCE_CONTROLS, false))
showLocked(getWindow());
else
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
@ -209,7 +209,7 @@ public class MainActivity extends AppCompatThemeActivity {
Error(e);
}
final String last = shared.getString(MainApplication.PREFERENCE_LAST, "");
final String last = shared.getString(AudioApplication.PREFERENCE_LAST, "");
Runnable done = new Runnable() {
@Override
public void run() {
@ -244,7 +244,7 @@ public class MainActivity extends AppCompatThemeActivity {
Storage.RecordingUri f = recordings.getItem(i);
if (f.name.equals(last)) {
SharedPreferences.Editor edit = shared.edit();
edit.putString(MainApplication.PREFERENCE_LAST, "");
edit.putString(AudioApplication.PREFERENCE_LAST, "");
edit.commit();
return i;
}
@ -295,7 +295,7 @@ public class MainActivity extends AppCompatThemeActivity {
long free = storage.getFree(uri);
long sec = Storage.average(this, free);
TextView text = (TextView) findViewById(R.id.space_left);
text.setText(MainApplication.formatFree(this, free, sec));
text.setText(AudioApplication.formatFree(this, free, sec));
}
public void Error(Throwable e) {

View file

@ -2,20 +2,16 @@ package com.github.axet.audiorecorder.activities;
import android.Manifest;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothDevice;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
@ -23,9 +19,7 @@ import android.preference.PreferenceManager;
import android.support.v4.media.session.MediaButtonReceiver;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
@ -55,14 +49,13 @@ import com.github.axet.audiolibrary.filters.VoiceFilter;
import com.github.axet.audiolibrary.widgets.PitchView;
import com.github.axet.audiorecorder.BuildConfig;
import com.github.axet.audiorecorder.R;
import com.github.axet.audiorecorder.app.MainApplication;
import com.github.axet.audiorecorder.app.AudioApplication;
import com.github.axet.audiorecorder.app.Storage;
import com.github.axet.audiorecorder.services.BluetoothReceiver;
import com.github.axet.audiorecorder.services.RecordingService;
import java.io.File;
import java.nio.ShortBuffer;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
public class RecordingActivity extends AppCompatThemeActivity {
@ -199,7 +192,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
@Override
public int getAppTheme() {
return MainApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);
return AudioApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);
}
@Override
@ -237,7 +230,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
try {
if (storage.recordingPending()) {
String file = shared.getString(MainApplication.PREFERENCE_TARGET, null);
String file = shared.getString(AudioApplication.PREFERENCE_TARGET, null);
if (file != null) {
if (file.startsWith(ContentResolver.SCHEME_CONTENT))
targetUri = Uri.parse(file);
@ -250,7 +243,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
if (targetUri == null)
targetUri = storage.getNewFile();
SharedPreferences.Editor editor = shared.edit();
editor.putString(MainApplication.PREFERENCE_TARGET, targetUri.toString());
editor.putString(AudioApplication.PREFERENCE_TARGET, targetUri.toString());
editor.commit();
} catch (RuntimeException e) {
Log.d(TAG, "onCreate", e);
@ -261,7 +254,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
title.setText(Storage.getDocumentName(targetUri));
if (shared.getBoolean(MainApplication.PREFERENCE_CALL, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_CALL, false)) {
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(pscl, PhoneStateListener.LISTEN_CALL_STATE);
}
@ -279,7 +272,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
@Override
public void run() {
stopRecording();
if (shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) {
try {
if (e != null) {
e.close();
@ -317,7 +310,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
if (encoder != null)
return;
String msg;
if (shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) {
msg = getString(R.string.recording_status_recording);
} else
msg = getString(R.string.recording_status_encoding);
@ -449,7 +442,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
if (shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) {
pitch.setOnTouchListener(null);
} else {
pitch.setOnTouchListener(new View.OnTouchListener() {
@ -536,21 +529,21 @@ public class RecordingActivity extends AppCompatThemeActivity {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
int rate = Integer.parseInt(shared.getString(MainApplication.PREFERENCE_RATE, ""));
int rate = Integer.parseInt(shared.getString(AudioApplication.PREFERENCE_RATE, ""));
int m = Sound.getChannels(this);
int c = Sound.DEFAULT_AUDIOFORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1;
long perSec = (c * m * rate);
String ext = shared.getString(MainApplication.PREFERENCE_ENCODING, "");
String ext = shared.getString(AudioApplication.PREFERENCE_ENCODING, "");
if (shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) {
perSec = Factory.getEncoderRate(ext, sampleRate);
}
long sec = free / perSec * 1000;
state.setText(s + "\n(" + MainApplication.formatFree(this, free, sec) + ")");
state.setText(s + "\n(" + AudioApplication.formatFree(this, free, sec) + ")");
}
void editPlay(boolean show) {
@ -697,7 +690,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = shared.edit();
editor.remove(MainApplication.PREFERENCE_TARGET);
editor.remove(AudioApplication.PREFERENCE_TARGET);
}
void startRecording() {
@ -729,7 +722,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
int user;
if (shared.getString(MainApplication.PREFERENCE_SOURCE, getString(R.string.source_mic)).equals(getString(R.string.source_raw))) {
if (shared.getString(AudioApplication.PREFERENCE_SOURCE, getString(R.string.source_mic)).equals(getString(R.string.source_raw))) {
if (Sound.isUnprocessedSupported(this))
user = MediaRecorder.AudioSource.UNPROCESSED;
else
@ -744,7 +737,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
MediaRecorder.AudioSource.DEFAULT
};
if (shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) {
final OnFlyEncoding fly = new OnFlyEncoding(storage, targetUri, getInfo());
if (e == null) { // do not recreate encoder if on-fly mode enabled
e = new Encoder() {
@ -895,7 +888,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
if (recorder != null)
recorder.release();
if (!shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) { // keep encoder open if encoding on fly enabled
if (!shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) { // keep encoder open if encoding on fly enabled
try {
if (e != null) {
e.close();
@ -941,7 +934,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
void updateSamples(long samplesTime) {
long ms = samplesTime / sampleRate * 1000;
time.setText(MainApplication.formatDuration(this, ms));
time.setText(AudioApplication.formatDuration(this, ms));
}
@Override
@ -967,7 +960,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
void encoding(final Runnable done) {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(RecordingActivity.this);
if (shared.getBoolean(MainApplication.PREFERENCE_FLY, false)) { // keep encoder open if encoding on fly enabled
if (shared.getBoolean(AudioApplication.PREFERENCE_FLY, false)) { // keep encoder open if encoding on fly enabled
try {
if (e != null) {
e.close();
@ -985,7 +978,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
@Override
public void run() {
SharedPreferences.Editor edit = shared.edit();
edit.putString(MainApplication.PREFERENCE_LAST, Storage.getDocumentName(targetUri));
edit.putString(AudioApplication.PREFERENCE_LAST, Storage.getDocumentName(targetUri));
edit.commit();
done.run();
}
@ -1000,12 +993,12 @@ public class RecordingActivity extends AppCompatThemeActivity {
encoder = new FileEncoder(this, in, fly);
if (shared.getBoolean(MainApplication.PREFERENCE_VOICE, false))
if (shared.getBoolean(AudioApplication.PREFERENCE_VOICE, false))
encoder.filters.add(new VoiceFilter(getInfo()));
float amp = shared.getFloat(MainApplication.PREFERENCE_VOLUME, 1);
float amp = shared.getFloat(AudioApplication.PREFERENCE_VOLUME, 1);
if (amp != 1)
encoder.filters.add(new AmplifierFilter(amp));
if (shared.getBoolean(MainApplication.PREFERENCE_SKIP, false))
if (shared.getBoolean(AudioApplication.PREFERENCE_SKIP, false))
encoder.filters.add(new SkipSilenceFilter(getInfo()));
encoding(encoder, fly, last);

View file

@ -33,7 +33,7 @@ import com.github.axet.audiolibrary.app.Sound;
import com.github.axet.audiolibrary.encoders.Factory;
import com.github.axet.audiolibrary.widgets.RecordingVolumePreference;
import com.github.axet.audiorecorder.R;
import com.github.axet.audiorecorder.app.MainApplication;
import com.github.axet.audiorecorder.app.AudioApplication;
import com.github.axet.audiorecorder.app.Storage;
import com.github.axet.audiorecorder.services.RecordingService;
@ -137,12 +137,12 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
@Override
public int getAppTheme() {
return MainApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);
return AudioApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);
}
@Override
public String getAppThemeKey() {
return MainApplication.PREFERENCE_THEME;
return AudioApplication.PREFERENCE_THEME;
}
@Override
@ -162,7 +162,7 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
// actionBar.setBackgroundDrawable(new ColorDrawable(MainApplication.getActionbarColor(this)));
// actionBar.setBackgroundDrawable(new ColorDrawable(AudioApplication.getActionbarColor(this)));
}
}
@ -189,18 +189,18 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
super.onSharedPreferenceChanged(sharedPreferences, key);
if (key.equals(MainApplication.PREFERENCE_CONTROLS)) {
if (sharedPreferences.getBoolean(MainApplication.PREFERENCE_CONTROLS, false)) {
if (key.equals(AudioApplication.PREFERENCE_CONTROLS)) {
if (sharedPreferences.getBoolean(AudioApplication.PREFERENCE_CONTROLS, false)) {
RecordingService.start(this);
} else {
RecordingService.stopService(this);
}
}
if (key.equals(MainApplication.PREFERENCE_STORAGE)) {
if (key.equals(AudioApplication.PREFERENCE_STORAGE)) {
Storage.migrateLocalStorageDialog(this, handler, new Storage(this));
}
if (key.equals(MainApplication.PREFERENCE_RATE)) {
int sampleRate = Integer.parseInt(sharedPreferences.getString(MainApplication.PREFERENCE_RATE, ""));
if (key.equals(AudioApplication.PREFERENCE_RATE)) {
int sampleRate = Integer.parseInt(sharedPreferences.getString(AudioApplication.PREFERENCE_RATE, ""));
if (sampleRate != Sound.getValidRecordRate(Sound.getInMode(this), sampleRate)) {
Toast.makeText(this, "Not supported Hz", Toast.LENGTH_SHORT).show();
}
@ -241,7 +241,7 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
void initPrefs(PreferenceManager pm, PreferenceScreen screen) {
final Context context = screen.getContext();
ListPreference enc = (ListPreference) pm.findPreference(MainApplication.PREFERENCE_ENCODING);
ListPreference enc = (ListPreference) pm.findPreference(AudioApplication.PREFERENCE_ENCODING);
String v = enc.getValue();
CharSequence[] ee = Factory.getEncodingTexts(context);
CharSequence[] vv = Factory.getEncodingValues(context);
@ -261,26 +261,26 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
screen.removePreference(enc);
}
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_RATE));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_THEME));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_CHANNELS));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_FORMAT));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_VOLUME));
bindPreferenceSummaryToValue(pm.findPreference(AudioApplication.PREFERENCE_RATE));
bindPreferenceSummaryToValue(pm.findPreference(AudioApplication.PREFERENCE_THEME));
bindPreferenceSummaryToValue(pm.findPreference(AudioApplication.PREFERENCE_CHANNELS));
bindPreferenceSummaryToValue(pm.findPreference(AudioApplication.PREFERENCE_FORMAT));
bindPreferenceSummaryToValue(pm.findPreference(AudioApplication.PREFERENCE_VOLUME));
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) pm.findPreference(MainApplication.PREFERENCE_STORAGE);
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) pm.findPreference(AudioApplication.PREFERENCE_STORAGE);
s.setStorage(new Storage(getContext()));
s.setPermissionsDialog(this, Storage.PERMISSIONS_RW, RESULT_STORAGE);
if (Build.VERSION.SDK_INT >= 21)
s.setStorageAccessFramework(this, RESULT_STORAGE);
AudioManager am = (AudioManager) context.getSystemService(AUDIO_SERVICE);
Preference bluetooth = pm.findPreference(MainApplication.PREFERENCE_SOURCE);
Preference bluetooth = pm.findPreference(AudioApplication.PREFERENCE_SOURCE);
if (!am.isBluetoothScoAvailableOffCall()) {
bluetooth.setVisible(false);
}
bindPreferenceSummaryToValue(bluetooth);
Preference p = pm.findPreference(MainApplication.PREFERENCE_CALL);
Preference p = pm.findPreference(AudioApplication.PREFERENCE_CALL);
p.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@ -314,13 +314,13 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) findPreference(MainApplication.PREFERENCE_STORAGE);
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) findPreference(AudioApplication.PREFERENCE_STORAGE);
switch (requestCode) {
case RESULT_STORAGE:
s.onRequestPermissionsResult(permissions, grantResults);
break;
case RESULT_CALL:
SwitchPreferenceCompat p = (SwitchPreferenceCompat) findPreference(MainApplication.PREFERENCE_CALL);
SwitchPreferenceCompat p = (SwitchPreferenceCompat) findPreference(AudioApplication.PREFERENCE_CALL);
if (!Storage.permitted(getContext(), PREMS))
p.setChecked(false);
else
@ -332,7 +332,7 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) findPreference(MainApplication.PREFERENCE_STORAGE);
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) findPreference(AudioApplication.PREFERENCE_STORAGE);
switch (requestCode) {
case RESULT_STORAGE:
s.onActivityResult(resultCode, data);
@ -343,7 +343,7 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
@Override
public void onResume() {
super.onResume();
SilencePreferenceCompat silent = (SilencePreferenceCompat) findPreference(MainApplication.PREFERENCE_SILENT);
SilencePreferenceCompat silent = (SilencePreferenceCompat) findPreference(AudioApplication.PREFERENCE_SILENT);
silent.onResume();
}
}

View file

@ -1,23 +1,17 @@
package com.github.axet.audiorecorder.app;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.view.ContextThemeWrapper;
import android.view.View;
import android.widget.RemoteViews;
import com.github.axet.androidlibrary.widgets.NotificationChannelCompat;
import com.github.axet.androidlibrary.widgets.RemoteNotificationCompat;
import com.github.axet.androidlibrary.widgets.RemoteViewsCompat;
import com.github.axet.androidlibrary.widgets.ThemeUtils;
import com.github.axet.audiolibrary.encoders.FormatFLAC;
import com.github.axet.audiolibrary.encoders.FormatM4A;
import com.github.axet.audiolibrary.encoders.FormatOGG;
@ -26,7 +20,7 @@ import com.github.axet.audiorecorder.activities.MainActivity;
import java.util.Locale;
public class MainApplication extends com.github.axet.audiolibrary.app.MainApplication {
public class AudioApplication extends com.github.axet.audiolibrary.app.MainApplication {
public static final String PREFERENCE_CONTROLS = "controls";
public static final String PREFERENCE_TARGET = "target";
@ -37,6 +31,10 @@ public class MainApplication extends com.github.axet.audiolibrary.app.MainApplic
public NotificationChannelCompat channelStatus;
public static AudioApplication from(Context context) {
return (AudioApplication) com.github.axet.audiolibrary.app.MainApplication.from(context);
}
public int getUserTheme() {
return getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);
}
@ -56,9 +54,9 @@ public class MainApplication extends com.github.axet.audiolibrary.app.MainApplic
SharedPreferences.Editor edit = shared.edit();
if (!FormatOGG.supported(this)) {
if (Build.VERSION.SDK_INT >= 18)
edit.putString(MainApplication.PREFERENCE_ENCODING, FormatM4A.EXT);
edit.putString(AudioApplication.PREFERENCE_ENCODING, FormatM4A.EXT);
else
edit.putString(MainApplication.PREFERENCE_ENCODING, FormatFLAC.EXT);
edit.putString(AudioApplication.PREFERENCE_ENCODING, FormatFLAC.EXT);
}
edit.putInt(PREFERENCE_VERSION, 2);
edit.commit();
@ -91,10 +89,10 @@ public class MainApplication extends com.github.axet.audiolibrary.app.MainApplic
PendingIntent main = PendingIntent.getService(this, 0,
new Intent(this, MainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
RemoteNotificationCompat.Builder builder = new RemoteNotificationCompat.Builder(this, MainApplication.getTheme(this, R.layout.notifictaion_recording_light, R.layout.notifictaion_recording_dark));
builder.view.setViewVisibility(R.id.notification_record, View.GONE);
builder.view.setViewVisibility(R.id.notification_pause, View.GONE);
builder.setTheme(MainApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark))
RemoteNotificationCompat.Builder builder = new RemoteNotificationCompat.Builder(this, R.layout.notifictaion);
builder.setViewVisibility(R.id.notification_record, View.GONE);
builder.setViewVisibility(R.id.notification_pause, View.GONE);
builder.setTheme(AudioApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark))
.setImageViewTint(R.id.icon_circle, R.attr.colorButtonNormal)
.setTitle(title)
.setText(text)

View file

@ -25,11 +25,11 @@ public class Storage extends com.github.axet.audiolibrary.app.Storage {
public Uri getNewFile() {
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
String ext = shared.getString(MainApplication.PREFERENCE_ENCODING, "");
String ext = shared.getString(AudioApplication.PREFERENCE_ENCODING, "");
String format = "%s";
format = shared.getString(MainApplication.PREFERENCE_FORMAT, format);
format = shared.getString(AudioApplication.PREFERENCE_FORMAT, format);
format = getFormatted(format, new Date());
@ -55,7 +55,7 @@ public class Storage extends com.github.axet.audiolibrary.app.Storage {
String format = "%s";
format = shared.getString(MainApplication.PREFERENCE_FORMAT, format);
format = shared.getString(AudioApplication.PREFERENCE_FORMAT, format);
format = getFormatted(format, new Date());

View file

@ -13,7 +13,7 @@ import android.preference.PreferenceManager;
import android.widget.Toast;
import com.github.axet.audiorecorder.R;
import com.github.axet.audiorecorder.app.MainApplication;
import com.github.axet.audiorecorder.app.AudioApplication;
// default bluetooth stack for API25 bugged and has to be cleared using this Receiver.
//
@ -140,7 +140,7 @@ public class BluetoothReceiver extends BroadcastReceiver {
public boolean isRecordingReady() {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
if (shared.getString(MainApplication.PREFERENCE_SOURCE, context.getString(R.string.source_mic)).equals(context.getString(R.string.source_bluetooth))) {
if (shared.getString(AudioApplication.PREFERENCE_SOURCE, context.getString(R.string.source_mic)).equals(context.getString(R.string.source_bluetooth))) {
bluetoothSource = true;
if (!startBluetooth())
return false;

View file

@ -9,27 +9,21 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
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.support.v7.view.ContextThemeWrapper;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RemoteViews;
import com.github.axet.androidlibrary.widgets.ProximityShader;
import com.github.axet.androidlibrary.widgets.RemoteNotificationCompat;
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;
import com.github.axet.audiorecorder.activities.RecordingActivity;
import com.github.axet.audiorecorder.app.MainApplication;
import com.github.axet.audiorecorder.app.AudioApplication;
import java.io.File;
@ -55,7 +49,7 @@ public class RecordingService extends Service {
public static void startIfEnabled(Context context) {
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
if (!shared.getBoolean(MainApplication.PREFERENCE_CONTROLS, false))
if (!shared.getBoolean(AudioApplication.PREFERENCE_CONTROLS, false))
return;
start(context);
}
@ -64,7 +58,7 @@ public class RecordingService extends Service {
Storage st = new Storage(context);
if (st.recordingPending()) {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
String f = shared.getString(MainApplication.PREFERENCE_TARGET, "");
String f = shared.getString(AudioApplication.PREFERENCE_TARGET, "");
String d;
if (f.startsWith(ContentResolver.SCHEME_CONTENT)) {
Uri u = Uri.parse(f);
@ -97,7 +91,7 @@ public class RecordingService extends Service {
public static void stopRecording(Context context) {
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
if (shared.getBoolean(MainApplication.PREFERENCE_CONTROLS, false)) {
if (shared.getBoolean(AudioApplication.PREFERENCE_CONTROLS, false)) {
start(context);
return;
}
@ -188,7 +182,7 @@ public class RecordingService extends Service {
new Intent(this, RecordingService.class).setAction(RECORD_BUTTON),
PendingIntent.FLAG_UPDATE_CURRENT);
RemoteNotificationCompat.Builder builder = new RemoteNotificationCompat.Builder(this, MainApplication.getTheme(this, R.layout.notifictaion_recording_light, R.layout.notifictaion_recording_dark));
RemoteNotificationCompat.Builder builder = new RemoteNotificationCompat.Builder(this, R.layout.notifictaion);
String title;
String text;
@ -197,35 +191,35 @@ public class RecordingService extends Service {
Uri f = storage.getStoragePath();
long free = storage.getFree(f);
long sec = Storage.average(this, free);
text = MainApplication.formatFree(this, free, sec);
builder.view.setViewVisibility(R.id.notification_record, View.VISIBLE);
builder.view.setOnClickPendingIntent(R.id.notification_record, re);
builder.view.setViewVisibility(R.id.notification_pause, View.GONE);
text = AudioApplication.formatFree(this, free, sec);
builder.setViewVisibility(R.id.notification_record, View.VISIBLE);
builder.setOnClickPendingIntent(R.id.notification_record, re);
builder.setViewVisibility(R.id.notification_pause, View.GONE);
} else {
if (recording)
title = getString(R.string.recording_title);
else
title = getString(R.string.pause_title);
text = ".../" + targetFile;
builder.view.setViewVisibility(R.id.notification_record, View.GONE);
builder.view.setViewVisibility(R.id.notification_pause, View.VISIBLE);
builder.setViewVisibility(R.id.notification_record, View.GONE);
builder.setViewVisibility(R.id.notification_pause, View.VISIBLE);
}
if (encoding) {
builder.view.setViewVisibility(R.id.notification_pause, View.GONE);
builder.setViewVisibility(R.id.notification_pause, View.GONE);
title = getString(R.string.encoding_title);
}
builder.view.setOnClickPendingIntent(R.id.notification_pause, pe);
builder.view.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.ic_play_arrow_black_24dp : R.drawable.ic_pause_black_24dp);
RemoteViewsCompat.setContentDescription(builder.view, R.id.notification_pause, getString(!recording ? R.string.record_button : R.string.pause_button));
builder.setOnClickPendingIntent(R.id.notification_pause, pe);
builder.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.ic_play_arrow_black_24dp : R.drawable.ic_pause_black_24dp);
RemoteViewsCompat.setContentDescription(builder.compact, R.id.notification_pause, getString(!recording ? R.string.record_button : R.string.pause_button));
builder.setMainIntent(main)
.setTheme(MainApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark))
.setTheme(AudioApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark))
.setImageViewTint(R.id.icon_circle, R.attr.colorButtonNormal)
.setTitle(title)
.setText(text)
.setChannel(((MainApplication) getApplication()).channelStatus)
.setChannel(AudioApplication.from(this).channelStatus)
.setWhen(notification)
.setOngoing(true)
.setSmallIcon(R.drawable.ic_mic);