Open Dialog after selecting MusicNoteFile

This commit is contained in:
Sebastian 2024-10-15 19:47:32 +02:00
parent 2b7215b61c
commit 39463c8df3
4 changed files with 35 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import core.notevault.R;
import core.notevault.databinding.FragmentHomeBinding;
import core.notevault.ui.metadatadialog.MetaDataDialog;
public class HomeFragment extends Fragment {
@ -51,6 +52,8 @@ public class HomeFragment extends Fragment {
private void handleFile(Uri uri) {
// Hier kannst du die Logik zum Speichern oder Anzeigen der Datei implementieren
MetaDataDialog metaDataDialog = new MetaDataDialog();
metaDataDialog.show(getParentFragmentManager(), MetaDataDialog.TAG);
homeViewModel.addNote(uri); // Speichere die URI im ViewModel
Toast.makeText(getActivity(), "Datei ausgewählt: " + uri.getPath(), Toast.LENGTH_SHORT).show();
}

View File

@ -4,6 +4,7 @@ import android.net.Uri;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import core.notevault.ui.metadatadialog.MetaDataDialog;
public class HomeViewModel extends ViewModel {
@ -19,6 +20,6 @@ public class HomeViewModel extends ViewModel {
}
public void addNote(Uri uri) {
System.out.println("Added file: " + uri.toString());
}
}

View File

@ -0,0 +1,23 @@
package core.notevault.ui.metadatadialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import core.notevault.R;
public class MetaDataDialog extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
return new AlertDialog.Builder(requireContext())
.setMessage("Import-Einstellungen")
.setPositiveButton("Speichern", (dialog, which) -> {} )
.create();
}
public static String TAG = "MetaDataDialog";
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/metadata_dialog">
</androidx.constraintlayout.widget.ConstraintLayout>