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

Commit 948f5fcf authored by Stefan Niedermann's avatar Stefan Niedermann Committed by Niedermann IT-Dienstleistungen
Browse files

Fix #1014 - 🔌 Handle offline state when adding accounts

parent ef7e2815
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class ImportAccountActivity extends AppCompatActivity {
                        runOnUiThread(() -> {
                            restoreCleanState();
                            if (e instanceof UnknownErrorException && e.getMessage().contains("No address associated with hostname")) {
                                // https://github.com/stefan-niedermann/nextcloud-notes/issues/1014
                                binding.status.setText(R.string.you_have_to_be_connected_to_the_internet_in_order_to_add_an_account);
                                binding.status.setVisibility(View.VISIBLE);
                            } else {
+6 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.nextcloud.android.sso.exceptions.AccountImportCancelledException;
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException;
import com.nextcloud.android.sso.exceptions.TokenMismatchException;
import com.nextcloud.android.sso.exceptions.UnknownErrorException;
import com.nextcloud.android.sso.helper.SingleAccountHelper;

import java.util.Collection;
@@ -71,6 +72,7 @@ import it.niedermann.owncloud.notes.main.navigation.NavigationClickListener;
import it.niedermann.owncloud.notes.main.navigation.NavigationItem;
import it.niedermann.owncloud.notes.persistence.CapabilitiesClient;
import it.niedermann.owncloud.notes.persistence.CapabilitiesWorker;
import it.niedermann.owncloud.notes.persistence.SSOClient;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.shared.model.Capabilities;
@@ -641,6 +643,7 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
                                    }).start();
                                }));
                            } catch (Exception e) {
                                SSOClient.invalidateAPICache(ssoAccount);
                                // Happens when importing an already existing account the second time
                                if (e instanceof TokenMismatchException && mainViewModel.getLocalAccountByAccountName(ssoAccount.name) != null) {
                                    Log.w(TAG, "Received " + TokenMismatchException.class.getSimpleName() + " and the given ssoAccount.name (" + ssoAccount.name + ") does already exist in the database. Assume that this account has already been imported.");
@@ -649,6 +652,9 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
                                        // TODO there is already a sync in progress and results in displaying a TokenMissMatchException snackbar which conflicts with this one
                                        coordinatorLayout.post(() -> BrandedSnackbar.make(coordinatorLayout, R.string.account_already_imported, Snackbar.LENGTH_LONG).show());
                                    });
                                } else if (e instanceof UnknownErrorException && e.getMessage().contains("No address associated with hostname")) {
                                    // https://github.com/stefan-niedermann/nextcloud-notes/issues/1014
                                    runOnUiThread(() -> Snackbar.make(coordinatorLayout, R.string.you_have_to_be_connected_to_the_internet_in_order_to_add_an_account, Snackbar.LENGTH_LONG).show());
                                } else {
                                    e.printStackTrace();
                                    runOnUiThread(() -> {
+2 −1
Original line number Diff line number Diff line
- ⚠️️ Display confirm dialog when deleting an account with unsynchronized changes (#989) - by @AlpAcA0072
- ➖ Allow dashes in note titles (#1104)
- 🌐 Support links in tables (#1115)
- 🔌 Handle offline state when adding accounts (#1014)
 No newline at end of file