The icon is the tick

This commit is contained in:
M66B 2015-10-24 20:50:27 +02:00
parent 0c51e0d6ba
commit 2cbd96bcb8
29 changed files with 51 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package eu.faircode.netguard;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.drawable.Drawable;
import java.util.ArrayList;
import java.util.Collections;
@ -39,6 +40,10 @@ public class Rule implements Comparable<Rule> {
return listRules;
}
public Drawable getIcon(Context context) {
return info.applicationInfo.loadIcon(context.getPackageManager());
}
@Override
public int compareTo(Rule other) {
int i = this.name.compareTo(other.name);

View File

@ -11,6 +11,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
@ -21,6 +22,8 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> {
private List<Rule> listRule;
public static class ViewHolder extends RecyclerView.ViewHolder {
public View view;
public ImageView ivIcon;
public TextView tvName;
public TextView tvPackage;
public CheckBox cbWifi;
@ -28,6 +31,8 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> {
public ViewHolder(View itemView) {
super(itemView);
this.view = itemView;
this.ivIcon = (ImageView) itemView.findViewById(R.id.ivIcon);
this.tvName = (TextView) itemView.findViewById(R.id.tvName);
this.tvPackage = (TextView) itemView.findViewById(R.id.tvPackage);
this.cbWifi = (CheckBox) itemView.findViewById(R.id.cbWifi);
@ -49,6 +54,8 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> {
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final Rule rule = listRule.get(position);
holder.ivIcon.setImageDrawable(rule.getIcon(holder.view.getContext()));
holder.tvName.setText(rule.name);
holder.tvPackage.setText(rule.info.packageName);

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/other_on" android:state_checked="false" />
<item android:drawable="@drawable/other_off" android:state_checked="true" />
<item android:drawable="@drawable/other_off" />
</selector>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_signal_cellular_off_black_24dp"
android:tint="@color/colorAccent" />

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_network_cell_black_24dp"
android:tint="@color/colorAccent" />

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/wifi_on" android:state_checked="false" />
<item android:drawable="@drawable/wifi_off" android:state_checked="true" />
<item android:drawable="@drawable/wifi_off" />
</selector>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_signal_wifi_off_black_24dp"
android:tint="@color/colorAccent" />

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_network_wifi_black_24dp"
android:tint="@color/colorAccent" />

View File

@ -5,17 +5,24 @@
android:orientation="horizontal"
android:paddingBottom="6dp">
<ImageView
android:id="@+id/ivIcon"
android:layout_width="?android:attr/listPreferredItemHeightSmall"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:layout_gravity="center_vertical" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="6dp">
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="@android:style/TextAppearance.Material.Medium" />
@ -24,7 +31,6 @@
android:id="@+id/tvPackage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:ellipsize="start"
android:singleLine="true"
android:textAppearance="@android:style/TextAppearance.Material.Small" />
@ -35,6 +41,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:button="@drawable/wifi"
android:paddingLeft="3dp" />
<CheckBox
@ -42,5 +49,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:button="@drawable/other"
android:paddingLeft="3dp" />
</LinearLayout>