Open Notes of Songs
This commit is contained in:
parent
73fe1bf812
commit
3088f5e7b0
@ -24,6 +24,11 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ui.home.FullScreenImageActivity"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar">
|
||||
<!-- Intent Filter hinzufügen, wenn Activity vom Launcher oder externen Apps aufgerufen werden soll -->
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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"};
|
||||
|
@ -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<NoteSongAdapter.NoteVi
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
static class NoteViewHolder extends RecyclerView.ViewHolder {
|
||||
public class NoteViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView titleTextView;
|
||||
|
||||
NoteViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
titleTextView = itemView.findViewById(R.id.note_title);
|
||||
|
||||
titleTextView.setOnClickListener(v -> {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
11
app/src/main/res/layout/activity_fullscreen_image.xml
Normal file
11
app/src/main/res/layout/activity_fullscreen_image.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fullscreen_image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitCenter"/>
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user