android: Show a retry button in the error banner
The button to view the log is now below the status info. And since the IMC results are just below that we don't need a special handling for that anymore.
This commit is contained in:
+25
-51
@@ -61,7 +61,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
private ProgressBar mProgress;
|
||||
private LinearLayout mErrorView;
|
||||
private TextView mErrorText;
|
||||
private Button mErrorDetails;
|
||||
private Button mErrorRetry;
|
||||
private Button mDismissError;
|
||||
private long mErrorConnectionID;
|
||||
private VpnStateService mService;
|
||||
@@ -81,6 +81,17 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
updateView();
|
||||
}
|
||||
};
|
||||
private OnClickListener mDisconnectListener = new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if (mService != null)
|
||||
{
|
||||
mService.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
@@ -117,22 +128,11 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
View view = inflater.inflate(R.layout.vpn_state_fragment, null);
|
||||
|
||||
mActionButton = (Button)view.findViewById(R.id.action);
|
||||
mActionButton.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if (mService != null)
|
||||
{
|
||||
mService.disconnect();
|
||||
}
|
||||
}
|
||||
});
|
||||
enableActionButton(null);
|
||||
|
||||
mErrorView = view.findViewById(R.id.vpn_error);
|
||||
mErrorText = view.findViewById(R.id.vpn_error_text);
|
||||
mErrorDetails = view.findViewById(R.id.error_details);
|
||||
mErrorRetry = view.findViewById(R.id.retry);
|
||||
mDismissError = view.findViewById(R.id.dismiss_error);
|
||||
mProgress = (ProgressBar)view.findViewById(R.id.progress);
|
||||
mStateView = (TextView)view.findViewById(R.id.vpn_state);
|
||||
@@ -140,14 +140,13 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
mProfileView = (TextView)view.findViewById(R.id.vpn_profile_label);
|
||||
mProfileNameView = (TextView)view.findViewById(R.id.vpn_profile_name);
|
||||
|
||||
mDismissError.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
mErrorRetry.setOnClickListener(v -> {
|
||||
if (mService != null)
|
||||
{
|
||||
clearError();
|
||||
mService.reconnect();
|
||||
}
|
||||
});
|
||||
mDismissError.setOnClickListener(v -> clearError());
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -255,15 +254,19 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
mErrorView.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
mErrorConnectionID = connectionID;
|
||||
mProfileNameView.setText(name);
|
||||
showProfile(true);
|
||||
mProgress.setVisibility(View.GONE);
|
||||
enableActionButton(null);
|
||||
mStateView.setText(R.string.state_error);
|
||||
mStateView.setTextColor(mColorStateError);
|
||||
showError(mService.getErrorText());
|
||||
enableActionButton(getString(R.string.show_log));
|
||||
mActionButton.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(getActivity(), LogActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
mErrorText.setText(getString(R.string.error_format, getString(mService.getErrorText())));
|
||||
mErrorView.setVisibility(View.VISIBLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -278,6 +281,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
mActionButton.setText(text);
|
||||
mActionButton.setEnabled(text != null);
|
||||
mActionButton.setVisibility(text != null ? View.VISIBLE : View.GONE);
|
||||
mActionButton.setOnClickListener(mDisconnectListener);
|
||||
}
|
||||
|
||||
private void clearError()
|
||||
@@ -292,34 +296,4 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
|
||||
}
|
||||
updateView();
|
||||
}
|
||||
|
||||
private void showError(int textid)
|
||||
{
|
||||
final List<RemediationInstruction> instructions = mService.getRemediationInstructions();
|
||||
final boolean show_instructions = mService.getImcState() == ImcState.BLOCK && !instructions.isEmpty();
|
||||
int text = show_instructions ? R.string.show_remediation_instructions : R.string.show_log;
|
||||
|
||||
mErrorText.setText(getString(R.string.error_format, getString(textid)));
|
||||
mErrorDetails.setText(text);
|
||||
mErrorDetails.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent intent;
|
||||
if (show_instructions)
|
||||
{
|
||||
intent = new Intent(getActivity(), RemediationInstructionsActivity.class);
|
||||
intent.putParcelableArrayListExtra(RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS,
|
||||
new ArrayList<RemediationInstruction>(instructions));
|
||||
}
|
||||
else
|
||||
{
|
||||
intent = new Intent(getActivity(), LogActivity.class);
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
mErrorView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/error_details"
|
||||
android:id="@+id/retry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/show_log"
|
||||
android:text="@string/retry"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
|
||||
@@ -197,6 +197,7 @@
|
||||
<string name="disconnect_question">VPN Verbindung trennen?</string>
|
||||
<string name="disconnect_active_connection">Dies trennt die aktuelle VPN Verbindung!</string>
|
||||
<string name="connect">Verbinden</string>
|
||||
<string name="retry">Wiederholen</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">VPN umschalten</string>
|
||||
|
||||
@@ -197,6 +197,7 @@
|
||||
<string name="disconnect_question">Disconnect VPN?</string>
|
||||
<string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
|
||||
<string name="connect">Połącz</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">Toggle VPN</string>
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
<string name="disconnect_question">Disconnect VPN?</string>
|
||||
<string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
|
||||
<string name="connect">Соединить</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">Toggle VPN</string>
|
||||
|
||||
@@ -195,6 +195,7 @@
|
||||
<string name="disconnect_question">Disconnect VPN?</string>
|
||||
<string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
|
||||
<string name="connect">Підключити</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">Toggle VPN</string>
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
<string name="disconnect_question">Disconnect VPN?</string>
|
||||
<string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
|
||||
<string name="connect">连接</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">Toggle VPN</string>
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
<string name="disconnect_question">Disconnect VPN?</string>
|
||||
<string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
|
||||
<string name="connect">連線</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">Toggle VPN</string>
|
||||
|
||||
@@ -197,6 +197,7 @@
|
||||
<string name="disconnect_question">Disconnect VPN?</string>
|
||||
<string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
|
||||
<string name="connect">Connect</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<!-- Quick Settings tile -->
|
||||
<string name="tile_default">Toggle VPN</string>
|
||||
|
||||
Reference in New Issue
Block a user