Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-03-20 20:17:57 +0300
committerStefan Niedermann <info@niedermann.it>2021-03-20 20:21:35 +0300
commit72fdeead894b854ca34c4f29dbf8a1452d1567fa (patch)
tree1a6a26a0efbea7169759bbe2b0ce8b334a28ef5f
parente3de67aa4824a4ffa19803a4211e3dd9d26986de (diff)
Fix #680 Loading indicator is shown indefinitely and no synchronization
Signed-off-by: Stefan Niedermann <info@niedermann.it>
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java2
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java36
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsModel.java5
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java2
-rw-r--r--app/src/main/res/values/strings.xml2
5 files changed, 40 insertions, 7 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
index e1909737f..877a5d977 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
@@ -508,10 +508,12 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
@Override
public void onError(Throwable throwable) {
+ binding.swipeRefreshLayout.setRefreshing(false);
if (throwable instanceof OfflineException) {
DeckLog.info("Cannot refresh capabilities because device is offline.");
} else {
super.onError(throwable);
+ ExceptionDialogFragment.newInstance(throwable, account).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName());
}
}
});
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
index 6bfd82b13..b87cee5f9 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
@@ -2,6 +2,7 @@ package it.niedermann.nextcloud.deck.ui.exception.tips;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
@@ -16,6 +17,7 @@ import androidx.annotation.StringRes;
import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView;
+import com.nextcloud.android.sso.Constants;
import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException;
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotSupportedException;
import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException;
@@ -39,14 +41,15 @@ import static it.niedermann.nextcloud.deck.ui.exception.ExceptionDialogFragment.
public class TipsAdapter extends RecyclerView.Adapter<TipsViewHolder> {
+ private static final String[] APPS = new String[]{Constants.PACKAGE_NAME_PROD, Constants.PACKAGE_NAME_DEV};
private static final Intent INTENT_APP_INFO = 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);
@NonNull
- private Consumer<Intent> actionButtonClickedListener;
+ private final Consumer<Intent> actionButtonClickedListener;
@NonNull
- private List<TipsModel> tips = new LinkedList<>();
+ private final List<TipsModel> tips = new LinkedList<>();
public TipsAdapter(@NonNull Consumer<Intent> actionButtonClickedListener) {
this.actionButtonClickedListener = actionButtonClickedListener;
@@ -113,6 +116,19 @@ public class TipsAdapter extends RecyclerView.Adapter<TipsViewHolder> {
}
} else if (throwable instanceof UploadAttachmentFailedException) {
add(R.string.error_dialog_attachment_upload_failed);
+ } else if (throwable instanceof ClassNotFoundException) {
+ final Throwable cause = ((ClassNotFoundException) throwable).getCause();
+ if (cause != null) {
+ final String message = cause.getMessage();
+ if (message != null && message.toLowerCase().contains("certificate")) {
+ final Intent filesOpenIntent = getOpenFilesIntent(context);
+ if (filesOpenIntent == null) {
+ add(R.string.error_dialog_certificate);
+ } else {
+ add(R.string.error_dialog_certificate, filesOpenIntent);
+ }
+ }
+ }
} else if (throwable instanceof DeckException) {
switch (((DeckException) throwable).getHint()) {
case CAPABILITIES_VERSION_NOT_PARSABLE:
@@ -142,7 +158,7 @@ public class TipsAdapter extends RecyclerView.Adapter<TipsViewHolder> {
add(R.string.error_dialog_tip_clear_storage_might_help);
add(R.string.error_dialog_tip_clear_storage, INTENT_APP_INFO);
} else if (throwable instanceof RuntimeException) {
- if (throwable.getMessage() != null && throwable.getMessage().contains("database")) {
+ if (throwable.getMessage() != null && throwable.getMessage().toLowerCase().contains("database")) {
Intent reportIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.url_report_bug)))
.putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_report_issue);
add(R.string.error_dialog_tip_database_upgrade_failed, reportIntent);
@@ -159,4 +175,18 @@ public class TipsAdapter extends RecyclerView.Adapter<TipsViewHolder> {
tips.add(new TipsModel(text, primaryAction));
notifyItemInserted(tips.size());
}
+
+ @Nullable
+ private static Intent getOpenFilesIntent(@NonNull Context context) {
+ final PackageManager pm = context.getPackageManager();
+ for (String app : APPS) {
+ try {
+ pm.getPackageInfo(app, PackageManager.GET_ACTIVITIES);
+ return pm.getLaunchIntentForPackage(app)
+ .putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_open_nextcloud_app);
+ } catch (PackageManager.NameNotFoundException ignored) {
+ }
+ }
+ return null;
+ }
} \ No newline at end of file
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsModel.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsModel.java
index 00bfa6b15..749579812 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsModel.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsModel.java
@@ -8,10 +8,9 @@ import androidx.annotation.StringRes;
@SuppressWarnings("WeakerAccess")
public class TipsModel {
@StringRes
- private int text;
+ private final int text;
@Nullable
- private
- Intent actionIntent;
+ private final Intent actionIntent;
TipsModel(@StringRes int text, @Nullable Intent actionIntent) {
this.text = text;
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java
index 622a32e3b..7d254459e 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsViewHolder.java
@@ -20,7 +20,7 @@ public class TipsViewHolder extends RecyclerView.ViewHolder {
binding = ItemTipBinding.bind(itemView);
}
- public void bind(TipsModel tip, Consumer<Intent> actionButtonClickedListener) {
+ public void bind(@NonNull TipsModel tip, @NonNull Consumer<Intent> actionButtonClickedListener) {
binding.tip.setText(tip.getText());
final Intent actionIntent = tip.getActionIntent();
if (actionIntent != null && actionIntent.hasExtra(INTENT_EXTRA_BUTTON_TEXT)) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ca5b0cc9b..e996d5570 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -246,8 +246,10 @@
<string name="error_dialog_user_not_found_in_database">The current user does not match the user we have in our database. If you are using LDAP on your Nextcloud instance, your Nextcloud app might have stored an old user ID.</string>
<string name="error_dialog_capabilities_not_parsable">We could not fetch the capabilities of your server. Please make sure your server is running well and other client apps are able to access Nextcloud.</string>
<string name="error_dialog_attachment_upload_failed">An attachment could not be uploaded. Please try to share it on another way and let us know about this bug.</string>
+ <string name="error_dialog_certificate">Something seems to be wrong with the certificate of the server. Please check all the accounts in the Nextcloud app for further information.</string>
<string name="error_dialog_tip_disable_battery_optimizations">Please disable all battery optimizations for Nextcloud and the Deck app.</string>
<string name="error_action_open_deck_info">Open App info</string>
+ <string name="error_action_open_nextcloud_app">Open Nextcloud app</string>
<string name="error_action_open_network">Network settings</string>
<string name="error_action_server_logs">Server logs</string>
<string name="error_action_install">Install</string>