Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb8ab685 authored by Chia-chi Yeh's avatar Chia-chi Yeh Committed by Android (Google) Code Review
Browse files

Merge "VpnDialogs: hide the fields when the statistic numbers are unavailable."

parents cbaa6669 b0736abc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -32,12 +32,12 @@
        <TextView android:id="@+id/duration" style="@style/value"/>
    </TableRow>

    <TableRow>
    <TableRow android:id="@+id/data_transmitted_row" android:visibility="gone">
        <TextView android:text="@string/data_transmitted" style="@style/label"/>
        <TextView android:id="@+id/data_transmitted" style="@style/value"/>
    </TableRow>

    <TableRow>
    <TableRow android:id="@+id/data_received_row" android:visibility="gone">
        <TextView android:text="@string/data_received" style="@style/label"/>
        <TextView android:id="@+id/data_received" style="@style/value"/>
    </TableRow>
+0 −2
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@
    <!-- Label for the network usage of data received over VPN. [CHAR LIMIT=20] -->
    <string name="data_received">Received:</string>

    <!-- Dummy string for a blank value. [CHAR LIMIT=40] -->
    <string name="blank_value">--</string>
    <!-- Formatted string for the network usage over VPN. [CHAR LIMIT=40] -->
    <string name="data_value_format">
        <xliff:g id="number">%1$s</xliff:g> bytes /
+0 −1
Original line number Diff line number Diff line
@@ -25,6 +25,5 @@
        <item name="android:gravity">center_vertical|left</item>
        <item name="android:textSize">18sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:text">@string/blank_value</item>
    </style>
</resources>
+11 −2
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class ManageDialog extends AlertActivity implements
    private TextView mDuration;
    private TextView mDataTransmitted;
    private TextView mDataReceived;
    private boolean mDataRowsHidden;

    private Handler mHandler;

@@ -76,6 +77,7 @@ public class ManageDialog extends AlertActivity implements
            mDuration = (TextView) view.findViewById(R.id.duration);
            mDataTransmitted = (TextView) view.findViewById(R.id.data_transmitted);
            mDataReceived = (TextView) view.findViewById(R.id.data_received);
            mDataRowsHidden = true;

            if (mConfig.user.equals(VpnConfig.LEGACY_VPN)) {
                mAlertParams.mIconId = android.R.drawable.ic_dialog_info;
@@ -140,8 +142,15 @@ public class ManageDialog extends AlertActivity implements
                        seconds / 3600, seconds / 60 % 60, seconds % 60));
            }

            String[] numbers = getStatistics();
            String[] numbers = getNumbers();
            if (numbers != null) {
                // First unhide the related data rows.
                if (mDataRowsHidden) {
                    findViewById(R.id.data_transmitted_row).setVisibility(View.VISIBLE);
                    findViewById(R.id.data_received_row).setVisibility(View.VISIBLE);
                    mDataRowsHidden = false;
                }

                // [1] and [2] are received data in bytes and packets.
                mDataReceived.setText(getString(R.string.data_value_format,
                        numbers[1], numbers[2]));
@@ -155,7 +164,7 @@ public class ManageDialog extends AlertActivity implements
        return true;
    }

    private String[] getStatistics() {
    private String[] getNumbers() {
        DataInputStream in = null;
        try {
            // See dev_seq_printf_stats() in net/core/dev.c.