mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-27 02:09:41 +00:00
parent
800b12c469
commit
e20e8234d7
2 changed files with 41 additions and 0 deletions
|
@ -27,6 +27,7 @@ import android.content.IntentFilter;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.net.VpnService;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -34,7 +35,9 @@ import android.os.Build;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v4.widget.CompoundButtonCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -762,9 +765,40 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}
|
||||
|
||||
private void menu_legend() {
|
||||
TypedValue tv = new TypedValue();
|
||||
getTheme().resolveAttribute(R.attr.colorOn, tv, true);
|
||||
int colorOn = tv.data;
|
||||
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
|
||||
int colorOff = tv.data;
|
||||
|
||||
// Create view
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
View view = inflater.inflate(R.layout.legend, null, false);
|
||||
ImageView ivWifiOn = (ImageView) view.findViewById(R.id.ivWifiOn);
|
||||
ImageView ivWifiOff = (ImageView) view.findViewById(R.id.ivWifiOff);
|
||||
ImageView ivOtherOn = (ImageView) view.findViewById(R.id.ivOtherOn);
|
||||
ImageView ivOtherOff = (ImageView) view.findViewById(R.id.ivOtherOff);
|
||||
ImageView ivScreenOn = (ImageView) view.findViewById(R.id.ivScreenOn);
|
||||
ImageView ivHostAllowed = (ImageView) view.findViewById(R.id.ivHostAllowed);
|
||||
ImageView ivHostBlocked = (ImageView) view.findViewById(R.id.ivHostBlocked);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
Drawable wrapWifiOn = DrawableCompat.wrap(ivWifiOn.getDrawable());
|
||||
Drawable wrapWifiOff = DrawableCompat.wrap(ivWifiOff.getDrawable());
|
||||
Drawable wrapOtherOn = DrawableCompat.wrap(ivOtherOn.getDrawable());
|
||||
Drawable wrapOtherOff = DrawableCompat.wrap(ivOtherOff.getDrawable());
|
||||
Drawable wrapScreenOn = DrawableCompat.wrap(ivScreenOn.getDrawable());
|
||||
Drawable wrapHostAllowed = DrawableCompat.wrap(ivHostAllowed.getDrawable());
|
||||
Drawable wrapHostBlocked = DrawableCompat.wrap(ivHostBlocked.getDrawable());
|
||||
|
||||
DrawableCompat.setTint(wrapWifiOn, colorOn);
|
||||
DrawableCompat.setTint(wrapWifiOff, colorOff);
|
||||
DrawableCompat.setTint(wrapOtherOn, colorOn);
|
||||
DrawableCompat.setTint(wrapOtherOff, colorOff);
|
||||
DrawableCompat.setTint(wrapScreenOn, colorOn);
|
||||
DrawableCompat.setTint(wrapHostAllowed, colorOn);
|
||||
DrawableCompat.setTint(wrapHostBlocked, colorOff);
|
||||
}
|
||||
|
||||
|
||||
// Show dialog
|
||||
dialogLegend = new AlertDialog.Builder(this)
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivWifiOn"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
@ -115,6 +116,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivWifiOff"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
@ -137,6 +139,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivOtherOn"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
@ -159,6 +162,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivOtherOff"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
@ -181,6 +185,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivScreenOn"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
@ -227,6 +232,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHostAllowed"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
@ -249,6 +255,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHostBlocked"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
|
Loading…
Reference in a new issue