Layout improvement

This commit is contained in:
M66B 2016-02-03 14:01:07 +01:00
parent 5ab87cdca8
commit 2834f1e555
2 changed files with 46 additions and 47 deletions

View File

@ -380,6 +380,27 @@ 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);
// 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() {
@Override
public void onClick(View view) {
context.startActivity(settings);
}
});
// Launch application
holder.btnLaunch.setVisibility(!debuggable || rule.intent == null ? View.GONE : View.VISIBLE);
holder.btnLaunch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(rule.intent);
}
});
// Show Wi-Fi screen on condition
holder.cbScreenWifi.setOnCheckedChangeListener(null);
holder.cbScreenWifi.setChecked(rule.screen_wifi);
@ -503,27 +524,6 @@ 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(
!debuggable || settings.resolveActivity(context.getPackageManager()) == null ? View.GONE : View.VISIBLE);
holder.btnSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(settings);
}
});
// Launch application
holder.btnLaunch.setVisibility(!debuggable || rule.intent == null ? View.GONE : View.VISIBLE);
holder.btnLaunch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(rule.intent);
}
});
// Show access rules
if (rule.expanded) {
// Access the database when expanded only

View File

@ -190,6 +190,27 @@
android:textStyle="italic"
android:visibility="gone" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="@string/title_launch" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -269,34 +290,12 @@
</LinearLayout>
</LinearLayout>
<LinearLayout
<ImageButton
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="4dp"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_delete_white_24dp" />
<ImageButton
android:id="@+id/btnSettings"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:src="@drawable/ic_settings_white_24dp" />
<Button
android:id="@+id/btnLaunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="@string/title_launch" />
</LinearLayout>
android:src="@drawable/ic_delete_white_24dp" />
<TextView
android:layout_width="wrap_content"