Merge "Remove delete action from notification" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e901be2678
@@ -278,14 +278,10 @@
|
|||||||
<string name="screenrecord_cancel_label">Cancel</string>
|
<string name="screenrecord_cancel_label">Cancel</string>
|
||||||
<!-- Label for notification action to share screen recording [CHAR LIMIT=35] -->
|
<!-- Label for notification action to share screen recording [CHAR LIMIT=35] -->
|
||||||
<string name="screenrecord_share_label">Share</string>
|
<string name="screenrecord_share_label">Share</string>
|
||||||
<!-- Label for notification action to delete a screen recording file [CHAR LIMIT=35] -->
|
|
||||||
<string name="screenrecord_delete_label">Delete</string>
|
|
||||||
<!-- A toast message shown after successfully canceling a screen recording [CHAR LIMIT=NONE] -->
|
<!-- A toast message shown after successfully canceling a screen recording [CHAR LIMIT=NONE] -->
|
||||||
<string name="screenrecord_cancel_success">Screen recording canceled</string>
|
<string name="screenrecord_cancel_success">Screen recording canceled</string>
|
||||||
<!-- Notification text shown after saving a screen recording to prompt the user to view it [CHAR LIMIT=100] -->
|
<!-- Notification text shown after saving a screen recording to prompt the user to view it [CHAR LIMIT=100] -->
|
||||||
<string name="screenrecord_save_message">Screen recording saved, tap to view</string>
|
<string name="screenrecord_save_message">Screen recording saved, tap to view</string>
|
||||||
<!-- A toast message shown after successfully deleting a screen recording [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="screenrecord_delete_description">Screen recording deleted</string>
|
|
||||||
<!-- A toast message shown when there is an error deleting a screen recording [CHAR LIMIT=NONE] -->
|
<!-- A toast message shown when there is an error deleting a screen recording [CHAR LIMIT=NONE] -->
|
||||||
<string name="screenrecord_delete_error">Error deleting screen recording</string>
|
<string name="screenrecord_delete_error">Error deleting screen recording</string>
|
||||||
<!-- A toast message shown when the screen recording cannot be started due to insufficient permissions [CHAR LIMIT=NONE] -->
|
<!-- A toast message shown when the screen recording cannot be started due to insufficient permissions [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import android.app.NotificationChannel;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -69,7 +68,6 @@ public class RecordingService extends Service implements MediaRecorder.OnInfoLis
|
|||||||
private static final String ACTION_STOP_NOTIF =
|
private static final String ACTION_STOP_NOTIF =
|
||||||
"com.android.systemui.screenrecord.STOP_FROM_NOTIF";
|
"com.android.systemui.screenrecord.STOP_FROM_NOTIF";
|
||||||
private static final String ACTION_SHARE = "com.android.systemui.screenrecord.SHARE";
|
private static final String ACTION_SHARE = "com.android.systemui.screenrecord.SHARE";
|
||||||
private static final String ACTION_DELETE = "com.android.systemui.screenrecord.DELETE";
|
|
||||||
|
|
||||||
private final RecordingController mController;
|
private final RecordingController mController;
|
||||||
|
|
||||||
@@ -181,23 +179,6 @@ public class RecordingService extends Service implements MediaRecorder.OnInfoLis
|
|||||||
startActivity(Intent.createChooser(shareIntent, shareLabel)
|
startActivity(Intent.createChooser(shareIntent, shareLabel)
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
break;
|
break;
|
||||||
case ACTION_DELETE:
|
|
||||||
// Close quick shade
|
|
||||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
|
||||||
|
|
||||||
ContentResolver resolver = getContentResolver();
|
|
||||||
Uri uri = Uri.parse(intent.getStringExtra(EXTRA_PATH));
|
|
||||||
resolver.delete(uri, null, null);
|
|
||||||
|
|
||||||
Toast.makeText(
|
|
||||||
this,
|
|
||||||
R.string.screenrecord_delete_description,
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
|
|
||||||
// Remove notification
|
|
||||||
mNotificationManager.cancelAsUser(null, NOTIFICATION_VIEW_ID, currentUser);
|
|
||||||
Log.d(TAG, "Deleted recording " + uri);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return Service.START_STICKY;
|
return Service.START_STICKY;
|
||||||
}
|
}
|
||||||
@@ -307,16 +288,6 @@ public class RecordingService extends Service implements MediaRecorder.OnInfoLis
|
|||||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE))
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Notification.Action deleteAction = new Notification.Action.Builder(
|
|
||||||
Icon.createWithResource(this, R.drawable.ic_screenrecord),
|
|
||||||
getResources().getString(R.string.screenrecord_delete_label),
|
|
||||||
PendingIntent.getService(
|
|
||||||
this,
|
|
||||||
REQUEST_CODE,
|
|
||||||
getDeleteIntent(this, uri.toString()),
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
|
extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
|
||||||
getResources().getString(R.string.screenrecord_name));
|
getResources().getString(R.string.screenrecord_name));
|
||||||
@@ -330,7 +301,6 @@ public class RecordingService extends Service implements MediaRecorder.OnInfoLis
|
|||||||
viewIntent,
|
viewIntent,
|
||||||
PendingIntent.FLAG_IMMUTABLE))
|
PendingIntent.FLAG_IMMUTABLE))
|
||||||
.addAction(shareAction)
|
.addAction(shareAction)
|
||||||
.addAction(deleteAction)
|
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.addExtras(extras);
|
.addExtras(extras);
|
||||||
|
|
||||||
@@ -409,11 +379,6 @@ public class RecordingService extends Service implements MediaRecorder.OnInfoLis
|
|||||||
.putExtra(EXTRA_PATH, path);
|
.putExtra(EXTRA_PATH, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Intent getDeleteIntent(Context context, String path) {
|
|
||||||
return new Intent(context, RecordingService.class).setAction(ACTION_DELETE)
|
|
||||||
.putExtra(EXTRA_PATH, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInfo(MediaRecorder mr, int what, int extra) {
|
public void onInfo(MediaRecorder mr, int what, int extra) {
|
||||||
Log.d(TAG, "Media recorder info: " + what);
|
Log.d(TAG, "Media recorder info: " + what);
|
||||||
|
|||||||
Reference in New Issue
Block a user