Commit 47b00642 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Ask for permission if needed in ML settings

parent b2fca4e0
......@@ -87,13 +87,13 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
case "directories":
if (VLCApplication.getMLInstance().isWorking())
UiTools.snacker(getView(), getString(R.string.settings_ml_block_scan));
else {
final FragmentActivity activity = getActivity();
final Intent intent = new Intent(VLCApplication.getAppContext(), SecondaryActivity.class);
else if (Permissions.canReadStorage(requireContext())) {
final FragmentActivity activity = requireActivity();
final Intent intent = new Intent(activity.getApplicationContext(), SecondaryActivity.class);
intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER);
startActivity(intent);
if (activity != null) activity.setResult(PreferencesActivity.RESULT_RESTART);
}
activity.setResult(PreferencesActivity.RESULT_RESTART);
} else Permissions.showStoragePermissionDialog(requireActivity(), false);
return true;
case "ui_category":
loadFragment(new PreferencesUi());
......
......@@ -24,12 +24,12 @@
package org.videolan.vlc.gui.tv.preferences;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
import android.view.MenuItem;
import org.videolan.vlc.PlaybackService;
......@@ -37,7 +37,7 @@ import org.videolan.vlc.R;
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class PreferencesActivity extends Activity implements PlaybackService.Client.Callback {
public class PreferencesActivity extends FragmentActivity implements PlaybackService.Client.Callback {
public final static String TAG = "VLC/PreferencesActivity";
......
......@@ -27,6 +27,7 @@ import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.preference.Preference;
import android.widget.Toast;
......@@ -34,6 +35,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Permissions;
import static org.videolan.vlc.gui.preferences.PreferencesActivity.KEY_VIDEO_APP_SWITCH;
......@@ -74,12 +76,12 @@ public class PreferencesFragment extends BasePreferenceFragment {
case "directories":
if (VLCApplication.getMLInstance().isWorking())
Toast.makeText(getContext(), getString(R.string.settings_ml_block_scan), Toast.LENGTH_SHORT).show();
else {
final Intent intent = new Intent(VLCApplication.getAppContext(), SecondaryActivity.class);
else if (Permissions.canReadStorage(getContext())) {
final Intent intent = new Intent(getContext().getApplicationContext(), SecondaryActivity.class);
intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER);
startActivity(intent);
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
}
} else Permissions.showStoragePermissionDialog((FragmentActivity) getActivity(), false);
return true;
case "ui_category":
loadFragment(new PreferencesUi());
......
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