Skip to content
Merged
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
16 changes: 16 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,16 @@
<!--
~ Nextcloud Notes - Android Client
~
~ SPDX-FileCopyrightText: 2018-2026 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:tint="#757575"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M473,880Q449,880 427,871Q405,862 388,845L184,640L214,609Q230,593 251.5,587.5Q273,582 294,588L360,607L360,280Q360,263 371.5,251.5Q383,240 400,240Q417,240 428.5,251.5Q440,263 440,280L440,713L343,686L445,788Q450,793 457.5,796.5Q465,800 473,800L640,800Q673,800 696.5,776.5Q720,753 720,720L720,560Q720,543 731.5,531.5Q743,520 760,520Q777,520 788.5,531.5Q800,543 800,560L800,720Q800,786 753,833Q706,880 640,880L473,880ZM480,600L480,440Q480,423 491.5,411.5Q503,400 520,400Q537,400 548.5,411.5Q560,423 560,440L560,600L480,600ZM600,600L600,480Q600,463 611.5,451.5Q623,440 640,440Q657,440 668.5,451.5Q680,463 680,480L680,600L600,600ZM580,680L580,680L580,680Q580,680 580,680Q580,680 580,680L580,680Q580,680 580,680Q580,680 580,680L580,680L580,680ZM880,280L680,280L680,220L796,220Q730,162 649,131Q568,100 480,100Q392,100 311,131Q230,162 164,220L280,220L280,280L80,280L80,80L140,80L140,161Q212,102 299,71Q386,40 480,40Q574,40 661,71Q748,102 820,161L820,80L880,80L880,280Z"/>
</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
Loading