Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class NotesApplication extends Application {
private static long lastInteraction = 0;
private static String PREF_KEY_THEME;
private static boolean isGridViewEnabled = false;
private static boolean isSwipeEnabled = true;
private static BrandingUtil brandingUtil;

@Override
Expand All @@ -45,6 +46,7 @@ public void onCreate() {
final var prefs = getDefaultSharedPreferences(getApplicationContext());
lockedPreference = prefs.getBoolean(getString(R.string.pref_key_lock), false);
isGridViewEnabled = getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_key_gridview), false);
isSwipeEnabled = getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_key_swipe_actions), true);
super.onCreate();
brandingUtil = BrandingUtil.getInstance(this);
if (BuildConfig.DEBUG) {
Expand Down Expand Up @@ -80,6 +82,14 @@ public static void updateGridViewEnabled(boolean gridView) {
isGridViewEnabled = gridView;
}

public static boolean isSwipeEnabled() {
return isSwipeEnabled;
}

public static void updateSwipeEnabled(boolean swipeEnabled) {
isSwipeEnabled = swipeEnabled;
}

public static DarkModeSetting getAppTheme(Context context) {
final var prefs = getDefaultSharedPreferences(context);
String mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.android.material.snackbar.Snackbar;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.branding.BrandedSnackbar;
import it.niedermann.owncloud.notes.main.MainViewModel;
import it.niedermann.owncloud.notes.main.items.ItemAdapter;
Expand Down Expand Up @@ -63,7 +64,7 @@ public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.
*/
@Override
public int getSwipeDirs(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
if (gridView || viewHolder instanceof SectionViewHolder) return 0;
if (gridView || !NotesApplication.isSwipeEnabled() || viewHolder instanceof SectionViewHolder) return 0;
return super.getSwipeDirs(recyclerView, viewHolder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra
private BrandedSwitchPreference lockPref;
private BrandedSwitchPreference wifiOnlyPref;
private BrandedSwitchPreference gridViewPref;
private BrandedSwitchPreference swipeActionsPref;
private BrandedSwitchPreference preventScreenCapturePref;
private BrandedSwitchPreference backgroundSyncPref;
private BrandedSwitchPreference keepScreenOnPref;
Expand Down Expand Up @@ -66,6 +67,17 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Log.e(TAG, "Could not find preference with key: \"" + getString(R.string.pref_key_gridview) + "\"");
}

swipeActionsPref = findPreference(getString(R.string.pref_key_swipe_actions));
if (swipeActionsPref != null) {
swipeActionsPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> {
final Boolean swipeEnabled = (Boolean) newValue;
Log.v(TAG, "swipeEnabled: " + swipeEnabled);
viewModel.resultCode$.setValue(Activity.RESULT_OK);
NotesApplication.updateSwipeEnabled(swipeEnabled);
return true;
});
}

keepScreenOnPref = findPreference(getString(R.string.pref_key_keep_screen_on));
if (keepScreenOnPref != null) {
keepScreenOnPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> {
Expand Down Expand Up @@ -144,6 +156,7 @@ public void applyBrand(int color) {
lockPref.applyBrand(color);
wifiOnlyPref.applyBrand(color);
gridViewPref.applyBrand(color);
swipeActionsPref.applyBrand(color);
showEcosystemAppBarPref.applyBrand(color);
preventScreenCapturePref.applyBrand(color);
backgroundSyncPref.applyBrand(color);
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/drawable/ic_swipe_grey600_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Nextcloud Notes - Android Client
~
~ SPDX-FileCopyrightText: 2018-2025 Google LLC
~ SPDX-License-Identifier: Apache-2.0
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:tint="#757575"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M640,680L583,624L767,440L583,256L640,200L880,440L640,680ZM80,760L80,600Q80,517 138.5,458.5Q197,400 280,400L527,400L383,256L440,200L680,440L440,680L383,624L527,480L280,480Q230,480 195,515Q160,550 160,600L160,760L80,760Z" />
</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
<string name="settings_enable_direct_edit_summary">When disabled, the advanced editor will be hidden.</string>
<string name="settings_keep_screen_on">Keep screen on</string>
<string name="settings_keep_screen_on_summary">When viewing or editing a note</string>
<string name="settings_swipe_actions">Swipe actions</string>
<string name="settings_swipe_actions_summary">Mark as favorite or delete notes with a swipe</string>

<string name="error_sync">Synchronization failed: %1$s</string>
<string name="error_synchronization">Synchronization failed</string>
Expand Down Expand Up @@ -261,6 +263,7 @@
<string name="pref_key_background_sync" translatable="false">backgroundSync</string>
<string name="pref_key_enable_direct_edit" translatable="false">directEditPreference</string>
<string name="pref_key_show_ecosystem_apps" translatable="false">show_ecosystem_apps</string>
<string name="pref_key_swipe_actions" translatable="false">swipe_actions</string>
<string name="pref_value_mode_edit" translatable="false">edit</string>
<string name="pref_value_mode_direct_edit" translatable="false">directEdit</string>
<string name="pref_value_mode_preview" translatable="false">preview</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
android:layout="@layout/item_pref"
android:title="@string/settings_gridview" />

<it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_swipe_grey600_24dp"
android:key="@string/pref_key_swipe_actions"
android:layout="@layout/item_pref"
android:title="@string/settings_swipe_actions"
android:summary="@string/settings_swipe_actions_summary" />

<it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
android:defaultValue="@string/pref_value_font_normal"
android:icon="@drawable/ic_text_format_grey600_24dp"
Expand Down