diff --git a/app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java b/app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java
index e93e587c..5d4795e0 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java
@@ -15,11 +15,16 @@ import static androidx.preference.PreferenceManager.getDefaultSharedPreferences;
import android.app.Application;
import android.content.Context;
+import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebView;
import androidx.appcompat.app.AppCompatDelegate;
+import com.nextcloud.android.sso.FilesAppTypeRegistry;
+import com.nextcloud.android.sso.model.FilesAppType;
+
+import it.niedermann.owncloud.notes.branding.BrandingUtil;
import it.niedermann.owncloud.notes.preferences.DarkModeSetting;
public class NotesApplication extends Application {
@@ -31,6 +36,7 @@ public class NotesApplication extends Application {
private static long lastInteraction = 0;
private static String PREF_KEY_THEME;
private static boolean isGridViewEnabled = false;
+ private static BrandingUtil brandingUtil;
@Override
public void onCreate() {
@@ -40,9 +46,26 @@ public class NotesApplication extends Application {
lockedPreference = prefs.getBoolean(getString(R.string.pref_key_lock), false);
isGridViewEnabled = getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_key_gridview), false);
super.onCreate();
+ brandingUtil = BrandingUtil.getInstance(this);
if (BuildConfig.DEBUG) {
WebView.setWebContentsDebuggingEnabled(true);
}
+ registerFilesAppType();
+ }
+
+ private void registerFilesAppType() {
+ String packageId = getResources().getString(R.string.package_id);
+ String accountType = getResources().getString(R.string.account_type);
+
+ if (TextUtils.isEmpty(packageId) || TextUtils.isEmpty(accountType)) {
+ return;
+ }
+
+ FilesAppTypeRegistry.getInstance().init(new FilesAppType(packageId, accountType, FilesAppType.Type.PROD));
+ }
+
+ public static BrandingUtil brandingUtil() {
+ return brandingUtil;
}
public static void setAppTheme(DarkModeSetting setting) {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerDialogFragment.java
index 75fb39e5..9f9a11ee 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerDialogFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerDialogFragment.java
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandedDialogFragment;
import it.niedermann.owncloud.notes.databinding.DialogChooseAccountBinding;
@@ -80,11 +81,11 @@ public class AccountPickerDialogFragment extends BrandedDialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- final var dialogBuilder = new MaterialAlertDialogBuilder(requireActivity())
+ final MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.simple_move)
.setNegativeButton(android.R.string.cancel, null);
- if (targetAccounts.size() > 0) {
+ if (!targetAccounts.isEmpty()) {
final var binding = DialogChooseAccountBinding.inflate(LayoutInflater.from(requireContext()));
final var adapter = new AccountChooserAdapter(targetAccounts, (account -> {
accountPickerListener.onAccountPicked(account);
@@ -96,6 +97,8 @@ public class AccountPickerDialogFragment extends BrandedDialogFragment {
dialogBuilder.setMessage(getString(R.string.no_other_accounts));
}
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(requireContext(), dialogBuilder);
+
return dialogBuilder.create();
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java
index 31876116..3c9e4e20 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java
@@ -7,6 +7,7 @@
*/
package it.niedermann.owncloud.notes.accountswitcher;
+
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
@@ -21,6 +22,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandedDialogFragment;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
@@ -107,9 +109,12 @@ public class AccountSwitcherDialog extends BrandedDialogFragment {
dismiss();
});
- return new MaterialAlertDialogBuilder(requireContext())
- .setView(binding.getRoot())
- .create();
+ final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext())
+ .setView(binding.getRoot());
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(requireContext(), builder);
+
+ return builder.create();
}
public static DialogFragment newInstance(long currentAccountId) {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java
index 500da3f3..1d15394c 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java
@@ -6,45 +6,51 @@
*/
package it.niedermann.owncloud.notes.branding;
-import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceViewHolder;
-import androidx.preference.SwitchPreference;
+import androidx.preference.SwitchPreferenceCompat;
-public class BrandedSwitchPreference extends SwitchPreference implements Branded {
+import com.google.android.material.materialswitch.MaterialSwitch;
+
+import it.niedermann.owncloud.notes.R;
+
+public class BrandedSwitchPreference extends SwitchPreferenceCompat implements Branded {
@ColorInt
private Integer mainColor = null;
- @SuppressLint("UseSwitchCompatOrMaterialCode")
@Nullable
- private Switch switchView;
+ private MaterialSwitch switchView;
public BrandedSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
+ setWidgetLayoutResource(R.layout.preference_switch);
}
public BrandedSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
+ setWidgetLayoutResource(R.layout.preference_switch);
}
public BrandedSwitchPreference(Context context, AttributeSet attrs) {
super(context, attrs);
+ setWidgetLayoutResource(R.layout.preference_switch);
}
public BrandedSwitchPreference(Context context) {
super(context);
+ setWidgetLayoutResource(R.layout.preference_switch);
}
@Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
+ public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
if (holder.itemView instanceof ViewGroup) {
@@ -65,7 +71,7 @@ public class BrandedSwitchPreference extends SwitchPreference implements Branded
private void applyBrand() {
if (switchView != null) {
final var util = BrandingUtil.of(mainColor, getContext());
- util.platform.colorSwitch(switchView);
+ util.material.colorMaterialSwitch(switchView);
}
}
@@ -76,19 +82,19 @@ public class BrandedSwitchPreference extends SwitchPreference implements Branded
* @return A Switch class or null
* @see Source
*/
- private Switch findSwitchWidget(View view) {
- if (view instanceof Switch) {
- return (Switch) view;
+ private MaterialSwitch findSwitchWidget(View view) {
+ if (view instanceof MaterialSwitch) {
+ return (MaterialSwitch) view;
}
if (view instanceof ViewGroup viewGroup) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
final var child = viewGroup.getChildAt(i);
if (child instanceof ViewGroup) {
- @SuppressLint("UseSwitchCompatOrMaterialCode") final var result = findSwitchWidget(child);
+ final var result = findSwitchWidget(child);
if (result != null) return result;
}
- if (child instanceof Switch) {
- return (Switch) child;
+ if (child instanceof MaterialSwitch) {
+ return (MaterialSwitch) child;
}
}
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
index d42ce8e0..71b0311b 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
@@ -54,6 +54,14 @@ public class BrandingUtil extends ViewThemeUtilsBase {
this.notes = new NotesViewThemeUtils(schemes);
}
+ public static BrandingUtil getInstance(@NonNull Context context) {
+ int color = BrandingUtil.readBrandMainColor(context);
+ return new BrandingUtil(
+ MaterialSchemes.Companion.fromColor(color),
+ new com.nextcloud.android.common.ui.color.ColorUtil(context)
+ );
+ }
+
public static BrandingUtil of(@ColorInt int color, @NonNull Context context) {
return CACHE.computeIfAbsent(color, c -> new BrandingUtil(
MaterialSchemes.Companion.fromColor(c),
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/DeleteAlertDialogBuilder.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/DeleteAlertDialogBuilder.java
index 8d9cdb15..1c8166b1 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/DeleteAlertDialogBuilder.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/DeleteAlertDialogBuilder.java
@@ -7,15 +7,14 @@
package it.niedermann.owncloud.notes.branding;
import android.content.Context;
-import android.content.DialogInterface;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
-import androidx.core.content.ContextCompat;
+import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import it.niedermann.owncloud.notes.R;
+import it.niedermann.owncloud.notes.NotesApplication;
public class DeleteAlertDialogBuilder extends MaterialAlertDialogBuilder {
@@ -35,9 +34,12 @@ public class DeleteAlertDialogBuilder extends MaterialAlertDialogBuilder {
}
public void applyBrand() {
- final var positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
- if (positiveButton != null) {
- positiveButton.setTextColor(ContextCompat.getColor(getContext(), R.color.danger));
+ if (dialog.getButton(AlertDialog.BUTTON_POSITIVE) instanceof MaterialButton positiveButton) {
+ NotesApplication.brandingUtil().material.colorMaterialButtonPrimaryTonal(positiveButton);
+ }
+
+ if (dialog.getButton(AlertDialog.BUTTON_NEGATIVE) instanceof MaterialButton negativeButton) {
+ NotesApplication.brandingUtil().material.colorMaterialButtonPrimaryBorderless(negativeButton);
}
}
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java
index 500a5bcf..ebc0c73b 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java
@@ -24,6 +24,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.List;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandedDialogFragment;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
@@ -155,13 +156,16 @@ public class CategoryDialogFragment extends BrandedDialogFragment {
}
});
- return new MaterialAlertDialogBuilder(requireContext())
+ final MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.change_category_title)
.setView(dialogView)
.setCancelable(true)
.setPositiveButton(R.string.action_edit_save, (dialog, which) -> listener.onCategoryChosen(editCategory.getText().toString()))
- .setNegativeButton(R.string.simple_cancel, null)
- .create();
+ .setNegativeButton(R.string.simple_cancel, null);
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(requireContext(), alertDialogBuilder);
+
+ return alertDialogBuilder.create();
}
@Override
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java
index 55b3bddb..c657912c 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java
@@ -17,6 +17,7 @@ import androidx.fragment.app.DialogFragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandedDialogFragment;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
@@ -59,13 +60,16 @@ public class EditTitleDialogFragment extends BrandedDialogFragment {
binding.title.setText(oldTitle);
}
- return new MaterialAlertDialogBuilder(requireContext())
+ final MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.change_note_title)
.setView(dialogView)
.setCancelable(true)
.setPositiveButton(R.string.action_edit_save, (dialog, which) -> listener.onTitleEdited(binding.title.getText().toString()))
- .setNegativeButton(R.string.simple_cancel, null)
- .create();
+ .setNegativeButton(R.string.simple_cancel, null);
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(requireContext(), alertDialogBuilder);
+
+ return alertDialogBuilder.create();
}
@Override
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionActivity.java
index 0d9f4d26..4401d0b3 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionActivity.java
@@ -19,6 +19,7 @@ import java.util.Collections;
import it.niedermann.android.util.ClipboardUtil;
import it.niedermann.nextcloud.exception.ExceptionUtil;
import it.niedermann.owncloud.notes.BuildConfig;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ActivityExceptionBinding;
import it.niedermann.owncloud.notes.exception.tips.TipsAdapter;
@@ -53,6 +54,11 @@ public class ExceptionActivity extends AppCompatActivity {
binding.copy.setOnClickListener((v) -> ClipboardUtil.copyToClipboard(this, getString(R.string.simple_exception), "```\n" + debugInfos + "\n```"));
binding.close.setOnClickListener((v) -> finish());
+ NotesApplication.brandingUtil().platform.themeStatusBar(this);
+ NotesApplication.brandingUtil().material.themeToolbar(binding.toolbar);
+ NotesApplication.brandingUtil().material.colorMaterialButtonPrimaryBorderless(binding.close);
+ NotesApplication.brandingUtil().material.colorMaterialButtonPrimaryFilled(binding.copy);
+
adapter.setThrowables(Collections.singletonList(throwable));
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionDialogFragment.java
index 4a6d1e87..4f5e15aa 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionDialogFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionDialogFragment.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import it.niedermann.android.util.ClipboardUtil;
import it.niedermann.nextcloud.exception.ExceptionUtil;
import it.niedermann.owncloud.notes.BuildConfig;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.DialogExceptionBinding;
import it.niedermann.owncloud.notes.exception.tips.TipsAdapter;
@@ -69,12 +70,15 @@ public class ExceptionDialogFragment extends AppCompatDialogFragment {
adapter.setThrowables(throwables);
- return new MaterialAlertDialogBuilder(requireActivity())
+ final MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(requireActivity())
.setView(binding.getRoot())
.setTitle(R.string.error_dialog_title)
.setPositiveButton(android.R.string.copy, (a, b) -> ClipboardUtil.copyToClipboard(requireContext(), getString(R.string.simple_exception), "```\n" + debugInfos + "\n```"))
- .setNegativeButton(R.string.simple_close, null)
- .create();
+ .setNegativeButton(R.string.simple_close, null);
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(requireContext(), alertDialogBuilder);
+
+ return alertDialogBuilder.create();
}
public static DialogFragment newInstance(ArrayList exceptions) {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java
index f0664154..159c41d0 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java
@@ -71,6 +71,7 @@ import java.util.stream.Collectors;
import it.niedermann.android.util.ColorUtil;
import it.niedermann.owncloud.notes.LockedActivity;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener;
import it.niedermann.owncloud.notes.accountswitcher.AccountSwitcherDialog;
@@ -179,37 +180,7 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
runOnUiThread(() -> mainViewModel.postCurrentAccount(account));
} catch (NextcloudFilesAppAccountNotFoundException e) {
// Verbose log output for https://github.com/nextcloud/notes-android/issues/1256
- runOnUiThread(() -> new MaterialAlertDialogBuilder(this)
- .setTitle(NextcloudFilesAppAccountNotFoundException.class.getSimpleName())
- .setMessage(R.string.backup)
- .setPositiveButton(R.string.simple_backup, (a, b) -> executor.submit(() -> {
- final var modifiedNotes = new LinkedList();
- for (final var account : mainViewModel.getAccounts()) {
- modifiedNotes.addAll(mainViewModel.getLocalModifiedNotes(account.getId()));
- }
- if (modifiedNotes.size() == 1) {
- final var note = modifiedNotes.get(0);
- ShareUtil.openShareDialog(this, note.getTitle(), note.getContent());
- } else {
- ShareUtil.openShareDialog(this,
- getResources().getQuantityString(R.plurals.share_multiple, modifiedNotes.size(), modifiedNotes.size()),
- mainViewModel.collectNoteContents(modifiedNotes.stream().map(Note::getId).collect(Collectors.toList())));
- }
- }))
- .setNegativeButton(R.string.simple_error, (a, b) -> {
- final var ssoPreferences = AccountImporter.getSharedPreferences(getApplicationContext());
- final var ssoPreferencesString = new StringBuilder()
- .append("Current SSO account: ").append(ssoPreferences.getString("PREF_CURRENT_ACCOUNT_STRING", null)).append("\n")
- .append("\n")
- .append("SSO SharedPreferences: ").append("\n");
- for (final var entry : ssoPreferences.getAll().entrySet()) {
- ssoPreferencesString.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
- }
- ssoPreferencesString.append("\n")
- .append("Available accounts in DB: ").append(TextUtils.join(", ", mainViewModel.getAccounts().stream().map(Account::getAccountName).collect(Collectors.toList())));
- runOnUiThread(() -> ExceptionDialogFragment.newInstance(new RuntimeException(e.getMessage(), new RuntimeException(ssoPreferencesString.toString(), e))).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName()));
- })
- .show());
+ runOnUiThread(() -> showAppAccountNotFoundAlertDialog(e));
} catch (NoCurrentAccountSelectedException e) {
runOnUiThread(() -> ExceptionDialogFragment.newInstance(e).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName()));
}
@@ -354,6 +325,43 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
});
}
+ private void showAppAccountNotFoundAlertDialog(NextcloudFilesAppAccountNotFoundException e) {
+ final MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(this)
+ .setTitle(NextcloudFilesAppAccountNotFoundException.class.getSimpleName())
+ .setMessage(R.string.backup)
+ .setPositiveButton(R.string.simple_backup, (a, b) -> executor.submit(() -> {
+ final var modifiedNotes = new LinkedList();
+ for (final var account : mainViewModel.getAccounts()) {
+ modifiedNotes.addAll(mainViewModel.getLocalModifiedNotes(account.getId()));
+ }
+ if (modifiedNotes.size() == 1) {
+ final var note = modifiedNotes.get(0);
+ ShareUtil.openShareDialog(this, note.getTitle(), note.getContent());
+ } else {
+ ShareUtil.openShareDialog(this,
+ getResources().getQuantityString(R.plurals.share_multiple, modifiedNotes.size(), modifiedNotes.size()),
+ mainViewModel.collectNoteContents(modifiedNotes.stream().map(Note::getId).collect(Collectors.toList())));
+ }
+ }))
+ .setNegativeButton(R.string.simple_error, (a, b) -> {
+ final var ssoPreferences = AccountImporter.getSharedPreferences(getApplicationContext());
+ final var ssoPreferencesString = new StringBuilder()
+ .append("Current SSO account: ").append(ssoPreferences.getString("PREF_CURRENT_ACCOUNT_STRING", null)).append("\n")
+ .append("\n")
+ .append("SSO SharedPreferences: ").append("\n");
+ for (final var entry : ssoPreferences.getAll().entrySet()) {
+ ssoPreferencesString.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
+ }
+ ssoPreferencesString.append("\n")
+ .append("Available accounts in DB: ").append(TextUtils.join(", ", mainViewModel.getAccounts().stream().map(Account::getAccountName).collect(Collectors.toList())));
+ runOnUiThread(() -> ExceptionDialogFragment.newInstance(new RuntimeException(e.getMessage(), new RuntimeException(ssoPreferencesString.toString(), e))).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName()));
+ });
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(this, alertDialogBuilder);
+
+ alertDialogBuilder.show();
+ }
+
@Override
protected void onResume() {
final var accountLiveData = mainViewModel.getCurrentAccount();
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java
index 12dda8d7..58384a8c 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountsActivity.java
@@ -28,6 +28,7 @@ import java.util.concurrent.Executors;
import java.util.function.Function;
import it.niedermann.owncloud.notes.LockedActivity;
+import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
import it.niedermann.owncloud.notes.branding.DeleteAlertDialogBuilder;
@@ -94,12 +95,7 @@ public class ManageAccountsActivity extends LockedActivity implements IManageAcc
public void onSuccess(Long unsynchronizedChangesCount) {
runOnUiThread(() -> {
if (unsynchronizedChangesCount > 0) {
- new DeleteAlertDialogBuilder(ManageAccountsActivity.this)
- .setTitle(getString(R.string.remove_account, accountToDelete.getUserName()))
- .setMessage(getResources().getQuantityString(R.plurals.remove_account_message, (int) unsynchronizedChangesCount.longValue(), accountToDelete.getAccountName(), unsynchronizedChangesCount))
- .setNeutralButton(android.R.string.cancel, null)
- .setPositiveButton(R.string.simple_remove, (d, l) -> viewModel.deleteAccount(accountToDelete, ManageAccountsActivity.this))
- .show();
+ showRemoveAccountAlertDialog(accountToDelete, unsynchronizedChangesCount);
} else {
viewModel.deleteAccount(accountToDelete, ManageAccountsActivity.this);
}
@@ -113,6 +109,18 @@ public class ManageAccountsActivity extends LockedActivity implements IManageAcc
});
}
+ private void showRemoveAccountAlertDialog(@NonNull Account accountToDelete, Long unsynchronizedChangesCount) {
+ final MaterialAlertDialogBuilder alertDialogBuilder = new DeleteAlertDialogBuilder(ManageAccountsActivity.this)
+ .setTitle(getString(R.string.remove_account, accountToDelete.getUserName()))
+ .setMessage(getResources().getQuantityString(R.plurals.remove_account_message, (int) unsynchronizedChangesCount.longValue(), accountToDelete.getAccountName(), unsynchronizedChangesCount))
+ .setNegativeButton(android.R.string.cancel, null)
+ .setPositiveButton(R.string.simple_remove, (d, l) -> viewModel.deleteAccount(accountToDelete, ManageAccountsActivity.this));
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(this, alertDialogBuilder);
+
+ alertDialogBuilder.show();
+ }
+
public void onChangeNotesPath(@NonNull Account localAccount) {
changeAccountSetting(localAccount,
R.string.settings_notes_path,
@@ -146,7 +154,7 @@ public class ManageAccountsActivity extends LockedActivity implements IManageAcc
binding.inputWrapper.setHint(title);
- final var dialog = new MaterialAlertDialogBuilder(this)
+ final MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(this)
.setTitle(title)
.setMessage(message)
.setView(binding.getRoot())
@@ -176,8 +184,13 @@ public class ManageAccountsActivity extends LockedActivity implements IManageAcc
ExceptionDialogFragment.newInstance(e).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName());
}
});
- })
- .show();
+ });
+
+ NotesApplication.brandingUtil().dialog.colorMaterialAlertDialogBackground(this, alertDialogBuilder);
+
+ var dialog = alertDialogBuilder.create();
+ alertDialogBuilder.show();
+
try {
repository.getServerSettings(AccountImporter.getSingleSignOnAccount(this, localAccount.getAccountName()), getPreferredApiVersion(localAccount.getApiVersion()))
.enqueue(new Callback<>() {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesActivity.java
index 723b895a..6c7d3c90 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesActivity.java
@@ -18,14 +18,13 @@ import it.niedermann.owncloud.notes.databinding.ActivityPreferencesBinding;
public class PreferencesActivity extends LockedActivity {
- private PreferencesViewModel viewModel;
private ActivityPreferencesBinding binding;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- viewModel = new ViewModelProvider(this).get(PreferencesViewModel.class);
+ PreferencesViewModel viewModel = new ViewModelProvider(this).get(PreferencesViewModel.class);
viewModel.resultCode$.observe(this, this::setResult);
binding = ActivityPreferencesBinding.inflate(getLayoutInflater());
diff --git a/app/src/main/res/layout/activity_exception.xml b/app/src/main/res/layout/activity_exception.xml
index f7e26d96..dcac31e2 100644
--- a/app/src/main/res/layout/activity_exception.xml
+++ b/app/src/main/res/layout/activity_exception.xml
@@ -81,7 +81,7 @@
android:orientation="horizontal"
android:weightSum="1.0">
-
-
+
+
diff --git a/app/src/main/res/values/setup.xml b/app/src/main/res/values/setup.xml
new file mode 100644
index 00000000..fc340f93
--- /dev/null
+++ b/app/src/main/res/values/setup.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index c0ddd171..36c07e91 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -7,7 +7,7 @@
~ SPDX-FileCopyrightText: 2022 Kévin Cocchi
~ SPDX-License-Identifier: GPL-3.0-or-later
-->
-
+
+
+
\ No newline at end of file