NetGuard v2.328版本的 MD5 值为:4adaa6f0accf8a6a5ab62c36e5a5d3f8
以下内容为反编译后的 ActivityMain.java 源代码,内容仅作参考
package eu.faircode.netguard;
import A.e;
import B.b;
import K0.r;
import android.content.BroadcastReceiver;
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.Configuration;
import android.net.Uri;
import android.net.VpnService;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ImageSpan;
import android.text.style.UnderlineSpan;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActivityC0095q;
import androidx.appcompat.app.C0091m;
import androidx.appcompat.app.DialogInterfaceC0092n;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.app.C0120c;
import androidx.core.content.f;
import androidx.core.text.d;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import eu.faircode.netguard.DatabaseHelper;
import eu.faircode.netguard.DownloadTask;
import eu.faircode.netguard.IAB;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import t.C0496d;
public class ActivityMain extends ActivityC0095q implements SharedPreferences.OnSharedPreferenceChangeListener {
private ImageView ivIcon;
private ImageView ivMetered;
private ImageView ivQueue;
private SwitchCompat swEnabled;
private SwipeRefreshLayout swipeRefresh;
private boolean running = false;
private AdapterRule adapter = null;
private MenuItem menuSearch = null;
private DialogInterfaceC0092n dialogFirst = null;
private DialogInterfaceC0092n dialogVpn = null;
private DialogInterfaceC0092n dialogDoze = null;
private DialogInterfaceC0092n dialogLegend = null;
private DialogInterfaceC0092n dialogAbout = null;
private IAB iab = null;
private DatabaseHelper.AccessChangedListener accessChangedListener = new DatabaseHelper.AccessChangedListener() {
@Override
public void onChanged() {
ActivityMain.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if (ActivityMain.this.adapter == null || !ActivityMain.this.adapter.isLive()) {
return;
}
ActivityMain.this.adapter.notifyDataSetChanged();
}
});
}
};
private BroadcastReceiver onRulesChanged = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("NetGuard.Main", "Received " + intent);
Util.logExtras(intent);
if (ActivityMain.this.adapter != null) {
if (intent.hasExtra("Connected") && intent.hasExtra("Metered")) {
ActivityMain.this.ivIcon.setImageResource(Util.isNetworkActive(ActivityMain.this) ? R.drawable.ic_security_white_24dp : R.drawable.ic_security_white_24dp_60);
if (intent.getBooleanExtra("Connected", false)) {
if (intent.getBooleanExtra("Metered", false)) {
ActivityMain.this.adapter.setMobileActive();
} else {
ActivityMain.this.adapter.setWifiActive();
}
ActivityMain.this.ivMetered.setVisibility(Util.isMeteredNetwork(ActivityMain.this) ? 0 : 4);
} else {
ActivityMain.this.adapter.setDisconnected();
ActivityMain.this.ivMetered.setVisibility(4);
}
} else {
ActivityMain.this.updateApplicationList(null);
}
}
}
};
private BroadcastReceiver onQueueChanged = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int i2;
Log.i("NetGuard.Main", "Received " + intent);
Util.logExtras(intent);
int intExtra = intent.getIntExtra("Size", -1);
ImageView imageView = ActivityMain.this.ivIcon;
if (intExtra == 0) {
i2 = 0;
boolean z2 = true;
} else {
i2 = 8;
}
imageView.setVisibility(i2);
ActivityMain.this.ivQueue.setVisibility(intExtra == 0 ? 8 : 0);
}
};
private BroadcastReceiver packageChangedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("NetGuard.Main", "Received " + intent);
Util.logExtras(intent);
ActivityMain.this.updateApplicationList(null);
}
};
public void checkDataSaving() {
if (Build.VERSION.SDK_INT >= 24) {
final Intent intent = new Intent("android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS", Uri.parse("package:" + getPackageName()));
if (Util.dataSaving(this) && getPackageManager().resolveActivity(intent, 0) != null) {
try {
final SharedPreferences f = b.f(this);
if (!f.getBoolean("nodata", false)) {
View inflate = LayoutInflater.from(this).inflate(R.layout.datasaving, (ViewGroup) null, false);
final CheckBox checkBox = (CheckBox) inflate.findViewById(R.id.cbDontAsk);
C0091m c0091m = new C0091m(this);
c0091m.m(inflate);
c0091m.d(true);
c0091m.j(17039379, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
f.edit().putBoolean("nodata", checkBox.isChecked()).apply();
ActivityMain.this.startActivity(intent);
}
});
c0091m.g(17039369, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
f.edit().putBoolean("nodata", checkBox.isChecked()).apply();
}
});
c0091m.h(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
ActivityMain.this.dialogDoze = null;
}
});
DialogInterfaceC0092n a2 = c0091m.a();
this.dialogDoze = a2;
a2.show();
}
} catch (Throwable th) {
Log.e("NetGuard.Main", th + "\n" + th.getStackTrace());
}
}
}
}
private void checkDoze() {
if (Build.VERSION.SDK_INT >= 23) {
final Intent intent = new Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS");
if (!Util.batteryOptimizing(this) || getPackageManager().resolveActivity(intent, 0) == null) {
checkDataSaving();
} else {
final SharedPreferences f = b.f(this);
if (f.getBoolean("nodoze", false)) {
checkDataSaving();
} else {
View inflate = LayoutInflater.from(this).inflate(R.layout.doze, (ViewGroup) null, false);
final CheckBox checkBox = (CheckBox) inflate.findViewById(R.id.cbDontAsk);
C0091m c0091m = new C0091m(this);
c0091m.m(inflate);
c0091m.d(true);
c0091m.j(17039379, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
f.edit().putBoolean("nodoze", checkBox.isChecked()).apply();
ActivityMain.this.startActivity(intent);
}
});
c0091m.g(17039369, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
f.edit().putBoolean("nodoze", checkBox.isChecked()).apply();
}
});
c0091m.h(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
ActivityMain.this.dialogDoze = null;
ActivityMain.this.checkDataSaving();
}
});
DialogInterfaceC0092n a2 = c0091m.a();
this.dialogDoze = a2;
a2.show();
}
}
}
}
private void checkExtras(Intent intent) {
if (intent.hasExtra("Approve")) {
Log.i("NetGuard.Main", "Requesting VPN approval");
this.swEnabled.toggle();
}
}
private static Intent getIntentApps(Context context) {
return new Intent("android.intent.action.VIEW", Uri.parse("https://4pda.to/forum/index.php?showuser=8471279"));
}
private static Intent getIntentInvite(Context context) {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("text/plain");
intent.putExtra("android.intent.extra.SUBJECT", context.getString(R.string.app_name));
intent.putExtra("android.intent.extra.TEXT", context.getString(R.string.msg_try) + "\n\nhttps://www.netguard.me/\n\n");
return intent;
}
public static Intent getIntentPro(Context context) {
if (Util.isPlayStoreInstall(context)) {
return new Intent(context, ActivityPro.class);
}
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse("https://contact.faircode.eu/?product=netguardstandalone"));
return intent;
}
public static Intent getIntentRate(Context context) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=" + context.getPackageName()));
if (intent.resolveActivity(context.getPackageManager()) == null) {
intent = new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=" + context.getPackageName()));
}
return intent;
}
private static Intent getIntentSupport() {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse("https://github.com/M66B/NetGuard/blob/master/FAQ.md"));
return intent;
}
private void markPro(MenuItem menuItem, String str) {
if (str == null || !IAB.isPurchased(str, this)) {
boolean z2 = b.f(this).getBoolean("dark_theme", false);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(" " + ((Object) menuItem.getTitle()));
spannableStringBuilder.setSpan(new ImageSpan(this, z2 ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, 33);
menuItem.setTitle(spannableStringBuilder);
}
}
public void menu_about() {
View inflate = LayoutInflater.from(this).inflate(R.layout.about, (ViewGroup) null, false);
TextView textView = (TextView) inflate.findViewById(R.id.tvVersionName);
TextView textView2 = (TextView) inflate.findViewById(R.id.tvVersionCode);
Button button = (Button) inflate.findViewById(R.id.btnRate);
TextView textView3 = (TextView) inflate.findViewById(R.id.tvEula);
TextView textView4 = (TextView) inflate.findViewById(R.id.tvPrivacy);
textView.setText(Util.getSelfVersionName(this));
if (!Util.hasValidFingerprint(this)) {
textView.setTextColor(-7829368);
}
textView2.setText(Integer.toString(Util.getSelfVersionCode(this)));
textView3.setMovementMethod(LinkMovementMethod.getInstance());
textView4.setMovementMethod(LinkMovementMethod.getInstance());
button.setVisibility(getIntentRate(this).resolveActivity(getPackageManager()) == null ? 8 : 0);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActivityMain activityMain = ActivityMain.this;
activityMain.startActivity(ActivityMain.getIntentRate(activityMain));
}
});
C0091m c0091m = new C0091m(this);
c0091m.m(inflate);
c0091m.d(true);
c0091m.h(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
ActivityMain.this.dialogAbout = null;
}
});
DialogInterfaceC0092n a2 = c0091m.a();
this.dialogAbout = a2;
a2.show();
}
private void menu_apps() {
startActivity(getIntentApps(this));
}
private void menu_legend() {
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.colorOn, typedValue, true);
getTheme().resolveAttribute(R.attr.colorOff, typedValue, true);
View inflate = LayoutInflater.from(this).inflate(R.layout.legend, (ViewGroup) null, false);
ImageView imageView = (ImageView) inflate.findViewById(R.id.ivLockdownOn);
ImageView imageView2 = (ImageView) inflate.findViewById(R.id.ivWifiOn);
ImageView imageView3 = (ImageView) inflate.findViewById(R.id.ivWifiOff);
ImageView imageView4 = (ImageView) inflate.findViewById(R.id.ivOtherOn);
ImageView imageView5 = (ImageView) inflate.findViewById(R.id.ivOtherOff);
ImageView imageView6 = (ImageView) inflate.findViewById(R.id.ivScreenOn);
ImageView imageView7 = (ImageView) inflate.findViewById(R.id.ivHostAllowed);
ImageView imageView8 = (ImageView) inflate.findViewById(R.id.ivHostBlocked);
C0091m c0091m = new C0091m(this);
c0091m.m(inflate);
c0091m.d(true);
c0091m.h(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
ActivityMain.this.dialogLegend = null;
}
});
DialogInterfaceC0092n a2 = c0091m.a();
this.dialogLegend = a2;
a2.show();
}
private void menu_lockdown(MenuItem menuItem) {
menuItem.setChecked(!menuItem.isChecked());
b.f(this).edit().putBoolean("lockdown", menuItem.isChecked()).apply();
ServiceSinkhole.reload("lockdown", this, false);
WidgetLockdown.updateWidgets(this);
}
private void menu_malware(MenuItem menuItem) {
menuItem.setChecked(!menuItem.isChecked());
final SharedPreferences f = b.f(this);
f.edit().putBoolean("malware", menuItem.isChecked()).apply();
if (menuItem.isChecked()) {
try {
new DownloadTask(this, new URL("https://urlhaus.abuse.ch/downloads/hostfile/"), new File(getFilesDir(), "malware.txt"), new DownloadTask.Listener() {
@Override
public void onCancelled() {
d.d(f, "malware", false);
}
@Override
public void onCompleted() {
d.d(f, "filter", true);
ServiceSinkhole.reload("malware download", ActivityMain.this, false);
}
@Override
public void onException(Throwable th) {
Toast.makeText(ActivityMain.this, th.getMessage(), 1).show();
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
return;
} catch (MalformedURLException e2) {
Toast.makeText(this, e2.toString(), 1).show();
return;
}
}
SharedPreferences.Editor edit = f.edit();
for (String str : f.getAll().keySet()) {
if (str.startsWith("malware.")) {
edit.remove(str);
}
}
edit.apply();
}
public void showHints() {
final SharedPreferences f = b.f(this);
boolean z2 = f.getBoolean("hint_usage", true);
final LinearLayout linearLayout = (LinearLayout) findViewById(R.id.llWhitelist);
Button button = (Button) findViewById(R.id.btnWhitelist);
int i2 = 0;
boolean z3 = true;
linearLayout.setVisibility((f.getBoolean("whitelist_wifi", false) || f.getBoolean("whitelist_other", false) || !f.getBoolean("hint_whitelist", true) || z2) ? 8 : 0);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
d.d(f, "hint_whitelist", false);
linearLayout.setVisibility(8);
}
});
final LinearLayout linearLayout2 = (LinearLayout) findViewById(R.id.llPush);
Button button2 = (Button) findViewById(R.id.btnPush);
linearLayout2.setVisibility((!f.getBoolean("hint_push", true) || z2) ? 8 : 0);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
d.d(f, "hint_push", false);
linearLayout2.setVisibility(8);
}
});
final LinearLayout linearLayout3 = (LinearLayout) findViewById(R.id.llSystem);
Button button3 = (Button) findViewById(R.id.btnSystem);
boolean z4 = f.getBoolean("manage_system", false);
boolean z5 = f.getBoolean("hint_system", true);
if (z4 || !z5) {
i2 = 8;
}
linearLayout3.setVisibility(i2);
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
d.d(f, "hint_system", false);
linearLayout3.setVisibility(8);
}
});
}
public void updateApplicationList(final String str) {
Log.i("NetGuard.Main", "Update search=" + str);
new AsyncTask() {
private boolean refreshing = true;
@Override
public List doInBackground(Object... objArr) {
return Rule.getRules(false, ActivityMain.this);
}
@Override
public void onPostExecute(List list) {
if (ActivityMain.this.running) {
if (ActivityMain.this.adapter != null) {
ActivityMain.this.adapter.set(list);
ActivityMain.this.updateSearch(str);
}
if (ActivityMain.this.swipeRefresh != null) {
this.refreshing = false;
ActivityMain.this.swipeRefresh.j(false);
}
}
}
@Override
protected void onPreExecute() {
ActivityMain.this.swipeRefresh.post(new Runnable() {
@Override
public void run() {
if (AnonymousClass25.this.refreshing) {
boolean z2 = !true;
ActivityMain.this.swipeRefresh.j(true);
}
}
});
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
}
public void updateSearch(String str) {
MenuItem menuItem = this.menuSearch;
if (menuItem != null) {
SearchView searchView = (SearchView) menuItem.getActionView();
if (str != null) {
this.menuSearch.expandActionView();
searchView.setQuery(str, true);
} else if (this.menuSearch.isActionViewExpanded()) {
this.adapter.getFilter().filter(searchView.getQuery().toString());
}
}
}
@Override
public void onActivityResult(int i2, int i3, Intent intent) {
boolean z2;
StringBuilder sb = new StringBuilder("onActivityResult request=");
sb.append(i2);
sb.append(" result=");
sb.append(i2);
sb.append(" ok=");
sb.append(i3 == -1);
Log.i("NetGuard.Main", sb.toString());
Util.logExtras(intent);
if (i2 == 1) {
SharedPreferences.Editor edit = b.f(this).edit();
if (i3 == -1) {
z2 = true;
int i4 = 3 >> 1;
} else {
z2 = false;
}
edit.putBoolean("enabled", z2).apply();
if (i3 == -1) {
ServiceSinkhole.start("prepared", this);
Toast makeText = Toast.makeText(this, (int) R.string.msg_on, 1);
makeText.setGravity(17, 0, 0);
makeText.show();
checkDoze();
} else if (i3 == 0) {
Toast.makeText(this, (int) R.string.msg_vpn_cancelled, 1).show();
}
} else if (i2 != 2) {
Log.w("NetGuard.Main", "Unknown activity result request=" + i2);
super.onActivityResult(i2, i3, intent);
}
}
@Override
public void onConfigurationChanged(Configuration configuration) {
Log.i("NetGuard.Main", "Config");
super.onConfigurationChanged(configuration);
Util.hasXposed(this);
}
@Override
public void onCreate(Bundle bundle) {
Log.i("NetGuard.Main", "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this));
Util.logExtras(getIntent());
int i2 = Build.VERSION.SDK_INT;
if (Util.hasXposed(this)) {
Log.i("NetGuard.Main", "Xposed running");
super.onCreate(bundle);
setContentView(R.layout.xposed);
return;
}
Util.setTheme(this);
super.onCreate(bundle);
setContentView(R.layout.main);
this.running = true;
final SharedPreferences f = b.f(this);
int i3 = 2 << 0;
boolean z2 = f.getBoolean("enabled", false);
boolean z3 = f.getBoolean("initialized", false);
ReceiverAutostart.upgrade(z3, this);
if (!getIntent().hasExtra("Approve")) {
if (z2) {
ServiceSinkhole.start("UI", this);
} else {
ServiceSinkhole.stop("UI", this, false);
}
}
final View inflate = getLayoutInflater().inflate(R.layout.actionmain, (ViewGroup) null, false);
this.ivIcon = (ImageView) inflate.findViewById(R.id.ivIcon);
this.ivQueue = (ImageView) inflate.findViewById(R.id.ivQueue);
this.swEnabled = (SwitchCompat) inflate.findViewById(R.id.swEnabled);
this.ivMetered = (ImageView) inflate.findViewById(R.id.ivMetered);
this.ivIcon.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
ActivityMain.this.menu_about();
return true;
}
});
getSupportActionBar().f(null);
this.ivQueue.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
int[] iArr = new int[2];
inflate.getLocationOnScreen(iArr);
Toast makeText = Toast.makeText(ActivityMain.this, (int) R.string.msg_queue, 1);
makeText.setGravity(51, ActivityMain.this.ivQueue.getLeft() + iArr[0], Math.round((ActivityMain.this.ivQueue.getBottom() + iArr[1]) - makeText.getView().getPaddingTop()));
makeText.show();
return true;
}
});
this.swEnabled.setChecked(z2);
this.swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z4) {
Log.i("NetGuard.Main", "Switch=" + z4);
d.d(f, "enabled", z4);
if (z4) {
try {
String string = Settings.Secure.getString(ActivityMain.this.getContentResolver(), "always_on_vpn_app");
Log.i("NetGuard.Main", "Always-on=" + string);
if (!TextUtils.isEmpty(string)) {
if (!ActivityMain.this.getPackageName().equals(string)) {
ActivityMain.this.swEnabled.setChecked(false);
Toast.makeText(ActivityMain.this, (int) R.string.msg_always_on, 1).show();
return;
} else if (Build.VERSION.SDK_INT < 29 && f.getBoolean("filter", false)) {
int i4 = Settings.Secure.getInt(ActivityMain.this.getContentResolver(), "always_on_vpn_lockdown", 0);
Log.i("NetGuard.Main", "Lockdown=" + i4);
if (i4 != 0) {
ActivityMain.this.swEnabled.setChecked(false);
Toast.makeText(ActivityMain.this, (int) R.string.msg_always_on_lockdown, 1).show();
return;
}
}
}
} catch (Throwable th) {
r.h(th, new StringBuilder(), "\n", th, "NetGuard.Main");
}
if (f.getBoolean("filter", false) && Util.isPrivateDns(ActivityMain.this)) {
Toast.makeText(ActivityMain.this, (int) R.string.msg_private_dns, 1).show();
}
try {
final Intent prepare = VpnService.prepare(ActivityMain.this);
if (prepare == null) {
Log.i("NetGuard.Main", "Prepare done");
ActivityMain.this.onActivityResult(1, -1, null);
} else {
View inflate2 = LayoutInflater.from(ActivityMain.this).inflate(R.layout.vpn, (ViewGroup) null, false);
ActivityMain activityMain = ActivityMain.this;
C0091m c0091m = new C0091m(activityMain);
c0091m.m(inflate2);
c0091m.d(false);
c0091m.j(17039379, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i5) {
if (ActivityMain.this.running) {
Log.i("NetGuard.Main", "Start intent=" + prepare);
try {
ActivityMain.this.startActivityForResult(prepare, 1);
} catch (Throwable th2) {
r.h(th2, new StringBuilder(), "\n", th2, "NetGuard.Main");
ActivityMain.this.onActivityResult(1, 0, null);
d.d(f, "enabled", false);
}
}
}
});
c0091m.h(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
boolean z5 = false | false;
ActivityMain.this.dialogVpn = null;
}
});
activityMain.dialogVpn = c0091m.a();
ActivityMain.this.dialogVpn.show();
}
} catch (Throwable th2) {
r.h(th2, new StringBuilder(), "\n", th2, "NetGuard.Main");
d.d(f, "enabled", false);
}
} else {
ServiceSinkhole.stop("switch off", ActivityMain.this, false);
}
}
});
if (z2) {
checkDoze();
}
this.ivMetered.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
int[] iArr = new int[2];
inflate.getLocationOnScreen(iArr);
Toast makeText = Toast.makeText(ActivityMain.this, (int) R.string.msg_metered, 1);
makeText.setGravity(51, ActivityMain.this.ivMetered.getLeft() + iArr[0], Math.round((ActivityMain.this.ivMetered.getBottom() + iArr[1]) - makeText.getView().getPaddingTop()));
makeText.show();
return true;
}
});
getSupportActionBar().d();
getSupportActionBar().b(inflate);
((TextView) findViewById(R.id.tvDisabled)).setVisibility(z2 ? 8 : 0);
TextView textView = (TextView) findViewById(R.id.tvNotifications);
textView.setVisibility(8);
if (i2 >= 33) {
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActivityMain.this.requestPermissions(new String[]{"android.permission.POST_NOTIFICATIONS"}, 4);
}
});
}
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rvApplication);
recyclerView.n0();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager();
linearLayoutManager.u0();
recyclerView.o0(linearLayoutManager);
AdapterRule adapterRule = new AdapterRule(this, findViewById(R.id.vwPopupAnchor));
this.adapter = adapterRule;
recyclerView.m0(adapterRule);
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh);
this.swipeRefresh = swipeRefreshLayout;
swipeRefreshLayout.g(-1, -1, -1);
this.swipeRefresh.i(typedValue.data);
this.swipeRefresh.h(new e() {
@Override
public void onRefresh() {
Rule.clearCache(ActivityMain.this);
ServiceSinkhole.reload("pull", ActivityMain.this, false);
ActivityMain.this.updateApplicationList(null);
}
});
final LinearLayout linearLayout = (LinearLayout) findViewById(R.id.llUsage);
Button button = (Button) findViewById(R.id.btnUsage);
linearLayout.setVisibility(f.getBoolean("hint_usage", true) ? 0 : 8);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
d.d(f, "hint_usage", false);
linearLayout.setVisibility(8);
ActivityMain.this.showHints();
}
});
final LinearLayout linearLayout2 = (LinearLayout) findViewById(R.id.llFairEmail);
((TextView) findViewById(R.id.tvFairEmail)).setMovementMethod(LinkMovementMethod.getInstance());
Button button2 = (Button) findViewById(R.id.btnFairEmail);
linearLayout2.setVisibility(f.getBoolean("hint_fairemail", true) ? 0 : 8);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
d.d(f, "hint_fairemail", false);
linearLayout2.setVisibility(8);
}
});
showHints();
f.registerOnSharedPreferenceChangeListener(this);
C0496d.b(this).c(this.onRulesChanged, new IntentFilter("eu.faircode.netguard.ACTION_RULES_CHANGED"));
C0496d.b(this).c(this.onQueueChanged, new IntentFilter("eu.faircode.netguard.ACTION_QUEUE_CHANGED"));
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
intentFilter.addDataScheme("package");
f.e(this, this.packageChangedReceiver, intentFilter);
if (!z3) {
View inflate2 = LayoutInflater.from(this).inflate(R.layout.first, (ViewGroup) null, false);
((TextView) inflate2.findViewById(R.id.tvFirst)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView) inflate2.findViewById(R.id.tvEula)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView) inflate2.findViewById(R.id.tvPrivacy)).setMovementMethod(LinkMovementMethod.getInstance());
C0091m c0091m = new C0091m(this);
c0091m.m(inflate2);
c0091m.d(false);
c0091m.j(R.string.app_agree, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i4) {
if (ActivityMain.this.running) {
d.d(f, "initialized", true);
}
}
});
c0091m.g(R.string.app_disagree, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i4) {
if (ActivityMain.this.running) {
ActivityMain.this.finish();
}
}
});
c0091m.h(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
ActivityMain.this.dialogFirst = null;
}
});
DialogInterfaceC0092n a2 = c0091m.a();
this.dialogFirst = a2;
a2.show();
}
updateApplicationList(getIntent().getStringExtra("Search"));
try {
IAB iab = new IAB(new IAB.Delegate() {
@Override
public void onError(String str) {
}
@Override
public void onReady(IAB iab2) {
try {
if (!IAB.isPurchased("log", ActivityMain.this)) {
f.edit().putBoolean("log", false).apply();
}
if (!IAB.isPurchased("theme", ActivityMain.this) && !"teal".equals(f.getString("theme", "teal"))) {
f.edit().putString("theme", "teal").apply();
}
if (!IAB.isPurchased("notify", ActivityMain.this)) {
f.edit().putBoolean("install", false).apply();
}
if (!IAB.isPurchased("speed", ActivityMain.this)) {
f.edit().putBoolean("show_stats", false).apply();
}
} finally {
try {
iab2.unbind();
} catch (Throwable th) {
}
}
iab2.unbind();
}
}, this);
this.iab = iab;
iab.bind();
} catch (Throwable th) {
r.h(th, new StringBuilder(), "\n", th, "NetGuard.Main");
}
SpannableString spannableString = new SpannableString(getString(R.string.app_support));
spannableString.setSpan(new UnderlineSpan(), 0, spannableString.length(), 0);
((TextView) findViewById(R.id.tvSupport)).setText(spannableString);
((LinearLayout) findViewById(R.id.llSupport)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActivityMain activityMain = ActivityMain.this;
activityMain.startActivity(ActivityMain.getIntentPro(activityMain));
}
});
checkExtras(getIntent());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
PackageManager packageManager = getPackageManager();
getMenuInflater().inflate(R.menu.main, menu);
MenuItem findItem = menu.findItem(R.id.menu_search);
this.menuSearch = findItem;
findItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
if (ActivityMain.this.getIntent().hasExtra("Search") && !ActivityMain.this.getIntent().getBooleanExtra("Related", false)) {
ActivityMain.this.finish();
}
return true;
}
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
return true;
}
});
final SearchView searchView = (SearchView) this.menuSearch.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String str) {
if (ActivityMain.this.adapter != null) {
ActivityMain.this.adapter.getFilter().filter(str);
}
return true;
}
@Override
public boolean onQueryTextSubmit(String str) {
if (ActivityMain.this.adapter != null) {
ActivityMain.this.adapter.getFilter().filter(str);
}
searchView.clearFocus();
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
ActivityMain.this.getIntent().removeExtra("Search");
if (ActivityMain.this.adapter != null) {
int i2 = 0 >> 0;
ActivityMain.this.adapter.getFilter().filter(null);
return true;
}
return true;
}
});
String stringExtra = getIntent().getStringExtra("Search");
if (stringExtra != null) {
this.menuSearch.expandActionView();
searchView.setQuery(stringExtra, true);
}
markPro(menu.findItem(R.id.menu_log), "log");
if (!IAB.isPurchasedAny(this)) {
markPro(menu.findItem(R.id.menu_pro), null);
}
if (!Util.hasValidFingerprint(this) || getIntentInvite(this).resolveActivity(packageManager) == null) {
menu.removeItem(R.id.menu_invite);
}
if (getIntentSupport().resolveActivity(getPackageManager()) == null) {
menu.removeItem(R.id.menu_support);
}
menu.findItem(R.id.menu_apps).setEnabled(getIntentApps(this).resolveActivity(packageManager) != null);
return true;
}
@Override
public void onDestroy() {
Log.i("NetGuard.Main", "Destroy");
if (Util.hasXposed(this)) {
super.onDestroy();
return;
}
this.running = false;
boolean z2 = true & false;
this.adapter = null;
b.f(this).unregisterOnSharedPreferenceChangeListener(this);
C0496d.b(this).e(this.onRulesChanged);
C0496d.b(this).e(this.onQueueChanged);
unregisterReceiver(this.packageChangedReceiver);
DialogInterfaceC0092n dialogInterfaceC0092n = this.dialogFirst;
if (dialogInterfaceC0092n != null) {
dialogInterfaceC0092n.dismiss();
this.dialogFirst = null;
}
DialogInterfaceC0092n dialogInterfaceC0092n2 = this.dialogVpn;
if (dialogInterfaceC0092n2 != null) {
dialogInterfaceC0092n2.dismiss();
this.dialogVpn = null;
}
DialogInterfaceC0092n dialogInterfaceC0092n3 = this.dialogDoze;
if (dialogInterfaceC0092n3 != null) {
dialogInterfaceC0092n3.dismiss();
this.dialogDoze = null;
}
DialogInterfaceC0092n dialogInterfaceC0092n4 = this.dialogLegend;
if (dialogInterfaceC0092n4 != null) {
dialogInterfaceC0092n4.dismiss();
this.dialogLegend = null;
}
DialogInterfaceC0092n dialogInterfaceC0092n5 = this.dialogAbout;
if (dialogInterfaceC0092n5 != null) {
dialogInterfaceC0092n5.dismiss();
this.dialogAbout = null;
}
IAB iab = this.iab;
if (iab != null) {
iab.unbind();
this.iab = null;
}
super.onDestroy();
}
@Override
public void onNewIntent(Intent intent) {
Log.i("NetGuard.Main", "New intent");
Util.logExtras(intent);
super.onNewIntent(intent);
if (Util.hasXposed(this)) {
return;
}
setIntent(intent);
if (intent.hasExtra("Refresh")) {
updateApplicationList(intent.getStringExtra("Search"));
} else {
updateSearch(intent.getStringExtra("Search"));
}
checkExtras(intent);
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
Log.i("NetGuard.Main", "Menu=" + ((Object) menuItem.getTitle()));
SharedPreferences f = b.f(this);
int i2 = 2 >> 1;
switch (menuItem.getItemId()) {
case R.id.menu_about:
menu_about();
return true;
case R.id.menu_app_disabled:
menuItem.setChecked(!menuItem.isChecked());
f.edit().putBoolean("show_disabled", menuItem.isChecked()).apply();
return true;
case R.id.menu_app_nointernet:
menuItem.setChecked(!menuItem.isChecked());
f.edit().putBoolean("show_nointernet", menuItem.isChecked()).apply();
return true;
case R.id.menu_app_system:
menuItem.setChecked(!menuItem.isChecked());
f.edit().putBoolean("show_system", menuItem.isChecked()).apply();
return true;
case R.id.menu_app_user:
menuItem.setChecked(!menuItem.isChecked());
f.edit().putBoolean("show_user", menuItem.isChecked()).apply();
return true;
case R.id.menu_apps:
menu_apps();
return true;
case R.id.menu_invite:
startActivityForResult(getIntentInvite(this), 2);
return true;
case R.id.menu_legend:
menu_legend();
return true;
case R.id.menu_lockdown:
menu_lockdown(menuItem);
return true;
case R.id.menu_log:
if (!Util.canFilter(this)) {
Toast.makeText(this, (int) R.string.msg_unavailable, 0).show();
} else if (IAB.isPurchased("log", this)) {
startActivity(new Intent(this, ActivityLog.class));
} else {
startActivity(new Intent(this, ActivityPro.class));
}
return true;
case R.id.menu_malware:
menu_malware(menuItem);
return true;
case R.id.menu_pro:
startActivity(new Intent(this, ActivityPro.class));
return true;
case R.id.menu_settings:
startActivity(new Intent(this, ActivitySettings.class));
return true;
case R.id.menu_sort_name:
menuItem.setChecked(true);
f.edit().putString("sort", "name").apply();
return true;
case R.id.menu_sort_uid:
menuItem.setChecked(true);
f.edit().putString("sort", "uid").apply();
return true;
case R.id.menu_support:
startActivity(getIntentSupport());
return true;
default:
return super.onOptionsItemSelected(menuItem);
}
}
@Override
public void onPause() {
Log.i("NetGuard.Main", "Pause");
super.onPause();
if (Util.hasXposed(this)) {
return;
}
DatabaseHelper.getInstance(this).removeAccessChangedListener(this.accessChangedListener);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
SharedPreferences f = b.f(this);
menu.findItem(R.id.menu_malware).setVisible(false);
if (f.getBoolean("manage_system", false)) {
menu.findItem(R.id.menu_app_user).setChecked(f.getBoolean("show_user", true));
menu.findItem(R.id.menu_app_system).setChecked(f.getBoolean("show_system", false));
} else {
SubMenu subMenu = menu.findItem(R.id.menu_filter).getSubMenu();
subMenu.removeItem(R.id.menu_app_user);
subMenu.removeItem(R.id.menu_app_system);
}
menu.findItem(R.id.menu_app_nointernet).setChecked(f.getBoolean("show_nointernet", true));
menu.findItem(R.id.menu_app_disabled).setChecked(f.getBoolean("show_disabled", true));
if ("uid".equals(f.getString("sort", "name"))) {
menu.findItem(R.id.menu_sort_uid).setChecked(true);
} else {
menu.findItem(R.id.menu_sort_name).setChecked(true);
}
menu.findItem(R.id.menu_lockdown).setChecked(f.getBoolean("lockdown", false));
menu.findItem(R.id.menu_malware).setChecked(f.getBoolean("malware", false));
return super.onPrepareOptionsMenu(menu);
}
@Override
public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
super.onRequestPermissionsResult(i2, strArr, iArr);
if (i2 == 3) {
if (iArr[0] == 0) {
ServiceSinkhole.reload("permission granted", this, false);
}
} else if (i2 != 4 || iArr[0] == 0 || C0120c.j(this)) {
} else {
try {
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", getPackageName(), null));
startActivity(intent);
} catch (Throwable th) {
Log.e("NetGuard.Main", th + "\n" + th.getStackTrace());
}
}
}
@Override
public void onResume() {
int i2;
TextView textView;
Log.i("NetGuard.Main", "Resume");
int i3 = Build.VERSION.SDK_INT;
if (Util.hasXposed(this)) {
super.onResume();
return;
}
DatabaseHelper.getInstance(this).addAccessChangedListener(this.accessChangedListener);
AdapterRule adapterRule = this.adapter;
if (adapterRule != null) {
adapterRule.notifyDataSetChanged();
}
PackageManager packageManager = getPackageManager();
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.llSupport);
int i4 = 8;
if (!IAB.isPurchasedAny(this) && getIntentPro(this).resolveActivity(packageManager) != null) {
i2 = 0;
linearLayout.setVisibility(i2);
boolean z2 = i3 >= 33 || f.a(this, "android.permission.POST_NOTIFICATIONS") == 0;
textView = (TextView) findViewById(R.id.tvNotifications);
if (textView != null) {
if (!z2) {
i4 = 0;
}
textView.setVisibility(i4);
}
super.onResume();
}
i2 = 8;
linearLayout.setVisibility(i2);
if (i3 >= 33) {
}
textView = (TextView) findViewById(R.id.tvNotifications);
if (textView != null) {
}
super.onResume();
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
Log.i("NetGuard.Main", "Preference " + str + "=" + sharedPreferences.getAll().get(str));
int i2 = 8;
if ("enabled".equals(str)) {
boolean z2 = sharedPreferences.getBoolean(str, false);
TextView textView = (TextView) findViewById(R.id.tvDisabled);
if (!z2) {
i2 = 0;
}
textView.setVisibility(i2);
SwitchCompat switchCompat = (SwitchCompat) getSupportActionBar().a().findViewById(R.id.swEnabled);
if (switchCompat.isChecked() != z2) {
switchCompat.setChecked(z2);
}
} else if ("whitelist_wifi".equals(str) || "screen_on".equals(str) || "screen_wifi".equals(str) || "whitelist_other".equals(str) || "screen_other".equals(str) || "whitelist_roaming".equals(str) || "show_user".equals(str) || "show_system".equals(str) || "show_nointernet".equals(str) || "show_disabled".equals(str) || "sort".equals(str) || "imported".equals(str)) {
updateApplicationList(null);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.llWhitelist);
boolean z3 = sharedPreferences.getBoolean("screen_on", true);
boolean z4 = sharedPreferences.getBoolean("whitelist_wifi", false);
boolean z5 = sharedPreferences.getBoolean("whitelist_other", false);
boolean z6 = sharedPreferences.getBoolean("hint_whitelist", true);
if (!z4 && !z5 && z3 && z6) {
i2 = 0;
}
linearLayout.setVisibility(i2);
} else if ("manage_system".equals(str)) {
invalidateOptionsMenu();
updateApplicationList(null);
LinearLayout linearLayout2 = (LinearLayout) findViewById(R.id.llSystem);
boolean z7 = sharedPreferences.getBoolean("manage_system", false);
boolean z8 = sharedPreferences.getBoolean("hint_system", true);
if (!z7 && z8) {
i2 = 0;
}
linearLayout2.setVisibility(i2);
} else if ("theme".equals(str) || "dark_theme".equals(str)) {
recreate();
}
}
}