diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a70fe8a..d970a5f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,11 @@ + + + + \ No newline at end of file diff --git a/app/src/main/java/core/notevault/MainActivity.java b/app/src/main/java/core/notevault/MainActivity.java index b235cf6..2cbf847 100644 --- a/app/src/main/java/core/notevault/MainActivity.java +++ b/app/src/main/java/core/notevault/MainActivity.java @@ -1,5 +1,7 @@ package core.notevault; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -62,8 +64,14 @@ public class MainActivity extends AppCompatActivity implements MetaDataDialog.On } @Override - public void onMetadataEntered(String title, String composer, int year, String genre) { - MusicNote musicNote = new MusicNote(title, null, composer, year, genre); + public void onMetadataEntered(Uri uri, String title, String composer, int year, String genre) { + MusicNote musicNote = new MusicNote(title, uri.toString(), composer, year, genre); + + // Anfordern der dauerhaften Lese-/Schreibberechtigungen für die URI + getContentResolver().takePersistableUriPermission( + uri, + Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION + ); new Thread(() -> { musicDB.musicNoteDao().insert(musicNote); diff --git a/app/src/main/java/core/notevault/ui/home/FullScreenImageActivity.java b/app/src/main/java/core/notevault/ui/home/FullScreenImageActivity.java new file mode 100644 index 0000000..9903cca --- /dev/null +++ b/app/src/main/java/core/notevault/ui/home/FullScreenImageActivity.java @@ -0,0 +1,27 @@ +package core.notevault.ui.home; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.widget.ImageView; +import androidx.appcompat.app.AppCompatActivity; +import core.notevault.R; + +public class FullScreenImageActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fullscreen_image); // Erstelle eine Layout-Datei + + ImageView imageView = findViewById(R.id.fullscreen_image_view); // Angenommen, du hast ein ImageView + + // Die URI aus dem Intent erhalten + Intent intent = getIntent(); + String imageUriString = intent.getStringExtra("imageUri"); + if (imageUriString != null) { + Uri imageUri = Uri.parse(imageUriString); + imageView.setImageURI(imageUri); // Setze die URI in das ImageView + } + } +} diff --git a/app/src/main/java/core/notevault/ui/home/HomeFragment.java b/app/src/main/java/core/notevault/ui/home/HomeFragment.java index 84f798c..0288be2 100644 --- a/app/src/main/java/core/notevault/ui/home/HomeFragment.java +++ b/app/src/main/java/core/notevault/ui/home/HomeFragment.java @@ -94,7 +94,7 @@ public class HomeFragment extends Fragment { } private void openFileChooser() { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("*/*"); // Alle Dateitypen String[] mimeTypes = {"application/pdf", "image/png", "image/jpeg"}; diff --git a/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java b/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java index 9cb8ab9..4314f76 100644 --- a/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java +++ b/app/src/main/java/core/notevault/ui/home/NoteSongAdapter.java @@ -1,5 +1,6 @@ package core.notevault.ui.home; +import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -48,12 +49,27 @@ public class NoteSongAdapter extends RecyclerView.Adapter { + int position = getAdapterPosition(); + if(position != RecyclerView.NO_POSITION) { + MusicNote musicNote = noteTitles.get(position); + + Intent intent = new Intent(itemView.getContext(), FullScreenImageActivity.class); + intent.putExtra("imageUri", musicNote.getFilePath()); // Hier URI hinzufügen + itemView.getContext().startActivity(intent); + } + }); + } + + public void bind(MusicNote note) { + titleTextView.setText(note.getTitle()); } } } diff --git a/app/src/main/java/core/notevault/ui/metadatadialog/MetaDataDialog.java b/app/src/main/java/core/notevault/ui/metadatadialog/MetaDataDialog.java index ff5777b..75eef02 100644 --- a/app/src/main/java/core/notevault/ui/metadatadialog/MetaDataDialog.java +++ b/app/src/main/java/core/notevault/ui/metadatadialog/MetaDataDialog.java @@ -19,7 +19,7 @@ public class MetaDataDialog extends DialogFragment { private Uri fileUri; public interface OnMetadataListener { - void onMetadataEntered(String title, String composer, int year, String genre); + void onMetadataEntered(Uri uri, String title, String composer, int year, String genre); } private OnMetadataListener listener; @@ -50,7 +50,7 @@ public class MetaDataDialog extends DialogFragment { String genre = genre_input.getText().toString(); - listener.onMetadataEntered(title, composer, year, genre); + listener.onMetadataEntered(fileUri, title, composer, year, genre); } ) .setNegativeButton("Abbrechen", (dialog, which) -> {} ) .create(); diff --git a/app/src/main/res/layout/activity_fullscreen_image.xml b/app/src/main/res/layout/activity_fullscreen_image.xml new file mode 100644 index 0000000..d62525a --- /dev/null +++ b/app/src/main/res/layout/activity_fullscreen_image.xml @@ -0,0 +1,11 @@ + + + + +