mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-25 07:32:46 +00:00
Added button to filter application with same uid
Also show application settings and launch button for everybody Closes #309
This commit is contained in:
parent
13bc0e237d
commit
38ba3513c0
9 changed files with 49 additions and 23 deletions
|
@ -31,7 +31,6 @@ import android.os.Build;
|
|||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -68,6 +67,7 @@ public class Rule {
|
|||
public boolean screen_other = false;
|
||||
public boolean roaming = false;
|
||||
|
||||
public boolean relateduids = false;
|
||||
public String[] related = null;
|
||||
|
||||
public float upspeed;
|
||||
|
@ -246,13 +246,16 @@ public class Rule {
|
|||
rule.screen_other = screen_other.getBoolean(info.packageName, rule.screen_other_default);
|
||||
rule.roaming = roaming.getBoolean(info.packageName, rule.roaming_default);
|
||||
|
||||
// Related packages
|
||||
List<String> listPkg = new ArrayList<>();
|
||||
if (pre_related.containsKey(info.packageName))
|
||||
listPkg.addAll(Arrays.asList(pre_related.get(info.packageName)));
|
||||
String[] pkgs = pm.getPackagesForUid(info.applicationInfo.uid);
|
||||
if (pkgs != null)
|
||||
if (pkgs != null && pkgs.length > 1) {
|
||||
rule.relateduids = true;
|
||||
listPkg.addAll(Arrays.asList(pkgs));
|
||||
listPkg.remove(info.packageName);
|
||||
}
|
||||
rule.related = listPkg.toArray(new String[0]);
|
||||
|
||||
long up = TrafficStats.getUidTxBytes(rule.info.applicationInfo.uid);
|
||||
|
|
|
@ -70,7 +70,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
private Activity context;
|
||||
private RecyclerView rv;
|
||||
private boolean filter;
|
||||
private boolean debuggable;
|
||||
private int colorText;
|
||||
private int colorAccent;
|
||||
private int colorChanged;
|
||||
|
@ -105,6 +104,10 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
public TextView tvDisabled;
|
||||
public TextView tvInternet;
|
||||
|
||||
public Button btnRelated;
|
||||
public ImageButton ibSettings;
|
||||
public ImageButton ibLaunch;
|
||||
|
||||
public ImageView ivWifiLegend;
|
||||
public CheckBox cbScreenWifi;
|
||||
|
||||
|
@ -113,8 +116,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
public CheckBox cbRoaming;
|
||||
|
||||
public ImageButton btnClear;
|
||||
public ImageButton btnSettings;
|
||||
public Button btnLaunch;
|
||||
|
||||
public ListView lvAccess;
|
||||
public TextView tvNolog;
|
||||
|
@ -147,6 +148,10 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
tvDisabled = (TextView) itemView.findViewById(R.id.tvDisabled);
|
||||
tvInternet = (TextView) itemView.findViewById(R.id.tvInternet);
|
||||
|
||||
btnRelated = (Button) itemView.findViewById(R.id.btnRelated);
|
||||
ibSettings = (ImageButton) itemView.findViewById(R.id.ibSettings);
|
||||
ibLaunch = (ImageButton) itemView.findViewById(R.id.ibLaunch);
|
||||
|
||||
ivWifiLegend = (ImageView) itemView.findViewById(R.id.ivWifiLegend);
|
||||
cbScreenWifi = (CheckBox) itemView.findViewById(R.id.cbScreenWifi);
|
||||
|
||||
|
@ -155,8 +160,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
cbRoaming = (CheckBox) itemView.findViewById(R.id.cbRoaming);
|
||||
|
||||
btnClear = (ImageButton) itemView.findViewById(R.id.btnClear);
|
||||
btnSettings = (ImageButton) itemView.findViewById(R.id.btnSettings);
|
||||
btnLaunch = (Button) itemView.findViewById(R.id.btnLaunch);
|
||||
|
||||
lvAccess = (ListView) itemView.findViewById(R.id.lvAccess);
|
||||
tvNolog = (TextView) itemView.findViewById(R.id.tvNolog);
|
||||
|
@ -197,7 +200,6 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
|
||||
this.context = context;
|
||||
this.filter = prefs.getBoolean("filter", false);
|
||||
this.debuggable = Util.isDebuggable(context);
|
||||
|
||||
if (prefs.getBoolean("dark_theme", false))
|
||||
colorChanged = Color.argb(128, Color.red(Color.DKGRAY), Color.green(Color.DKGRAY), Color.blue(Color.DKGRAY));
|
||||
|
@ -394,12 +396,22 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
holder.tvDisabled.setVisibility(rule.enabled ? View.GONE : View.VISIBLE);
|
||||
holder.tvInternet.setVisibility(rule.internet ? View.GONE : View.VISIBLE);
|
||||
|
||||
// Show related
|
||||
holder.btnRelated.setVisibility(rule.relateduids ? View.VISIBLE : View.GONE);
|
||||
holder.btnRelated.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent main = new Intent(context, ActivityMain.class);
|
||||
main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(rule.info.applicationInfo.uid));
|
||||
context.startActivity(main);
|
||||
}
|
||||
});
|
||||
|
||||
// Launch application settings
|
||||
final Intent settings = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
settings.setData(Uri.parse("package:" + rule.info.packageName));
|
||||
holder.btnSettings.setVisibility(
|
||||
!debuggable || settings.resolveActivity(context.getPackageManager()) == null ? View.GONE : View.VISIBLE);
|
||||
holder.btnSettings.setOnClickListener(new View.OnClickListener() {
|
||||
holder.ibSettings.setVisibility(settings.resolveActivity(context.getPackageManager()) == null ? View.GONE : View.VISIBLE);
|
||||
holder.ibSettings.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
context.startActivity(settings);
|
||||
|
@ -407,8 +419,8 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
});
|
||||
|
||||
// Launch application
|
||||
holder.btnLaunch.setVisibility(!debuggable || rule.intent == null ? View.GONE : View.VISIBLE);
|
||||
holder.btnLaunch.setOnClickListener(new View.OnClickListener() {
|
||||
holder.ibLaunch.setVisibility(rule.intent == null ? View.GONE : View.VISIBLE);
|
||||
holder.ibLaunch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
context.startActivity(rule.intent);
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_launch_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_launch_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 253 B |
BIN
app/src/main/res/drawable-mdpi/ic_launch_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_launch_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 175 B |
BIN
app/src/main/res/drawable-xhdpi/ic_launch_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_launch_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 258 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_launch_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_launch_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 343 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_launch_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_launch_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 434 B |
|
@ -200,19 +200,30 @@
|
|||
android:layout_marginTop="4dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnSettings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_settings_white_24dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnLaunch"
|
||||
android:id="@+id/btnRelated"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/title_related" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibSettings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_settings_white_24dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibLaunch"
|
||||
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/title_launch" />
|
||||
android:src="@drawable/ic_launch_white_24dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -158,7 +158,7 @@ Your internet traffic is not being sent to a remote VPN server.</string>
|
|||
<string name="title_roaming">Block when roaming</string>
|
||||
<string name="title_disabled">is disabled</string>
|
||||
<string name="title_internet">has no internet permission</string>
|
||||
<string name="title_launch">Start application</string>
|
||||
<string name="title_related">Filter related</string>
|
||||
<string name="title_access">Access attempts</string>
|
||||
<string name="title_no_log"><u>Logging is not enabled</u></string>
|
||||
<string name="title_precedence">Access rules take precedence over other rules</string>
|
||||
|
|
Loading…
Reference in a new issue