use of com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotSupportedException in project nextcloud-notes by stefan-niedermann.
the class TipsAdapter method setThrowables.
public void setThrowables(@NonNull List<Throwable> throwables) {
for (final var throwable : throwables) {
if (throwable instanceof TokenMismatchException) {
add(R.string.error_dialog_tip_token_mismatch_retry);
add(R.string.error_dialog_tip_token_mismatch_clear_storage);
final var intent = new Intent(ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + BuildConfig.APPLICATION_ID)).putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_open_deck_info);
add(R.string.error_dialog_tip_clear_storage, intent);
} else if (throwable instanceof NextcloudFilesAppNotSupportedException) {
add(R.string.error_dialog_tip_files_outdated);
} else if (throwable instanceof NextcloudApiNotRespondingException) {
if (VERSION.SDK_INT >= VERSION_CODES.M) {
add(R.string.error_dialog_tip_disable_battery_optimizations, new Intent().setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS).putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_open_battery_settings));
} else {
add(R.string.error_dialog_tip_disable_battery_optimizations);
}
add(R.string.error_dialog_tip_files_force_stop);
add(R.string.error_dialog_tip_files_delete_storage);
final var intent = new Intent(ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + BuildConfig.APPLICATION_ID)).putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_open_deck_info);
add(R.string.error_dialog_tip_clear_storage, intent);
} else if (throwable instanceof SocketTimeoutException || throwable instanceof ConnectException) {
add(R.string.error_dialog_timeout_instance);
add(R.string.error_dialog_timeout_toggle, new Intent(Settings.ACTION_WIFI_SETTINGS).putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_open_network));
} else if (throwable instanceof JSONException || throwable instanceof NullPointerException) {
add(R.string.error_dialog_check_server);
} else if (throwable instanceof NextcloudHttpRequestFailedException) {
final int statusCode = ((NextcloudHttpRequestFailedException) throwable).getStatusCode();
switch(statusCode) {
case 302:
add(R.string.error_dialog_server_app_enabled);
add(R.string.error_dialog_redirect);
break;
case 500:
add(R.string.error_dialog_check_server_logs);
break;
case 503:
add(R.string.error_dialog_check_maintenance);
break;
case 507:
add(R.string.error_dialog_insufficient_storage);
break;
}
} else if (throwable instanceof UnknownErrorException) {
if ("com.nextcloud.android.sso.QueryParam".equals(throwable.getMessage())) {
add(R.string.error_dialog_min_version, new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.nextcloud.client")).putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_update_files_app));
}
}
}
notifyDataSetChanged();
}
Aggregations