mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 14:49:53 +01:00
Add optional summary text to transport cards.
This commit is contained in:
@@ -157,6 +157,14 @@ public class TransportsActivity extends BriarActivity {
|
|||||||
switchCompat.isChecked()));
|
switchCompat.isChecked()));
|
||||||
switchCompat.setChecked(t.isSwitchChecked);
|
switchCompat.setChecked(t.isSwitchChecked);
|
||||||
|
|
||||||
|
TextView summary = view.findViewById(R.id.summary);
|
||||||
|
if (t.summary == 0) {
|
||||||
|
summary.setVisibility(GONE);
|
||||||
|
} else {
|
||||||
|
summary.setText(t.summary);
|
||||||
|
summary.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
TextView deviceStatus = view.findViewById(R.id.deviceStatus);
|
TextView deviceStatus = view.findViewById(R.id.deviceStatus);
|
||||||
deviceStatus.setText(getBulletString(t.deviceStatus));
|
deviceStatus.setText(getBulletString(t.deviceStatus));
|
||||||
|
|
||||||
@@ -170,19 +178,20 @@ public class TransportsActivity extends BriarActivity {
|
|||||||
|
|
||||||
Transport tor = createTransport(TorConstants.ID,
|
Transport tor = createTransport(TorConstants.ID,
|
||||||
R.drawable.transport_tor, R.string.transport_tor,
|
R.drawable.transport_tor, R.string.transport_tor,
|
||||||
R.string.tor_enable_title, R.string.tor_device_status_offline,
|
R.string.tor_enable_title, R.string.tor_enable_summary,
|
||||||
|
R.string.tor_device_status_offline,
|
||||||
R.string.tor_plugin_status_inactive);
|
R.string.tor_plugin_status_inactive);
|
||||||
transports.add(tor);
|
transports.add(tor);
|
||||||
|
|
||||||
Transport wifi = createTransport(LanTcpConstants.ID,
|
Transport wifi = createTransport(LanTcpConstants.ID,
|
||||||
R.drawable.transport_lan, R.string.transport_lan_long,
|
R.drawable.transport_lan, R.string.transport_lan_long,
|
||||||
R.string.wifi_setting, R.string.lan_device_status_off,
|
R.string.wifi_setting, 0, R.string.lan_device_status_off,
|
||||||
R.string.lan_plugin_status_inactive);
|
R.string.lan_plugin_status_inactive);
|
||||||
transports.add(wifi);
|
transports.add(wifi);
|
||||||
|
|
||||||
Transport bt = createTransport(BluetoothConstants.ID,
|
Transport bt = createTransport(BluetoothConstants.ID,
|
||||||
R.drawable.transport_bt, R.string.transport_bt,
|
R.drawable.transport_bt, R.string.transport_bt,
|
||||||
R.string.bluetooth_setting, R.string.bt_device_status_off,
|
R.string.bluetooth_setting, 0, R.string.bt_device_status_off,
|
||||||
R.string.bt_plugin_status_inactive);
|
R.string.bt_plugin_status_inactive);
|
||||||
transports.add(bt);
|
transports.add(bt);
|
||||||
|
|
||||||
@@ -294,11 +303,11 @@ public class TransportsActivity extends BriarActivity {
|
|||||||
|
|
||||||
private Transport createTransport(TransportId id,
|
private Transport createTransport(TransportId id,
|
||||||
@DrawableRes int iconDrawable, @StringRes int title,
|
@DrawableRes int iconDrawable, @StringRes int title,
|
||||||
@StringRes int switchLabel, @StringRes int deviceStatus,
|
@StringRes int switchLabel, @StringRes int summary,
|
||||||
@StringRes int pluginStatus) {
|
@StringRes int deviceStatus, @StringRes int pluginStatus) {
|
||||||
int iconColor = getIconColor(STARTING_STOPPING);
|
int iconColor = getIconColor(STARTING_STOPPING);
|
||||||
Transport transport = new Transport(id, iconDrawable, iconColor, title,
|
Transport transport = new Transport(id, iconDrawable, iconColor, title,
|
||||||
switchLabel, false, deviceStatus, pluginStatus, false);
|
switchLabel, false, summary, deviceStatus, pluginStatus, false);
|
||||||
viewModel.getPluginState(id).observe(this, state -> {
|
viewModel.getPluginState(id).observe(this, state -> {
|
||||||
transport.iconColor = getIconColor(state);
|
transport.iconColor = getIconColor(state);
|
||||||
transport.pluginStatus = getPluginStatus(transport.id, state);
|
transport.pluginStatus = getPluginStatus(transport.id, state);
|
||||||
@@ -318,7 +327,7 @@ public class TransportsActivity extends BriarActivity {
|
|||||||
@DrawableRes
|
@DrawableRes
|
||||||
private final int iconDrawable;
|
private final int iconDrawable;
|
||||||
@StringRes
|
@StringRes
|
||||||
private final int title, switchLabel;
|
private final int title, switchLabel, summary;
|
||||||
|
|
||||||
@ColorRes
|
@ColorRes
|
||||||
private int iconColor;
|
private int iconColor;
|
||||||
@@ -326,10 +335,15 @@ public class TransportsActivity extends BriarActivity {
|
|||||||
private int deviceStatus, pluginStatus;
|
private int deviceStatus, pluginStatus;
|
||||||
private boolean isSwitchChecked, showPluginStatus;
|
private boolean isSwitchChecked, showPluginStatus;
|
||||||
|
|
||||||
private Transport(TransportId id, @DrawableRes int iconDrawable,
|
private Transport(TransportId id,
|
||||||
@ColorRes int iconColor, @StringRes int title,
|
@DrawableRes int iconDrawable,
|
||||||
@StringRes int switchLabel, boolean isSwitchChecked,
|
@ColorRes int iconColor,
|
||||||
@StringRes int deviceStatus, @StringRes int pluginStatus,
|
@StringRes int title,
|
||||||
|
@StringRes int switchLabel,
|
||||||
|
boolean isSwitchChecked,
|
||||||
|
@StringRes int summary,
|
||||||
|
@StringRes int deviceStatus,
|
||||||
|
@StringRes int pluginStatus,
|
||||||
boolean showPluginStatus) {
|
boolean showPluginStatus) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.iconDrawable = iconDrawable;
|
this.iconDrawable = iconDrawable;
|
||||||
@@ -337,6 +351,7 @@ public class TransportsActivity extends BriarActivity {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
this.switchLabel = switchLabel;
|
this.switchLabel = switchLabel;
|
||||||
this.isSwitchChecked = isSwitchChecked;
|
this.isSwitchChecked = isSwitchChecked;
|
||||||
|
this.summary = summary;
|
||||||
this.deviceStatus = deviceStatus;
|
this.deviceStatus = deviceStatus;
|
||||||
this.pluginStatus = pluginStatus;
|
this.pluginStatus = pluginStatus;
|
||||||
this.showPluginStatus = showPluginStatus;
|
this.showPluginStatus = showPluginStatus;
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
tools:ignore="UseCompoundDrawables">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
@@ -31,8 +32,8 @@
|
|||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_large"
|
||||||
tools:text="@string/transport_tor" />
|
tools:text="@string/transport_tor" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -41,13 +42,27 @@
|
|||||||
android:id="@+id/switchCompat"
|
android:id="@+id/switchCompat"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_medium"
|
||||||
|
android:widgetLayout="@layout/preference_switch_compat"
|
||||||
tools:checked="true"
|
tools:checked="true"
|
||||||
tools:text="@string/tor_enable_title" />
|
tools:text="@string/tor_enable_title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/summary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:layout_marginRight="32dp"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:text="@string/tor_enable_summary"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:text="@string/status_heading"
|
android:text="@string/status_heading"
|
||||||
android:textColor="?android:attr/textColorPrimary" />
|
android:textColor="?android:attr/textColorPrimary" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user