mirror of
https://github.com/M66B/NetGuard.git
synced 2025-03-15 08:29:02 +00:00
Move export/import and vpn settings to settings activity
This commit is contained in:
parent
801e518795
commit
3404a7ecdf
16 changed files with 314 additions and 284 deletions
|
@ -49,7 +49,6 @@ import android.support.v7.widget.SearchView;
|
|||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -66,23 +65,9 @@ import com.android.vending.billing.IInAppBillingService;
|
|||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
public class ActivityMain extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = "NetGuard.Main";
|
||||
|
@ -103,16 +88,12 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
|
||||
private static final int REQUEST_VPN = 1;
|
||||
private static final int REQUEST_IAB = 2;
|
||||
private static final int REQUEST_EXPORT = 3;
|
||||
private static final int REQUEST_IMPORT = 4;
|
||||
|
||||
// adb shell pm clear com.android.vending
|
||||
private static final String SKU_DONATE = "donation";
|
||||
// private static final String SKU_DONATE = "android.test.purchased";
|
||||
private static final String ACTION_IAB = "eu.faircode.netguard.IAB";
|
||||
|
||||
private static final Intent INTENT_VPN_SETTINGS = new Intent("android.net.vpn.SETTINGS");
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.i(TAG, "Create");
|
||||
|
@ -337,14 +318,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
Log.i(TAG, "IAB response=" + getIABResult(response));
|
||||
}
|
||||
|
||||
} else if (requestCode == REQUEST_EXPORT) {
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
handleExport(data);
|
||||
|
||||
} else if (requestCode == REQUEST_IMPORT) {
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
handleImport(data);
|
||||
|
||||
} else {
|
||||
Log.w(TAG, "Unknown activity result request=" + requestCode);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
@ -505,9 +478,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}
|
||||
});
|
||||
|
||||
menu.findItem(R.id.menu_export).setEnabled(getIntentCreateDocument().resolveActivity(getPackageManager()) != null);
|
||||
menu.findItem(R.id.menu_import).setEnabled(getIntentOpenDocument().resolveActivity(getPackageManager()) != null);
|
||||
menu.findItem(R.id.menu_vpn_settings).setEnabled(INTENT_VPN_SETTINGS.resolveActivity(getPackageManager()) != null);
|
||||
menu.findItem(R.id.menu_support).setEnabled(getIntentSupport().resolveActivity(getPackageManager()) != null);
|
||||
|
||||
return true;
|
||||
|
@ -519,22 +489,10 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_export:
|
||||
startActivityForResult(getIntentCreateDocument(), REQUEST_EXPORT);
|
||||
return true;
|
||||
|
||||
case R.id.menu_import:
|
||||
startActivityForResult(getIntentOpenDocument(), REQUEST_IMPORT);
|
||||
return true;
|
||||
|
||||
case R.id.menu_settings:
|
||||
startActivity(new Intent(this, ActivitySettings.class));
|
||||
return true;
|
||||
|
||||
case R.id.menu_vpn_settings:
|
||||
startActivity(INTENT_VPN_SETTINGS);
|
||||
return true;
|
||||
|
||||
case R.id.menu_support:
|
||||
startActivity(getIntentSupport());
|
||||
return true;
|
||||
|
@ -670,95 +628,12 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}.execute();
|
||||
}
|
||||
|
||||
private void handleExport(final Intent data) {
|
||||
new AsyncTask<Object, Object, Throwable>() {
|
||||
@Override
|
||||
protected Throwable doInBackground(Object... objects) {
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = getContentResolver().openOutputStream(data.getData());
|
||||
Log.i(TAG, "Writing URI=" + data.getData());
|
||||
xmlExport(out);
|
||||
return null;
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
return ex;
|
||||
} finally {
|
||||
if (out != null)
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Throwable ex) {
|
||||
if (ex == null)
|
||||
Toast.makeText(ActivityMain.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(ActivityMain.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void handleImport(final Intent data) {
|
||||
new AsyncTask<Object, Object, Throwable>() {
|
||||
@Override
|
||||
protected Throwable doInBackground(Object... objects) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = getContentResolver().openInputStream(data.getData());
|
||||
Log.i(TAG, "Reading URI=" + data.getData());
|
||||
xmlImport(in);
|
||||
return null;
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
return ex;
|
||||
} finally {
|
||||
if (in != null)
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Throwable ex) {
|
||||
if (ex == null) {
|
||||
SinkholeService.reload(null, ActivityMain.this);
|
||||
recreate();
|
||||
Toast.makeText(ActivityMain.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
||||
} else
|
||||
Toast.makeText(ActivityMain.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private static Intent getIntentSupport() {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse("http://forum.xda-developers.com/showthread.php?t=3233012"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent getIntentCreateDocument() {
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("text/xml");
|
||||
intent.putExtra(Intent.EXTRA_TITLE, "netguard.xml");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent getIntentOpenDocument() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("text/xml");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static boolean IABisAvailable(String sku, IInAppBillingService service, Context context) throws RemoteException, JSONException {
|
||||
ArrayList<String> skuList = new ArrayList<>();
|
||||
skuList.add(sku);
|
||||
|
@ -839,119 +714,4 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
return Integer.toString(responseCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void xmlExport(OutputStream out) throws IOException {
|
||||
XmlSerializer serializer = Xml.newSerializer();
|
||||
serializer.setOutput(out, "UTF-8");
|
||||
serializer.startDocument(null, true);
|
||||
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
|
||||
serializer.startTag(null, "netguard");
|
||||
|
||||
serializer.startTag(null, "application");
|
||||
xmlExport(PreferenceManager.getDefaultSharedPreferences(this), serializer);
|
||||
serializer.endTag(null, "application");
|
||||
|
||||
serializer.startTag(null, "wifi");
|
||||
xmlExport(getSharedPreferences("wifi", Context.MODE_PRIVATE), serializer);
|
||||
serializer.endTag(null, "wifi");
|
||||
|
||||
serializer.startTag(null, "mobile");
|
||||
xmlExport(getSharedPreferences("other", Context.MODE_PRIVATE), serializer);
|
||||
serializer.endTag(null, "mobile");
|
||||
|
||||
serializer.startTag(null, "unused");
|
||||
xmlExport(getSharedPreferences("unused", Context.MODE_PRIVATE), serializer);
|
||||
serializer.endTag(null, "unused");
|
||||
|
||||
serializer.endTag(null, "netguard");
|
||||
serializer.endDocument();
|
||||
serializer.flush();
|
||||
}
|
||||
|
||||
private void xmlExport(SharedPreferences prefs, XmlSerializer serializer) throws IOException {
|
||||
Map<String, ?> settings = prefs.getAll();
|
||||
for (String key : settings.keySet()) {
|
||||
Object value = settings.get(key);
|
||||
if (value instanceof Boolean) {
|
||||
serializer.startTag(null, "setting");
|
||||
serializer.attribute(null, "key", key);
|
||||
serializer.attribute(null, "type", "boolean");
|
||||
serializer.attribute(null, "value", value.toString());
|
||||
serializer.endTag(null, "setting");
|
||||
} else
|
||||
Log.e(TAG, "Unknown key=" + key);
|
||||
}
|
||||
}
|
||||
|
||||
private void xmlImport(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||
XmlImportHandler handler = new XmlImportHandler();
|
||||
reader.setContentHandler(handler);
|
||||
reader.parse(new InputSource(in));
|
||||
|
||||
xmlImport(handler.application, PreferenceManager.getDefaultSharedPreferences(this));
|
||||
xmlImport(handler.wifi, getSharedPreferences("wifi", Context.MODE_PRIVATE));
|
||||
xmlImport(handler.mobile, getSharedPreferences("other", Context.MODE_PRIVATE));
|
||||
xmlImport(handler.unused, getSharedPreferences("unused", Context.MODE_PRIVATE));
|
||||
}
|
||||
|
||||
private void xmlImport(Map<String, Object> settings, SharedPreferences prefs) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
for (String key : prefs.getAll().keySet())
|
||||
editor.remove(key);
|
||||
|
||||
for (String key : settings.keySet()) {
|
||||
Object value = settings.get(key);
|
||||
if (value instanceof Boolean)
|
||||
editor.putBoolean(key, (Boolean) value);
|
||||
else
|
||||
Log.e(TAG, "Unknown type=" + value.getClass());
|
||||
}
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private class XmlImportHandler extends DefaultHandler {
|
||||
public Map<String, Object> application = new HashMap<>();
|
||||
public Map<String, Object> wifi = new HashMap<>();
|
||||
public Map<String, Object> mobile = new HashMap<>();
|
||||
public Map<String, Object> unused = new HashMap<>();
|
||||
private Map<String, Object> current = null;
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||
if (qName.equals("netguard"))
|
||||
; // Ignore
|
||||
|
||||
else if (qName.equals("application"))
|
||||
current = application;
|
||||
|
||||
else if (qName.equals("wifi"))
|
||||
current = wifi;
|
||||
|
||||
else if (qName.equals("mobile"))
|
||||
current = mobile;
|
||||
|
||||
else if (qName.equals("unused"))
|
||||
current = unused;
|
||||
|
||||
else if (qName.equals("setting")) {
|
||||
String key = attributes.getValue("key");
|
||||
String type = attributes.getValue("type");
|
||||
String value = attributes.getValue("value");
|
||||
|
||||
if (current == null)
|
||||
Log.e(TAG, "No current key=" + key);
|
||||
else {
|
||||
if ("boolean".equals(type))
|
||||
current.put(key, Boolean.parseBoolean(value));
|
||||
else
|
||||
Log.e(TAG, "Unknown type key=" + key);
|
||||
}
|
||||
|
||||
} else
|
||||
Log.e(TAG, "Unknown element qname=" + qName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,13 +19,39 @@ package eu.faircode.netguard;
|
|||
Copyright 2015 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
public class ActivitySettings extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = "NetGuard.Settings";
|
||||
|
||||
public static final int REQUEST_EXPORT = 1;
|
||||
public static final int REQUEST_IMPORT = 2;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
setTheme(prefs.getBoolean("dark_theme", false) ? R.style.AppThemeDark : R.style.AppTheme);
|
||||
|
@ -61,4 +87,204 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
else if ("dark_theme".equals(name))
|
||||
recreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
|
||||
Log.i(TAG, "onActivityResult request=" + requestCode + " result=" + requestCode + " ok=" + (resultCode == RESULT_OK));
|
||||
if (requestCode == REQUEST_EXPORT) {
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
handleExport(data);
|
||||
|
||||
} else if (requestCode == REQUEST_IMPORT) {
|
||||
if (resultCode == RESULT_OK && data != null)
|
||||
handleImport(data);
|
||||
|
||||
} else {
|
||||
Log.w(TAG, "Unknown activity result request=" + requestCode);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleExport(final Intent data) {
|
||||
new AsyncTask<Object, Object, Throwable>() {
|
||||
@Override
|
||||
protected Throwable doInBackground(Object... objects) {
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = getContentResolver().openOutputStream(data.getData());
|
||||
Log.i(TAG, "Writing URI=" + data.getData());
|
||||
xmlExport(out);
|
||||
return null;
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
return ex;
|
||||
} finally {
|
||||
if (out != null)
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Throwable ex) {
|
||||
if (ex == null)
|
||||
Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void handleImport(final Intent data) {
|
||||
new AsyncTask<Object, Object, Throwable>() {
|
||||
@Override
|
||||
protected Throwable doInBackground(Object... objects) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = getContentResolver().openInputStream(data.getData());
|
||||
Log.i(TAG, "Reading URI=" + data.getData());
|
||||
xmlImport(in);
|
||||
return null;
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
return ex;
|
||||
} finally {
|
||||
if (in != null)
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Throwable ex) {
|
||||
if (ex == null) {
|
||||
SinkholeService.reload(null, ActivitySettings.this);
|
||||
recreate();
|
||||
Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
|
||||
} else
|
||||
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void xmlExport(OutputStream out) throws IOException {
|
||||
XmlSerializer serializer = Xml.newSerializer();
|
||||
serializer.setOutput(out, "UTF-8");
|
||||
serializer.startDocument(null, true);
|
||||
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
|
||||
serializer.startTag(null, "netguard");
|
||||
|
||||
serializer.startTag(null, "application");
|
||||
xmlExport(PreferenceManager.getDefaultSharedPreferences(this), serializer);
|
||||
serializer.endTag(null, "application");
|
||||
|
||||
serializer.startTag(null, "wifi");
|
||||
xmlExport(getSharedPreferences("wifi", Context.MODE_PRIVATE), serializer);
|
||||
serializer.endTag(null, "wifi");
|
||||
|
||||
serializer.startTag(null, "mobile");
|
||||
xmlExport(getSharedPreferences("other", Context.MODE_PRIVATE), serializer);
|
||||
serializer.endTag(null, "mobile");
|
||||
|
||||
serializer.startTag(null, "unused");
|
||||
xmlExport(getSharedPreferences("unused", Context.MODE_PRIVATE), serializer);
|
||||
serializer.endTag(null, "unused");
|
||||
|
||||
serializer.endTag(null, "netguard");
|
||||
serializer.endDocument();
|
||||
serializer.flush();
|
||||
}
|
||||
|
||||
private void xmlExport(SharedPreferences prefs, XmlSerializer serializer) throws IOException {
|
||||
Map<String, ?> settings = prefs.getAll();
|
||||
for (String key : settings.keySet()) {
|
||||
Object value = settings.get(key);
|
||||
if (value instanceof Boolean) {
|
||||
serializer.startTag(null, "setting");
|
||||
serializer.attribute(null, "key", key);
|
||||
serializer.attribute(null, "type", "boolean");
|
||||
serializer.attribute(null, "value", value.toString());
|
||||
serializer.endTag(null, "setting");
|
||||
} else
|
||||
Log.e(TAG, "Unknown key=" + key);
|
||||
}
|
||||
}
|
||||
|
||||
private void xmlImport(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||
XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||
XmlImportHandler handler = new XmlImportHandler();
|
||||
reader.setContentHandler(handler);
|
||||
reader.parse(new InputSource(in));
|
||||
|
||||
xmlImport(handler.application, PreferenceManager.getDefaultSharedPreferences(this));
|
||||
xmlImport(handler.wifi, getSharedPreferences("wifi", Context.MODE_PRIVATE));
|
||||
xmlImport(handler.mobile, getSharedPreferences("other", Context.MODE_PRIVATE));
|
||||
xmlImport(handler.unused, getSharedPreferences("unused", Context.MODE_PRIVATE));
|
||||
}
|
||||
|
||||
private void xmlImport(Map<String, Object> settings, SharedPreferences prefs) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
for (String key : prefs.getAll().keySet())
|
||||
editor.remove(key);
|
||||
|
||||
for (String key : settings.keySet()) {
|
||||
Object value = settings.get(key);
|
||||
if (value instanceof Boolean)
|
||||
editor.putBoolean(key, (Boolean) value);
|
||||
else
|
||||
Log.e(TAG, "Unknown type=" + value.getClass());
|
||||
}
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private class XmlImportHandler extends DefaultHandler {
|
||||
public Map<String, Object> application = new HashMap<>();
|
||||
public Map<String, Object> wifi = new HashMap<>();
|
||||
public Map<String, Object> mobile = new HashMap<>();
|
||||
public Map<String, Object> unused = new HashMap<>();
|
||||
private Map<String, Object> current = null;
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||
if (qName.equals("netguard"))
|
||||
; // Ignore
|
||||
|
||||
else if (qName.equals("application"))
|
||||
current = application;
|
||||
|
||||
else if (qName.equals("wifi"))
|
||||
current = wifi;
|
||||
|
||||
else if (qName.equals("mobile"))
|
||||
current = mobile;
|
||||
|
||||
else if (qName.equals("unused"))
|
||||
current = unused;
|
||||
|
||||
else if (qName.equals("setting")) {
|
||||
String key = attributes.getValue("key");
|
||||
String type = attributes.getValue("type");
|
||||
String value = attributes.getValue("value");
|
||||
|
||||
if (current == null)
|
||||
Log.e(TAG, "No current key=" + key);
|
||||
else {
|
||||
if ("boolean".equals(type))
|
||||
current.put(key, Boolean.parseBoolean(value));
|
||||
else
|
||||
Log.e(TAG, "Unknown type key=" + key);
|
||||
}
|
||||
|
||||
} else
|
||||
Log.e(TAG, "Unknown element qname=" + qName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,57 @@ package eu.faircode.netguard;
|
|||
Copyright 2015 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
public class FragmentSettings extends PreferenceFragment {
|
||||
private static final Intent INTENT_VPN_SETTINGS = new Intent("android.net.vpn.SETTINGS");
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
Preference pref_export = getPreferenceScreen().findPreference("export");
|
||||
pref_export.setEnabled(getIntentCreateDocument().resolveActivity(getActivity().getPackageManager()) != null);
|
||||
pref_export.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
getActivity().startActivityForResult(getIntentCreateDocument(), ActivitySettings.REQUEST_EXPORT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Preference pref_import = getPreferenceScreen().findPreference("import");
|
||||
pref_import.setEnabled(getIntentCreateDocument().resolveActivity(getActivity().getPackageManager()) != null);
|
||||
pref_import.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
getActivity().startActivityForResult(getIntentOpenDocument(), ActivitySettings.REQUEST_IMPORT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Preference pref_vpn = getPreferenceScreen().findPreference("vpn");
|
||||
pref_vpn.setEnabled(INTENT_VPN_SETTINGS.resolveActivity(getActivity().getPackageManager()) != null);
|
||||
pref_vpn.setIntent(INTENT_VPN_SETTINGS);
|
||||
}
|
||||
|
||||
|
||||
private static Intent getIntentCreateDocument() {
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("text/xml");
|
||||
intent.putExtra(Intent.EXTRA_TITLE, "netguard.xml");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent getIntentOpenDocument() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("text/xml");
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,18 +7,9 @@
|
|||
android:title="@string/menu_search"
|
||||
netguard:actionViewClass="android.support.v7.widget.SearchView"
|
||||
netguard:showAsAction="always|collapseActionView" />
|
||||
<item
|
||||
android:id="@+id/menu_export"
|
||||
android:title="@string/menu_export" />
|
||||
<item
|
||||
android:id="@+id/menu_import"
|
||||
android:title="@string/menu_import" />
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings" />
|
||||
<item
|
||||
android:id="@+id/menu_vpn_settings"
|
||||
android:title="@string/menu_vpn_settings" />
|
||||
<item
|
||||
android:id="@+id/menu_support"
|
||||
android:title="@string/menu_support" />
|
||||
|
|
|
@ -8,10 +8,7 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
\n\nBy using NetGuard, you agree to the <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">البحث عن تطبيقات</string>
|
||||
<string name="menu_export">Export settings</string>
|
||||
<string name="menu_import">Import settings</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_vpn_settings">فتح إعدادات الـVPN</string>
|
||||
<string name="menu_support">الدعم</string>
|
||||
<string name="menu_about">حول</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
<string name="setting_dark">استخدام الثيم الداكن</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Export settings</string>
|
||||
<string name="setting_import">Import settings</string>
|
||||
<string name="setting_vpn">فتح إعدادات الـVPN</string>
|
||||
|
||||
<string name="msg_sure">هل أنت متأكد؟</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -4,13 +4,10 @@
|
|||
<string name="app_first">Netguard wurde mit großer Sorgfalt entwickelt, jedoch ist es unmöglich zu garantieren, dass es auf jedem Gerät korrekt arbeitet.
|
||||
Es ist bekannt, dass Netguard zu Abstürzen führen kann und, dass auf manchen Geräten sämtlicher Netzwerkverkehr blockiert wird.
|
||||
Das wird von Fehlern in Android oder in Software vom Hersteller verursacht. Bitte beschuldigen sie bei solchen Fehlern nicht Netguard.
|
||||
+\n\nMit der Verwendung von NetGuard, akzeptierst du die <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
\n\nMit der Verwendung von NetGuard, akzeptierst du die <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">Suche nach Apps</string>
|
||||
<string name="menu_export">Exportiere Einstellungen</string>
|
||||
<string name="menu_import">Importiere Einstellungen</string>
|
||||
<string name="menu_settings">Einstellungen</string>
|
||||
<string name="menu_vpn_settings">Öffne Android VPN Einstellungen</string>
|
||||
<string name="menu_support">Hilfe</string>
|
||||
<string name="menu_about">Über</string>
|
||||
|
||||
|
@ -21,6 +18,9 @@ Das wird von Fehlern in Android oder in Software vom Hersteller verursacht. Bitt
|
|||
<string name="setting_dark">Verwende dunkles Theme</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Exportiere Einstellungen</string>
|
||||
<string name="setting_import">Importiere Einstellungen</string>
|
||||
<string name="setting_vpn">Öffne Android VPN Einstellungen</string>
|
||||
|
||||
<string name="msg_sure">Bist du sicher?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -8,10 +8,7 @@ Esto es causado por errores en Android, o por el software proporcionado por el f
|
|||
\n\nAl utilizar NetGuard, estás aceptando la <a href="http://www.gnu.org/licenses/gpl.txt">Licencia Pública GNU General Public versión 3</a></string>
|
||||
|
||||
<string name="menu_search">Buscar aplicación</string>
|
||||
<string name="menu_export">Exportar configuración</string>
|
||||
<string name="menu_import">Importar configuración</string>
|
||||
<string name="menu_settings">Configuración</string>
|
||||
<string name="menu_vpn_settings">Abrir configuración VPN de Android</string>
|
||||
<string name="menu_support">Soporte</string>
|
||||
<string name="menu_about">Acerca de</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ Esto es causado por errores en Android, o por el software proporcionado por el f
|
|||
<string name="setting_dark">Usar tema oscuro</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Exportar configuración</string>
|
||||
<string name="setting_import">Importar configuración</string>
|
||||
<string name="setting_vpn">Abrir configuración VPN de Android</string>
|
||||
|
||||
<string name="msg_sure">¿Estás seguro?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -8,10 +8,7 @@ Ceci est causé par des bugs dans Android, ou dans le logiciel fourni par le con
|
|||
\n\nEn utilisant NetGuard, vous acceptez la <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">Recherche application</string>
|
||||
<string name="menu_export">Exporter paramètres</string>
|
||||
<string name="menu_import">Importer paramètres</string>
|
||||
<string name="menu_settings">Paramètres</string>
|
||||
<string name="menu_vpn_settings">Ouvrir les paramètres VPN</string>
|
||||
<string name="menu_support">Support</string>
|
||||
<string name="menu_about">À propos</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ Ceci est causé par des bugs dans Android, ou dans le logiciel fourni par le con
|
|||
<string name="setting_dark">Utiliser le thème sombre</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Exporter paramètres</string>
|
||||
<string name="setting_import">Importer paramètres</string>
|
||||
<string name="setting_vpn">Ouvrir les paramètres VPN</string>
|
||||
|
||||
<string name="msg_sure">Etes-vous sûr ?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -9,10 +9,7 @@ Ció è causato da alcuni bug contenuti in Android, o in programmi forniti dal p
|
|||
</string>
|
||||
|
||||
<string name="menu_search">Cerca applicazione</string>
|
||||
<string name="menu_export">Esporta impostazioni</string>
|
||||
<string name="menu_import">Importa impostazioni</string>
|
||||
<string name="menu_settings">Impostazioni</string>
|
||||
<string name="menu_vpn_settings">Apri impostazioni VPN</string>
|
||||
<string name="menu_support">Supporto</string>
|
||||
<string name="menu_about">Info</string>
|
||||
|
||||
|
@ -23,6 +20,9 @@ Ció è causato da alcuni bug contenuti in Android, o in programmi forniti dal p
|
|||
<string name="setting_dark">Usa il tema scuro</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Esporta impostazioni</string>
|
||||
<string name="setting_import">Importa impostazioni</string>
|
||||
<string name="setting_vpn">Apri impostazioni VPN</string>
|
||||
|
||||
<string name="msg_sure">Sei sicuro?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -8,10 +8,7 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
\n\nBy using NetGuard, you agree to the <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">앱 검색</string>
|
||||
<string name="menu_export">Export settings</string>
|
||||
<string name="menu_import">Import settings</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_vpn_settings">Android VPN 설정 열기</string>
|
||||
<string name="menu_support">지원</string>
|
||||
<string name="menu_about">넷가드 정보</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
<string name="setting_dark">어두운 테마 사용</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Export settings</string>
|
||||
<string name="setting_import">Import settings</string>
|
||||
<string name="setting_vpn">Android VPN 설정 열기</string>
|
||||
|
||||
<string name="msg_sure">계속 하시겠습니까?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -8,10 +8,7 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
\n\nBy using NetGuard, you agree to the <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">Zoek naar applicatie</string>
|
||||
<string name="menu_export">Exporteer instellingen</string>
|
||||
<string name="menu_import">Importeer instellingen</string>
|
||||
<string name="menu_settings">Instellingen</string>
|
||||
<string name="menu_vpn_settings">Open Android VPN-instellingen</string>
|
||||
<string name="menu_support">Ondersteuning</string>
|
||||
<string name="menu_about">Over</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
<string name="setting_dark">Gebruik donker thema</string>
|
||||
<string name="setting_indicators">Toon staat indicatoren</string>
|
||||
<string name="setting_notification">Toon statusbalk notificatie</string>
|
||||
<string name="setting_export">Exporteer instellingen</string>
|
||||
<string name="setting_import">Importeer instellingen</string>
|
||||
<string name="setting_vpn">Open Android VPN-instellingen</string>
|
||||
|
||||
<string name="msg_sure">Weet u het zeker?</string>
|
||||
<string name="msg_started">Regels worden afgedwongen</string>
|
||||
|
|
|
@ -8,10 +8,7 @@ Acest lucru este cauzat de bug-uri in Android sau in software-ul pus la dispozit
|
|||
\n\nFolosind NetGuard, sunteti de acord cu <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">Cauta aplicatii</string>
|
||||
<string name="menu_export">Exporta setari</string>
|
||||
<string name="menu_import">Importa setari</string>
|
||||
<string name="menu_settings">Setari</string>
|
||||
<string name="menu_vpn_settings">Deschide setari VPN Android</string>
|
||||
<string name="menu_support">Asistenta</string>
|
||||
<string name="menu_about">Despre</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ Acest lucru este cauzat de bug-uri in Android sau in software-ul pus la dispozit
|
|||
<string name="setting_dark">Foloseste tema intunecata</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Exporta setari</string>
|
||||
<string name="setting_import">Importa setari</string>
|
||||
<string name="setting_vpn">Deschide setari VPN Android</string>
|
||||
|
||||
<string name="msg_sure">Esti sigur?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -8,10 +8,7 @@ Je to spôsobené chybami v Androide alebo v softvéri poskytovanom výrobcom, p
|
|||
\n\nPoužívaním aplikácie NetGuard súhlasíte so <a href="http://www.gnu.org/licenses/gpl.txt">Všeobecnou verejnou licenciou GNU, verzia 3</a></string>
|
||||
|
||||
<string name="menu_search">Hľadať aplikáciu</string>
|
||||
<string name="menu_export">Exportovať nastavenia</string>
|
||||
<string name="menu_import">Importovať nastavenia</string>
|
||||
<string name="menu_settings">Nastavenia</string>
|
||||
<string name="menu_vpn_settings">Otvoriť nastavenia VPN</string>
|
||||
<string name="menu_support">Podpora</string>
|
||||
<string name="menu_about">O aplikácii</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@ Je to spôsobené chybami v Androide alebo v softvéri poskytovanom výrobcom, p
|
|||
<string name="setting_dark">Použiť tmavú tému</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Exportovať nastavenia</string>
|
||||
<string name="setting_import">Importovať nastavenia</string>
|
||||
<string name="setting_vpn">Otvoriť nastavenia VPN</string>
|
||||
|
||||
<string name="msg_sure">Ste si istý?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -8,10 +8,7 @@
|
|||
\n\n使用NetGuard即表明您接受 <a href="http://www.gnu.org/licenses/gpl.txt">GNU通用公共许可协议第三版</a></string>
|
||||
|
||||
<string name="menu_search">搜索应用</string>
|
||||
<string name="menu_export">导出设置</string>
|
||||
<string name="menu_import">导入设置</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_vpn_settings">打开安卓VPN设置</string>
|
||||
<string name="menu_support">软件支持</string>
|
||||
<string name="menu_about">关于</string>
|
||||
|
||||
|
@ -22,6 +19,9 @@
|
|||
<string name="setting_dark">使用暗色主题</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">导出设置</string>
|
||||
<string name="setting_import">导入设置</string>
|
||||
<string name="setting_vpn">打开安卓VPN设置</string>
|
||||
|
||||
<string name="msg_sure">是否确认?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -9,10 +9,7 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
\n\nBy using NetGuard, you agree to the <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License version 3</a></string>
|
||||
|
||||
<string name="menu_search">Search for application</string>
|
||||
<string name="menu_export">Export settings</string>
|
||||
<string name="menu_import">Import settings</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_vpn_settings">Open Android VPN settings</string>
|
||||
<string name="menu_support">Support</string>
|
||||
<string name="menu_about">About</string>
|
||||
|
||||
|
@ -23,6 +20,9 @@ This is caused by bugs in Android, or in the software provided by the manufactur
|
|||
<string name="setting_dark">Use dark theme</string>
|
||||
<string name="setting_indicators">Show state indicators</string>
|
||||
<string name="setting_notification">Show status bar notification</string>
|
||||
<string name="setting_export">Export settings</string>
|
||||
<string name="setting_import">Import settings</string>
|
||||
<string name="setting_vpn">Open Android VPN settings</string>
|
||||
|
||||
<string name="msg_sure">Are you sure?</string>
|
||||
<string name="msg_started">Enforcing rules</string>
|
||||
|
|
|
@ -28,4 +28,13 @@
|
|||
android:defaultValue="false"
|
||||
android:key="notification"
|
||||
android:title="@string/setting_notification" />
|
||||
<Preference
|
||||
android:key="export"
|
||||
android:title="@string/setting_export" />
|
||||
<Preference
|
||||
android:key="import"
|
||||
android:title="@string/setting_import" />
|
||||
<Preference
|
||||
android:key="vpn"
|
||||
android:title="@string/setting_vpn" />
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Add table
Reference in a new issue