mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 13:54:09 +00:00
Allow importing of virtual files
This commit is contained in:
parent
28bb934b12
commit
1b2a70bf41
2 changed files with 18 additions and 10 deletions
16
app/app.iml
16
app/app.iml
|
@ -64,14 +64,6 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/all/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/renderscript" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/assets" type="java-test-resource" />
|
||||
|
@ -80,6 +72,14 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
|
|
|
@ -22,12 +22,14 @@ package eu.faircode.netguard;
|
|||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.database.Cursor;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
|
@ -903,7 +905,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
InputStream in = null;
|
||||
try {
|
||||
Log.i(TAG, "Reading URI=" + data.getData());
|
||||
in = getContentResolver().openInputStream(data.getData());
|
||||
ContentResolver resolver = getContentResolver();
|
||||
String[] streamTypes = resolver.getStreamTypes(data.getData(), "*/*");
|
||||
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(data.getData(), streamTypes[0], null);
|
||||
in = descriptor.createInputStream();
|
||||
out = new FileOutputStream(hosts);
|
||||
|
||||
int len;
|
||||
|
@ -963,7 +968,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
InputStream in = null;
|
||||
try {
|
||||
Log.i(TAG, "Reading URI=" + data.getData());
|
||||
in = getContentResolver().openInputStream(data.getData());
|
||||
ContentResolver resolver = getContentResolver();
|
||||
String[] streamTypes = resolver.getStreamTypes(data.getData(), "*/*");
|
||||
AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(data.getData(), streamTypes[0], null);
|
||||
in = descriptor.createInputStream();
|
||||
xmlImport(in);
|
||||
return null;
|
||||
} catch (Throwable ex) {
|
||||
|
|
Loading…
Reference in a new issue