Skip to content

Commit 9451694

Browse files
alperozturk96backportbot[bot]
authored andcommitted
chore: upgrade android sdk 36
Signed-off-by: alperozturk <[email protected]> [skip ci]
1 parent 713eb51 commit 9451694

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ apply plugin: 'com.android.application'
1111
apply plugin: 'org.jetbrains.kotlin.android'
1212

1313
android {
14-
compileSdkVersion 35
1514
namespace = 'it.niedermann.owncloud.notes'
1615

1716
defaultConfig {

app/src/main/java/it/niedermann/owncloud/notes/LockedActivity.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import android.util.Log;
1616
import android.view.WindowManager;
1717

18+
import androidx.activity.OnBackPressedCallback;
1819
import androidx.annotation.Nullable;
1920
import androidx.preference.PreferenceManager;
2021

@@ -41,6 +42,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4142
if (isTaskRoot()) {
4243
askToUnlock();
4344
}
45+
46+
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
47+
@Override
48+
public void handleOnBackPressed() {
49+
setEnabled(false);
50+
getOnBackPressedDispatcher().onBackPressed();
51+
NotesApplication.updateLastInteraction();
52+
}
53+
});
4454
}
4555

4656
@Override
@@ -60,12 +70,6 @@ protected void onStop() {
6070
}
6171
}
6272

63-
@Override
64-
public void onBackPressed() {
65-
super.onBackPressed();
66-
NotesApplication.updateLastInteraction();
67-
}
68-
6973
@Override
7074
public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) {
7175
NotesApplication.updateLastInteraction();

app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.view.WindowManager;
1919
import android.widget.Toast;
2020

21+
import androidx.activity.OnBackPressedCallback;
2122
import androidx.annotation.NonNull;
2223
import androidx.annotation.Nullable;
2324
import androidx.core.graphics.Insets;
@@ -108,6 +109,15 @@ protected void onCreate(final Bundle savedInstanceState) {
108109
setSupportActionBar(binding.toolbar);
109110
binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog());
110111
setImeInsets();
112+
113+
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
114+
@Override
115+
public void handleOnBackPressed() {
116+
setEnabled(false);
117+
getOnBackPressedDispatcher().onBackPressed();
118+
close();
119+
}
120+
});
111121
}
112122

113123
private void setImeInsets() {
@@ -360,12 +370,6 @@ private void launchReadonlyNote() {
360370
replaceFragment();
361371
}
362372

363-
@Override
364-
public void onBackPressed() {
365-
super.onBackPressed();
366-
close();
367-
}
368-
369373
@Override
370374
public boolean onCreateOptionsMenu(Menu menu) {
371375
getMenuInflater().inflate(R.menu.menu_note_activity, menu);

app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.util.Log;
3030
import android.view.View;
3131

32+
import androidx.activity.OnBackPressedCallback;
3233
import androidx.annotation.ColorInt;
3334
import androidx.annotation.NonNull;
3435
import androidx.annotation.Nullable;
@@ -329,6 +330,20 @@ public void onError(@NonNull Throwable t) {
329330
menuAdapter.updateAccount(this, nextAccount);
330331
}
331332
});
333+
334+
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
335+
@Override
336+
public void handleOnBackPressed() {
337+
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {
338+
updateToolbars(false);
339+
} else if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
340+
binding.drawerLayout.closeDrawer(GravityCompat.START);
341+
} else {
342+
setEnabled(false);
343+
getOnBackPressedDispatcher().onBackPressed();
344+
}
345+
}
346+
});
332347
}
333348

334349
private void showAppAccountNotFoundAlertDialog(NextcloudFilesAppAccountNotFoundException e) {
@@ -802,17 +817,6 @@ public void onNoteFavoriteClick(int position, View view) {
802817
}});
803818
}
804819

805-
@Override
806-
public void onBackPressed() {
807-
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {
808-
updateToolbars(false);
809-
} else if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
810-
binding.drawerLayout.closeDrawer(GravityCompat.START);
811-
} else {
812-
super.onBackPressed();
813-
}
814-
}
815-
816820
private void updateToolbars(boolean enableSearch) {
817821
activityBinding.homeToolbar.setVisibility(enableSearch ? GONE : VISIBLE);
818822
activityBinding.searchToolbar.setVisibility(enableSearch ? VISIBLE : GONE);

0 commit comments

Comments
 (0)