Commit 098d3a11 authored by Geoffrey Métais's avatar Geoffrey Métais

Upgrade AppCompat to v27.1.0 & set minSDK 14

parent d9c5a255
......@@ -24,7 +24,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.videolan.vlc.plugin.api">
<uses-sdk android:minSdkVersion="9" />
<uses-sdk android:minSdkVersion="14" />
<application android:label="@string/app_name"
android:supportsRtl="true">
......
......@@ -24,11 +24,12 @@ allprojects {
}
ext {
appCompatVersion = '25.2.0'
appCompatVersion = '27.1.0'
constraintLayoutVersion = '1.1.0-beta6'
archVersion = '1.1.0'
buildToolsVersion = "27.0.2"
compileSdkVersion = 26
minSdkVersion = 9
minSdkVersion = 14
targetSdkVersion = 26
versionName = '3.0.5'
versionCode = 3000510
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.videolan" android:versionCode="2" android:versionName="3.0.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="24"/>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26"/>
</manifest>
......@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.videolan.medialibrary">
<uses-sdk android:minSdkVersion="9" />
<uses-sdk android:minSdkVersion="14" />
<application/>
......
......@@ -5,7 +5,7 @@
android:installLocation="auto">
<uses-sdk
tools:overrideLibrary="android.support.v17.leanback, android.support.v14.preference, android.support.v17.preference" />
tools:overrideLibrary="android.support.v17.leanback, android.support.v17.preference" />
<uses-permission android:name="android.permission.READ_LOGS"
android:maxSdkVersion="18" /> <!-- android:maxSdkVersion="15" -->
......
......@@ -376,9 +376,11 @@ class AudioPlayer : PlaybackServiceFragment(), PlaybackService.Callback, Playlis
fun showAdvancedOptions(v: View) {
if (!isVisible) return
val advOptionsDialog = AdvOptionsDialog()
advOptionsDialog.arguments = Bundle().apply { putInt(AdvOptionsDialog.MODE_KEY, AdvOptionsDialog.MODE_AUDIO) }
advOptionsDialog.show(activity.supportFragmentManager, "fragment_adv_options")
activity?.let {
val advOptionsDialog = AdvOptionsDialog()
advOptionsDialog.arguments = Bundle().apply { putInt(AdvOptionsDialog.MODE_KEY, AdvOptionsDialog.MODE_AUDIO) }
advOptionsDialog.show(it.supportFragmentManager, "fragment_adv_options")
}
}
fun show() {
......
......@@ -28,18 +28,15 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.media.session.MediaSession;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v7.app.NotificationCompat;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.StartActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Util;
import static org.videolan.vlc.util.Constants.ACTION_PAUSE_SCAN;
import static org.videolan.vlc.util.Constants.ACTION_RESUME_SCAN;
......@@ -57,114 +54,59 @@ public class NotificationHelper {
final PendingIntent piBackward = PendingIntent.getBroadcast(ctx, 0, new Intent(Constants.ACTION_REMOTE_BACKWARD), PendingIntent.FLAG_UPDATE_CURRENT);
final PendingIntent piPlay = PendingIntent.getBroadcast(ctx, 0, new Intent(Constants.ACTION_REMOTE_PLAYPAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
final PendingIntent piForward = PendingIntent.getBroadcast(ctx, 0, new Intent(Constants.ACTION_REMOTE_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT);
if (AndroidUtil.isOOrLater) {
final Notification.Builder builder = new Notification.Builder(ctx, "vlc_playback");
builder.setSmallIcon(video ? R.drawable.ic_notif_video : R.drawable.ic_notif_audio)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(title)
.setContentText(Util.getMediaDescription(artist, album))
.setLargeIcon(cover)
.setTicker(title + " - " + artist)
.setAutoCancel(!playing)
.setOngoing(playing)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setDeleteIntent(piStop)
.setContentIntent(spi)
.addAction(R.drawable.ic_widget_previous_w, ctx.getString(R.string.previous), piBackward);
if (playing)
builder.addAction(R.drawable.ic_widget_pause_w, ctx.getString(R.string.pause), piPlay);
else
builder.addAction(R.drawable.ic_widget_play_w, ctx.getString(R.string.play), piPlay);
builder.addAction(R.drawable.ic_widget_next_w, ctx.getString(R.string.next), piForward);
builder.addAction(R.drawable.ic_widget_close_w, ctx.getString(R.string.stop), piStop);
final Notification.MediaStyle ms = new Notification.MediaStyle()
.setShowActionsInCompactView(0,1,2);
if (sessionToken != null)
ms.setMediaSession((MediaSession.Token) sessionToken.getToken());
builder.setStyle(ms);
return builder.build();
} else {
final NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
builder.setSmallIcon(video ? R.drawable.ic_notif_video : R.drawable.ic_notif_audio)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(title)
.setContentText(getMediaDescription(artist, album))
.setLargeIcon(cover)
.setTicker(title + " - " + artist)
.setAutoCancel(!playing)
.setOngoing(playing)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setDeleteIntent(piStop)
.setContentIntent(spi)
.addAction(R.drawable.ic_widget_previous_w, ctx.getString(R.string.previous), piBackward);
if (playing)
builder.addAction(R.drawable.ic_widget_pause_w, ctx.getString(R.string.pause), piPlay);
else
builder.addAction(R.drawable.ic_widget_play_w, ctx.getString(R.string.play), piPlay);
builder.addAction(R.drawable.ic_widget_next_w, ctx.getString(R.string.next), piForward);
builder.addAction(R.drawable.ic_widget_close_w, ctx.getString(R.string.stop), piStop);
if (AndroidDevices.showMediaStyle) {
builder.setStyle(new NotificationCompat.MediaStyle()
.setMediaSession(sessionToken)
.setShowActionsInCompactView(0,1,2)
.setShowCancelButton(true)
.setCancelButtonIntent(piStop)
);
}
return builder.build();
final NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, "vlc_playback");
builder.setSmallIcon(video ? R.drawable.ic_notif_video : R.drawable.ic_notif_audio)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(title)
.setContentText(getMediaDescription(artist, album))
.setLargeIcon(cover)
.setTicker(title + " - " + artist)
.setAutoCancel(!playing)
.setOngoing(playing)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setDeleteIntent(piStop)
.setContentIntent(spi)
.addAction(R.drawable.ic_widget_previous_w, ctx.getString(R.string.previous), piBackward);
if (playing) builder.addAction(R.drawable.ic_widget_pause_w, ctx.getString(R.string.pause), piPlay);
else builder.addAction(R.drawable.ic_widget_play_w, ctx.getString(R.string.play), piPlay);
builder.addAction(R.drawable.ic_widget_next_w, ctx.getString(R.string.next), piForward);
builder.addAction(R.drawable.ic_widget_close_w, ctx.getString(R.string.stop), piStop);
if (AndroidDevices.showMediaStyle) {
builder.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
.setMediaSession(sessionToken)
.setShowActionsInCompactView(0,1,2)
.setShowCancelButton(true)
.setCancelButtonIntent(piStop)
);
}
return builder.build();
}
private static android.support.v4.app.NotificationCompat.Builder scanCompatBuilder;
private static Notification.Builder scanBuilder;
private static final Intent notificationIntent = new Intent();
public static Notification createScanNotification(Context ctx, String progressText, boolean updateActions, boolean paused) {
if (AndroidUtil.isOOrLater) {
if (scanBuilder == null) {
scanBuilder = new Notification.Builder(ctx, "vlc_medialibrary")
.setContentIntent(PendingIntent.getActivity(ctx, 0, new Intent(ctx, StartActivity.class), PendingIntent.FLAG_UPDATE_CURRENT))
.setSmallIcon(R.drawable.ic_notif_scan)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(ctx.getString(R.string.ml_scanning))
.setAutoCancel(false)
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
.setOngoing(true);
}
scanBuilder.setContentText(progressText);
if (updateActions) {
notificationIntent.setAction(paused ? ACTION_RESUME_SCAN : ACTION_PAUSE_SCAN);
final PendingIntent pi = PendingIntent.getBroadcast(ctx.getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Notification.Action playpause = paused ? new Notification.Action(R.drawable.ic_play, ctx.getString(R.string.resume), pi)
: new Notification.Action(R.drawable.ic_pause, ctx.getString(R.string.pause), pi);
scanBuilder.setActions(playpause);
}
return scanBuilder.build();
} else {
if (scanCompatBuilder == null) {
scanCompatBuilder = new NotificationCompat.Builder(ctx)
.setContentIntent(PendingIntent.getActivity(ctx, 0, new Intent(ctx, StartActivity.class), PendingIntent.FLAG_UPDATE_CURRENT))
.setSmallIcon(R.drawable.ic_notif_scan)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(ctx.getString(R.string.ml_scanning))
.setAutoCancel(false)
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
.setOngoing(true);
}
scanCompatBuilder.setContentText(progressText);
if (scanCompatBuilder == null) {
scanCompatBuilder = new NotificationCompat.Builder(ctx, "vlc_medialibrary")
.setContentIntent(PendingIntent.getActivity(ctx, 0, new Intent(ctx, StartActivity.class), PendingIntent.FLAG_UPDATE_CURRENT))
.setSmallIcon(R.drawable.ic_notif_scan)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(ctx.getString(R.string.ml_scanning))
.setAutoCancel(false)
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
.setOngoing(true);
}
scanCompatBuilder.setContentText(progressText);
if (updateActions) {
notificationIntent.setAction(paused ? ACTION_RESUME_SCAN : ACTION_PAUSE_SCAN);
final PendingIntent pi = PendingIntent.getBroadcast(ctx.getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Action playpause = paused ? new NotificationCompat.Action(R.drawable.ic_play, ctx.getString(R.string.resume), pi)
: new NotificationCompat.Action(R.drawable.ic_pause, ctx.getString(R.string.pause), pi);
scanCompatBuilder.mActions.clear();
scanCompatBuilder.addAction(playpause);
}
return scanCompatBuilder.build();
if (updateActions) {
notificationIntent.setAction(paused ? ACTION_RESUME_SCAN : ACTION_PAUSE_SCAN);
final PendingIntent pi = PendingIntent.getBroadcast(ctx.getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Action playpause = paused ? new NotificationCompat.Action(R.drawable.ic_play, ctx.getString(R.string.resume), pi)
: new NotificationCompat.Action(R.drawable.ic_pause, ctx.getString(R.string.pause), pi);
scanCompatBuilder.mActions.clear();
scanCompatBuilder.addAction(playpause);
}
return scanCompatBuilder.build();
}
@RequiresApi(api = Build.VERSION_CODES.O)
......
......@@ -57,8 +57,8 @@ class StoragePermissionsDelegate : BaseHeadlessFragment() {
intent.removeExtra(Constants.EXTRA_UPGRADE)
intent.removeExtra(Constants.EXTRA_FIRST_RUN)
}
mWrite = arguments.getBoolean("write")
if (AndroidUtil.isMarshMallowOrLater && !canReadStorage(activity)) {
mWrite = arguments?.getBoolean("write") ?: false
if (AndroidUtil.isMarshMallowOrLater && !canReadStorage(activity!!)) {
if (shouldShowRequestPermissionRationale(Manifest.permission.READ_EXTERNAL_STORAGE))
Permissions.showStoragePermissionDialog(mActivity, false)
else
......
......@@ -29,7 +29,7 @@ class WriteExternalDelegate : BaseHeadlessFragment() {
private fun showDialog() {
if (!isAdded) return
val builder = AlertDialog.Builder(activity)
val builder = AlertDialog.Builder(activity!!)
builder.setMessage(R.string.sdcard_permission_dialog_message)
.setTitle(R.string.sdcard_permission_dialog_title)
.setPositiveButton(R.string.ok, { _, _ ->
......@@ -44,17 +44,19 @@ class WriteExternalDelegate : BaseHeadlessFragment() {
private fun showHelpDialog() {
if (!isAdded) return
val inflater = activity.layoutInflater
AlertDialog.Builder(activity).setView(inflater.inflate(R.layout.dialog_sd_write, null))
.setOnDismissListener { showDialog() }
.create().show()
activity?.let {
val inflater = it.layoutInflater
AlertDialog.Builder(it).setView(inflater.inflate(R.layout.dialog_sd_write, null))
.setOnDismissListener { showDialog() }
.create().show()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (data !== null && requestCode == REQUEST_CODE_STORAGE_ACCES) {
if (resultCode == Activity.RESULT_OK) {
val context = context
val context = context ?: return
val treeUri = data.data
PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).edit()
.putString("tree_uri_"+ storage, treeUri.toString()).apply()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment