diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 71d1156..a70fe8a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,7 +1,7 @@
-
+
+
\ No newline at end of file
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 e95a5e7..7ee13eb 100644
--- a/app/src/main/java/core/notevault/ui/home/HomeFragment.java
+++ b/app/src/main/java/core/notevault/ui/home/HomeFragment.java
@@ -1,32 +1,71 @@
package core.notevault.ui.home;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
+import android.provider.OpenableColumns;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import core.notevault.R;
import core.notevault.databinding.FragmentHomeBinding;
public class HomeFragment extends Fragment {
+ private static final int PICK_FILE_REQUEST_CODE = 1;
private FragmentHomeBinding binding;
+ private HomeViewModel homeViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
- HomeViewModel homeViewModel =
+ homeViewModel =
new ViewModelProvider(this).get(HomeViewModel.class);
binding = FragmentHomeBinding.inflate(inflater, container, false);
View root = binding.getRoot();
- final TextView textView = binding.textHome;
- homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
+ FloatingActionButton importBtn = root.findViewById(R.id.importMusicNotesBtn);
+ importBtn.setOnClickListener(v -> openFileChooser());
+
return root;
}
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == PICK_FILE_REQUEST_CODE && resultCode == getActivity().RESULT_OK && data != null) {
+ Uri uri = data.getData();
+ if (uri != null) {
+ handleFile(uri);
+ }
+ }
+ }
+
+ private void handleFile(Uri uri) {
+ // Hier kannst du die Logik zum Speichern oder Anzeigen der Datei implementieren
+ homeViewModel.addNote(uri); // Speichere die URI im ViewModel
+ Toast.makeText(getActivity(), "Datei ausgewählt: " + uri.getPath(), Toast.LENGTH_SHORT).show();
+ }
+
+ private void openFileChooser() {
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+ intent.setType("*/*"); // Alle Dateitypen
+
+ String[] mimeTypes = {"application/pdf", "image/png", "image/jpeg"};
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
+
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ startActivityForResult(intent, PICK_FILE_REQUEST_CODE);
+ }
+
@Override
public void onDestroyView() {
super.onDestroyView();
diff --git a/app/src/main/java/core/notevault/ui/home/HomeViewModel.java b/app/src/main/java/core/notevault/ui/home/HomeViewModel.java
index 2ae87cf..009ad9b 100644
--- a/app/src/main/java/core/notevault/ui/home/HomeViewModel.java
+++ b/app/src/main/java/core/notevault/ui/home/HomeViewModel.java
@@ -1,5 +1,6 @@
package core.notevault.ui.home;
+import android.net.Uri;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
@@ -16,4 +17,8 @@ public class HomeViewModel extends ViewModel {
public LiveData getText() {
return mText;
}
+
+ public void addNote(Uri uri) {
+ System.out.println("Added file: " + uri.toString());
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/add_24dp_e8eaed_fill0_wght400_grad0_opsz24.xml b/app/src/main/res/drawable/add_24dp_e8eaed_fill0_wght400_grad0_opsz24.xml
new file mode 100644
index 0000000..e4bb397
--- /dev/null
+++ b/app/src/main/res/drawable/add_24dp_e8eaed_fill0_wght400_grad0_opsz24.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/icons/add_24dp_E8EAED_FILL0_wght400_GRAD0_opsz24.svg b/app/src/main/res/icons/add_24dp_E8EAED_FILL0_wght400_GRAD0_opsz24.svg
new file mode 100644
index 0000000..6a0e78b
--- /dev/null
+++ b/app/src/main/res/icons/add_24dp_E8EAED_FILL0_wght400_GRAD0_opsz24.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index d91141c..fb49c97 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -20,4 +20,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
+
+
\ No newline at end of file