Fix non-SAF actions

This commit is contained in:
wb9688 2020-07-30 16:01:08 +02:00 committed by Stypox
parent cb4e6159c4
commit febb21a01d
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
2 changed files with 5 additions and 20 deletions

View file

@ -7,7 +7,6 @@ import android.content.DialogInterface
import android.content.Intent
import android.content.IntentFilter
import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
import android.os.Parcelable
import android.view.LayoutInflater
@ -21,7 +20,6 @@ import androidx.lifecycle.ViewModelProvider
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.GridLayoutManager
import com.nononsenseapps.filepicker.Utils
import com.xwray.groupie.Group
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.Item
@ -58,7 +56,6 @@ import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService
import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.KEY_VALUE
import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE
import org.schabi.newpipe.streams.io.StoredFileHelper
import org.schabi.newpipe.util.FilePickerActivityHelper
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.OnClickGesture
import org.schabi.newpipe.util.ShareUtils
@ -205,13 +202,9 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
super.onActivityResult(requestCode, resultCode, data)
if (data != null && data.data != null && resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_EXPORT_CODE) {
var uri = data.data!!
if (FilePickerActivityHelper.isOwnFileUri(activity, uri)) {
uri = Uri.fromFile(Utils.getFileForUri(uri))
}
activity.startService(
Intent(activity, SubscriptionsExportService::class.java)
.putExtra(SubscriptionsExportService.KEY_FILE_PATH, uri)
.putExtra(SubscriptionsExportService.KEY_FILE_PATH, data.data)
)
} else if (requestCode == REQUEST_IMPORT_CODE) {
ImportConfirmationDialog.show(

View file

@ -5,7 +5,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
@ -16,7 +15,6 @@ import androidx.core.content.ContextCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import com.nononsenseapps.filepicker.Utils;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.schabi.newpipe.DownloaderImpl;
@ -27,17 +25,14 @@ import org.schabi.newpipe.error.ReCaptchaActivity;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.util.FilePickerActivityHelper;
import org.schabi.newpipe.streams.io.StoredFileHelper;
import org.schabi.newpipe.util.ZipHelper;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.schabi.newpipe.streams.io.StoredFileHelper;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
public class ContentSettingsFragment extends BasePreferenceFragment {
@ -147,7 +142,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
}
@Override
public void onActivityResult(final int requestCode, final int resultCode,
public void onActivityResult(final int requestCode,
final int resultCode,
@Nullable final Intent data) {
assureCorrectAppLanguage(getContext());
super.onActivityResult(requestCode, resultCode, data);
@ -160,11 +156,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
if ((requestCode == REQUEST_IMPORT_PATH || requestCode == REQUEST_EXPORT_PATH)
&& resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
Uri uri = data.getData();
if (FilePickerActivityHelper.isOwnFileUri(requireActivity(), uri)) {
uri = Uri.fromFile(Utils.getFileForUri(uri));
}
final StoredFileHelper file = new StoredFileHelper(getContext(), uri,
final StoredFileHelper file = new StoredFileHelper(getContext(), data.getData(),
"application/zip");
if (requestCode == REQUEST_EXPORT_PATH) {
exportDatabase(file);