mirror of https://github.com/M66B/NetGuard.git
Added button to open Android application settings
This commit is contained in:
parent
e83e09975a
commit
b5759c45da
|
@ -20,6 +20,7 @@ package eu.faircode.netguard;
|
|||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
|
@ -37,6 +38,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -73,6 +75,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
public LinearLayout llConfiguration;
|
||||
public CheckBox cbUsing;
|
||||
public CheckBox cbRoaming;
|
||||
public ImageButton btnSettings;
|
||||
public Button btnLaunch;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
|
@ -95,6 +98,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
tvPackage = (TextView) itemView.findViewById(R.id.tvPackage);
|
||||
cbUsing = (CheckBox) itemView.findViewById(R.id.cbUsing);
|
||||
cbRoaming = (CheckBox) itemView.findViewById(R.id.cbRoaming);
|
||||
btnSettings = (ImageButton) itemView.findViewById(R.id.btnSettings);
|
||||
btnLaunch = (Button) itemView.findViewById(R.id.btnLaunch);
|
||||
|
||||
final View wifiParent = (View) cbWifi.getParent();
|
||||
|
@ -270,6 +274,19 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
}
|
||||
});
|
||||
|
||||
// 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(
|
||||
settings.resolveActivity(context.getPackageManager()) == null || !Util.isDebuggable(context) ? View.GONE : View.VISIBLE);
|
||||
holder.btnSettings.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
context.startActivity(settings);
|
||||
}
|
||||
});
|
||||
|
||||
// Launch application
|
||||
holder.btnLaunch.setVisibility(rule.intent == null ? View.GONE : View.VISIBLE);
|
||||
holder.btnLaunch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 460 B |
Binary file not shown.
After Width: | Height: | Size: 326 B |
Binary file not shown.
After Width: | Height: | Size: 562 B |
Binary file not shown.
After Width: | Height: | Size: 843 B |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -125,11 +125,24 @@
|
|||
android:text="@string/title_roaming"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnLaunch"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/title_launch" />
|
||||
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:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="@string/title_launch" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue