Merge branch 'audiorecorder-3.0.34'

This commit is contained in:
Alexey Kuznetsov 2017-08-10 16:49:19 +03:00
commit 41ebbb6fd0
6 changed files with 23 additions and 11 deletions

View file

@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 9
targetSdkVersion 23
versionCode 198
versionName "3.0.33"
versionCode 199
versionName "3.0.34"
}
signingConfigs {
release {

View file

@ -123,7 +123,7 @@ public class MainActivity extends AppCompatActivity {
list.setEmptyView(findViewById(R.id.empty_list));
recordings.setToolbar((ViewGroup) findViewById(R.id.recording_toolbar));
RecordingService.startIfEnabled(this);
RecordingService.startIfPending(this);
IntentFilter ff = new IntentFilter();
ff.addAction(Intent.ACTION_SCREEN_OFF);

View file

@ -11,6 +11,6 @@ public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent i) {
Log.d(TAG, "onReceive");
RecordingService.startIfEnabledPending(context);
RecordingService.startIfPending(context);
}
}

View file

@ -29,6 +29,6 @@ public class OnExternalReceiver extends BroadcastReceiver {
if (!isExternal(context))
return;
RecordingService.startIfEnabledPending(context);
RecordingService.startIfPending(context);
}
}

View file

@ -14,6 +14,6 @@ public class OnUpgradeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive");
RecordingService.startIfEnabledPending(context);
RecordingService.startIfPending(context);
}
}

View file

@ -5,6 +5,7 @@ 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;
@ -54,13 +55,24 @@ public class RecordingService extends Service {
start(context);
}
public static void startIfEnabledPending(Context context) {
Storage s = new Storage(context);
if (s.recordingPending()) {
public static void startIfPending(Context context) {
Storage st = new Storage(context);
if (st.recordingPending()) {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
String f = shared.getString(MainApplication.PREFERENCE_TARGET, "");
File file = new File(f);
startService(context, file.getName(), false, false);
String d;
Uri u = Uri.parse(f);
String s = u.getScheme();
if (s.equals(ContentResolver.SCHEME_CONTENT)) {
d = Storage.getDocumentName(u);
} else if (s.equals(ContentResolver.SCHEME_FILE)) {
File file = new File(u.getPath());
d = file.getName();
} else {
File file = new File(f);
d = file.getName();
}
startService(context, d, false, false);
return;
}
startIfEnabled(context);