NetGuard v2.328版本的 MD5 值为:4adaa6f0accf8a6a5ab62c36e5a5d3f8
以下内容为反编译后的 AdapterRule.java 源代码,内容仅作参考
package eu.faircode.netguard;
import B.b;
import K0.r;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CursorAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.C0091m;
import androidx.core.content.f;
import androidx.core.text.d;
import androidx.recyclerview.widget.C;
import androidx.recyclerview.widget.P;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.request.g;
import eu.faircode.netguard.Util;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class AdapterRule extends C implements Filterable {
private View anchor;
private int colorChanged;
private int colorGrayed;
private int colorOff;
private int colorOn;
private int colorText;
private int iconSize;
private LayoutInflater inflater;
private RecyclerView rv;
private boolean wifiActive = true;
private boolean otherActive = true;
private boolean live = true;
private List listAll = new ArrayList();
private List listFiltered = new ArrayList();
private List messaging = Arrays.asList("com.discord", "com.facebook.mlite", "com.facebook.orca", "com.instagram.android", "com.Slack", "com.skype.raider", "com.snapchat.android", "com.whatsapp", "com.whatsapp.w4b");
private List download = Arrays.asList("com.google.android.youtube");
public class AnonymousClass15 implements AdapterView.OnItemClickListener {
final AdapterAccess val$badapter;
final Context val$context;
final Rule val$rule;
AnonymousClass15(Context context, AdapterAccess adapterAccess, Rule rule) {
this.val$context = context;
this.val$badapter = adapterAccess;
this.val$rule = rule;
}
@Override
public void onItemClick(AdapterView adapterView, View view, int i2, long j2) {
PackageManager packageManager = this.val$context.getPackageManager();
Cursor cursor = (Cursor) this.val$badapter.getItem(i2);
final long j3 = cursor.getLong(cursor.getColumnIndex("ID"));
int i3 = cursor.getInt(cursor.getColumnIndex("version"));
int i4 = cursor.getInt(cursor.getColumnIndex("protocol"));
final String string = cursor.getString(cursor.getColumnIndex("daddr"));
int i5 = cursor.getInt(cursor.getColumnIndex("dport"));
long j4 = cursor.getLong(cursor.getColumnIndex("time"));
int i6 = cursor.getInt(cursor.getColumnIndex("block"));
PopupMenu popupMenu = new PopupMenu(this.val$context, AdapterRule.this.anchor);
popupMenu.inflate(R.menu.access);
MenuItem findItem = popupMenu.getMenu().findItem(R.id.menu_host);
StringBuilder sb = new StringBuilder();
sb.append(Util.getProtocolName(i4, i3, false));
sb.append(" ");
sb.append(string);
sb.append(i5 > 0 ? r.b("/", i5) : "");
findItem.setTitle(sb.toString());
SubMenu subMenu = popupMenu.getMenu().findItem(R.id.menu_host).getSubMenu();
Cursor cursor2 = null;
try {
cursor2 = DatabaseHelper.getInstance(this.val$context).getAlternateQNames(string);
boolean z2 = false;
while (cursor2.moveToNext()) {
subMenu.add(0, 0, 0, cursor2.getString(0)).setEnabled(false);
z2 = true;
}
cursor2.close();
popupMenu.getMenu().findItem(R.id.menu_host).setEnabled(z2);
AdapterRule.this.markPro(this.val$context, popupMenu.getMenu().findItem(R.id.menu_allow), "filter");
AdapterRule.this.markPro(this.val$context, popupMenu.getMenu().findItem(R.id.menu_block), "filter");
final Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://www.dnslytics.com/whois-lookup/" + string));
if (packageManager.resolveActivity(intent, 0) == null) {
popupMenu.getMenu().removeItem(R.id.menu_whois);
} else {
popupMenu.getMenu().findItem(R.id.menu_whois).setTitle(this.val$context.getString(R.string.title_log_whois, string));
}
final Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse("https://www.speedguide.net/port.php?port=" + i5));
if (i5 <= 0 || packageManager.resolveActivity(intent2, 0) == null) {
popupMenu.getMenu().removeItem(R.id.menu_port);
} else {
popupMenu.getMenu().findItem(R.id.menu_port).setTitle(this.val$context.getString(R.string.title_log_port, Integer.valueOf(i5)));
}
popupMenu.getMenu().findItem(R.id.menu_time).setTitle(DateFormat.getDateTimeInstance().format(Long.valueOf(j4)));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int itemId = menuItem.getItemId();
boolean z3 = true;
switch (itemId) {
case R.id.menu_allow:
if (!IAB.isPurchased("filter", AnonymousClass15.this.val$context)) {
AnonymousClass15.this.val$context.startActivity(new Intent(AnonymousClass15.this.val$context, ActivityPro.class));
break;
} else {
DatabaseHelper.getInstance(AnonymousClass15.this.val$context).setAccess(j3, 0);
ServiceSinkhole.reload("allow host", AnonymousClass15.this.val$context, false);
break;
}
case R.id.menu_block:
if (!IAB.isPurchased("filter", AnonymousClass15.this.val$context)) {
AnonymousClass15.this.val$context.startActivity(new Intent(AnonymousClass15.this.val$context, ActivityPro.class));
break;
} else {
DatabaseHelper.getInstance(AnonymousClass15.this.val$context).setAccess(j3, 1);
ServiceSinkhole.reload("block host", AnonymousClass15.this.val$context, false);
break;
}
case R.id.menu_copy:
((ClipboardManager) AnonymousClass15.this.val$context.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("netguard", string));
return true;
case R.id.menu_port:
AnonymousClass15.this.val$context.startActivity(intent2);
break;
case R.id.menu_reset:
DatabaseHelper.getInstance(AnonymousClass15.this.val$context).setAccess(j3, -1);
ServiceSinkhole.reload("reset host", AnonymousClass15.this.val$context, false);
break;
case R.id.menu_whois:
AnonymousClass15.this.val$context.startActivity(intent);
break;
default:
z3 = false;
break;
}
if (itemId == R.id.menu_allow || itemId == R.id.menu_block || itemId == R.id.menu_reset) {
new AsyncTask() {
@Override
public Long doInBackground(Object... objArr) {
return Long.valueOf(DatabaseHelper.getInstance(AnonymousClass15.this.val$context).getHostCount(AnonymousClass15.this.val$rule.uid, false));
}
@Override
public void onPostExecute(Long l2) {
AnonymousClass15.this.val$rule.hosts = l2.longValue();
AdapterRule.this.notifyDataSetChanged();
}
}.execute(new Object[0]);
}
return z3;
}
});
if (i6 == 0) {
popupMenu.getMenu().removeItem(R.id.menu_allow);
} else if (i6 == 1) {
popupMenu.getMenu().removeItem(R.id.menu_block);
}
popupMenu.show();
} catch (Throwable th) {
if (cursor2 != null) {
cursor2.close();
}
throw th;
}
}
}
public class ViewHolder extends P {
public ImageButton btnClear;
public ImageButton btnClearAccess;
public Button btnLogging;
public Button btnRelated;
public CheckBox cbApply;
public CheckBox cbLockdown;
public CheckBox cbNotify;
public CheckBox cbOther;
public CheckBox cbRoaming;
public CheckBox cbScreenOther;
public CheckBox cbScreenWifi;
public CheckBox cbWifi;
public ImageButton ibLaunch;
public ImageButton ibSettings;
public ImageView ivExpander;
public ImageView ivIcon;
public ImageView ivLive;
public ImageView ivLockdown;
public ImageView ivLockdownLegend;
public ImageView ivOtherLegend;
public ImageView ivScreenOther;
public ImageView ivScreenWifi;
public ImageView ivWifiLegend;
public LinearLayout llApplication;
public LinearLayout llConfiguration;
public LinearLayout llFilter;
public LinearLayout llScreenOther;
public LinearLayout llScreenWifi;
public ListView lvAccess;
public RelativeLayout rlLockdown;
public TextView tvDisabled;
public TextView tvHosts;
public TextView tvInternet;
public TextView tvLogging;
public TextView tvName;
public TextView tvPackage;
public TextView tvRemarkDownload;
public TextView tvRemarkMessaging;
public TextView tvRoaming;
public TextView tvUid;
public TextView tvVersion;
public View view;
public ViewHolder(View view) {
super(view);
this.view = view;
this.llApplication = (LinearLayout) view.findViewById(R.id.llApplication);
this.ivIcon = (ImageView) view.findViewById(R.id.ivIcon);
this.ivExpander = (ImageView) view.findViewById(R.id.ivExpander);
this.tvName = (TextView) view.findViewById(R.id.tvName);
this.tvHosts = (TextView) view.findViewById(R.id.tvHosts);
this.rlLockdown = (RelativeLayout) view.findViewById(R.id.rlLockdown);
this.ivLockdown = (ImageView) view.findViewById(R.id.ivLockdown);
this.cbWifi = (CheckBox) view.findViewById(R.id.cbWifi);
this.ivScreenWifi = (ImageView) view.findViewById(R.id.ivScreenWifi);
this.cbOther = (CheckBox) view.findViewById(R.id.cbOther);
this.ivScreenOther = (ImageView) view.findViewById(R.id.ivScreenOther);
this.tvRoaming = (TextView) view.findViewById(R.id.tvRoaming);
this.tvRemarkMessaging = (TextView) view.findViewById(R.id.tvRemarkMessaging);
this.tvRemarkDownload = (TextView) view.findViewById(R.id.tvRemarkDownload);
this.llConfiguration = (LinearLayout) view.findViewById(R.id.llConfiguration);
this.tvUid = (TextView) view.findViewById(R.id.tvUid);
this.tvPackage = (TextView) view.findViewById(R.id.tvPackage);
this.tvVersion = (TextView) view.findViewById(R.id.tvVersion);
this.tvInternet = (TextView) view.findViewById(R.id.tvInternet);
this.tvDisabled = (TextView) view.findViewById(R.id.tvDisabled);
this.btnRelated = (Button) view.findViewById(R.id.btnRelated);
this.ibSettings = (ImageButton) view.findViewById(R.id.ibSettings);
this.ibLaunch = (ImageButton) view.findViewById(R.id.ibLaunch);
this.cbApply = (CheckBox) view.findViewById(R.id.cbApply);
this.llScreenWifi = (LinearLayout) view.findViewById(R.id.llScreenWifi);
this.ivWifiLegend = (ImageView) view.findViewById(R.id.ivWifiLegend);
this.cbScreenWifi = (CheckBox) view.findViewById(R.id.cbScreenWifi);
this.llScreenOther = (LinearLayout) view.findViewById(R.id.llScreenOther);
this.ivOtherLegend = (ImageView) view.findViewById(R.id.ivOtherLegend);
this.cbScreenOther = (CheckBox) view.findViewById(R.id.cbScreenOther);
this.cbRoaming = (CheckBox) view.findViewById(R.id.cbRoaming);
this.cbLockdown = (CheckBox) view.findViewById(R.id.cbLockdown);
this.ivLockdownLegend = (ImageView) view.findViewById(R.id.ivLockdownLegend);
this.btnClear = (ImageButton) view.findViewById(R.id.btnClear);
this.llFilter = (LinearLayout) view.findViewById(R.id.llFilter);
this.ivLive = (ImageView) view.findViewById(R.id.ivLive);
this.tvLogging = (TextView) view.findViewById(R.id.tvLogging);
this.btnLogging = (Button) view.findViewById(R.id.btnLogging);
this.lvAccess = (ListView) view.findViewById(R.id.lvAccess);
this.btnClearAccess = (ImageButton) view.findViewById(R.id.btnClearAccess);
this.cbNotify = (CheckBox) view.findViewById(R.id.cbNotify);
final View view2 = (View) this.cbWifi.getParent();
view2.post(new Runnable() {
@Override
public void run() {
Rect rect = new Rect();
ViewHolder.this.cbWifi.getHitRect(rect);
rect.bottom += rect.top;
rect.right += rect.left;
rect.top = 0;
rect.left = 0;
view2.setTouchDelegate(new TouchDelegate(rect, ViewHolder.this.cbWifi));
}
});
final View view3 = (View) this.cbOther.getParent();
view3.post(new Runnable() {
@Override
public void run() {
Rect rect = new Rect();
ViewHolder.this.cbOther.getHitRect(rect);
rect.bottom += rect.top;
rect.right += rect.left;
rect.top = 0;
rect.left = 0;
view3.setTouchDelegate(new TouchDelegate(rect, ViewHolder.this.cbOther));
}
});
}
}
public AdapterRule(Context context, View view) {
SharedPreferences f = b.f(context);
this.anchor = view;
this.inflater = LayoutInflater.from(context);
if (f.getBoolean("dark_theme", false)) {
this.colorChanged = Color.argb(128, Color.red(-12303292), Color.green(-12303292), Color.blue(-12303292));
} else {
this.colorChanged = Color.argb(128, Color.red(-3355444), Color.green(-3355444), Color.blue(-3355444));
}
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{16842806});
try {
this.colorText = obtainStyledAttributes.getColor(0, 0);
obtainStyledAttributes.recycle();
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorOn, typedValue, true);
this.colorOn = typedValue.data;
context.getTheme().resolveAttribute(R.attr.colorOff, typedValue, true);
this.colorOff = typedValue.data;
this.colorGrayed = f.b(context, R.color.colorGrayed);
TypedValue typedValue2 = new TypedValue();
context.getTheme().resolveAttribute(16842829, typedValue2, true);
this.iconSize = Math.round((TypedValue.complexToDimensionPixelSize(typedValue2.data, context.getResources().getDisplayMetrics()) * context.getResources().getDisplayMetrics().density) + 0.5f);
setHasStableIds(true);
} catch (Throwable th) {
obtainStyledAttributes.recycle();
throw th;
}
}
public void markPro(Context context, MenuItem menuItem, String str) {
if (str == null || !IAB.isPurchased(str, context)) {
boolean z2 = b.f(context).getBoolean("dark_theme", false);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(" " + ((Object) menuItem.getTitle()));
spannableStringBuilder.setSpan(new ImageSpan(context, z2 ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, 33);
menuItem.setTitle(spannableStringBuilder);
}
}
public void updateRule(Context context, Rule rule, boolean z2, List list) {
String[] strArr;
SharedPreferences sharedPreferences = context.getSharedPreferences("wifi", 0);
SharedPreferences sharedPreferences2 = context.getSharedPreferences("other", 0);
SharedPreferences sharedPreferences3 = context.getSharedPreferences("apply", 0);
SharedPreferences sharedPreferences4 = context.getSharedPreferences("screen_wifi", 0);
SharedPreferences sharedPreferences5 = context.getSharedPreferences("screen_other", 0);
SharedPreferences sharedPreferences6 = context.getSharedPreferences("roaming", 0);
SharedPreferences sharedPreferences7 = context.getSharedPreferences("lockdown", 0);
SharedPreferences sharedPreferences8 = context.getSharedPreferences("notify", 0);
if (rule.wifi_blocked == rule.wifi_default) {
sharedPreferences.edit().remove(rule.packageName).apply();
} else {
sharedPreferences.edit().putBoolean(rule.packageName, rule.wifi_blocked).apply();
}
if (rule.other_blocked == rule.other_default) {
sharedPreferences2.edit().remove(rule.packageName).apply();
} else {
sharedPreferences2.edit().putBoolean(rule.packageName, rule.other_blocked).apply();
}
if (rule.apply) {
sharedPreferences3.edit().remove(rule.packageName).apply();
} else {
sharedPreferences3.edit().putBoolean(rule.packageName, rule.apply).apply();
}
if (rule.screen_wifi == rule.screen_wifi_default) {
sharedPreferences4.edit().remove(rule.packageName).apply();
} else {
sharedPreferences4.edit().putBoolean(rule.packageName, rule.screen_wifi).apply();
}
if (rule.screen_other == rule.screen_other_default) {
sharedPreferences5.edit().remove(rule.packageName).apply();
} else {
sharedPreferences5.edit().putBoolean(rule.packageName, rule.screen_other).apply();
}
if (rule.roaming == rule.roaming_default) {
sharedPreferences6.edit().remove(rule.packageName).apply();
} else {
sharedPreferences6.edit().putBoolean(rule.packageName, rule.roaming).apply();
}
if (rule.lockdown) {
sharedPreferences7.edit().putBoolean(rule.packageName, rule.lockdown).apply();
} else {
sharedPreferences7.edit().remove(rule.packageName).apply();
}
if (rule.notify) {
sharedPreferences8.edit().remove(rule.packageName).apply();
} else {
sharedPreferences8.edit().putBoolean(rule.packageName, rule.notify).apply();
}
rule.updateChanged(context);
Log.i("NetGuard.Adapter", "Updated " + rule);
ArrayList arrayList = new ArrayList();
for (String str : rule.related) {
Iterator it = list.iterator();
while (it.hasNext()) {
Rule rule2 = (Rule) it.next();
if (rule2.packageName.equals(str)) {
rule2.wifi_blocked = rule.wifi_blocked;
rule2.other_blocked = rule.other_blocked;
rule2.apply = rule.apply;
rule2.screen_wifi = rule.screen_wifi;
rule2.screen_other = rule.screen_other;
rule2.roaming = rule.roaming;
rule2.lockdown = rule.lockdown;
rule2.notify = rule.notify;
arrayList.add(rule2);
}
}
}
if (z2) {
list = new ArrayList(list);
}
list.remove(rule);
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
list.remove((Rule) it2.next());
}
Iterator it3 = arrayList.iterator();
while (it3.hasNext()) {
updateRule(context, (Rule) it3.next(), false, list);
}
if (z2) {
notifyDataSetChanged();
androidx.core.app.C.c(context).b(rule.uid);
ServiceSinkhole.reload("rule changed", context, false);
}
}
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected Filter.FilterResults performFiltering(CharSequence charSequence) {
int i2;
String str;
ArrayList arrayList = new ArrayList();
if (charSequence == null) {
arrayList.addAll(AdapterRule.this.listAll);
} else {
String trim = charSequence.toString().toLowerCase().trim();
try {
i2 = Integer.parseInt(trim.toString());
} catch (NumberFormatException unused) {
i2 = -1;
}
for (Rule rule : AdapterRule.this.listAll) {
if (rule.uid == i2 || rule.packageName.toLowerCase().contains(trim) || ((str = rule.name) != null && str.toLowerCase().contains(trim))) {
arrayList.add(rule);
}
}
}
Filter.FilterResults filterResults = new Filter.FilterResults();
filterResults.values = arrayList;
filterResults.count = arrayList.size();
return filterResults;
}
@Override
protected void publishResults(CharSequence charSequence, Filter.FilterResults filterResults) {
AdapterRule.this.listFiltered.clear();
if (filterResults == null) {
AdapterRule.this.listFiltered.addAll(AdapterRule.this.listAll);
} else {
AdapterRule.this.listFiltered.addAll((List) filterResults.values);
if (AdapterRule.this.listFiltered.size() == 1) {
((Rule) AdapterRule.this.listFiltered.get(0)).expanded = true;
}
}
AdapterRule.this.notifyDataSetChanged();
}
};
}
@Override
public int getItemCount() {
return this.listFiltered.size();
}
@Override
public long getItemId(int i2) {
Rule rule = (Rule) this.listFiltered.get(i2);
return (rule.packageName.hashCode() * 100000) + rule.uid;
}
public boolean isLive() {
return this.live;
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
this.rv = recyclerView;
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, int i2) {
final Context context = viewHolder.itemView.getContext();
final SharedPreferences f = b.f(context);
final boolean z2 = f.getBoolean("log_app", false);
final boolean z3 = f.getBoolean("filter", false);
final boolean z4 = f.getBoolean("notify_access", false);
final Rule rule = (Rule) this.listFiltered.get(i2);
viewHolder.llApplication.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Rule rule2 = rule;
rule2.expanded = !rule2.expanded;
AdapterRule.this.notifyItemChanged(viewHolder.getAdapterPosition());
}
});
viewHolder.itemView.setBackgroundColor(rule.changed ? this.colorChanged : 0);
viewHolder.ivExpander.setImageLevel(rule.expanded ? 1 : 0);
if (rule.icon <= 0) {
viewHolder.ivIcon.setImageResource(17301651);
} else {
GlideRequest load = GlideApp.with(viewHolder.itemView.getContext()).applyDefaultRequestOptions((g) new g().format(DecodeFormat.PREFER_RGB_565)).load(Uri.parse("android.resource://" + rule.packageName + "/" + rule.icon));
int i3 = this.iconSize;
load.override(i3, i3).into(viewHolder.ivIcon);
}
viewHolder.tvName.setText(rule.name);
int i4 = rule.system ? this.colorOff : this.colorText;
if (!rule.internet || !rule.enabled) {
i4 = Color.argb(128, Color.red(i4), Color.green(i4), Color.blue(i4));
}
viewHolder.tvName.setTextColor(i4);
viewHolder.tvHosts.setVisibility(rule.hosts > 0 ? 0 : 8);
viewHolder.tvHosts.setText(Long.toString(rule.hosts));
boolean z5 = f.getBoolean("lockdown", false);
boolean z6 = f.getBoolean("lockdown_wifi", true);
boolean z7 = f.getBoolean("lockdown_other", true);
if ((this.otherActive && !z7) || (this.wifiActive && !z6)) {
z5 = false;
}
viewHolder.rlLockdown.setVisibility((!z5 || rule.lockdown) ? 8 : 0);
viewHolder.ivLockdown.setEnabled(rule.apply);
boolean z8 = f.getBoolean("screen_on", true);
viewHolder.cbWifi.setEnabled(rule.apply);
viewHolder.cbWifi.setAlpha(this.wifiActive ? 1.0f : 0.5f);
viewHolder.cbWifi.setOnCheckedChangeListener(null);
viewHolder.cbWifi.setChecked(rule.wifi_blocked);
viewHolder.cbWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.wifi_blocked = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.ivScreenWifi.setEnabled(rule.apply);
viewHolder.ivScreenWifi.setAlpha(this.wifiActive ? 1.0f : 0.5f);
viewHolder.ivScreenWifi.setVisibility((rule.screen_wifi && rule.wifi_blocked) ? 0 : 4);
viewHolder.cbOther.setEnabled(rule.apply);
viewHolder.cbOther.setAlpha(this.otherActive ? 1.0f : 0.5f);
viewHolder.cbOther.setOnCheckedChangeListener(null);
viewHolder.cbOther.setChecked(rule.other_blocked);
viewHolder.cbOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.other_blocked = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.ivScreenOther.setEnabled(rule.apply);
viewHolder.ivScreenOther.setAlpha(this.otherActive ? 1.0f : 0.5f);
viewHolder.ivScreenOther.setVisibility((rule.screen_other && rule.other_blocked) ? 0 : 4);
viewHolder.tvRoaming.setTextColor(rule.apply ? this.colorOff : this.colorGrayed);
viewHolder.tvRoaming.setAlpha(this.otherActive ? 1.0f : 0.5f);
viewHolder.tvRoaming.setVisibility((!rule.roaming || (rule.other_blocked && !rule.screen_other)) ? 4 : 0);
viewHolder.tvRemarkMessaging.setVisibility(this.messaging.contains(rule.packageName) ? 0 : 8);
viewHolder.tvRemarkDownload.setVisibility(this.download.contains(rule.packageName) ? 0 : 8);
viewHolder.llConfiguration.setVisibility(rule.expanded ? 0 : 8);
viewHolder.tvUid.setText(Integer.toString(rule.uid));
viewHolder.tvPackage.setText(rule.packageName);
viewHolder.tvVersion.setText(rule.version);
viewHolder.tvInternet.setVisibility(rule.internet ? 8 : 0);
viewHolder.tvDisabled.setVisibility(rule.enabled ? 8 : 0);
viewHolder.btnRelated.setVisibility(rule.relateduids ? 0 : 8);
viewHolder.btnRelated.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, ActivityMain.class);
intent.putExtra("Search", Integer.toString(rule.uid));
intent.putExtra("Related", true);
context.startActivity(intent);
}
});
if (rule.expanded) {
final Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.parse("package:" + rule.packageName));
if (intent.resolveActivity(context.getPackageManager()) == null) {
intent = null;
}
viewHolder.ibSettings.setVisibility(intent == null ? 8 : 0);
viewHolder.ibSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(intent);
}
});
} else {
viewHolder.ibSettings.setVisibility(8);
}
if (rule.expanded) {
final Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(rule.packageName);
if (launchIntentForPackage == null || launchIntentForPackage.resolveActivity(context.getPackageManager()) == null) {
launchIntentForPackage = null;
}
viewHolder.ibLaunch.setVisibility(launchIntentForPackage == null ? 8 : 0);
viewHolder.ibLaunch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(launchIntentForPackage);
}
});
} else {
viewHolder.ibLaunch.setVisibility(8);
}
viewHolder.cbApply.setEnabled(rule.pkg && z3);
viewHolder.cbApply.setOnCheckedChangeListener(null);
viewHolder.cbApply.setChecked(rule.apply);
viewHolder.cbApply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.apply = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.llScreenWifi.setVisibility(z8 ? 0 : 8);
viewHolder.cbScreenWifi.setEnabled(rule.wifi_blocked && rule.apply);
viewHolder.cbScreenWifi.setOnCheckedChangeListener(null);
viewHolder.cbScreenWifi.setChecked(rule.screen_wifi);
viewHolder.cbScreenWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.screen_wifi = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.llScreenOther.setVisibility(z8 ? 0 : 8);
viewHolder.cbScreenOther.setEnabled(rule.other_blocked && rule.apply);
viewHolder.cbScreenOther.setOnCheckedChangeListener(null);
viewHolder.cbScreenOther.setChecked(rule.screen_other);
viewHolder.cbScreenOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.screen_other = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.cbRoaming.setEnabled((!rule.other_blocked || rule.screen_other) && rule.apply);
viewHolder.cbRoaming.setOnCheckedChangeListener(null);
viewHolder.cbRoaming.setChecked(rule.roaming);
viewHolder.cbRoaming.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.roaming = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.cbLockdown.setEnabled(rule.apply);
viewHolder.cbLockdown.setOnCheckedChangeListener(null);
viewHolder.cbLockdown.setChecked(rule.lockdown);
viewHolder.cbLockdown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
Rule rule2 = rule;
rule2.lockdown = z9;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
viewHolder.btnClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Util.areYouSure(view.getContext(), R.string.msg_clear_rules, new Util.DoubtListener() {
@Override
public void onSure() {
viewHolder.cbApply.setChecked(true);
AnonymousClass12 anonymousClass12 = AnonymousClass12.this;
viewHolder.cbWifi.setChecked(rule.wifi_default);
AnonymousClass12 anonymousClass122 = AnonymousClass12.this;
viewHolder.cbOther.setChecked(rule.other_default);
AnonymousClass12 anonymousClass123 = AnonymousClass12.this;
viewHolder.cbScreenWifi.setChecked(rule.screen_wifi_default);
AnonymousClass12 anonymousClass124 = AnonymousClass12.this;
viewHolder.cbScreenOther.setChecked(rule.screen_other_default);
AnonymousClass12 anonymousClass125 = AnonymousClass12.this;
viewHolder.cbRoaming.setChecked(rule.roaming_default);
viewHolder.cbLockdown.setChecked(false);
}
});
}
});
viewHolder.llFilter.setVisibility(Util.canFilter(context) ? 0 : 8);
viewHolder.ivLive.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AdapterRule adapterRule = AdapterRule.this;
boolean z9 = true | true;
adapterRule.live = !adapterRule.live;
TypedValue typedValue = new TypedValue();
view.getContext().getTheme().resolveAttribute(AdapterRule.this.live ? R.attr.iconPause : R.attr.iconPlay, typedValue, true);
viewHolder.ivLive.setImageResource(typedValue.resourceId);
if (AdapterRule.this.live) {
AdapterRule.this.notifyDataSetChanged();
}
}
});
viewHolder.tvLogging.setText((z2 && z3) ? R.string.title_logging_enabled : R.string.title_logging_disabled);
viewHolder.btnLogging.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
View inflate = LayoutInflater.from(context).inflate(R.layout.enable, (ViewGroup) null, false);
final CheckBox checkBox = (CheckBox) inflate.findViewById(R.id.cbLogging);
CheckBox checkBox2 = (CheckBox) inflate.findViewById(R.id.cbFiltering);
final CheckBox checkBox3 = (CheckBox) inflate.findViewById(R.id.cbNotify);
checkBox.setChecked(z2);
checkBox2.setChecked(z3);
checkBox2.setEnabled(true);
((TextView) inflate.findViewById(R.id.tvFilter4)).setVisibility(8);
checkBox3.setChecked(z4);
checkBox3.setEnabled(z2);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
d.d(f, "log_app", z9);
checkBox3.setEnabled(z9);
if (!z9) {
checkBox3.setChecked(false);
d.d(f, "notify_access", false);
}
ServiceSinkhole.reload("changed notify", context, false);
AdapterRule.this.notifyDataSetChanged();
}
});
checkBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
if (z9) {
checkBox.setChecked(true);
}
d.d(f, "filter", z9);
ServiceSinkhole.reload("changed filter", context, false);
AdapterRule.this.notifyDataSetChanged();
}
});
checkBox3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z9) {
d.d(f, "notify_access", z9);
ServiceSinkhole.reload("changed notify", context, false);
AdapterRule.this.notifyDataSetChanged();
}
});
C0091m c0091m = new C0091m(context);
c0091m.m(inflate);
c0091m.d(true);
c0091m.a().show();
}
});
if (rule.expanded) {
AdapterAccess adapterAccess = new AdapterAccess(context, DatabaseHelper.getInstance(context).getAccess(rule.uid));
viewHolder.lvAccess.setOnItemClickListener(new AnonymousClass15(context, adapterAccess, rule));
viewHolder.lvAccess.setAdapter((ListAdapter) adapterAccess);
} else {
viewHolder.lvAccess.setAdapter((ListAdapter) null);
viewHolder.lvAccess.setOnItemClickListener(null);
}
viewHolder.btnClearAccess.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Util.areYouSure(view.getContext(), R.string.msg_reset_access, new Util.DoubtListener() {
@Override
public void onSure() {
DatabaseHelper.getInstance(context).clearAccess(rule.uid, true);
if (!AdapterRule.this.live) {
AdapterRule.this.notifyDataSetChanged();
}
if (AdapterRule.this.rv != null) {
AdapterRule.this.rv.l0(viewHolder.getAdapterPosition());
}
}
});
}
});
CheckBox checkBox = viewHolder.cbNotify;
boolean z9 = false;
if (f.getBoolean("notify_access", false) && rule.apply) {
z9 = true;
}
checkBox.setEnabled(z9);
viewHolder.cbNotify.setOnCheckedChangeListener(null);
viewHolder.cbNotify.setChecked(rule.notify);
viewHolder.cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z10) {
Rule rule2 = rule;
rule2.notify = z10;
AdapterRule adapterRule = AdapterRule.this;
adapterRule.updateRule(context, rule2, true, adapterRule.listAll);
}
});
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i2) {
return new ViewHolder(this.inflater.inflate(R.layout.rule, viewGroup, false));
}
@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
this.rv = null;
}
@Override
public void onViewRecycled(ViewHolder viewHolder) {
super.onViewRecycled((P) viewHolder);
CursorAdapter cursorAdapter = (CursorAdapter) viewHolder.lvAccess.getAdapter();
if (cursorAdapter != null) {
Log.i("NetGuard.Adapter", "Closing access cursor");
cursorAdapter.changeCursor(null);
viewHolder.lvAccess.setAdapter((ListAdapter) null);
}
}
public void set(List list) {
this.listAll = list;
ArrayList arrayList = new ArrayList();
this.listFiltered = arrayList;
arrayList.addAll(list);
notifyDataSetChanged();
}
public void setDisconnected() {
this.wifiActive = false;
this.otherActive = false;
notifyDataSetChanged();
}
public void setMobileActive() {
this.wifiActive = false;
this.otherActive = true;
notifyDataSetChanged();
}
public void setWifiActive() {
this.wifiActive = true;
this.otherActive = false;
notifyDataSetChanged();
}
}