mirror of https://github.com/M66B/NetGuard.git
parent
2c4807c37c
commit
f9141cba78
|
@ -470,26 +470,16 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
||||||
holder.btnClear.setOnClickListener(new View.OnClickListener() {
|
holder.btnClear.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
new AlertDialog.Builder(context)
|
Util.areYouSure(view.getContext(), new Util.DoubtListener() {
|
||||||
.setTitle(R.string.msg_sure)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onSure() {
|
||||||
holder.cbWifi.setChecked(rule.wifi_default);
|
holder.cbWifi.setChecked(rule.wifi_default);
|
||||||
holder.cbOther.setChecked(rule.other_default);
|
holder.cbOther.setChecked(rule.other_default);
|
||||||
holder.cbScreenWifi.setChecked(rule.screen_wifi_default);
|
holder.cbScreenWifi.setChecked(rule.screen_wifi_default);
|
||||||
holder.cbScreenOther.setChecked(rule.screen_other_default);
|
holder.cbScreenOther.setChecked(rule.screen_other_default);
|
||||||
holder.cbRoaming.setChecked(rule.roaming_default);
|
holder.cbRoaming.setChecked(rule.roaming_default);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create().show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -585,22 +575,12 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
||||||
holder.btnClearAccess.setOnClickListener(new View.OnClickListener() {
|
holder.btnClearAccess.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
new AlertDialog.Builder(context)
|
Util.areYouSure(view.getContext(), new Util.DoubtListener() {
|
||||||
.setTitle(R.string.msg_sure)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onSure() {
|
||||||
dh.clearAccess(rule.info.applicationInfo.uid);
|
dh.clearAccess(rule.info.applicationInfo.uid);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create().show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.Manifest;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.ApplicationErrorReport;
|
import android.app.ApplicationErrorReport;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
@ -41,6 +42,7 @@ import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v4.net.ConnectivityManagerCompat;
|
import android.support.v4.net.ConnectivityManagerCompat;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
@ -410,6 +412,29 @@ public class Util {
|
||||||
return Math.round(dips * context.getResources().getDisplayMetrics().density + 0.5f);
|
return Math.round(dips * context.getResources().getDisplayMetrics().density + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface DoubtListener {
|
||||||
|
public void onSure();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void areYouSure(Context context, final DoubtListener listener) {
|
||||||
|
new AlertDialog.Builder(context)
|
||||||
|
.setView(R.layout.sure)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
listener.onSure();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
public static String md5(String text, String salt) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
public static String md5(String text, String salt) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
||||||
// MD5
|
// MD5
|
||||||
byte[] bytes = MessageDigest.getInstance("MD5").digest((text + salt).getBytes("UTF-8"));
|
byte[] bytes = MessageDigest.getInstance("MD5").digest((text + salt).getBytes("UTF-8"));
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="16dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textAppearance="@style/TextLarge"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/msg_sure"
|
||||||
|
android:textAppearance="@style/TextMedium" />
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue