mirror of https://github.com/M66B/NetGuard.git
parent
e0e2ae47d8
commit
a9e14fdbed
|
@ -340,7 +340,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
TextView tvFirst = (TextView) view.findViewById(R.id.tvFirst);
|
||||
TextView tvSubmit = (TextView) view.findViewById(R.id.tvSubmit);
|
||||
tvFirst.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
tvSubmit.setVisibility(Util.canSubmit(false, this) ? View.VISIBLE : View.GONE);
|
||||
tvSubmit.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? View.VISIBLE : View.GONE);
|
||||
|
||||
// Show dialog
|
||||
dialogFirst = new AlertDialog.Builder(this)
|
||||
|
@ -582,9 +582,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
|
||||
} else if ("theme".equals(name) || "dark_theme".equals(name))
|
||||
recreate();
|
||||
|
||||
else if ("submit".equals(name))
|
||||
updateApplicationList(null);
|
||||
}
|
||||
|
||||
private DatabaseHelper.AccessChangedListener accessChangedListener = new DatabaseHelper.AccessChangedListener() {
|
||||
|
|
|
@ -95,21 +95,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_THEME, null, filter);
|
||||
Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_PRO1, null, filter);
|
||||
|
||||
// Submit
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
CheckBox cbSubmit = (CheckBox) findViewById(R.id.cbSubmit);
|
||||
cbSubmit.setChecked(prefs.getBoolean("submit", true));
|
||||
cbSubmit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton button, boolean isChecked) {
|
||||
prefs.edit().putBoolean("submit", isChecked).apply();
|
||||
ServiceSinkhole.reload("submit changed", ActivityPro.this);
|
||||
if (!isChecked && Util.canSubmit(false, ActivityPro.this))
|
||||
ServiceJob.cancelAll(ActivityPro.this);
|
||||
}
|
||||
});
|
||||
cbSubmit.setVisibility(View.GONE);
|
||||
|
||||
// Challenge
|
||||
TextView tvChallenge = (TextView) findViewById(R.id.tvChallenge);
|
||||
tvChallenge.setText(Build.SERIAL);
|
||||
|
@ -289,8 +274,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
|
||||
tvAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.VISIBLE : View.GONE);
|
||||
|
||||
cbSubmit.setEnabled(IAB.isPurchasedAny(this));
|
||||
|
||||
llChallenge.setVisibility(
|
||||
IAB.isPurchased(SKU_DONATION, this) || Util.isPlayStoreInstall(this)
|
||||
? View.GONE : View.VISIBLE);
|
||||
|
|
|
@ -1283,9 +1283,6 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
|||
} else if ("show_stats".equals(key)) {
|
||||
if (!IAB.isPurchased(ActivityPro.SKU_SPEED, context))
|
||||
return;
|
||||
} else if ("submit".equals(key)) {
|
||||
if (!IAB.isPurchasedAny(context))
|
||||
return;
|
||||
}
|
||||
|
||||
if ("hosts_last_import".equals(key) || "hosts_last_download".equals(key))
|
||||
|
|
|
@ -128,6 +128,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
public TextView tvNoLog;
|
||||
public TextView tvNoFilter;
|
||||
public CheckBox cbNotify;
|
||||
public CheckBox cbSubmit;
|
||||
public ImageButton btnClearAccess;
|
||||
public TextView tvStatistics;
|
||||
|
||||
|
@ -176,6 +177,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
tvNoLog = (TextView) itemView.findViewById(R.id.tvNoLog);
|
||||
tvNoFilter = (TextView) itemView.findViewById(R.id.tvNoFilter);
|
||||
cbNotify = (CheckBox) itemView.findViewById(R.id.cbNotify);
|
||||
cbSubmit = (CheckBox) itemView.findViewById(R.id.cbSubmit);
|
||||
btnClearAccess = (ImageButton) itemView.findViewById(R.id.btnClearAccess);
|
||||
tvStatistics = (TextView) itemView.findViewById(R.id.tvStatistics);
|
||||
|
||||
|
@ -401,9 +403,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
holder.tvInternet.setVisibility(rule.internet ? View.GONE : View.VISIBLE);
|
||||
|
||||
// Apply
|
||||
boolean submit = (rule.info.applicationInfo.uid == Process.myUid() && prefs.getBoolean("submit", true));
|
||||
holder.cbApply.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? View.GONE : View.VISIBLE);
|
||||
holder.cbApply.setEnabled(rule.pkg && !submit);
|
||||
holder.cbApply.setEnabled(rule.pkg);
|
||||
holder.cbApply.setOnCheckedChangeListener(null);
|
||||
holder.cbApply.setChecked(rule.apply);
|
||||
holder.cbApply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
@ -501,7 +501,6 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
});
|
||||
|
||||
// Reset rule
|
||||
holder.btnClear.setEnabled(!submit);
|
||||
holder.btnClear.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -597,7 +596,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
if (IAB.isPurchased(ActivityPro.SKU_FILTER, context)) {
|
||||
DatabaseHelper.getInstance(context).setAccess(id, 0);
|
||||
ServiceSinkhole.reload("allow host", context);
|
||||
if (Util.canSubmit(true, context))
|
||||
if (rule.submit)
|
||||
ServiceJob.submit(rule, version, protocol, daddr, dport, 0, context);
|
||||
} else
|
||||
context.startActivity(new Intent(context, ActivityPro.class));
|
||||
|
@ -607,7 +606,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
if (IAB.isPurchased(ActivityPro.SKU_FILTER, context)) {
|
||||
DatabaseHelper.getInstance(context).setAccess(id, 1);
|
||||
ServiceSinkhole.reload("block host", context);
|
||||
if (Util.canSubmit(true, context))
|
||||
if (rule.submit)
|
||||
ServiceJob.submit(rule, version, protocol, daddr, dport, 1, context);
|
||||
} else
|
||||
context.startActivity(new Intent(context, ActivityPro.class));
|
||||
|
@ -616,7 +615,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
case R.id.menu_reset:
|
||||
DatabaseHelper.getInstance(context).setAccess(id, -1);
|
||||
ServiceSinkhole.reload("reset host", context);
|
||||
if (Util.canSubmit(true, context))
|
||||
if (rule.submit)
|
||||
ServiceJob.submit(rule, version, protocol, daddr, dport, -1, context);
|
||||
return true;
|
||||
}
|
||||
|
@ -639,7 +638,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
holder.lvAccess.setOnItemClickListener(null);
|
||||
}
|
||||
|
||||
// Show disable access notifications setting
|
||||
// Notify on access
|
||||
holder.cbNotify.setOnCheckedChangeListener(null);
|
||||
holder.cbNotify.setEnabled(prefs.getBoolean("notify_access", false) && rule.apply);
|
||||
holder.cbNotify.setChecked(rule.notify);
|
||||
|
@ -651,6 +650,18 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
}
|
||||
});
|
||||
|
||||
// Usage data sharing
|
||||
holder.cbSubmit.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? View.VISIBLE : View.GONE);
|
||||
holder.cbSubmit.setOnCheckedChangeListener(null);
|
||||
holder.cbSubmit.setChecked(rule.submit);
|
||||
holder.cbSubmit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
rule.submit = isChecked;
|
||||
updateRule(rule, true, listAll);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear access log
|
||||
holder.btnClearAccess.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -678,6 +689,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
SharedPreferences screen_other = context.getSharedPreferences("screen_other", Context.MODE_PRIVATE);
|
||||
SharedPreferences roaming = context.getSharedPreferences("roaming", Context.MODE_PRIVATE);
|
||||
SharedPreferences notify = context.getSharedPreferences("notify", Context.MODE_PRIVATE);
|
||||
SharedPreferences submit = context.getSharedPreferences("submit", Context.MODE_PRIVATE);
|
||||
SharedPreferences history = context.getSharedPreferences("history", Context.MODE_PRIVATE);
|
||||
|
||||
if (rule.wifi_blocked == rule.wifi_default)
|
||||
|
@ -715,6 +727,11 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
else
|
||||
notify.edit().putBoolean(rule.info.packageName, rule.notify).apply();
|
||||
|
||||
if (rule.submit)
|
||||
submit.edit().remove(rule.info.packageName).apply();
|
||||
else
|
||||
submit.edit().putBoolean(rule.info.packageName, rule.submit).apply();
|
||||
|
||||
rule.last_modified = new Date().getTime();
|
||||
history.edit().putLong(rule.info.packageName + ":modified", rule.last_modified).apply();
|
||||
|
||||
|
@ -749,7 +766,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
ServiceSinkhole.reload("rule changed", context);
|
||||
}
|
||||
|
||||
if (Util.canSubmit(true, context))
|
||||
if (rule.submit)
|
||||
ServiceJob.submit(rule, context);
|
||||
}
|
||||
|
||||
|
|
|
@ -178,14 +178,6 @@ public class IAB implements ServiceConnection {
|
|||
prefs.getBoolean(ActivityPro.SKU_DONATION, false));
|
||||
}
|
||||
|
||||
public static boolean isPurchasedAny(Context context) {
|
||||
return isPurchased(ActivityPro.SKU_LOG, context) ||
|
||||
isPurchased(ActivityPro.SKU_FILTER, context) ||
|
||||
isPurchased(ActivityPro.SKU_NOTIFY, context) ||
|
||||
isPurchased(ActivityPro.SKU_SPEED, context) ||
|
||||
isPurchased(ActivityPro.SKU_THEME, context);
|
||||
}
|
||||
|
||||
public static String getResult(int responseCode) {
|
||||
switch (responseCode) {
|
||||
case 0:
|
||||
|
|
|
@ -239,9 +239,6 @@ public class Receiver extends BroadcastReceiver {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
editor.putBoolean("filter", true); // Mandatory
|
||||
|
||||
if (oldVersion > 2016071301)
|
||||
editor.remove("submit");
|
||||
|
||||
editor.putInt("version", newVersion);
|
||||
editor.apply();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public class Rule {
|
|||
|
||||
public boolean apply = true;
|
||||
public boolean notify = true;
|
||||
public boolean submit = true;
|
||||
|
||||
public boolean relateduids = false;
|
||||
public String[] related = null;
|
||||
|
@ -224,6 +225,7 @@ public class Rule {
|
|||
SharedPreferences roaming = context.getSharedPreferences("roaming", Context.MODE_PRIVATE);
|
||||
SharedPreferences apply = context.getSharedPreferences("apply", Context.MODE_PRIVATE);
|
||||
SharedPreferences notify = context.getSharedPreferences("notify", Context.MODE_PRIVATE);
|
||||
SharedPreferences submit = context.getSharedPreferences("submit", Context.MODE_PRIVATE);
|
||||
SharedPreferences history = context.getSharedPreferences("history", Context.MODE_PRIVATE);
|
||||
|
||||
// Get settings
|
||||
|
@ -237,7 +239,6 @@ public class Rule {
|
|||
boolean show_system = prefs.getBoolean("show_system", false);
|
||||
boolean show_nointernet = prefs.getBoolean("show_nointernet", true);
|
||||
boolean show_disabled = prefs.getBoolean("show_disabled", true);
|
||||
boolean submit = prefs.getBoolean("submit", true);
|
||||
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
|
||||
|
@ -342,11 +343,12 @@ public class Rule {
|
|||
rule.screen_other = screen_other.getBoolean(info.packageName, rule.screen_other_default);
|
||||
rule.roaming = roaming.getBoolean(info.packageName, rule.roaming_default);
|
||||
|
||||
if (info.applicationInfo.uid == Process.myUid() && submit)
|
||||
rule.apply = false;
|
||||
else
|
||||
rule.apply = apply.getBoolean(info.packageName, true);
|
||||
rule.apply = apply.getBoolean(info.packageName, true);
|
||||
rule.notify = notify.getBoolean(info.packageName, true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
rule.submit = submit.getBoolean(info.packageName, true);
|
||||
else
|
||||
rule.submit = false;
|
||||
|
||||
rule.last_modified = history.getLong(info.packageName + ":modified", 0);
|
||||
rule.last_submitted = history.getLong(info.packageName + ":submitted", 0);
|
||||
|
|
|
@ -406,11 +406,6 @@ public class Util {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean canSubmit(boolean submit, Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return ((!submit || prefs.getBoolean("submit", true)) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
|
||||
}
|
||||
|
||||
public static void setTheme(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean dark = prefs.getBoolean("dark_theme", false);
|
||||
|
|
|
@ -246,16 +246,6 @@
|
|||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSubmit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:checked="true"
|
||||
android:enabled="false"
|
||||
android:text="@string/title_pro_submit"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llChallenge"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -387,6 +387,14 @@
|
|||
android:text="@string/title_notify"
|
||||
android:textAppearance="@style/TextSmall" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSubmit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/title_submit"
|
||||
android:textAppearance="@style/TextSmall" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnClearAccess"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -220,6 +220,7 @@ Your internet traffic is not being sent to a remote VPN server.</string>
|
|||
<string name="title_mediaserver">mediaserver</string>
|
||||
<string name="title_nobody">nobody</string>
|
||||
<string name="title_notify">Notify internet access attempts</string>
|
||||
<string name="title_submit">Share anonymized usage data</string>
|
||||
<string name="title_dontask">Don\'t ask again</string>
|
||||
|
||||
<string name="title_log_whois">Whois %1$s</string>
|
||||
|
@ -233,7 +234,6 @@ Your internet traffic is not being sent to a remote VPN server.</string>
|
|||
<string name="title_pro_speed">Network speed graph notification</string>
|
||||
<string name="title_pro_theme">Appearance (theme, colors)</string>
|
||||
<string name="title_pro_all">All above pro features</string>
|
||||
<string name="title_pro_submit">Share anonymized usage data to improve NetGuard</string>
|
||||
<string name="title_pro_buy">Details</string>
|
||||
<string name="title_pro_bought">Enabled</string>
|
||||
<string name="title_pro_challenge">Challenge</string>
|
||||
|
|
Loading…
Reference in New Issue