Skip to content

Commit

Permalink
Revert #2101
Browse files Browse the repository at this point in the history
Revert "change preference summary text"

This reverts commit 79359fc.

Revert "Add SPDX header"

This reverts commit 9b19ae5.

Revert "Store preference for richtext-editing"

This reverts commit 6291cdc.

Revert "Allow an edit fab to replace the rich text fab"

This reverts commit c15c529.

Signed-off-by: Andy Scherzinger <[email protected]>
  • Loading branch information
AndyScherzinger committed Apr 18, 2024
1 parent 75468ec commit 5d8c7e4
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ protected FloatingActionButton getSearchPrevButton() {
return binding.directEditing;
}

protected ExtendedFloatingActionButton getNormalEditButton() {
// the edit fragment does not have a button
return null;
}

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment implements O
public void onPrepareOptionsMenu(@NonNull Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.findItem(R.id.menu_edit).setVisible(true);
if(getNormalEditButton().getVisibility() == View.VISIBLE) {
menu.findItem(R.id.menu_edit).setVisible(false);
}

menu.findItem(R.id.menu_preview).setVisible(false);
}

Expand Down Expand Up @@ -90,11 +86,6 @@ protected FloatingActionButton getSearchPrevButton() {
return binding.directEditing;
}

@Override
protected ExtendedFloatingActionButton getNormalEditButton() {
return binding.edit;
}

@Override
protected Layout getLayout() {
binding.singleNoteContent.onPreDraw();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;

import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
Expand All @@ -42,7 +41,7 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment {
private SearchView searchView;
private String searchQuery = null;
private static final int delay = 50; // If the search string does not change after $delay ms, then the search task starts.
private boolean directEditRemotelyAvailable = false; // avoid using this directly, instead use: isDirectEditEnabled()
private boolean directEditAvailable = false;

@ColorInt
private int color;
Expand All @@ -67,7 +66,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
@Override
protected void onScroll(int scrollY, int oldScrollY) {
super.onScroll(scrollY, oldScrollY);
if (isDirectEditEnabled()) {
if (directEditAvailable) {
// only show FAB if search is not active
if (getSearchNextButton() == null || getSearchNextButton().getVisibility() != View.VISIBLE) {
final ExtendedFloatingActionButton directFab = getDirectEditingButton();
Expand All @@ -80,7 +79,7 @@ protected void onScroll(int scrollY, int oldScrollY) {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
checkDirectEditingAvailable();
if (isDirectEditEnabled()) {
if (directEditAvailable) {
final ExtendedFloatingActionButton directEditingButton = getDirectEditingButton();
directEditingButton.setExtended(false);
ExtendedFabUtil.toggleExtendedOnLongClick(directEditingButton);
Expand All @@ -91,35 +90,18 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
});
} else {
getDirectEditingButton().setVisibility(View.GONE);
ExtendedFloatingActionButton edit = getNormalEditButton();
if(edit!=null) {
edit.setVisibility(View.VISIBLE);
edit.setOnClickListener(v -> {
if (listener != null) {
listener.changeMode(NoteFragmentListener.Mode.EDIT, true);
}
});
}
}
}

private void checkDirectEditingAvailable() {
try {
final SingleSignOnAccount ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(requireContext());
final Account localAccount = repo.getAccountByName(ssoAccount.name);
directEditRemotelyAvailable = localAccount != null && localAccount.isDirectEditingAvailable();
directEditAvailable = localAccount != null && localAccount.isDirectEditingAvailable();
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
Log.w(TAG, "checkDirectEditingAvailable: ", e);
directEditRemotelyAvailable = false;
}
}

protected boolean isDirectEditEnabled() {
if (!directEditRemotelyAvailable) {
return false;
directEditAvailable = false;
}
final var sp = PreferenceManager.getDefaultSharedPreferences(requireContext().getApplicationContext());
return sp.getBoolean(getString(R.string.pref_key_enable_direct_edit), true);
}

@Override
Expand Down Expand Up @@ -270,7 +252,6 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
@NonNull
protected abstract ExtendedFloatingActionButton getDirectEditingButton();

protected abstract ExtendedFloatingActionButton getNormalEditButton();

private void showSearchFabs() {
ExtendedFabUtil.setExtendedFabVisibility(getDirectEditingButton(), false);
Expand Down Expand Up @@ -366,9 +347,5 @@ public void applyBrand(int color) {
util.material.themeFAB(getSearchNextButton());
util.material.themeFAB(getSearchPrevButton());
util.material.themeExtendedFAB(getDirectEditingButton());
var editFab = getNormalEditButton();
if(editFab != null) {
util.material.themeExtendedFAB(editFab);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra
private BrandedSwitchPreference preventScreenCapturePref;
private BrandedSwitchPreference backgroundSyncPref;
private BrandedSwitchPreference keepScreenOnPref;
private BrandedSwitchPreference enableDirectEditorPref;

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Expand Down Expand Up @@ -109,8 +108,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
SyncWorker.update(requireContext(), (Boolean) newValue);
return true;
});

enableDirectEditorPref = findPreference(getString(R.string.pref_key_enable_direct_edit));
}


Expand Down Expand Up @@ -138,6 +135,5 @@ public void applyBrand(int color) {
preventScreenCapturePref.applyBrand(color);
backgroundSyncPref.applyBrand(color);
keepScreenOnPref.applyBrand(color);
enableDirectEditorPref.applyBrand(color);
}
}
16 changes: 0 additions & 16 deletions app/src/main/res/drawable/ic_rich_editing_grey600_24dp.xml

This file was deleted.

15 changes: 0 additions & 15 deletions app/src/main/res/layout/fragment_note_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,4 @@
app:layout_anchor="@id/scrollView"
app:layout_anchorGravity="bottom|end"
app:icon="@drawable/ic_rich_editing" />

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/edit"
style="?attr/floatingActionButtonPrimaryStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/spacer_2x"
android:contentDescription="@string/noteMode_plain_edit"
android:text="@string/noteMode_plain_edit"
android:visibility="visible"
app:backgroundTint="@color/defaultBrand"
app:layout_anchor="@id/scrollView"
app:layout_anchorGravity="bottom|end"
app:icon="@drawable/ic_edit_grey600_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
<string name="settings_background_sync">Background synchronization</string>
<string name="settings_prevent_screen_capture">Prevent screen capture</string>
<string name="settings_gridview">Grid view</string>
<string name="settings_enable_direct_edit">Direct Edit</string>
<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>

Expand Down Expand Up @@ -124,7 +122,6 @@
<string name="pref_category_security" translatable="false">security</string>
<string name="pref_key_last_note_mode" translatable="false">lastNoteMode</string>
<string name="pref_key_background_sync" translatable="false">backgroundSync</string>
<string name="pref_key_enable_direct_edit" translatable="false">directEditPreference</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
9 changes: 0 additions & 9 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@
android:summary="%s"
android:title="@string/settings_note_mode_new" />

<it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_rich_editing_grey600_24dp"
android:key="@string/pref_key_enable_direct_edit"
android:layout="@layout/item_pref"
android:title="@string/settings_enable_direct_edit"
android:summary="@string/settings_enable_direct_edit_summary" />


<it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
android:icon="@drawable/ic_baseline_dashboard_24"
android:key="@string/pref_key_gridview"
Expand Down

0 comments on commit 5d8c7e4

Please sign in to comment.