diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-06-22 14:59:07 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-06-22 16:40:29 +0300 |
commit | a2718c397ab439bfd5f4f3f225d428f92ca4275b (patch) | |
tree | 7650f32603a20a8742dd4823c6165618231ccd39 /app | |
parent | a848ddfe6a0ca3800c44a1d464e9dfc3c548d50c (diff) |
Refactor packages to match actual use case
Diffstat (limited to 'app')
137 files changed, 671 insertions, 735 deletions
diff --git a/app/build.gradle b/app/build.gradle index 98c28e55..dba5d43f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,6 +18,10 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + buildFeatures { + viewBinding true + } + buildTypes { debug { testCoverageEnabled true @@ -34,10 +38,6 @@ android { abortOnError false } - viewBinding { - enabled = true - } - flavorDimensions "version" productFlavors { diff --git a/app/src/androidTest/java/it/niedermann/nextcloud/deck/util/ColorUtilTest.java b/app/src/androidTest/java/it/niedermann/nextcloud/deck/util/ColorUtilTest.java index 2977c08b..5830cc5b 100644 --- a/app/src/androidTest/java/it/niedermann/nextcloud/deck/util/ColorUtilTest.java +++ b/app/src/androidTest/java/it/niedermann/nextcloud/deck/util/ColorUtilTest.java @@ -14,7 +14,7 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.List; -import it.niedermann.owncloud.notes.util.ColorUtil; +import it.niedermann.owncloud.notes.shared.util.ColorUtil; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/app/src/androidTest/java/it/niedermann/owncloud/notes/persistence/NotesDatabaseTest.java b/app/src/androidTest/java/it/niedermann/owncloud/notes/persistence/NotesDatabaseTest.java index 19c3146b..a34a3f41 100644 --- a/app/src/androidTest/java/it/niedermann/owncloud/notes/persistence/NotesDatabaseTest.java +++ b/app/src/androidTest/java/it/niedermann/owncloud/notes/persistence/NotesDatabaseTest.java @@ -1,14 +1,14 @@ package it.niedermann.owncloud.notes.persistence; -import it.niedermann.owncloud.notes.model.Capabilities; -import it.niedermann.owncloud.notes.model.Category; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.DBStatus; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.model.NavigationAdapter; -import it.niedermann.owncloud.notes.util.CategorySortingMethod; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.model.Capabilities; +import it.niedermann.owncloud.notes.shared.model.Category; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; +import it.niedermann.owncloud.notes.main.NavigationAdapter; +import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; import android.content.Context; import android.content.SharedPreferences; diff --git a/app/src/dev/res/xml/shortcuts.xml b/app/src/dev/res/xml/shortcuts.xml index fcecd23d..086d61f8 100644 --- a/app/src/dev/res/xml/shortcuts.xml +++ b/app/src/dev/res/xml/shortcuts.xml @@ -10,7 +10,7 @@ tools:targetApi="n_mr1"> <intent android:action="android.intent.action.CREATE_DOCUMENT" - android:targetClass="it.niedermann.owncloud.notes.android.activity.EditNoteActivity" + android:targetClass="it.niedermann.owncloud.notes.edit.EditNoteActivity" android:targetPackage="it.niedermann.owncloud.notes.dev" /> <categories android:name="android.shortcut.conversation" /> </shortcut> diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3117ead..ea5992b1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,7 +7,7 @@ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application - android:name=".util.Notes" + android:name=".NotesApplication" android:allowBackup="true" android:fullBackupContent="true" android:icon="@mipmap/ic_launcher" @@ -19,7 +19,7 @@ tools:targetApi="n"> <activity - android:name=".android.activity.SplashscreenActivity" + android:name=".SplashscreenActivity" android:label="@string/app_name" android:theme="@style/SplashTheme"> <intent-filter> @@ -32,7 +32,7 @@ </activity> <activity - android:name=".android.activity.NotesListViewActivity" + android:name=".main.MainActivity" android:label="@string/app_name"> <intent-filter> @@ -48,7 +48,7 @@ </activity> <activity - android:name=".android.activity.AppendToNoteActivity" + android:name=".AppendToNoteActivity" android:label="@string/append_to_note"> <intent-filter> @@ -59,32 +59,32 @@ </activity> <activity - android:name=".android.activity.ExceptionActivity" + android:name=".exception.ExceptionActivity" android:label="@string/app_name" /> <activity - android:name=".formattinghelp.FormattingHelpActivity" + android:name=".FormattingHelpActivity" android:label="@string/action_formatting_help" - android:parentActivityName=".android.activity.NotesListViewActivity" + android:parentActivityName=".main.MainActivity" android:windowSoftInputMode="stateHidden" /> <activity android:name=".manageaccounts.ManageAccountsActivity" android:label="@string/manage_accounts" - android:parentActivityName=".android.activity.NotesListViewActivity" + android:parentActivityName=".main.MainActivity" android:windowSoftInputMode="stateHidden" /> <activity - android:name=".android.activity.PreferencesActivity" + android:name=".preferences.PreferencesActivity" android:label="@string/action_settings" - android:parentActivityName=".android.activity.NotesListViewActivity" + android:parentActivityName=".main.MainActivity" android:windowSoftInputMode="stateHidden" /> <activity - android:name=".android.activity.EditNoteActivity" + android:name=".edit.EditNoteActivity" android:label="@string/simple_edit" android:launchMode="singleTask" - android:parentActivityName=".android.activity.NotesListViewActivity" + android:parentActivityName=".main.MainActivity" android:windowSoftInputMode="stateHidden"> <intent-filter android:label="@string/action_create"> <action android:name="android.intent.action.SEND" /> @@ -108,17 +108,17 @@ </activity> <activity - android:name=".android.activity.AboutActivity" + android:name=".about.AboutActivity" android:label="@string/simple_about" - android:parentActivityName=".android.activity.NotesListViewActivity" /> + android:parentActivityName=".main.MainActivity" /> - <activity android:name=".android.activity.SelectSingleNoteActivity"> + <activity android:name=".widget.singlenote.SingleNoteWidgetConfigurationActivity"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> </intent-filter> </activity> - <activity android:name=".android.activity.NoteListWidgetConfigurationActivity"> + <activity android:name=".widget.notelist.NoteListWidgetConfigurationActivity"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> @@ -126,7 +126,7 @@ </activity> <receiver - android:name=".android.appwidget.CreateNoteWidget" + android:name=".widget.createnote.CreateNoteWidget" android:label="@string/widget_create_note"> <intent-filter> @@ -139,7 +139,7 @@ </receiver> <receiver - android:name=".android.appwidget.SingleNoteWidget" + android:name=".widget.singlenote.SingleNoteWidget" android:label="@string/widget_single_note_title"> <intent-filter> @@ -152,7 +152,7 @@ </receiver> <receiver - android:name=".android.appwidget.NoteListWidget" + android:name=".widget.notelist.NoteListWidget" android:label="@string/widget_note_list_title"> <intent-filter> @@ -165,15 +165,15 @@ </receiver> <service - android:name=".android.appwidget.SingleNoteWidgetService" + android:name=".widget.singlenote.SingleNoteWidgetService" android:permission="android.permission.BIND_REMOTEVIEWS" /> <service - android:name=".android.appwidget.NoteListWidgetService" + android:name=".widget.notelist.NoteListWidgetService" android:permission="android.permission.BIND_REMOTEVIEWS" /> <service - android:name=".android.quicksettings.NewNoteTileService" + android:name=".quicksettings.NewNoteTileService" android:description="@string/action_create" android:icon="@drawable/ic_quicksettings_new" android:label="@string/action_create" diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/AppendToNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/AppendToNoteActivity.java index 4f5722aa..23e68804 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/AppendToNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/AppendToNoteActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes; import android.content.Intent; import android.os.Bundle; @@ -9,10 +9,10 @@ import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; -import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.main.MainActivity; -public class AppendToNoteActivity extends NotesListViewActivity { +public class AppendToNoteActivity extends MainActivity { private static final String TAG = AppendToNoteActivity.class.getSimpleName(); @@ -28,7 +28,7 @@ public class AppendToNoteActivity extends NotesListViewActivity { if (actionBar != null) { getSupportActionBar().setTitle(R.string.append_to_note); } else { - Log.e(TAG, "SupportActioBar is null. Expected toolbar to be present to set a title."); + Log.e(TAG, "SupportActionBar is null. Expected toolbar to be present to set a title."); } binding.activityNotesListView.toolbar.setSubtitle(receivedText); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/formattinghelp/FormattingHelpActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/FormattingHelpActivity.java index 10bfb6e1..0e537956 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/formattinghelp/FormattingHelpActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/FormattingHelpActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.formattinghelp; +package it.niedermann.owncloud.notes; import android.content.Intent; import android.content.SharedPreferences; @@ -21,13 +21,13 @@ import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandedActivity; import it.niedermann.owncloud.notes.databinding.ActivityFormattingHelpBinding; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_CHECKED_MINUS; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_CHECKED_STAR; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.getMarkDownConfiguration; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.parseCompat; -import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_CHECKED_MINUS; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_CHECKED_STAR; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getMarkDownConfiguration; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.parseCompat; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.getFontSizeFromPreferences; public class FormattingHelpActivity extends BrandedActivity { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/LockedActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/LockedActivity.java index 07a544df..8b024050 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/LockedActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/LockedActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes; import android.app.KeyguardManager; import android.content.Context; @@ -9,10 +9,8 @@ import android.util.Log; import androidx.annotation.Nullable; -import it.niedermann.owncloud.notes.ExceptionHandler; -import it.niedermann.owncloud.notes.R; +import it.niedermann.owncloud.notes.exception.ExceptionHandler; import it.niedermann.owncloud.notes.branding.BrandedActivity; -import it.niedermann.owncloud.notes.util.Notes; public abstract class LockedActivity extends BrandedActivity { @@ -45,37 +43,37 @@ public abstract class LockedActivity extends BrandedActivity { protected void onStop() { super.onStop(); if (isTaskRoot()) { - Notes.updateLastInteraction(); + NotesApplication.updateLastInteraction(); } } @Override public void onBackPressed() { super.onBackPressed(); - Notes.updateLastInteraction(); + NotesApplication.updateLastInteraction(); } @Override public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) { - Notes.updateLastInteraction(); + NotesApplication.updateLastInteraction(); super.startActivityForResult(intent, requestCode, options); } @Override public void startActivityForResult(Intent intent, int requestCode) { - Notes.updateLastInteraction(); + NotesApplication.updateLastInteraction(); super.startActivityForResult(intent, requestCode); } @Override public void startActivity(Intent intent) { - Notes.updateLastInteraction(); + NotesApplication.updateLastInteraction(); super.startActivity(intent); } @Override public void startActivity(Intent intent, @Nullable Bundle options) { - Notes.updateLastInteraction(); + NotesApplication.updateLastInteraction(); super.startActivity(intent, options); } @@ -86,7 +84,7 @@ public abstract class LockedActivity extends BrandedActivity { if (requestCode == REQUEST_CODE_UNLOCK) { if (resultCode == RESULT_OK) { Log.v(TAG, "Successfully unlocked device"); - Notes.unlock(); + NotesApplication.unlock(); } else { Log.e(TAG, "Result code of unlocking was " + resultCode); finish(); @@ -95,7 +93,7 @@ public abstract class LockedActivity extends BrandedActivity { } private void askToUnlock() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Notes.isLocked()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && NotesApplication.isLocked()) { KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); if (keyguardManager != null) { Intent i = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.unlock_notes), null); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/Notes.java b/app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java index 1b660313..dce36d2b 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/Notes.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes; import android.app.Application; import android.content.Context; @@ -9,13 +9,12 @@ import android.util.Log; import androidx.appcompat.app.AppCompatDelegate; import androidx.preference.PreferenceManager; -import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.DarkModeSetting; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; import static androidx.preference.PreferenceManager.getDefaultSharedPreferences; -public class Notes extends Application { - private static final String TAG = Notes.class.getSimpleName(); +public class NotesApplication extends Application { + private static final String TAG = NotesApplication.class.getSimpleName(); private static final long LOCK_TIME = 30 * 1000; private static boolean lockedPreference = false; @@ -73,7 +72,7 @@ public class Notes extends Application { public static void setLockedPreference(boolean lockedPreference) { Log.i(TAG, "New locked preference: " + lockedPreference); - Notes.lockedPreference = lockedPreference; + NotesApplication.lockedPreference = lockedPreference; } public static boolean isLocked() { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SplashscreenActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/SplashscreenActivity.java index c05f5b47..ad14204f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SplashscreenActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/SplashscreenActivity.java @@ -1,11 +1,12 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes; import android.content.Intent; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; -import it.niedermann.owncloud.notes.ExceptionHandler; +import it.niedermann.owncloud.notes.exception.ExceptionHandler; +import it.niedermann.owncloud.notes.main.MainActivity; /** @@ -18,7 +19,7 @@ public class SplashscreenActivity extends AppCompatActivity { super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this)); - Intent intent = new Intent(this, NotesListViewActivity.class); + Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/AboutActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutActivity.java index 9dbdc062..d764ba7a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/AboutActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.about; import android.os.Bundle; @@ -9,9 +9,7 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentContributingTab; -import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentCreditsTab; -import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentLicenseTab; +import it.niedermann.owncloud.notes.LockedActivity; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.databinding.ActivityAboutBinding; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/about/AboutFragmentContributingTab.java b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentContributingTab.java index 21c6e2e7..369c77a0 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/about/AboutFragmentContributingTab.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentContributingTab.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment.about; +package it.niedermann.owncloud.notes.about; import android.os.Bundle; import android.view.LayoutInflater; @@ -10,7 +10,7 @@ import androidx.fragment.app.Fragment; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.FragmentAboutContributionTabBinding; -import it.niedermann.owncloud.notes.util.SupportUtil; +import it.niedermann.owncloud.notes.shared.util.SupportUtil; public class AboutFragmentContributingTab extends Fragment { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/about/AboutFragmentCreditsTab.java b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentCreditsTab.java index 52aadbbb..fc18f5ea 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/about/AboutFragmentCreditsTab.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentCreditsTab.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment.about; +package it.niedermann.owncloud.notes.about; import android.os.Bundle; import android.view.LayoutInflater; @@ -11,7 +11,7 @@ import androidx.fragment.app.Fragment; import it.niedermann.owncloud.notes.BuildConfig; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.FragmentAboutCreditsTabBinding; -import it.niedermann.owncloud.notes.util.SupportUtil; +import it.niedermann.owncloud.notes.shared.util.SupportUtil; public class AboutFragmentCreditsTab extends Fragment { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/about/AboutFragmentLicenseTab.java b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentLicenseTab.java index b5b984cd..41f8266a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/about/AboutFragmentLicenseTab.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentLicenseTab.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment.about; +package it.niedermann.owncloud.notes.about; import android.content.Intent; import android.content.res.ColorStateList; @@ -16,8 +16,8 @@ import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandedFragment; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.databinding.FragmentAboutLicenseTabBinding; -import it.niedermann.owncloud.notes.util.ColorUtil; -import it.niedermann.owncloud.notes.util.SupportUtil; +import it.niedermann.owncloud.notes.shared.util.ColorUtil; +import it.niedermann.owncloud.notes.shared.util.SupportUtil; public class AboutFragmentLicenseTab extends BrandedFragment { 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 new file mode 100644 index 00000000..5ac670db --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerDialogFragment.java @@ -0,0 +1,106 @@ +package it.niedermann.owncloud.notes.accountpicker; + +import android.app.Dialog; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; +import java.util.Objects; + +import it.niedermann.owncloud.notes.R; +import it.niedermann.owncloud.notes.branding.BrandedAlertDialogBuilder; +import it.niedermann.owncloud.notes.branding.BrandedDialogFragment; +import it.niedermann.owncloud.notes.databinding.DialogChooseAccountBinding; +import it.niedermann.owncloud.notes.persistence.NotesDatabase; +import it.niedermann.owncloud.notes.shared.account.AccountChooserAdapter; +import it.niedermann.owncloud.notes.shared.account.AccountChooserViewHolder; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; + +/** + * A {@link DialogFragment} which provides an {@link LocalAccount} chooser that hides the given {@link LocalAccount}. + * This can be useful when one wants to pick e. g. a target for move a note from one {@link LocalAccount} to another.. + */ +public class AccountPickerDialogFragment extends BrandedDialogFragment { + + private AccountPickerListener accountPickerListener; + private static final String PARAM_ACCOUNT_ID_TO_EXCLUDE = "account_id_to_exclude"; + private long accountIdToExclude; + + /** + * Use newInstance()-Method + */ + public AccountPickerDialogFragment() { + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + if (context instanceof AccountPickerListener) { + this.accountPickerListener = (AccountPickerListener) context; + } else { + throw new ClassCastException("Caller must implement " + AccountPickerListener.class.getSimpleName()); + } + accountIdToExclude = requireArguments().getLong(PARAM_ACCOUNT_ID_TO_EXCLUDE, -1L); + if (accountIdToExclude < 0) { + throw new IllegalArgumentException(PARAM_ACCOUNT_ID_TO_EXCLUDE + " must be greater 0"); + } + } + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + View view = View.inflate(getContext(), R.layout.dialog_choose_account, null); + DialogChooseAccountBinding binding = DialogChooseAccountBinding.bind(view); + + NotesDatabase db = NotesDatabase.getInstance(getActivity()); + List<LocalAccount> accountsList = db.getAccounts(); + + for (int i = 0; i < accountsList.size(); i++) { + if (accountsList.get(i).getId() == accountIdToExclude) { + accountsList.remove(i); + break; + } + } + + RecyclerView.Adapter<AccountChooserViewHolder> adapter = new AccountChooserAdapter(accountsList, (account -> { + accountPickerListener.onAccountPicked(account); + dismiss(); + })); + binding.accountsList.setAdapter(adapter); + + return new BrandedAlertDialogBuilder(requireActivity()) + .setView(binding.getRoot()) + .setTitle(R.string.simple_move) + .setNegativeButton(android.R.string.cancel, null) + .create(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + Objects.requireNonNull(requireDialog().getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); + return super.onCreateView(inflater, container, savedInstanceState); + } + + public static DialogFragment newInstance(long accountIdToExclude) { + final DialogFragment fragment = new AccountPickerDialogFragment(); + final Bundle args = new Bundle(); + args.putLong(PARAM_ACCOUNT_ID_TO_EXCLUDE, accountIdToExclude); + fragment.setArguments(args); + return fragment; + } + + @Override + public void applyBrand(int mainColor, int textColor) { + // Nothing to do... + } +} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerListener.java b/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerListener.java new file mode 100644 index 00000000..c77e1824 --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerListener.java @@ -0,0 +1,9 @@ +package it.niedermann.owncloud.notes.accountpicker; + +import androidx.annotation.NonNull; + +import it.niedermann.owncloud.notes.shared.model.LocalAccount; + +public interface AccountPickerListener { + void onAccountPicked(@NonNull LocalAccount account); +}
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherAdapter.java index 0223a53f..92e77e74 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherAdapter.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherAdapter.java @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; public class AccountSwitcherAdapter extends RecyclerView.Adapter<AccountSwitcherViewHolder> { 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 78f20984..4286cf1e 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 @@ -20,12 +20,15 @@ import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandedDialogFragment; import it.niedermann.owncloud.notes.databinding.DialogAccountSwitcherBinding; import it.niedermann.owncloud.notes.manageaccounts.ManageAccountsActivity; -import it.niedermann.owncloud.notes.model.LocalAccount; import it.niedermann.owncloud.notes.persistence.NotesDatabase; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; -import static it.niedermann.owncloud.notes.android.activity.NotesListViewActivity.manage_account; import static it.niedermann.owncloud.notes.branding.BrandingUtil.applyBrandToLayerDrawable; +import static it.niedermann.owncloud.notes.main.MainActivity.manage_account; +/** + * Displays all available {@link LocalAccount} entries and provides basic operations for them, like adding or switching + */ public class AccountSwitcherDialog extends BrandedDialogFragment { private static final String KEY_CURRENT_ACCOUNT_ID = "current_account_id"; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherListener.java b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherListener.java index 2e26277f..35750f2f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherListener.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherListener.java @@ -1,6 +1,6 @@ package it.niedermann.owncloud.notes.accountswitcher; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; public interface AccountSwitcherListener { void addAccount(); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java index 1196d878..fcc3d91c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java @@ -13,7 +13,7 @@ import com.bumptech.glide.request.RequestOptions; import it.niedermann.android.glidesso.SingleSignOnUrl; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; public class AccountSwitcherViewHolder extends RecyclerView.ViewHolder { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/AlwaysAutoCompleteTextView.java b/app/src/main/java/it/niedermann/owncloud/notes/android/AlwaysAutoCompleteTextView.java deleted file mode 100644 index b391bd9b..00000000 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/AlwaysAutoCompleteTextView.java +++ /dev/null @@ -1,56 +0,0 @@ -package it.niedermann.owncloud.notes.android; - -import android.content.Context; -import android.util.AttributeSet; -import android.util.Log; -import android.view.WindowManager; - -import androidx.appcompat.widget.AppCompatAutoCompleteTextView; - -/** - * Extension of the {@link AppCompatAutoCompleteTextView}, but this one is always open, i.e. you can see the list of suggestions even the TextView is empty. - */ -public class AlwaysAutoCompleteTextView extends AppCompatAutoCompleteTextView { - - private static final String TAG = AlwaysAutoCompleteTextView.class.getSimpleName(); - - private int myThreshold; - - public AlwaysAutoCompleteTextView(Context context) { - super(context); - } - - public AlwaysAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public AlwaysAutoCompleteTextView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public void setThreshold(int threshold) { - myThreshold = Math.max(threshold, 0); - } - - @Override - public boolean enoughToFilter() { - return getText().length() >= myThreshold; - } - - @Override - public int getThreshold() { - return myThreshold; - } - - public void showFullDropDown() { - try { - performFiltering(getText(), 0); - showDropDown(); - } catch (WindowManager.BadTokenException e) { - // https://github.com/stefan-niedermann/nextcloud-notes/issues/366 - e.printStackTrace(); - Log.e(TAG, "Exception", e); - } - } -}
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteWidgetHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteWidgetHelper.java deleted file mode 100644 index 02382e5c..00000000 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteWidgetHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -package it.niedermann.owncloud.notes.android.appwidget; - -import android.content.SharedPreferences; - -import it.niedermann.owncloud.notes.android.DarkModeSetting; - -final class NoteWidgetHelper { - private NoteWidgetHelper() { - // Helper class for static methods - } - - @SuppressWarnings("WeakerAccess") //Making it package-private would generate a warning in PMD - public static DarkModeSetting getDarkThemeSetting(SharedPreferences prefs, String darkModeKey, int appWidgetId) { - try { - String themeName = prefs.getString(darkModeKey + appWidgetId, DarkModeSetting.SYSTEM_DEFAULT.name()); - return DarkModeSetting.valueOf(themeName); - } catch (ClassCastException e) { - //DARK_THEME was a boolean in older versions of the app. We thereofre have to still support the old setting. - boolean isDarkTheme = prefs.getBoolean(darkModeKey + appWidgetId, false); - return isDarkTheme ? DarkModeSetting.DARK : DarkModeSetting.LIGHT; - } - } -} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/AccountChooserAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/AccountChooserAdapter.java deleted file mode 100644 index 800660b5..00000000 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/AccountChooserAdapter.java +++ /dev/null @@ -1,79 +0,0 @@ -package it.niedermann.owncloud.notes.android.fragment; - -import android.net.Uri; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.RequestOptions; - -import java.util.List; - -import it.niedermann.android.glidesso.SingleSignOnUrl; -import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; -import it.niedermann.owncloud.notes.model.LocalAccount; - -import static it.niedermann.owncloud.notes.android.fragment.AccountChooserAdapter.AccountChooserViewHolder; - -public class AccountChooserAdapter extends RecyclerView.Adapter<AccountChooserViewHolder> { - - @NonNull - private final List<LocalAccount> localAccounts; - @NonNull - private final MoveAccountListener moveAccountListener; - - AccountChooserAdapter(@NonNull List<LocalAccount> localAccounts, @NonNull MoveAccountListener moveAccountListener) { - super(); - this.localAccounts = localAccounts; - this.moveAccountListener = moveAccountListener; - } - - @NonNull - @Override - public AccountChooserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_account_choose, parent, false); - return new AccountChooserViewHolder(v); - } - - @Override - public void onBindViewHolder(@NonNull AccountChooserViewHolder holder, int position) { - holder.bind(localAccounts.get(position), moveAccountListener); - } - - @Override - public int getItemCount() { - return localAccounts.size(); - } - - static class AccountChooserViewHolder extends RecyclerView.ViewHolder { - private final ItemAccountChooseBinding binding; - - private AccountChooserViewHolder(View view) { - super(view); - binding = ItemAccountChooseBinding.bind(view); - } - - public void bind(LocalAccount localAccount, MoveAccountListener moveAccountListener) { - Glide - .with(binding.accountItemAvatar.getContext()) - .load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64")) - .placeholder(R.drawable.ic_account_circle_grey_24dp) - .error(R.drawable.ic_account_circle_grey_24dp) - .apply(RequestOptions.circleCropTransform()) - .into(binding.accountItemAvatar); - - binding.accountLayout.setOnClickListener((v) -> moveAccountListener.moveToAccount(localAccount)); - binding.accountName.setText(localAccount.getUserName()); - binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost()); - } - } - - public interface MoveAccountListener { - void moveToAccount(LocalAccount account); - } -} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/MoveAccountDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/MoveAccountDialogFragment.java deleted file mode 100644 index 2b959c4b..00000000 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/MoveAccountDialogFragment.java +++ /dev/null @@ -1,82 +0,0 @@ -package it.niedermann.owncloud.notes.android.fragment; - -import android.app.Dialog; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatDialogFragment; -import androidx.recyclerview.widget.RecyclerView; - -import java.util.List; -import java.util.Objects; - -import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.fragment.AccountChooserAdapter.MoveAccountListener; -import it.niedermann.owncloud.notes.branding.BrandedAlertDialogBuilder; -import it.niedermann.owncloud.notes.databinding.DialogChooseAccountBinding; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.persistence.NotesDatabase; - -import static it.niedermann.owncloud.notes.android.fragment.AccountChooserAdapter.AccountChooserViewHolder; - -public class MoveAccountDialogFragment extends AppCompatDialogFragment implements MoveAccountListener { - private MoveAccountListener moveAccountListener; - - /** - * Use newInstance()-Method - */ - public MoveAccountDialogFragment() { - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - if (context instanceof MoveAccountListener) { - this.moveAccountListener = (MoveAccountListener) context; - } else { - throw new ClassCastException("Caller must implement " + MoveAccountListener.class.getSimpleName()); - } - } - - @NonNull - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - View view = View.inflate(getContext(), R.layout.dialog_choose_account, null); - DialogChooseAccountBinding binding = DialogChooseAccountBinding.bind(view); - - NotesDatabase db = NotesDatabase.getInstance(getActivity()); - List<LocalAccount> accountsList = db.getAccounts(); - - RecyclerView.Adapter<AccountChooserViewHolder> adapter = new AccountChooserAdapter(accountsList, this); - binding.accountsList.setAdapter(adapter); - - return new BrandedAlertDialogBuilder(requireActivity()) - .setView(binding.getRoot()) - .setTitle(R.string.simple_move) - .setNegativeButton(android.R.string.cancel, null) - .create(); - } - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - Objects.requireNonNull(requireDialog().getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); - return super.onCreateView(inflater, container, savedInstanceState); - } - - public static MoveAccountDialogFragment newInstance() { - return new MoveAccountDialogFragment(); - } - - @Override - public void moveToAccount(LocalAccount account) { - moveAccountListener.moveToAccount(account); - dismiss(); - } -} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java index 42b9c5cb..b4c534f6 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java @@ -9,7 +9,7 @@ import androidx.annotation.StringRes; import com.google.android.material.snackbar.BaseTransientBottomBar; import com.google.android.material.snackbar.Snackbar; -import it.niedermann.owncloud.notes.util.ColorUtil; +import it.niedermann.owncloud.notes.shared.util.ColorUtil; public class BrandedSnackbar { 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 878917fa..d22fb4a3 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 @@ -17,9 +17,9 @@ import androidx.core.graphics.drawable.DrawableCompat; import androidx.preference.PreferenceManager; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.NotesApplication; -import static it.niedermann.owncloud.notes.util.ColorUtil.contrastRatioIsSufficient; +import static it.niedermann.owncloud.notes.shared.util.ColorUtil.contrastRatioIsSufficient; public class BrandingUtil { @@ -81,7 +81,7 @@ public class BrandingUtil { @ColorInt public static int getSecondaryForegroundColorDependingOnTheme(@NonNull Context context, @ColorInt int mainColor) { final int primaryColor = context.getResources().getColor(R.color.primary); - final boolean isDarkTheme = Notes.isDarkThemeActive(context); + final boolean isDarkTheme = NotesApplication.isDarkThemeActive(context); if (isDarkTheme && !contrastRatioIsSufficient(mainColor, primaryColor)) { Log.v(TAG, "Contrast ratio between brand color " + String.format("#%06X", (0xFFFFFF & mainColor)) + " and dark theme is too low. Falling back to WHITE as brand color."); return Color.WHITE; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/BaseNoteFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java index c3ccdeb0..f9579c86 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/BaseNoteFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit; import android.app.PendingIntent; import android.content.Context; @@ -30,26 +30,28 @@ import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.nextcloud.android.sso.model.SingleSignOnAccount; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; -import it.niedermann.owncloud.notes.android.fragment.CategoryDialogFragment.CategoryDialogListener; -import it.niedermann.owncloud.notes.android.fragment.EditTitleDialogFragment.EditTitleListener; +import it.niedermann.owncloud.notes.edit.category.CategoryDialogFragment; +import it.niedermann.owncloud.notes.edit.title.EditTitleDialogFragment; +import it.niedermann.owncloud.notes.accountpicker.AccountPickerDialogFragment; +import it.niedermann.owncloud.notes.edit.category.CategoryDialogFragment.CategoryDialogListener; +import it.niedermann.owncloud.notes.edit.title.EditTitleDialogFragment.EditTitleListener; import it.niedermann.owncloud.notes.branding.BrandedFragment; -import it.niedermann.owncloud.notes.model.ApiVersion; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.DBStatus; -import it.niedermann.owncloud.notes.model.ISyncCallback; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.ApiVersion; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.ColorUtil; -import it.niedermann.owncloud.notes.util.NoteUtil; -import it.niedermann.owncloud.notes.util.ShareUtil; +import it.niedermann.owncloud.notes.shared.util.ColorUtil; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.util.ShareUtil; import static androidx.core.content.pm.ShortcutManagerCompat.isRequestPinShortcutSupported; -import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.ACTION_SHORTCUT; +import static it.niedermann.owncloud.notes.edit.EditNoteActivity.ACTION_SHORTCUT; import static it.niedermann.owncloud.notes.branding.BrandingUtil.tintMenuIcon; -import static it.niedermann.owncloud.notes.util.ColorUtil.isColorDark; -import static it.niedermann.owncloud.notes.util.Notes.isDarkThemeActive; +import static it.niedermann.owncloud.notes.shared.util.ColorUtil.isColorDark; +import static it.niedermann.owncloud.notes.NotesApplication.isDarkThemeActive; public abstract class BaseNoteFragment extends BrandedFragment implements CategoryDialogListener, EditTitleListener { @@ -239,7 +241,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego showEditTitleDialog(); return true; case R.id.menu_move: - MoveAccountDialogFragment.newInstance().show(requireActivity().getSupportFragmentManager(), BaseNoteFragment.class.getSimpleName()); + AccountPickerDialogFragment.newInstance(note.getAccountId()).show(requireActivity().getSupportFragmentManager(), BaseNoteFragment.class.getSimpleName()); return true; case R.id.menu_share: ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java index d8d032ee..14fea067 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.edit; import android.content.Intent; import android.content.SharedPreferences; @@ -7,6 +7,7 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; @@ -17,21 +18,18 @@ import java.io.InputStreamReader; import java.util.Calendar; import java.util.Objects; +import it.niedermann.owncloud.notes.LockedActivity; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.fragment.BaseNoteFragment; -import it.niedermann.owncloud.notes.android.fragment.NoteEditFragment; -import it.niedermann.owncloud.notes.android.fragment.NotePreviewFragment; -import it.niedermann.owncloud.notes.android.fragment.NoteReadonlyFragment; import it.niedermann.owncloud.notes.databinding.ActivityEditBinding; -import it.niedermann.owncloud.notes.model.Category; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener; +import it.niedermann.owncloud.notes.main.MainActivity; +import it.niedermann.owncloud.notes.shared.model.Category; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; -import static it.niedermann.owncloud.notes.android.fragment.AccountChooserAdapter.MoveAccountListener; - -public class EditNoteActivity extends LockedActivity implements BaseNoteFragment.NoteFragmentListener, MoveAccountListener { +public class EditNoteActivity extends LockedActivity implements BaseNoteFragment.NoteFragmentListener, AccountPickerListener { private static final String TAG = EditNoteActivity.class.getSimpleName(); @@ -264,14 +262,14 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment } } else { // Maybe account is not authenticated -> note == null - Log.e(TAG, "note is null, start " + NotesListViewActivity.class.getSimpleName()); - startActivity(new Intent(this, NotesListViewActivity.class)); + Log.e(TAG, "note is null, start " + MainActivity.class.getSimpleName()); + startActivity(new Intent(this, MainActivity.class)); finish(); } } @Override - public void moveToAccount(LocalAccount account) { + public void onAccountPicked(@NonNull LocalAccount account) { fragment.moveNote(account); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java index 1a1ab089..ba297b95 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit; import android.content.Context; import android.content.SharedPreferences; @@ -32,16 +32,15 @@ import com.yydcdut.markdown.syntax.edit.EditFactory; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.FragmentNoteEditBinding; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.model.ISyncCallback; -import it.niedermann.owncloud.notes.util.MarkDownUtil; -import it.niedermann.owncloud.notes.util.NotesTextWatcher; -import it.niedermann.owncloud.notes.util.format.ContextBasedFormattingCallback; -import it.niedermann.owncloud.notes.util.format.ContextBasedRangeFormattingCallback; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; +import it.niedermann.owncloud.notes.shared.util.MarkDownUtil; +import it.niedermann.owncloud.notes.edit.format.ContextBasedFormattingCallback; +import it.niedermann.owncloud.notes.edit.format.ContextBasedRangeFormattingCallback; import static androidx.core.view.ViewCompat.isAttachedToWindow; -import static it.niedermann.owncloud.notes.util.DisplayUtils.searchAndColor; -import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; +import static it.niedermann.owncloud.notes.shared.util.DisplayUtils.searchAndColor; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.getFontSizeFromPreferences; public class NoteEditFragment extends SearchableBaseNoteFragment { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java index 751cf474..1eb90c43 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit; import android.content.Intent; import android.content.SharedPreferences; @@ -33,22 +33,21 @@ import com.yydcdut.markdown.MarkdownProcessor; import com.yydcdut.markdown.syntax.text.TextFactory; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; import it.niedermann.owncloud.notes.databinding.FragmentNotePreviewBinding; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.MarkDownUtil; -import it.niedermann.owncloud.notes.util.NoteLinksUtils; -import it.niedermann.owncloud.notes.util.SSOUtil; - -import static it.niedermann.owncloud.notes.util.DisplayUtils.searchAndColor; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_CHECKED_MINUS; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_CHECKED_STAR; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.parseCompat; -import static it.niedermann.owncloud.notes.util.NoteLinksUtils.extractNoteRemoteId; -import static it.niedermann.owncloud.notes.util.NoteLinksUtils.replaceNoteLinksWithDummyUrls; -import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; +import it.niedermann.owncloud.notes.shared.util.MarkDownUtil; +import it.niedermann.owncloud.notes.shared.util.NoteLinksUtils; +import it.niedermann.owncloud.notes.shared.util.SSOUtil; + +import static it.niedermann.owncloud.notes.shared.util.DisplayUtils.searchAndColor; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_CHECKED_MINUS; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_CHECKED_STAR; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.parseCompat; +import static it.niedermann.owncloud.notes.shared.util.NoteLinksUtils.extractNoteRemoteId; +import static it.niedermann.owncloud.notes.shared.util.NoteLinksUtils.replaceNoteLinksWithDummyUrls; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.getFontSizeFromPreferences; public class NotePreviewFragment extends SearchableBaseNoteFragment implements OnRefreshListener { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteReadonlyFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteReadonlyFragment.java index 18607c90..3b5e4c6e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteReadonlyFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteReadonlyFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit; import android.content.Intent; import android.content.SharedPreferences; @@ -26,17 +26,16 @@ import com.yydcdut.markdown.MarkdownProcessor; import com.yydcdut.markdown.syntax.text.TextFactory; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; import it.niedermann.owncloud.notes.databinding.FragmentNotePreviewBinding; -import it.niedermann.owncloud.notes.model.ISyncCallback; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.MarkDownUtil; -import it.niedermann.owncloud.notes.util.NoteLinksUtils; +import it.niedermann.owncloud.notes.shared.util.MarkDownUtil; +import it.niedermann.owncloud.notes.shared.util.NoteLinksUtils; import static androidx.core.view.ViewCompat.isAttachedToWindow; -import static it.niedermann.owncloud.notes.util.DisplayUtils.searchAndColor; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.parseCompat; -import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; +import static it.niedermann.owncloud.notes.shared.util.DisplayUtils.searchAndColor; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.parseCompat; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.getFontSizeFromPreferences; public class NoteReadonlyFragment extends SearchableBaseNoteFragment { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesTextWatcher.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotesTextWatcher.java index 76f1bfce..f9ced1ae 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesTextWatcher.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotesTextWatcher.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.edit; import android.text.Editable; import android.text.TextWatcher; @@ -7,8 +7,10 @@ import android.widget.EditText; import androidx.annotation.NonNull; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS_TRAILING_SPACE; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR_TRAILING_SPACE; +import it.niedermann.owncloud.notes.shared.util.MarkDownUtil; + +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS_TRAILING_SPACE; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR_TRAILING_SPACE; /** * Implements auto-continuation for checked-lists diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java index 3aa2da79..5ae9b22a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit; import android.graphics.Color; import android.os.Bundle; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/CategoryAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryAdapter.java index 5872172a..d938cb53 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/CategoryAdapter.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryAdapter.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit.category; import android.content.Context; import android.graphics.drawable.Drawable; @@ -17,9 +17,9 @@ import java.util.List; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemCategoryBinding; -import it.niedermann.owncloud.notes.model.NavigationAdapter.CategoryNavigationItem; -import it.niedermann.owncloud.notes.model.NavigationAdapter.NavigationItem; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.main.NavigationAdapter.CategoryNavigationItem; +import it.niedermann.owncloud.notes.main.NavigationAdapter.NavigationItem; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; public class CategoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/CategoryDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java index cd194cc0..881e8478 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/CategoryDialogFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit.category; import android.app.Dialog; import android.app.DialogFragment; @@ -22,7 +22,7 @@ import it.niedermann.owncloud.notes.branding.BrandedAlertDialogBuilder; import it.niedermann.owncloud.notes.branding.BrandedDialogFragment; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.databinding.DialogChangeCategoryBinding; -import it.niedermann.owncloud.notes.model.NavigationAdapter; +import it.niedermann.owncloud.notes.main.NavigationAdapter; import it.niedermann.owncloud.notes.persistence.NotesDatabase; /** @@ -58,8 +58,8 @@ public class CategoryDialogFragment extends BrandedDialogFragment { void onCategoryChosen(String category); } - static final String PARAM_ACCOUNT_ID = "account_id"; - static final String PARAM_CATEGORY = "category"; + public static final String PARAM_ACCOUNT_ID = "account_id"; + public static final String PARAM_CATEGORY = "category"; private long accountId; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedFormattingCallback.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/format/ContextBasedFormattingCallback.java index 68010dab..a3789dbd 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedFormattingCallback.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/format/ContextBasedFormattingCallback.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util.format; +package it.niedermann.owncloud.notes.edit.format; import android.graphics.Typeface; import android.text.SpannableStringBuilder; @@ -11,12 +11,12 @@ import android.view.MenuItem; import android.widget.EditText; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.util.MarkDownUtil; +import it.niedermann.owncloud.notes.shared.util.MarkDownUtil; -import static it.niedermann.owncloud.notes.util.ClipboardUtil.getClipboardURLorNull; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS_TRAILING_SPACE; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.getEndOfLine; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.getStartOfLine; +import static it.niedermann.owncloud.notes.shared.util.ClipboardUtil.getClipboardURLorNull; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS_TRAILING_SPACE; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getEndOfLine; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getStartOfLine; public class ContextBasedFormattingCallback implements ActionMode.Callback { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedRangeFormattingCallback.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/format/ContextBasedRangeFormattingCallback.java index cac2da3a..91f3b9f3 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedRangeFormattingCallback.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/format/ContextBasedRangeFormattingCallback.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util.format; +package it.niedermann.owncloud.notes.edit.format; import android.graphics.Typeface; import android.text.SpannableStringBuilder; @@ -12,7 +12,7 @@ import android.widget.EditText; import it.niedermann.owncloud.notes.R; -import static it.niedermann.owncloud.notes.util.ClipboardUtil.getClipboardURLorNull; +import static it.niedermann.owncloud.notes.shared.util.ClipboardUtil.getClipboardURLorNull; public class ContextBasedRangeFormattingCallback implements ActionMode.Callback { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/EditTitleDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java index 1dfd995d..e9473399 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/EditTitleDialogFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.edit.title; import android.app.AlertDialog; import android.app.Dialog; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/ExceptionActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionActivity.java index 4b232cc4..4999a30e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/ExceptionActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.exception; import android.annotation.SuppressLint; import android.content.ClipData; @@ -11,11 +11,10 @@ import androidx.appcompat.app.AppCompatActivity; import java.util.Objects; -import it.niedermann.owncloud.notes.ExceptionUtil; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ActivityExceptionBinding; -import static it.niedermann.owncloud.notes.ExceptionHandler.KEY_THROWABLE; +import static it.niedermann.owncloud.notes.exception.ExceptionHandler.KEY_THROWABLE; public class ExceptionActivity extends AppCompatActivity { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/ExceptionDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionDialogFragment.java index 520996ef..4760c07d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/ExceptionDialogFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionDialogFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.exception; import android.app.Dialog; import android.content.Context; @@ -27,12 +27,11 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import it.niedermann.owncloud.notes.ExceptionUtil; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.DialogExceptionBinding; import it.niedermann.owncloud.notes.databinding.ItemTipBinding; -import static it.niedermann.owncloud.notes.util.ClipboardUtil.copyToClipboard; +import static it.niedermann.owncloud.notes.shared.util.ClipboardUtil.copyToClipboard; public class ExceptionDialogFragment extends AppCompatDialogFragment { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/ExceptionHandler.java b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionHandler.java index 1f73d2db..d4fa7986 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/ExceptionHandler.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionHandler.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes; +package it.niedermann.owncloud.notes.exception; import android.app.Activity; import android.content.Context; @@ -8,8 +8,6 @@ import android.util.Log; import androidx.annotation.NonNull; -import it.niedermann.owncloud.notes.android.activity.ExceptionActivity; - public class ExceptionHandler implements Thread.UncaughtExceptionHandler { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/ExceptionUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionUtil.java index f00c6fca..23f11ee0 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/ExceptionUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes; +package it.niedermann.owncloud.notes.exception; import android.content.Context; import android.content.pm.PackageManager; @@ -13,6 +13,8 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.List; +import it.niedermann.owncloud.notes.BuildConfig; + public class ExceptionUtil { private ExceptionUtil() { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java index ab6eaa68..1163c053 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.main; import android.animation.AnimatorInflater; import android.annotation.SuppressLint; @@ -50,30 +50,31 @@ import java.util.List; import java.util.Map; import it.niedermann.owncloud.notes.R; +import it.niedermann.owncloud.notes.about.AboutActivity; import it.niedermann.owncloud.notes.accountswitcher.AccountSwitcherDialog; import it.niedermann.owncloud.notes.accountswitcher.AccountSwitcherListener; -import it.niedermann.owncloud.notes.android.MultiSelectedActionModeCallback; -import it.niedermann.owncloud.notes.android.NotesListViewItemTouchHelper; -import it.niedermann.owncloud.notes.android.fragment.AccountChooserAdapter.MoveAccountListener; -import it.niedermann.owncloud.notes.android.fragment.ExceptionDialogFragment; +import it.niedermann.owncloud.notes.LockedActivity; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; +import it.niedermann.owncloud.notes.exception.ExceptionDialogFragment; import it.niedermann.owncloud.notes.branding.BrandedSnackbar; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.databinding.ActivityNotesListViewBinding; import it.niedermann.owncloud.notes.databinding.DrawerLayoutBinding; -import it.niedermann.owncloud.notes.formattinghelp.FormattingHelpActivity; -import it.niedermann.owncloud.notes.model.Capabilities; -import it.niedermann.owncloud.notes.model.Category; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.GridItemDecoration; -import it.niedermann.owncloud.notes.model.ISyncCallback; -import it.niedermann.owncloud.notes.model.Item; -import it.niedermann.owncloud.notes.model.ItemAdapter; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.model.NavigationAdapter; -import it.niedermann.owncloud.notes.model.NavigationAdapter.CategoryNavigationItem; -import it.niedermann.owncloud.notes.model.NavigationAdapter.NavigationItem; -import it.niedermann.owncloud.notes.model.NoteClickListener; -import it.niedermann.owncloud.notes.model.SectionItemDecoration; +import it.niedermann.owncloud.notes.FormattingHelpActivity; +import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener; +import it.niedermann.owncloud.notes.shared.model.Capabilities; +import it.niedermann.owncloud.notes.shared.model.Category; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; +import it.niedermann.owncloud.notes.shared.model.Item; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; +import it.niedermann.owncloud.notes.main.NavigationAdapter.CategoryNavigationItem; +import it.niedermann.owncloud.notes.main.NavigationAdapter.NavigationItem; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.main.items.ItemAdapter; +import it.niedermann.owncloud.notes.main.items.section.SectionItemDecoration; +import it.niedermann.owncloud.notes.main.items.grid.GridItemDecoration; +import it.niedermann.owncloud.notes.main.items.list.NotesListViewItemTouchHelper; import it.niedermann.owncloud.notes.persistence.CapabilitiesClient; import it.niedermann.owncloud.notes.persistence.CapabilitiesWorker; import it.niedermann.owncloud.notes.persistence.LoadNotesListTask; @@ -81,21 +82,22 @@ import it.niedermann.owncloud.notes.persistence.LoadNotesListTask.NotesLoadedLis import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper; import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper.ViewProvider; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.CategorySortingMethod; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.preferences.PreferencesActivity; +import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static it.niedermann.owncloud.notes.branding.BrandingUtil.getSecondaryForegroundColorDependingOnTheme; -import static it.niedermann.owncloud.notes.util.ColorUtil.contrastRatioIsSufficient; -import static it.niedermann.owncloud.notes.util.Notes.isDarkThemeActive; -import static it.niedermann.owncloud.notes.util.Notes.isGridViewEnabled; -import static it.niedermann.owncloud.notes.util.SSOUtil.askForNewAccount; +import static it.niedermann.owncloud.notes.shared.util.ColorUtil.contrastRatioIsSufficient; +import static it.niedermann.owncloud.notes.NotesApplication.isDarkThemeActive; +import static it.niedermann.owncloud.notes.NotesApplication.isGridViewEnabled; +import static it.niedermann.owncloud.notes.shared.util.SSOUtil.askForNewAccount; import static java.util.Arrays.asList; -public class NotesListViewActivity extends LockedActivity implements NoteClickListener, ViewProvider, MoveAccountListener, AccountSwitcherListener { +public class MainActivity extends LockedActivity implements NoteClickListener, ViewProvider, AccountPickerListener, AccountSwitcherListener { - private static final String TAG = NotesListViewActivity.class.getSimpleName(); + private static final String TAG = MainActivity.class.getSimpleName(); private boolean gridView = true; @@ -878,7 +880,7 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi if (selected) { v.setSelected(true); mActionMode = startSupportActionMode(new MultiSelectedActionModeCallback( - this, this, db, mActionMode, adapter, listView, this::refreshLists, getSupportFragmentManager(), activityBinding.searchView + this, this, db, localAccount.getId(), adapter, listView, this::refreshLists, getSupportFragmentManager(), activityBinding.searchView )); int checkedItemCount = adapter.getSelected().size(); mActionMode.setTitle(getResources().getQuantityString(R.plurals.ab_selected, checkedItemCount, checkedItemCount)); @@ -955,7 +957,7 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi } @Override - public void moveToAccount(LocalAccount account) { + public void onAccountPicked(@NonNull LocalAccount account) { List<Integer> selection = new ArrayList<>(adapter.getSelected()); adapter.deselect(0); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java b/app/src/main/java/it/niedermann/owncloud/notes/main/MultiSelectedActionModeCallback.java index b90be5d7..8a7d9ecb 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/MultiSelectedActionModeCallback.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/MultiSelectedActionModeCallback.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android; +package it.niedermann.owncloud.notes.main; import android.content.Context; import android.graphics.drawable.Drawable; @@ -26,14 +26,13 @@ import java.util.ArrayList; import java.util.List; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.activity.NotesListViewActivity; -import it.niedermann.owncloud.notes.android.fragment.MoveAccountDialogFragment; import it.niedermann.owncloud.notes.branding.BrandedSnackbar; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.ItemAdapter; +import it.niedermann.owncloud.notes.accountpicker.AccountPickerDialogFragment; +import it.niedermann.owncloud.notes.main.items.ItemAdapter; import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper.ViewProvider; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.ShareUtil; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.util.ShareUtil; public class MultiSelectedActionModeCallback implements Callback { @@ -43,6 +42,7 @@ public class MultiSelectedActionModeCallback implements Callback { private final Context context; private final ViewProvider viewProvider; private final NotesDatabase db; + private final long currentLocalAccountId; private final ItemAdapter adapter; private final RecyclerView recyclerView; private final Runnable refreshLists; @@ -50,10 +50,11 @@ public class MultiSelectedActionModeCallback implements Callback { private final SearchView searchView; public MultiSelectedActionModeCallback( - Context context, ViewProvider viewProvider, NotesDatabase db, ActionMode actionMode, ItemAdapter adapter, RecyclerView recyclerView, Runnable refreshLists, FragmentManager fragmentManager, SearchView searchView) { + Context context, ViewProvider viewProvider, NotesDatabase db, long currentLocalAccountId, ItemAdapter adapter, RecyclerView recyclerView, Runnable refreshLists, FragmentManager fragmentManager, SearchView searchView) { this.context = context; this.viewProvider = viewProvider; this.db = db; + this.currentLocalAccountId = currentLocalAccountId; this.adapter = adapter; this.recyclerView = recyclerView; this.refreshLists = refreshLists; @@ -129,7 +130,7 @@ public class MultiSelectedActionModeCallback implements Callback { } return true; case R.id.menu_move: - MoveAccountDialogFragment.newInstance().show(fragmentManager, NotesListViewActivity.class.getSimpleName()); + AccountPickerDialogFragment.newInstance(currentLocalAccountId).show(fragmentManager, MainActivity.class.getSimpleName()); return true; case R.id.menu_share: final String subject = (adapter.getSelected().size() == 1) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NavigationAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/main/NavigationAdapter.java index 938f2f7e..d12a92e7 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NavigationAdapter.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/NavigationAdapter.java @@ -1,7 +1,6 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main; import android.content.Context; -import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -21,7 +20,7 @@ import java.util.List; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.databinding.ItemNavigationBinding; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.ViewHolder> { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/ItemAdapter.java index f6efada4..645533a7 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/ItemAdapter.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items; import android.content.Context; import android.content.SharedPreferences; @@ -25,8 +25,17 @@ import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemGridOnlyTit import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithExcerptBinding; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithoutExcerptBinding; import it.niedermann.owncloud.notes.databinding.ItemNotesListSectionItemBinding; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.Item; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.main.items.grid.NoteViewGridHolder; +import it.niedermann.owncloud.notes.main.items.grid.NoteViewGridHolderOnlyTitle; +import it.niedermann.owncloud.notes.main.items.list.NoteViewHolderWithExcerpt; +import it.niedermann.owncloud.notes.main.items.list.NoteViewHolderWithoutExcerpt; +import it.niedermann.owncloud.notes.main.items.section.SectionItem; +import it.niedermann.owncloud.notes.main.items.section.SectionViewHolder; -import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.getFontSizeFromPreferences; public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Branded { @@ -65,7 +74,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i /* - FIXME this causes {@link it.niedermann.owncloud.notes.android.NotesListViewItemTouchHelper} to not call clearView anymore → After marking a note as favorite, it stays yellow. + FIXME this causes {@link it.niedermann.owncloud.notes.noteslist.items.list.NotesListViewItemTouchHelper} to not call clearView anymore → After marking a note as favorite, it stays yellow. @Override public long getItemId(int position) { return getItemViewType(position) == TYPE_SECTION diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java index de83784c..13c4f874 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items; import android.content.Context; import android.content.res.ColorStateList; @@ -28,12 +28,15 @@ import java.util.regex.Pattern; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.NotesApplication; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; -import static it.niedermann.owncloud.notes.util.ColorUtil.contrastRatioIsSufficient; -import static it.niedermann.owncloud.notes.util.ColorUtil.isColorDark; +import static it.niedermann.owncloud.notes.shared.util.ColorUtil.contrastRatioIsSufficient; +import static it.niedermann.owncloud.notes.shared.util.ColorUtil.isColorDark; public abstract class NoteViewHolder extends RecyclerView.ViewHolder { @NonNull @@ -56,7 +59,7 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { } protected void bindCategory(@NonNull Context context, @NonNull TextView noteCategory, boolean showCategory, @NonNull String category, int mainColor) { - final boolean isDarkThemeActive = Notes.isDarkThemeActive(context); + final boolean isDarkThemeActive = NotesApplication.isDarkThemeActive(context); noteCategory.setVisibility(showCategory && !category.isEmpty() ? View.VISIBLE : View.GONE); noteCategory.setText(category); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/GridItemDecoration.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/GridItemDecoration.java index 68b349e0..f411cf16 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/GridItemDecoration.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/GridItemDecoration.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.grid; import android.graphics.Rect; import android.view.View; @@ -8,6 +8,9 @@ import androidx.annotation.Px; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager; +import it.niedermann.owncloud.notes.main.items.ItemAdapter; +import it.niedermann.owncloud.notes.main.items.section.SectionItemDecoration; + public class GridItemDecoration extends SectionItemDecoration { @NonNull diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolder.java index fa1f91c4..765b970a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolder.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.grid; import android.content.Context; import android.graphics.Typeface; @@ -11,11 +11,13 @@ import androidx.annotation.Nullable; import androidx.annotation.Px; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemGridBinding; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.main.items.NoteViewHolder; import static android.view.View.GONE; -import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; -import static it.niedermann.owncloud.notes.util.NoteUtil.EXCERPT_LINE_SEPARATOR; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.EXCERPT_LINE_SEPARATOR; public class NoteViewGridHolder extends NoteViewHolder { @NonNull diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolderOnlyTitle.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolderOnlyTitle.java index 3cee19e9..6468e964 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolderOnlyTitle.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolderOnlyTitle.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.grid; import android.content.Context; import android.graphics.Typeface; @@ -10,9 +10,9 @@ import androidx.annotation.Nullable; import androidx.annotation.Px; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemGridOnlyTitleBinding; - -import static android.view.View.INVISIBLE; -import static android.view.View.VISIBLE; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.main.items.NoteViewHolder; public class NoteViewGridHolderOnlyTitle extends NoteViewHolder { @NonNull diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithExcerpt.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithExcerpt.java index 05dc07c4..0f41d745 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithExcerpt.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithExcerpt.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.list; import android.content.Context; import android.view.View; @@ -8,6 +8,10 @@ import androidx.annotation.Nullable; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithExcerptBinding; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.main.items.NoteViewHolder; public class NoteViewHolderWithExcerpt extends NoteViewHolder { @NonNull diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithoutExcerpt.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithoutExcerpt.java index 2af456a8..9b056925 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithoutExcerpt.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithoutExcerpt.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.list; import android.content.Context; import android.view.View; @@ -8,6 +8,10 @@ import androidx.annotation.Nullable; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithoutExcerptBinding; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.main.items.NoteViewHolder; public class NoteViewHolderWithoutExcerpt extends NoteViewHolder { @NonNull diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/NotesListViewItemTouchHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NotesListViewItemTouchHelper.java index ed3cc8c2..3251269c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/NotesListViewItemTouchHelper.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NotesListViewItemTouchHelper.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android; +package it.niedermann.owncloud.notes.main.items.list; import android.content.Context; import android.graphics.Canvas; @@ -17,11 +17,11 @@ import com.nextcloud.android.sso.model.SingleSignOnAccount; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandedSnackbar; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.ISyncCallback; -import it.niedermann.owncloud.notes.model.ItemAdapter; -import it.niedermann.owncloud.notes.model.NoteViewHolder; -import it.niedermann.owncloud.notes.model.SectionViewHolder; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; +import it.niedermann.owncloud.notes.main.items.ItemAdapter; +import it.niedermann.owncloud.notes.main.items.NoteViewHolder; +import it.niedermann.owncloud.notes.main.items.section.SectionViewHolder; import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper.ViewProvider; import it.niedermann.owncloud.notes.persistence.NotesDatabase; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/SectionItem.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/section/SectionItem.java index 27e4758a..bd01163d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/SectionItem.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/section/SectionItem.java @@ -1,4 +1,6 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.section; + +import it.niedermann.owncloud.notes.shared.model.Item; public class SectionItem implements Item { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/SectionItemDecoration.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/section/SectionItemDecoration.java index 8868f4e8..1ebcbe48 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/SectionItemDecoration.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/section/SectionItemDecoration.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.section; import android.graphics.Rect; import android.view.View; @@ -8,6 +8,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Px; import androidx.recyclerview.widget.RecyclerView; +import it.niedermann.owncloud.notes.main.items.ItemAdapter; + public class SectionItemDecoration extends RecyclerView.ItemDecoration { @NonNull diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/SectionViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/section/SectionViewHolder.java index 7f8447fd..b1ce4c45 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/SectionViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/section/SectionViewHolder.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.main.items.section; import androidx.recyclerview.widget.RecyclerView; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountAdapter.java index 50ab925b..33156fb6 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountAdapter.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountAdapter.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; public class ManageAccountAdapter extends RecyclerView.Adapter<ManageAccountViewHolder> { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java index 39ae6891..0ec7f186 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java @@ -15,7 +15,7 @@ import com.bumptech.glide.request.RequestOptions; import it.niedermann.android.glidesso.SingleSignOnUrl; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; import static android.view.View.GONE; import static android.view.View.VISIBLE; 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 eb6747c3..7cf64230 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 @@ -12,9 +12,9 @@ import com.nextcloud.android.sso.model.SingleSignOnAccount; import java.util.List; -import it.niedermann.owncloud.notes.android.activity.LockedActivity; +import it.niedermann.owncloud.notes.LockedActivity; import it.niedermann.owncloud.notes.databinding.ActivityManageAccountsBinding; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; import it.niedermann.owncloud.notes.persistence.NotesDatabase; public class ManageAccountsActivity extends LockedActivity { @@ -23,7 +23,6 @@ public class ManageAccountsActivity extends LockedActivity { private ManageAccountAdapter adapter; private NotesDatabase db = null; - @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index d80aa094..46d36e1c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -22,7 +22,7 @@ import it.niedermann.owncloud.notes.persistence.migration.Migration_6_7; import it.niedermann.owncloud.notes.persistence.migration.Migration_7_8; import it.niedermann.owncloud.notes.persistence.migration.Migration_8_9; import it.niedermann.owncloud.notes.persistence.migration.Migration_9_10; -import it.niedermann.owncloud.notes.util.DatabaseIndexUtil; +import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil; abstract class AbstractNotesDatabase extends SQLiteOpenHelper { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java index b9865e3a..9a08bc1e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import it.niedermann.owncloud.notes.model.Capabilities; +import it.niedermann.owncloud.notes.shared.model.Capabilities; @WorkerThread public class CapabilitiesClient { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesWorker.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesWorker.java index 31b30b33..26e18311 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesWorker.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesWorker.java @@ -20,8 +20,8 @@ import java.net.HttpURLConnection; import java.util.Objects; import java.util.concurrent.TimeUnit; -import it.niedermann.owncloud.notes.model.Capabilities; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.Capabilities; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; public class CapabilitiesWorker extends Worker { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java index e7d88691..0380b0be 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java @@ -13,12 +13,12 @@ import java.util.Calendar; import java.util.List; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.model.Category; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.Item; -import it.niedermann.owncloud.notes.model.SectionItem; -import it.niedermann.owncloud.notes.util.CategorySortingMethod; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.model.Category; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.Item; +import it.niedermann.owncloud.notes.main.items.section.SectionItem; +import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; public class LoadNotesListTask extends AsyncTask<Void, Void, List<Item>> { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java index 7158c9d2..4b2f4b7d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java @@ -33,16 +33,16 @@ import java.util.Objects; import java.util.Set; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.fragment.ExceptionDialogFragment; +import it.niedermann.owncloud.notes.exception.ExceptionDialogFragment; import it.niedermann.owncloud.notes.branding.BrandedSnackbar; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.DBStatus; -import it.niedermann.owncloud.notes.model.ISyncCallback; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.model.SyncResultStatus; -import it.niedermann.owncloud.notes.util.SSOUtil; -import it.niedermann.owncloud.notes.util.ServerResponse; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.SyncResultStatus; +import it.niedermann.owncloud.notes.shared.util.SSOUtil; +import it.niedermann.owncloud.notes.shared.model.ServerResponse; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClient.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClient.java index 207b4d49..c9ab9b39 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClient.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClient.java @@ -25,10 +25,10 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import it.niedermann.owncloud.notes.model.ApiVersion; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.util.ServerResponse.NoteResponse; -import it.niedermann.owncloud.notes.util.ServerResponse.NotesResponse; +import it.niedermann.owncloud.notes.shared.model.ApiVersion; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.ServerResponse.NoteResponse; +import it.niedermann.owncloud.notes.shared.model.ServerResponse.NotesResponse; @SuppressWarnings("WeakerAccess") @WorkerThread diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV02.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV02.java index 965e3a90..e529dd8c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV02.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV02.java @@ -12,9 +12,9 @@ import org.json.JSONObject; import java.util.HashMap; import java.util.Map; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.util.ServerResponse.NoteResponse; -import it.niedermann.owncloud.notes.util.ServerResponse.NotesResponse; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.ServerResponse.NoteResponse; +import it.niedermann.owncloud.notes.shared.model.ServerResponse.NotesResponse; @WorkerThread public class NotesClientV02 extends NotesClient { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV1.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV1.java index 75da6a56..220d4f8f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV1.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClientV1.java @@ -12,9 +12,9 @@ import org.json.JSONObject; import java.util.HashMap; import java.util.Map; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.util.ServerResponse.NoteResponse; -import it.niedermann.owncloud.notes.util.ServerResponse.NotesResponse; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.ServerResponse.NoteResponse; +import it.niedermann.owncloud.notes.shared.model.ServerResponse.NotesResponse; @WorkerThread public class NotesClientV1 extends NotesClient { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java index 236d566d..1663b289 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java @@ -42,27 +42,27 @@ import java.util.NoSuchElementException; import java.util.Set; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; -import it.niedermann.owncloud.notes.model.ApiVersion; -import it.niedermann.owncloud.notes.model.Capabilities; -import it.niedermann.owncloud.notes.model.Category; -import it.niedermann.owncloud.notes.model.CloudNote; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.DBStatus; -import it.niedermann.owncloud.notes.model.ISyncCallback; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.model.NavigationAdapter; -import it.niedermann.owncloud.notes.model.NoteListsWidgetData; -import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; -import it.niedermann.owncloud.notes.util.CategorySortingMethod; -import it.niedermann.owncloud.notes.util.ColorUtil; -import it.niedermann.owncloud.notes.util.NoteUtil; - -import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.ACTION_SHORTCUT; -import static it.niedermann.owncloud.notes.android.appwidget.NoteListWidget.updateNoteListWidgets; -import static it.niedermann.owncloud.notes.android.appwidget.SingleNoteWidget.updateSingleNoteWidgets; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_CATEGORY; -import static it.niedermann.owncloud.notes.util.NoteUtil.generateNoteExcerpt; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; +import it.niedermann.owncloud.notes.shared.model.ApiVersion; +import it.niedermann.owncloud.notes.shared.model.Capabilities; +import it.niedermann.owncloud.notes.shared.model.Category; +import it.niedermann.owncloud.notes.shared.model.CloudNote; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.shared.model.DBStatus; +import it.niedermann.owncloud.notes.shared.model.ISyncCallback; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; +import it.niedermann.owncloud.notes.main.NavigationAdapter; +import it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData; +import it.niedermann.owncloud.notes.widget.singlenote.SingleNoteWidgetData; +import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod; +import it.niedermann.owncloud.notes.shared.util.ColorUtil; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; + +import static it.niedermann.owncloud.notes.edit.EditNoteActivity.ACTION_SHORTCUT; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListWidget.updateNoteListWidgets; +import static it.niedermann.owncloud.notes.widget.singlenote.SingleNoteWidget.updateSingleNoteWidgets; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_CATEGORY; +import static it.niedermann.owncloud.notes.shared.util.NoteUtil.generateNoteExcerpt; /** * Helps to add, get, update and delete Notes with the option to trigger a Resync with the Server. diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/SyncWorker.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/SyncWorker.java index f1277666..4a29bd6d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/SyncWorker.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/SyncWorker.java @@ -20,7 +20,7 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.model.LocalAccount; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; public class SyncWorker extends Worker { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_10_11.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_10_11.java index 82a627aa..4d45a3ce 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_10_11.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_10_11.java @@ -8,7 +8,7 @@ import androidx.preference.PreferenceManager; import java.util.Map; -import it.niedermann.owncloud.notes.android.DarkModeSetting; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; public class Migration_10_11 { /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_11_12.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_11_12.java index 82a9984e..6fd531c9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_11_12.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_11_12.java @@ -5,7 +5,7 @@ import android.database.sqlite.SQLiteDatabase; import androidx.annotation.NonNull; -import it.niedermann.owncloud.notes.model.ApiVersion; +import it.niedermann.owncloud.notes.shared.model.ApiVersion; import it.niedermann.owncloud.notes.persistence.CapabilitiesWorker; public class Migration_11_12 { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_12_13.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_12_13.java index 895a59a1..77954c3f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_12_13.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_12_13.java @@ -6,7 +6,7 @@ import android.database.sqlite.SQLiteDatabase; import androidx.annotation.NonNull; import androidx.work.WorkManager; -import it.niedermann.owncloud.notes.model.Capabilities; +import it.niedermann.owncloud.notes.shared.model.Capabilities; public class Migration_12_13 { /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_13_14.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_13_14.java index d69396d3..66a2f643 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_13_14.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_13_14.java @@ -11,7 +11,7 @@ import androidx.preference.PreferenceManager; import java.util.Map; -import it.niedermann.owncloud.notes.android.DarkModeSetting; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; public class Migration_13_14 { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_14_15.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_14_15.java index b025bbaa..e69c8ff1 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_14_15.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_14_15.java @@ -7,7 +7,7 @@ import android.util.Log; import java.util.Hashtable; -import it.niedermann.owncloud.notes.util.DatabaseIndexUtil; +import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil; public class Migration_14_15 { /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_15_16.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_15_16.java index 396f29e1..49056239 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_15_16.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_15_16.java @@ -12,7 +12,7 @@ import androidx.preference.PreferenceManager; import java.util.Map; -import it.niedermann.owncloud.notes.android.DarkModeSetting; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; public class Migration_15_16 { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_4_5.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_4_5.java index 612ed1cb..aa807944 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_4_5.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_4_5.java @@ -4,8 +4,6 @@ import android.database.sqlite.SQLiteDatabase; import androidx.annotation.NonNull; -import it.niedermann.owncloud.notes.model.DBStatus; - public class Migration_4_5 { /** * Differentiate between local id and remote id @@ -13,6 +11,6 @@ public class Migration_4_5 { public Migration_4_5(@NonNull SQLiteDatabase db) { db.execSQL("ALTER TABLE NOTES ADD COLUMN REMOTEID INTEGER"); db.execSQL("UPDATE NOTES SET REMOTEID=ID WHERE (REMOTEID IS NULL OR REMOTEID=0) AND STATUS!=?", new String[]{"LOCAL_CREATED"}); - db.execSQL("UPDATE NOTES SET REMOTEID=0, STATUS=? WHERE STATUS=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), "LOCAL_CREATED"}); + db.execSQL("UPDATE NOTES SET REMOTEID=0, STATUS=? WHERE STATUS=?", new String[]{"LOCAL_EDITED", "LOCAL_CREATED"}); } } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_6_7.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_6_7.java index 399d6f40..e7d0eadd 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_6_7.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_6_7.java @@ -4,7 +4,7 @@ import android.database.sqlite.SQLiteDatabase; import androidx.annotation.NonNull; -import it.niedermann.owncloud.notes.util.DatabaseIndexUtil; +import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil; public class Migration_6_7 { /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_7_8.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_7_8.java index 9a968fe1..d1fd40c0 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_7_8.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_7_8.java @@ -4,7 +4,7 @@ import android.database.sqlite.SQLiteDatabase; import androidx.annotation.NonNull; -import it.niedermann.owncloud.notes.util.DatabaseIndexUtil; +import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil; public class Migration_7_8 { public Migration_7_8(@NonNull SQLiteDatabase db) { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_8_9.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_8_9.java index 31957fc0..03e171f3 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_8_9.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_8_9.java @@ -15,9 +15,9 @@ import androidx.preference.PreferenceManager; import java.net.MalformedURLException; import java.net.URL; -import it.niedermann.owncloud.notes.android.appwidget.NoteListWidget; -import it.niedermann.owncloud.notes.android.appwidget.SingleNoteWidget; -import it.niedermann.owncloud.notes.util.DatabaseIndexUtil; +import it.niedermann.owncloud.notes.widget.notelist.NoteListWidget; +import it.niedermann.owncloud.notes.widget.singlenote.SingleNoteWidget; +import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil; public class Migration_8_9 { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java index c5bf2c02..b17b8675 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_9_10.java @@ -6,7 +6,7 @@ import android.database.sqlite.SQLiteDatabase; import androidx.annotation.NonNull; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; public class Migration_9_10 { /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/DarkModeSetting.java b/app/src/main/java/it/niedermann/owncloud/notes/preferences/DarkModeSetting.java index 410a5719..d34ffe74 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/DarkModeSetting.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/preferences/DarkModeSetting.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android; +package it.niedermann.owncloud.notes.preferences; import androidx.appcompat.app.AppCompatDelegate; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/PreferencesActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesActivity.java index ba945a6c..e808a3a0 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/PreferencesActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesActivity.java @@ -1,11 +1,11 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.preferences; import android.os.Bundle; import androidx.annotation.Nullable; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.fragment.PreferencesFragment; +import it.niedermann.owncloud.notes.LockedActivity; import it.niedermann.owncloud.notes.databinding.ActivityPreferencesBinding; /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java index ff9561e6..d324b9f6 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.fragment; +package it.niedermann.owncloud.notes.preferences; import android.app.Activity; import android.content.Context; @@ -12,15 +12,14 @@ import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.DarkModeSetting; import it.niedermann.owncloud.notes.branding.Branded; import it.niedermann.owncloud.notes.branding.BrandedSwitchPreference; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.persistence.SyncWorker; -import it.niedermann.owncloud.notes.util.DeviceCredentialUtil; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.shared.util.DeviceCredentialUtil; +import it.niedermann.owncloud.notes.NotesApplication; -import static it.niedermann.owncloud.notes.android.appwidget.NoteListWidget.updateNoteListWidgets; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListWidget.updateNoteListWidgets; public class PreferencesFragment extends PreferenceFragmentCompat implements Branded { @@ -63,7 +62,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra final Boolean gridView = (Boolean) newValue; Log.v(TAG, "gridView: " + gridView); requireActivity().setResult(Activity.RESULT_OK); - Notes.updateGridViewEnabled(gridView); + NotesApplication.updateGridViewEnabled(gridView); return true; }); } else { @@ -82,7 +81,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra } } else { lockPref.setOnPreferenceChangeListener((preference, newValue) -> { - Notes.setLockedPreference((Boolean) newValue); + NotesApplication.setLockedPreference((Boolean) newValue); return true; }); } @@ -93,7 +92,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra final ListPreference themePref = findPreference(getString(R.string.pref_key_theme)); assert themePref != null; themePref.setOnPreferenceChangeListener((preference, newValue) -> { - Notes.setAppTheme(DarkModeSetting.valueOf((String) newValue)); + NotesApplication.setAppTheme(DarkModeSetting.valueOf((String) newValue)); requireActivity().setResult(Activity.RESULT_OK); requireActivity().recreate(); return true; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java b/app/src/main/java/it/niedermann/owncloud/notes/quicksettings/NewNoteTileService.java index ca101c88..01308785 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/quicksettings/NewNoteTileService.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.quicksettings; +package it.niedermann.owncloud.notes.quicksettings; import android.annotation.TargetApi; import android.content.Intent; @@ -6,7 +6,7 @@ import android.os.Build; import android.service.quicksettings.Tile; import android.service.quicksettings.TileService; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; /** * This {@link TileService} adds a quick settings tile that leads to the new note view. diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserAdapter.java new file mode 100644 index 00000000..dd28f431 --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserAdapter.java @@ -0,0 +1,44 @@ +package it.niedermann.owncloud.notes.shared.account; + +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.core.util.Consumer; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; + +public class AccountChooserAdapter extends RecyclerView.Adapter<AccountChooserViewHolder> { + + @NonNull + private final List<LocalAccount> localAccounts; + @NonNull + private final Consumer<LocalAccount> targetAccountConsumer; + + public AccountChooserAdapter(@NonNull List<LocalAccount> localAccounts, @NonNull Consumer<LocalAccount> targetAccountConsumer) { + super(); + this.localAccounts = localAccounts; + this.targetAccountConsumer = targetAccountConsumer; + } + + @NonNull + @Override + public AccountChooserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new AccountChooserViewHolder(ItemAccountChooseBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull AccountChooserViewHolder holder, int position) { + holder.bind(localAccounts.get(position), targetAccountConsumer); + } + + @Override + public int getItemCount() { + return localAccounts.size(); + } + +} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java new file mode 100644 index 00000000..9fc2f382 --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java @@ -0,0 +1,37 @@ +package it.niedermann.owncloud.notes.shared.account; + +import android.net.Uri; + +import androidx.core.util.Consumer; +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; + +import it.niedermann.android.glidesso.SingleSignOnUrl; +import it.niedermann.owncloud.notes.R; +import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; + +public class AccountChooserViewHolder extends RecyclerView.ViewHolder { + private final ItemAccountChooseBinding binding; + + protected AccountChooserViewHolder(ItemAccountChooseBinding binding) { + super(binding.getRoot()); + this.binding = binding; + } + + public void bind(LocalAccount localAccount, Consumer<LocalAccount> targetAccountConsumer) { + Glide + .with(binding.accountItemAvatar.getContext()) + .load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64")) + .placeholder(R.drawable.ic_account_circle_grey_24dp) + .error(R.drawable.ic_account_circle_grey_24dp) + .apply(RequestOptions.circleCropTransform()) + .into(binding.accountItemAvatar); + + binding.accountLayout.setOnClickListener((v) -> targetAccountConsumer.accept(localAccount)); + binding.accountName.setText(localAccount.getUserName()); + binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost()); + } +}
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/ApiVersion.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/ApiVersion.java index 058dcae8..b27afd7a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/ApiVersion.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/ApiVersion.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import androidx.annotation.NonNull; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/Capabilities.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/Capabilities.java index aae6ad1b..b182ca63 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/Capabilities.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/Capabilities.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import android.util.Log; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/Category.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/Category.java index 72f176c8..ab1d10a1 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/Category.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/Category.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import androidx.annotation.Nullable; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/CategorySortingMethod.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/CategorySortingMethod.java index f5199cd6..35ab8b66 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/CategorySortingMethod.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/CategorySortingMethod.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.model; public enum CategorySortingMethod { SORT_MODIFIED_DESC("MODIFIED DESC"), diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/CloudNote.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/CloudNote.java index 345c76ca..cf6c51e8 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/CloudNote.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/CloudNote.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import androidx.annotation.NonNull; @@ -7,7 +7,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; /** * CloudNote represents a remote note from an OwnCloud server. diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/DBNote.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/DBNote.java index d2be6aa2..059a1ce3 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/DBNote.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/DBNote.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import androidx.annotation.NonNull; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/DBStatus.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/DBStatus.java index f98b887e..4b7e61e4 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/DBStatus.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/DBStatus.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; /** * Helps to distinguish between different local change types for Server Synchronization. diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/ISyncCallback.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/ISyncCallback.java index 37026756..b5b9093c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/ISyncCallback.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/ISyncCallback.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; /** * Callback diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/Item.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/Item.java index d3191e4d..362bc390 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/Item.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/Item.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; public interface Item { boolean isSection(); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/LocalAccount.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/LocalAccount.java index bfcb4d74..aaafd750 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/LocalAccount.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/LocalAccount.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import androidx.annotation.ColorInt; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteClickListener.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/NoteClickListener.java index 8dd1748d..7194752c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteClickListener.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/NoteClickListener.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import android.view.View; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/ServerResponse.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/ServerResponse.java index ca915b98..9f34b907 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/ServerResponse.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/ServerResponse.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.model; import androidx.annotation.Nullable; @@ -11,7 +11,6 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; -import it.niedermann.owncloud.notes.model.CloudNote; import it.niedermann.owncloud.notes.persistence.NotesClient; /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/SyncResultStatus.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/SyncResultStatus.java index bea217db..2031568b 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/SyncResultStatus.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/model/SyncResultStatus.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; public class SyncResultStatus { public boolean pullSuccessful = true; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/ClipboardUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/ClipboardUtil.java index 16738c8f..fa0edeec 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/ClipboardUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/ClipboardUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.content.ClipData; import android.content.ClipboardManager; @@ -44,7 +44,7 @@ public class ClipboardUtil { } @Nullable - public static String getClipboardURLorNull(Context context) { + public static String getClipboardURLorNull(@NonNull Context context) { final ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE); if (clipboardManager == null) { return null; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/ColorUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/ColorUtil.java index 3b44c0f2..a7f1b566 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/ColorUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/ColorUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.graphics.Color; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/CustomAppGlideModule.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/CustomAppGlideModule.java index c48a1666..03eb1097 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/CustomAppGlideModule.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/CustomAppGlideModule.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.content.Context; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/DatabaseIndexUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DatabaseIndexUtil.java index c6b0c844..235711ef 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/DatabaseIndexUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DatabaseIndexUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/DeviceCredentialUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DeviceCredentialUtil.java index d79dc9d6..034eea5a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/DeviceCredentialUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DeviceCredentialUtil.java @@ -1,8 +1,7 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.app.KeyguardManager; import android.content.Context; -import android.os.Build; import android.util.Log; /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/DisplayUtils.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java index 50931618..91c2b13a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/DisplayUtils.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.content.Context; import android.graphics.Color; @@ -33,10 +33,11 @@ import androidx.annotation.Nullable; import java.util.regex.Matcher; import java.util.regex.Pattern; +import it.niedermann.owncloud.notes.NotesApplication; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; -import static it.niedermann.owncloud.notes.util.ColorUtil.isColorDark; +import static it.niedermann.owncloud.notes.shared.util.ColorUtil.isColorDark; public class DisplayUtils { @@ -95,7 +96,7 @@ public class DisplayUtils { @Override public void updateDrawState(TextPaint tp) { if (current) { - if (Notes.isDarkThemeActive(context)) { + if (NotesApplication.isDarkThemeActive(context)) { if (isColorDark(mainColor)) { tp.bgColor = Color.WHITE; tp.setColor(mainColor); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/MarkDownUtil.java index 5609aaea..43a8937e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/MarkDownUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.content.Context; import android.graphics.Color; @@ -15,6 +15,7 @@ import com.yydcdut.markdown.span.MDImageSpan; import com.yydcdut.markdown.theme.ThemeDefault; import com.yydcdut.markdown.theme.ThemeSonsOfObsidian; +import it.niedermann.owncloud.notes.NotesApplication; import it.niedermann.owncloud.notes.R; /** @@ -45,7 +46,7 @@ public class MarkDownUtil { * @return RxMDConfiguration */ public static Builder getMarkDownConfiguration(Context context) { - return getMarkDownConfiguration(context, Notes.isDarkThemeActive(context)); + return getMarkDownConfiguration(context, NotesApplication.isDarkThemeActive(context)); } public static Builder getMarkDownConfiguration(Context context, Boolean darkTheme) { @@ -65,7 +66,6 @@ public class MarkDownUtil { .setTodoDoneColor(ResourcesCompat.getColor(context.getResources(), darkTheme ? R.color.widget_fg_dark_theme : R.color.widget_fg_default, null)) .setLinkFontColor(ResourcesCompat.getColor(context.getResources(), R.color.defaultBrand, null)) - .setRxMDImageLoader(new NotesImageLoader(context)) .setDefaultImageSize(400, 300); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NoteLinksUtils.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NoteLinksUtils.java index b8d5c027..389e2bef 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/NoteLinksUtils.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NoteLinksUtils.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.text.TextUtils; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NoteUtil.java index 6e6f6244..014d3377 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NoteUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.content.Context; import android.content.SharedPreferences; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/SSOUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/SSOUtil.java index 77fa0d2c..da529136 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/SSOUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/SSOUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.app.Activity; import android.content.Context; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/ShareUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/ShareUtil.java index 1a1f6f37..09ad7124 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/ShareUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/ShareUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.content.Context; import android.content.Intent; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/SupportUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/SupportUtil.java index 39abc105..e480b30b 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/SupportUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/SupportUtil.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import android.os.Build; import android.text.Html; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesImageLoader.java b/app/src/main/java/it/niedermann/owncloud/notes/util/NotesImageLoader.java deleted file mode 100644 index e0b008ac..00000000 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesImageLoader.java +++ /dev/null @@ -1,42 +0,0 @@ -package it.niedermann.owncloud.notes.util; - -import android.content.Context; -import android.util.Base64; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.yydcdut.markdown.loader.DefaultLoader; - -import java.io.IOException; - -/** - * Extends Default Loader with Base64 capabilities - */ -public class NotesImageLoader extends DefaultLoader { - - /** - * Constructor - * - * @param context Context - */ - NotesImageLoader(Context context) { - super(context); - } - - @Nullable - @Override - public byte[] loadSync(@NonNull String url) throws IOException { - byte[] bytes = super.loadSync(url); - if (bytes == null && url.trim().startsWith("data:image/")) { - return base64(url); - } - return bytes; - } - - @Nullable - private static byte[] base64(@NonNull String url) { - String content = url.substring(url.indexOf(",")); - return Base64.decode(content, Base64.DEFAULT); - } -} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/AbstractWidgetData.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/AbstractWidgetData.java index 672ba170..019a2153 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/AbstractWidgetData.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/AbstractWidgetData.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.widget; public abstract class AbstractWidgetData { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/CreateNoteWidget.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/createnote/CreateNoteWidget.java index d025015b..d4a6b1d2 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/CreateNoteWidget.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/createnote/CreateNoteWidget.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.createnote; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; @@ -8,7 +8,7 @@ import android.content.Intent; import android.widget.RemoteViews; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; /** * Implementation of App Widget functionality. diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidget.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.java index 2a59aaa8..7584b966 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidget.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.notelist; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; @@ -14,20 +14,19 @@ import android.widget.RemoteViews; import java.util.NoSuchElementException; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.DarkModeSetting; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; -import it.niedermann.owncloud.notes.android.activity.NotesListViewActivity; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; +import it.niedermann.owncloud.notes.main.MainActivity; import it.niedermann.owncloud.notes.branding.BrandingUtil; -import it.niedermann.owncloud.notes.model.Category; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.model.NoteListsWidgetData; +import it.niedermann.owncloud.notes.shared.model.Category; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.NotesApplication; -import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.PARAM_CATEGORY; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_ALL; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_CATEGORY; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_STARRED; +import static it.niedermann.owncloud.notes.edit.EditNoteActivity.PARAM_CATEGORY; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_ALL; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_CATEGORY; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_STARRED; public class NoteListWidget extends AppWidgetProvider { private static final String TAG = NoteListWidget.class.getSimpleName(); @@ -61,7 +60,7 @@ public class NoteListWidget extends AppWidgetProvider { // Launch application when user taps the header icon or app title Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName(context.getPackageName(), - NotesListViewActivity.class.getName())); + MainActivity.class.getName())); // Open the main app if the user taps the widget header PendingIntent openAppI = PendingIntent.getActivity(context, PENDING_INTENT_OPEN_APP_RQ, @@ -79,7 +78,7 @@ public class NoteListWidget extends AppWidgetProvider { Log.v(TAG, "-- data - " + data); - if (Notes.isDarkThemeActive(context, darkTheme)) { + if (NotesApplication.isDarkThemeActive(context, darkTheme)) { views = new RemoteViews(context.getPackageName(), R.layout.widget_note_list_dark); views.setTextViewText(R.id.widget_note_list_title_tv_dark, getWidgetTitle(context, data.getMode(), category)); views.setOnClickPendingIntent(R.id.widget_note_header_icon_dark, openAppI); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NoteListWidgetConfigurationActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetConfigurationActivity.java index 01d35902..e927c3b1 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NoteListWidgetConfigurationActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetConfigurationActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.widget.notelist; import android.app.Activity; import android.appwidget.AppWidgetManager; @@ -21,13 +21,13 @@ import java.util.List; import java.util.Map; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.appwidget.NoteListWidget; -import it.niedermann.owncloud.notes.model.LocalAccount; -import it.niedermann.owncloud.notes.model.NavigationAdapter; -import it.niedermann.owncloud.notes.model.NavigationAdapter.CategoryNavigationItem; -import it.niedermann.owncloud.notes.model.NoteListsWidgetData; +import it.niedermann.owncloud.notes.LockedActivity; +import it.niedermann.owncloud.notes.main.MainActivity; +import it.niedermann.owncloud.notes.shared.model.LocalAccount; +import it.niedermann.owncloud.notes.main.NavigationAdapter; +import it.niedermann.owncloud.notes.main.NavigationAdapter.CategoryNavigationItem; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.NotesApplication; public class NoteListWidgetConfigurationActivity extends LockedActivity { private static final String TAG = Activity.class.getSimpleName(); @@ -71,11 +71,11 @@ public class NoteListWidgetConfigurationActivity extends LockedActivity { finish(); } - itemRecent = new NavigationAdapter.NavigationItem(NotesListViewActivity.ADAPTER_KEY_RECENT, + itemRecent = new NavigationAdapter.NavigationItem(MainActivity.ADAPTER_KEY_RECENT, getString(R.string.label_all_notes), null, R.drawable.ic_access_time_grey600_24dp); - itemFavorites = new NavigationAdapter.NavigationItem(NotesListViewActivity.ADAPTER_KEY_STARRED, + itemFavorites = new NavigationAdapter.NavigationItem(MainActivity.ADAPTER_KEY_STARRED, getString(R.string.label_favorites), null, R.drawable.ic_star_yellow_24dp); @@ -102,7 +102,7 @@ public class NoteListWidgetConfigurationActivity extends LockedActivity { } data.setAccountId(localAccount.getId()); - data.setThemeMode(Notes.getAppTheme(getApplicationContext()).getModeId()); + data.setThemeMode(NotesApplication.getAppTheme(getApplicationContext()).getModeId()); db.createOrUpdateNoteListWidgetData(data); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidgetFactory.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetFactory.java index 9956ff05..5fde5010 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidgetFactory.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetFactory.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.notelist; import android.appwidget.AppWidgetManager; import android.content.Context; @@ -12,16 +12,15 @@ import android.widget.RemoteViewsService; import java.util.List; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.DarkModeSetting; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.NoteListsWidgetData; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; +import it.niedermann.owncloud.notes.shared.model.DBNote; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.NotesApplication; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_ALL; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_CATEGORY; -import static it.niedermann.owncloud.notes.model.NoteListsWidgetData.MODE_DISPLAY_STARRED; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_ALL; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_CATEGORY; +import static it.niedermann.owncloud.notes.widget.notelist.NoteListsWidgetData.MODE_DISPLAY_STARRED; public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFactory { private static final String TAG = NoteListWidgetFactory.class.getSimpleName(); @@ -40,7 +39,7 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact db = NotesDatabase.getInstance(context); data = db.getNoteListWidgetData(appWidgetId); - darkTheme = Notes.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode())); + darkTheme = NotesApplication.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode())); } @Override diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidgetService.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetService.java index 573ef7ea..873cd241 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidgetService.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetService.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.notelist; import android.content.Intent; import android.widget.RemoteViewsService; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteListsWidgetData.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListsWidgetData.java index ded1a31f..a21714ce 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteListsWidgetData.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListsWidgetData.java @@ -1,9 +1,11 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.widget.notelist; import androidx.annotation.IntRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import it.niedermann.owncloud.notes.widget.AbstractWidgetData; + public class NoteListsWidgetData extends AbstractWidgetData { public static final int MODE_DISPLAY_ALL = 0; public static final int MODE_DISPLAY_STARRED = 1; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidget.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidget.java index 2237b9cb..777cd25e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidget.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidget.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.singlenote; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; @@ -13,12 +13,11 @@ import android.widget.RemoteViews; import java.util.NoSuchElementException; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.DarkModeSetting; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; -import it.niedermann.owncloud.notes.android.fragment.BaseNoteFragment; -import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; +import it.niedermann.owncloud.notes.edit.BaseNoteFragment; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.NotesApplication; public class SingleNoteWidget extends AppWidgetProvider { @@ -43,7 +42,7 @@ public class SingleNoteWidget extends AppWidgetProvider { RemoteViews views; - if (Notes.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode()))) { + if (NotesApplication.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode()))) { views = new RemoteViews(context.getPackageName(), R.layout.widget_single_note_dark); views.setPendingIntentTemplate(R.id.single_note_widget_lv_dark, templatePendingIntent); views.setRemoteAdapter(R.id.single_note_widget_lv_dark, serviceIntent); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java index 0ad1fa5a..ef3bbbe6 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.activity; +package it.niedermann.owncloud.notes.widget.singlenote; import android.app.Activity; import android.appwidget.AppWidgetManager; @@ -12,15 +12,13 @@ import android.widget.Toast; import androidx.appcompat.widget.Toolbar; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import it.niedermann.owncloud.notes.ExceptionHandler; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.appwidget.SingleNoteWidget; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; -import it.niedermann.owncloud.notes.util.Notes; - -public class SelectSingleNoteActivity extends NotesListViewActivity { +import it.niedermann.owncloud.notes.exception.ExceptionHandler; +import it.niedermann.owncloud.notes.main.MainActivity; +import it.niedermann.owncloud.notes.shared.model.DBNote; +import it.niedermann.owncloud.notes.NotesApplication; +public class SingleNoteWidgetConfigurationActivity extends MainActivity { @Override protected void onCreate(Bundle savedInstanceState) { @@ -59,7 +57,7 @@ public class SelectSingleNoteActivity extends NotesListViewActivity { appWidgetId, note.getAccountId(), note.getId(), - Notes.getAppTheme(this).getModeId() + NotesApplication.getAppTheme(this).getModeId() ) ); final Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/SingleNoteWidgetData.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetData.java index 556c1041..79b83006 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/SingleNoteWidgetData.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetData.java @@ -1,4 +1,6 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.widget.singlenote; + +import it.niedermann.owncloud.notes.widget.AbstractWidgetData; public class SingleNoteWidgetData extends AbstractWidgetData { private long noteId; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetFactory.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java index b7eee1cc..939c41ef 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetFactory.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetFactory.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.singlenote; import android.appwidget.AppWidgetManager; import android.content.Context; @@ -14,15 +14,14 @@ import com.yydcdut.markdown.syntax.text.TextFactory; import java.util.NoSuchElementException; import it.niedermann.owncloud.notes.R; -import it.niedermann.owncloud.notes.android.DarkModeSetting; -import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; -import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; +import it.niedermann.owncloud.notes.preferences.DarkModeSetting; +import it.niedermann.owncloud.notes.edit.EditNoteActivity; +import it.niedermann.owncloud.notes.shared.model.DBNote; import it.niedermann.owncloud.notes.persistence.NotesDatabase; -import it.niedermann.owncloud.notes.util.MarkDownUtil; -import it.niedermann.owncloud.notes.util.Notes; +import it.niedermann.owncloud.notes.shared.util.MarkDownUtil; +import it.niedermann.owncloud.notes.NotesApplication; -import static it.niedermann.owncloud.notes.util.MarkDownUtil.parseCompat; +import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.parseCompat; public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFactory { @@ -45,7 +44,7 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa markdownProcessor.factory(TextFactory.create()); try { SingleNoteWidgetData data = db.getSingleNoteWidgetData(appWidgetId); - darkModeActive = Notes.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode())); + darkModeActive = NotesApplication.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode())); } catch (NoSuchElementException e) { Log.w(TAG, "Widget with ID " + appWidgetId + " seems to be not configured yet."); } finally { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetService.java b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetService.java index e194d54d..691acae9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetService.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetService.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.android.appwidget; +package it.niedermann.owncloud.notes.widget.singlenote; import android.content.Intent; import android.widget.RemoteViewsService; diff --git a/app/src/main/res/layout/activity_formatting_help.xml b/app/src/main/res/layout/activity_formatting_help.xml index 476698a3..54aa64ec 100644 --- a/app/src/main/res/layout/activity_formatting_help.xml +++ b/app/src/main/res/layout/activity_formatting_help.xml @@ -27,7 +27,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context="it.niedermann.owncloud.notes.android.activity.EditNoteActivity"> + tools:context="it.niedermann.owncloud.notes.edit.EditNoteActivity"> <com.yydcdut.markdown.MarkdownTextView android:id="@+id/content" diff --git a/app/src/main/res/layout/activity_notes_list_view.xml b/app/src/main/res/layout/activity_notes_list_view.xml index a19b6afc..34b3907a 100644 --- a/app/src/main/res/layout/activity_notes_list_view.xml +++ b/app/src/main/res/layout/activity_notes_list_view.xml @@ -108,7 +108,7 @@ android:id="@+id/swiperefreshlayout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity"> + tools:context="it.niedermann.owncloud.notes.main.MainActivity"> <FrameLayout android:layout_width="match_parent" diff --git a/app/src/main/res/layout/fragment_note_edit.xml b/app/src/main/res/layout/fragment_note_edit.xml index 86306e1a..289d3128 100644 --- a/app/src/main/res/layout/fragment_note_edit.xml +++ b/app/src/main/res/layout/fragment_note_edit.xml @@ -21,7 +21,7 @@ android:layout_height="match_parent" android:fillViewport="true" android:orientation="vertical" - tools:context="it.niedermann.owncloud.notes.android.activity.EditNoteActivity"> + tools:context="it.niedermann.owncloud.notes.edit.EditNoteActivity"> <com.yydcdut.markdown.MarkdownEditText android:id="@+id/editContent" diff --git a/app/src/main/res/layout/fragment_note_preview.xml b/app/src/main/res/layout/fragment_note_preview.xml index 4899af96..61ee74a9 100644 --- a/app/src/main/res/layout/fragment_note_preview.xml +++ b/app/src/main/res/layout/fragment_note_preview.xml @@ -10,7 +10,7 @@ android:id="@+id/swiperefreshlayout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity" + tools:context="it.niedermann.owncloud.notes.main.MainActivity" tools:ignore="MergeRootFrame"> <ScrollView @@ -18,7 +18,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context="it.niedermann.owncloud.notes.android.activity.EditNoteActivity"> + tools:context="it.niedermann.owncloud.notes.edit.EditNoteActivity"> <com.yydcdut.markdown.MarkdownTextView android:id="@+id/single_note_content" diff --git a/app/src/main/res/xml/note_list_widget_provider_info.xml b/app/src/main/res/xml/note_list_widget_provider_info.xml index 370d3b03..9f628a2c 100644 --- a/app/src/main/res/xml/note_list_widget_provider_info.xml +++ b/app/src/main/res/xml/note_list_widget_provider_info.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:initialLayout="@layout/widget_note_list" - android:configure="it.niedermann.owncloud.notes.android.activity.NoteListWidgetConfigurationActivity" + android:configure="it.niedermann.owncloud.notes.widget.notelist.NoteListWidgetConfigurationActivity" android:minHeight="110dp" android:minWidth="180dp" android:minResizeHeight="40dp" diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml/shortcuts.xml index 2a04f9d5..7e748cf9 100644 --- a/app/src/main/res/xml/shortcuts.xml +++ b/app/src/main/res/xml/shortcuts.xml @@ -10,7 +10,7 @@ tools:targetApi="n_mr1"> <intent android:action="android.intent.action.CREATE_DOCUMENT" - android:targetClass="it.niedermann.owncloud.notes.android.activity.EditNoteActivity" + android:targetClass="it.niedermann.owncloud.notes.edit.EditNoteActivity" android:targetPackage="it.niedermann.owncloud.notes" /> <categories android:name="android.shortcut.conversation" /> </shortcut> diff --git a/app/src/main/res/xml/single_note_widget_provider_info.xml b/app/src/main/res/xml/single_note_widget_provider_info.xml index 7497659e..b48e11a2 100644 --- a/app/src/main/res/xml/single_note_widget_provider_info.xml +++ b/app/src/main/res/xml/single_note_widget_provider_info.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:initialLayout="@layout/widget_single_note" - android:configure="it.niedermann.owncloud.notes.android.activity.SelectSingleNoteActivity" + android:configure="it.niedermann.owncloud.notes.widget.singlenote.SingleNoteWidgetConfigurationActivity" android:minHeight="110dp" android:minWidth="180dp" android:minResizeHeight="40dp" diff --git a/app/src/test/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragmentTest.java b/app/src/test/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragmentTest.java index 06251867..1d2bda5c 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragmentTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragmentTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import java.lang.reflect.Method; import java.util.Arrays; +import it.niedermann.owncloud.notes.edit.SearchableBaseNoteFragment; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; diff --git a/app/src/test/java/it/niedermann/owncloud/notes/model/NoteTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/model/NoteTest.java index b07b0796..bd15fe17 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/model/NoteTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/model/NoteTest.java @@ -1,8 +1,8 @@ -package it.niedermann.owncloud.notes.model; +package it.niedermann.owncloud.notes.shared.model; import junit.framework.TestCase; -import it.niedermann.owncloud.notes.util.NoteUtil; +import it.niedermann.owncloud.notes.shared.util.NoteUtil; /** * Tests the Note Model diff --git a/app/src/test/java/it/niedermann/owncloud/notes/util/CategorySortingMethodTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/CategorySortingMethodTest.java index 949962d8..aca3df2a 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/util/CategorySortingMethodTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/CategorySortingMethodTest.java @@ -1,8 +1,8 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import org.junit.Test; -import it.niedermann.owncloud.notes.util.CategorySortingMethod; +import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod; import static org.junit.Assert.*; diff --git a/app/src/test/java/it/niedermann/owncloud/notes/util/MarkDownUtilTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/MarkDownUtilTest.java index 96d616e8..41221ab5 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/util/MarkDownUtilTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/MarkDownUtilTest.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import junit.framework.TestCase; diff --git a/app/src/test/java/it/niedermann/owncloud/notes/util/NoteLinksUtilsTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/NoteLinksUtilsTest.java index 44ebc22d..b4d5bb98 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/util/NoteLinksUtilsTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/NoteLinksUtilsTest.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import junit.framework.TestCase; @@ -8,7 +8,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import static it.niedermann.owncloud.notes.util.NoteLinksUtils.RELATIVE_LINK_WORKAROUND_PREFIX; +import static it.niedermann.owncloud.notes.shared.util.NoteLinksUtils.RELATIVE_LINK_WORKAROUND_PREFIX; public class NoteLinksUtilsTest extends TestCase { diff --git a/app/src/test/java/it/niedermann/owncloud/notes/util/NoteUtilTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/NoteUtilTest.java index c5d0ff7d..90ee505f 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/util/NoteUtilTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/NoteUtilTest.java @@ -1,4 +1,4 @@ -package it.niedermann.owncloud.notes.util; +package it.niedermann.owncloud.notes.shared.util; import junit.framework.TestCase; |