drop unused popup storage permission request
This commit is contained in:
parent
d9b042d9e3
commit
2f66913813
11 changed files with 21 additions and 78 deletions
|
@ -60,7 +60,6 @@ import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.Constants;
|
||||||
import org.schabi.newpipe.util.KioskTranslator;
|
import org.schabi.newpipe.util.KioskTranslator;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.PermissionHelper;
|
|
||||||
import org.schabi.newpipe.util.ServiceHelper;
|
import org.schabi.newpipe.util.ServiceHelper;
|
||||||
import org.schabi.newpipe.util.StateSaver;
|
import org.schabi.newpipe.util.StateSaver;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
@ -422,17 +421,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (requestCode) {
|
|
||||||
case PermissionHelper.DOWNLOADS_REQUEST_CODE:
|
|
||||||
NavigationHelper.openDownloads(this);
|
|
||||||
break;
|
|
||||||
case PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE:
|
|
||||||
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
|
|
||||||
if (fragment instanceof VideoDetailFragment) {
|
|
||||||
((VideoDetailFragment) fragment).openDownloadDialog();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -382,10 +382,8 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedChoiceKey.equals(getString(R.string.download_key))) {
|
if (selectedChoiceKey.equals(getString(R.string.download_key))) {
|
||||||
if (PermissionHelper.checkStoragePermissions(this, PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE)) {
|
|
||||||
selectionIsDownload = true;
|
selectionIsDownload = true;
|
||||||
openDownloadDialog();
|
openDownloadDialog();
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,9 +451,6 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestCode == PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE) {
|
|
||||||
openDownloadDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AdapterChoiceItem {
|
private static class AdapterChoiceItem {
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
import org.schabi.newpipe.util.FilenameUtils;
|
import org.schabi.newpipe.util.FilenameUtils;
|
||||||
import org.schabi.newpipe.util.ListHelper;
|
import org.schabi.newpipe.util.ListHelper;
|
||||||
import org.schabi.newpipe.util.PermissionHelper;
|
|
||||||
import org.schabi.newpipe.util.SecondaryStreamHelper;
|
import org.schabi.newpipe.util.SecondaryStreamHelper;
|
||||||
import org.schabi.newpipe.util.StreamItemAdapter;
|
import org.schabi.newpipe.util.StreamItemAdapter;
|
||||||
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
|
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
|
||||||
|
@ -173,10 +172,6 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
|
Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
|
||||||
if (!PermissionHelper.checkStoragePermissions(getActivity(), PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE)) {
|
|
||||||
getDialog().dismiss();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = getContext();
|
context = getContext();
|
||||||
|
|
||||||
|
@ -217,32 +212,6 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
|
|
||||||
context.unbindService(this);
|
context.unbindService(this);
|
||||||
|
|
||||||
// check of download paths are defined
|
|
||||||
if (!askForSavePath) {
|
|
||||||
String msg = "";
|
|
||||||
if (mainStorageVideo == null) msg += getString(R.string.download_path_title);
|
|
||||||
if (mainStorageAudio == null)
|
|
||||||
msg += getString(R.string.download_path_audio_title);
|
|
||||||
|
|
||||||
if (!msg.isEmpty()) {
|
|
||||||
String title;
|
|
||||||
if (mainStorageVideo == null && mainStorageAudio == null) {
|
|
||||||
title = getString(R.string.general_error);
|
|
||||||
msg = getString(R.string.no_available_dir) + ":\n" + msg;
|
|
||||||
} else {
|
|
||||||
title = msg;
|
|
||||||
msg = getString(R.string.no_available_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
new AlertDialog.Builder(context)
|
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
|
||||||
.setTitle(title)
|
|
||||||
.setMessage(msg)
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -602,6 +571,9 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck
|
||||||
// * save path not defined (via download settings)
|
// * save path not defined (via download settings)
|
||||||
// * the user as checked the "ask where to download" option
|
// * the user as checked the "ask where to download" option
|
||||||
|
|
||||||
|
if (!askForSavePath)
|
||||||
|
Toast.makeText(context, getString(R.string.no_available_dir), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
StoredFileHelper.requestSafWithFileCreation(this, REQUEST_DOWNLOAD_PATH_SAF, filename, mime);
|
StoredFileHelper.requestSafWithFileCreation(this, REQUEST_DOWNLOAD_PATH_SAF, filename, mime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,10 +385,7 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.detail_controls_download:
|
case R.id.detail_controls_download:
|
||||||
if (PermissionHelper.checkStoragePermissions(activity,
|
|
||||||
PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE)) {
|
|
||||||
this.openDownloadDialog();
|
this.openDownloadDialog();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case R.id.detail_uploader_root_layout:
|
case R.id.detail_uploader_root_layout:
|
||||||
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
|
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.nononsenseapps.filepicker.Utils;
|
import com.nononsenseapps.filepicker.Utils;
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasInvalidPath(DOWNLOAD_PATH_VIDEO_PREFERENCE) || hasInvalidPath(DOWNLOAD_PATH_AUDIO_PREFERENCE)) {
|
if (hasInvalidPath(DOWNLOAD_PATH_VIDEO_PREFERENCE) || hasInvalidPath(DOWNLOAD_PATH_AUDIO_PREFERENCE)) {
|
||||||
Toast.makeText(ctx, R.string.download_pick_path, Toast.LENGTH_SHORT).show();
|
|
||||||
updatePreferencesSummary();
|
updatePreferencesSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.schabi.newpipe.settings;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
@ -66,9 +67,11 @@ public class NewPipeSettings {
|
||||||
PreferenceManager.setDefaultValues(context, R.xml.video_audio_settings, true);
|
PreferenceManager.setDefaultValues(context, R.xml.video_audio_settings, true);
|
||||||
PreferenceManager.setDefaultValues(context, R.xml.debug_settings, true);
|
PreferenceManager.setDefaultValues(context, R.xml.debug_settings, true);
|
||||||
|
|
||||||
|
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||||
getVideoDownloadFolder(context);
|
getVideoDownloadFolder(context);
|
||||||
getAudioDownloadFolder(context);
|
getAudioDownloadFolder(context);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void getVideoDownloadFolder(Context context) {
|
private static void getVideoDownloadFolder(Context context) {
|
||||||
getDir(context, R.string.download_path_video_key, Environment.DIRECTORY_MOVIES);
|
getDir(context, R.string.download_path_video_key, Environment.DIRECTORY_MOVIES);
|
||||||
|
|
|
@ -446,9 +446,6 @@ public class NavigationHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean openDownloads(Activity activity) {
|
public static boolean openDownloads(Activity activity) {
|
||||||
if (!PermissionHelper.checkStoragePermissions(activity, PermissionHelper.DOWNLOADS_REQUEST_CODE)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(activity, DownloadActivity.class);
|
Intent intent = new Intent(activity, DownloadActivity.class);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -18,9 +18,6 @@ import android.widget.Toast;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
public class PermissionHelper {
|
public class PermissionHelper {
|
||||||
public static final int DOWNLOAD_DIALOG_REQUEST_CODE = 778;
|
|
||||||
public static final int DOWNLOADS_REQUEST_CODE = 777;
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean checkStoragePermissions(Activity activity, int requestCode) {
|
public static boolean checkStoragePermissions(Activity activity, int requestCode) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package us.shandian.giga.service;
|
package us.shandian.giga.service;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -30,7 +28,6 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.support.v4.app.NotificationCompat.Builder;
|
import android.support.v4.app.NotificationCompat.Builder;
|
||||||
import android.support.v4.content.PermissionChecker;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -257,18 +254,20 @@ public class DownloadManagerService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
|
/*
|
||||||
int permissionCheck;
|
int permissionCheck;
|
||||||
// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
// permissionCheck = PermissionChecker.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
|
permissionCheck = PermissionChecker.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||||
// if (permissionCheck == PermissionChecker.PERMISSION_DENIED) {
|
if (permissionCheck == PermissionChecker.PERMISSION_DENIED) {
|
||||||
// Toast.makeText(this, "Permission denied (read)", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Permission denied (read)", Toast.LENGTH_SHORT).show();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
permissionCheck = PermissionChecker.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
permissionCheck = PermissionChecker.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
if (permissionCheck == PermissionChecker.PERMISSION_DENIED) {
|
if (permissionCheck == PermissionChecker.PERMISSION_DENIED) {
|
||||||
Toast.makeText(this, "Permission denied (write)", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Permission denied (write)", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return mBinder;
|
return mBinder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
<string name="msg_running_detail">Toque para ver detalles</string>
|
<string name="msg_running_detail">Toque para ver detalles</string>
|
||||||
<string name="msg_wait">Por favor espere…</string>
|
<string name="msg_wait">Por favor espere…</string>
|
||||||
<string name="msg_copied">Copiado al portapapeles</string>
|
<string name="msg_copied">Copiado al portapapeles</string>
|
||||||
<string name="no_available_dir">Por favor, seleccione un directorio de descarga disponible</string>
|
<string name="no_available_dir">Por favor, defina un directorio de descarga mas tarde en ajustes</string>
|
||||||
<string name="could_not_load_image">No se pudo cargar la imagen</string>
|
<string name="could_not_load_image">No se pudo cargar la imagen</string>
|
||||||
<string name="app_ui_crash">La interfaz de la app dejó de funcionar</string>
|
<string name="app_ui_crash">La interfaz de la app dejó de funcionar</string>
|
||||||
<string name="info_labels">Lo sucedido:\\nPetición:\\nIdioma del contenido:\\nServicio:\\nHora GMT:\\nPaquete:\\nVersión:\\nVersión del SO:</string>
|
<string name="info_labels">Lo sucedido:\\nPetición:\\nIdioma del contenido:\\nServicio:\\nHora GMT:\\nPaquete:\\nVersión:\\nVersión del SO:</string>
|
||||||
|
@ -458,7 +458,6 @@ abrir en modo popup</string>
|
||||||
<string name="error_progress_lost">Se perdió el progreso porque el archivo fue eliminado</string>
|
<string name="error_progress_lost">Se perdió el progreso porque el archivo fue eliminado</string>
|
||||||
<string name="error_timeout">Tiempo de espera excedido</string>
|
<string name="error_timeout">Tiempo de espera excedido</string>
|
||||||
|
|
||||||
<string name="download_pick_path">Seleccione los directorios de descarga</string>
|
|
||||||
<string name="downloads_storage_ask_title">Preguntar dónde descargar</string>
|
<string name="downloads_storage_ask_title">Preguntar dónde descargar</string>
|
||||||
<string name="downloads_storage_ask_summary">Se preguntará dónde guardar cada descarga</string>
|
<string name="downloads_storage_ask_summary">Se preguntará dónde guardar cada descarga</string>
|
||||||
<string name="downloads_storage_ask_summary_kitkat">Se preguntará dónde guardar cada descarga.\nHabilita esta opción si quieres descargar en la tarjeta SD externa</string>
|
<string name="downloads_storage_ask_summary_kitkat">Se preguntará dónde guardar cada descarga.\nHabilita esta opción si quieres descargar en la tarjeta SD externa</string>
|
||||||
|
|
|
@ -294,7 +294,7 @@
|
||||||
<string name="msg_running_detail">Tap for details</string>
|
<string name="msg_running_detail">Tap for details</string>
|
||||||
<string name="msg_wait">Please wait…</string>
|
<string name="msg_wait">Please wait…</string>
|
||||||
<string name="msg_copied">Copied to clipboard</string>
|
<string name="msg_copied">Copied to clipboard</string>
|
||||||
<string name="no_available_dir">Please select an available download folder</string>
|
<string name="no_available_dir">Please define an download folder later in settings</string>
|
||||||
<string name="msg_popup_permission">This permission is needed to\nopen in popup mode</string>
|
<string name="msg_popup_permission">This permission is needed to\nopen in popup mode</string>
|
||||||
<string name="one_item_deleted">1 item deleted.</string>
|
<string name="one_item_deleted">1 item deleted.</string>
|
||||||
<!-- Checksum types -->
|
<!-- Checksum types -->
|
||||||
|
@ -553,8 +553,6 @@
|
||||||
<string name="start_downloads">Start downloads</string>
|
<string name="start_downloads">Start downloads</string>
|
||||||
<string name="pause_downloads">Pause downloads</string>
|
<string name="pause_downloads">Pause downloads</string>
|
||||||
|
|
||||||
<string name="download_pick_path">Select the downloads save path</string>
|
|
||||||
|
|
||||||
<string name="downloads_storage_ask_title">Ask where to download</string>
|
<string name="downloads_storage_ask_title">Ask where to download</string>
|
||||||
<string name="downloads_storage_ask_summary">You will be asked where to save each download</string>
|
<string name="downloads_storage_ask_summary">You will be asked where to save each download</string>
|
||||||
<string name="downloads_storage_ask_summary_kitkat">You will be asked where to save each download.\nEnable this option if you want download to the external SD Card</string>
|
<string name="downloads_storage_ask_summary_kitkat">You will be asked where to save each download.\nEnable this option if you want download to the external SD Card</string>
|
||||||
|
|
Loading…
Reference in a new issue