From c91b8a391a9c3e8f4713c1705ee6259f515f62df Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Sun, 31 Dec 2023 13:28:03 +0100 Subject: [PATCH] Fix back button AlbumActivity --- .../org/pixeldroid/app/posts/AlbumActivity.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/org/pixeldroid/app/posts/AlbumActivity.kt b/app/src/main/java/org/pixeldroid/app/posts/AlbumActivity.kt index 2f241f37..eb5982a2 100644 --- a/app/src/main/java/org/pixeldroid/app/posts/AlbumActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/posts/AlbumActivity.kt @@ -1,11 +1,13 @@ package org.pixeldroid.app.posts import android.os.Bundle +import android.view.MenuItem import android.view.View import androidx.appcompat.app.AppCompatActivity import org.pixeldroid.app.databinding.ActivityAlbumBinding import org.pixeldroid.app.utils.api.objects.Attachment + class AlbumActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -36,4 +38,17 @@ class AlbumActivity : AppCompatActivity() { supportActionBar?.setDisplayShowTitleEnabled(false) supportActionBar?.setBackgroundDrawable(null) } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + android.R.id.home -> { + // Handle up arrow manually, + // since "up" isn't defined for this activity + onBackPressedDispatcher.onBackPressed() + true + } + + else -> super.onOptionsItemSelected(item) + } + } } \ No newline at end of file