Skip to content
Snippets Groups Projects
Commit e56b14e8 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Confirm app exit in multiwindow mode

parent c94b6fba
No related branches found
No related tags found
No related merge requests found
......@@ -489,6 +489,7 @@
<string name="allow_sdraw_overlays_description">VLC needs you to grant this permission display your video in a popup over other applications.</string>
<string name="permission_ask_again">Grant permission</string>
<string name="exit_app">Close VLC</string>
<string name="exit_app_msg">Are you sur you want to quit VLC?</string>
<!-- fast scroller -->
<string name="fastscroller_track">FastScroller track</string>
......
......@@ -51,6 +51,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FilterQueryProvider;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.MediaParsingService;
......@@ -349,7 +350,7 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
@Override
public void onBackPressed() {
/* Close the menu first */
if(mDrawerLayout.isDrawerOpen(mNavigationView)) {
if (mDrawerLayout.isDrawerOpen(mNavigationView)) {
mDrawerLayout.closeDrawer(mNavigationView);
return;
}
......@@ -367,6 +368,10 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
((ExtensionBrowser) fragment).goBack();
return;
}
if (AndroidUtil.isNougatOrLater && isInMultiWindowMode()) {
UiTools.confirmExit(this);
return;
}
finish();
}
......
......@@ -26,6 +26,7 @@ package org.videolan.vlc.gui.helpers;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.databinding.BindingAdapter;
......@@ -46,6 +47,7 @@ import android.support.annotation.RequiresApi;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
......@@ -301,35 +303,35 @@ public class UiTools {
if (bitmap == null || bitmap.getConfig() == null)
return null;
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(VLCApplication.getAppContext());
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(VLCApplication.getAppContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
//Create the Allocations (in/out) with the Renderscript and the in/out bitmaps
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
//Create the Allocations (in/out) with the Renderscript and the in/out bitmaps
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
//Set the radius of the blur
blurScript.setRadius(radius);
//Set the radius of the blur
blurScript.setRadius(radius);
//Perform the Renderscript
blurScript.setInput(allIn);
blurScript.forEach(allOut);
//Perform the Renderscript
blurScript.setInput(allIn);
blurScript.forEach(allOut);
//Copy the final bitmap created by the out Allocation to the outBitmap
allOut.copyTo(outBitmap);
//Copy the final bitmap created by the out Allocation to the outBitmap
allOut.copyTo(outBitmap);
//After finishing everything, we destroy the Renderscript.
rs.destroy();
//After finishing everything, we destroy the Renderscript.
rs.destroy();
return outBitmap;
}
return outBitmap;
}
public static void updateSortTitles(SortableFragment sortable, Menu menu) {
MenuItem item = menu.findItem(R.id.ml_menu_sortby_name);
......@@ -395,4 +397,20 @@ public class UiTools {
item.setTitle(R.string.sortby_number);
}
}
public static void confirmExit(final Activity activity) {
new AlertDialog.Builder(activity)
.setMessage(R.string.exit_app_msg)
.setTitle(R.string.exit_app)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
activity.finish();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
}).create().show();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment