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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'

android {
compileSdkVersion 35
namespace = 'it.niedermann.owncloud.notes'

defaultConfig {
applicationId "it.niedermann.owncloud.notes"
minSdk 24
targetSdk 35
compileSdk = 36
targetSdk 36
versionCode 40060005
versionName "4.6.0 Alpha 5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/it/niedermann/owncloud/notes/LockedActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.util.Log;
import android.view.WindowManager;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;

Expand All @@ -41,6 +42,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (isTaskRoot()) {
askToUnlock();
}

getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
setEnabled(false);
getOnBackPressedDispatcher().onBackPressed();
NotesApplication.updateLastInteraction();
}
});
}

@Override
Expand All @@ -60,12 +70,6 @@ protected void onStop() {
}
}

@Override
public void onBackPressed() {
super.onBackPressed();
NotesApplication.updateLastInteraction();
}

@Override
public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) {
NotesApplication.updateLastInteraction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.view.WindowManager;
import android.widget.Toast;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
Expand Down Expand Up @@ -105,6 +106,15 @@ protected void onCreate(final Bundle savedInstanceState) {
setSupportActionBar(binding.toolbar);
binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog());
setImeInsets();

getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
setEnabled(false);
getOnBackPressedDispatcher().onBackPressed();
close();
}
});
}

private void setImeInsets() {
Expand Down Expand Up @@ -357,12 +367,6 @@ private void launchReadonlyNote() {
replaceFragment();
}

@Override
public void onBackPressed() {
super.onBackPressed();
close();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_note_activity, menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.util.Log;
import android.view.View;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -329,6 +330,20 @@ public void onError(@NonNull Throwable t) {
menuAdapter.updateAccount(this, nextAccount);
}
});

getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {
updateToolbars(false);
} else if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
binding.drawerLayout.closeDrawer(GravityCompat.START);
} else {
setEnabled(false);
getOnBackPressedDispatcher().onBackPressed();
}
}
});
}

private void showAppAccountNotFoundAlertDialog(NextcloudFilesAppAccountNotFoundException e) {
Expand Down Expand Up @@ -802,17 +817,6 @@ public void onNoteFavoriteClick(int position, View view) {
}});
}

@Override
public void onBackPressed() {
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {
updateToolbars(false);
} else if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
binding.drawerLayout.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}

private void updateToolbars(boolean enableSearch) {
activityBinding.homeToolbar.setVisibility(enableSearch ? GONE : VISIBLE);
activityBinding.searchToolbar.setVisibility(enableSearch ? VISIBLE : GONE);
Expand Down
Loading