Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-07-22 17:12:00 +0300
committerStefan Niedermann <info@niedermann.it>2020-07-22 17:12:00 +0300
commitf72138d30509322ac22643a137beaa5a89e9d682 (patch)
tree04e22f0b673dde9aef3b052777452e56336058dc /app/src/main
parentd8d7ec08fcee3b5b89d8f2e52b6587503fb2b606 (diff)
#573 projects - Enhance resources dialog
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourcesDialog.java31
-rw-r--r--app/src/main/res/layout/dialog_project_resources.xml30
2 files changed, 20 insertions, 41 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourcesDialog.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourcesDialog.java
index 574e2c8f1..77af3fc70 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourcesDialog.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourcesDialog.java
@@ -1,13 +1,13 @@
package it.niedermann.nextcloud.deck.ui.card.projectresources;
+import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.lifecycle.ViewModelProvider;
@@ -15,9 +15,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.databinding.DialogProjectResourcesBinding;
import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProjectResource;
+import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder;
import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment;
import it.niedermann.nextcloud.deck.ui.card.EditCardViewModel;
@@ -42,24 +42,21 @@ public class CardProjectResourcesDialog extends BrandedDialogFragment {
this.projectName = args.getString(KEY_PROJECT_NAME);
}
+ @NonNull
@Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final DialogProjectResourcesBinding binding = DialogProjectResourcesBinding.inflate(inflater, container, false);
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final DialogProjectResourcesBinding binding = DialogProjectResourcesBinding.inflate(LayoutInflater.from(requireContext()));
final EditCardViewModel viewModel = new ViewModelProvider(requireActivity()).get(EditCardViewModel.class);
-
- // TODO check if necessary
- // This might be a zombie fragment with an empty EditCardViewModel after Android killed the activity (but not the fragment instance
- // See https://github.com/stefan-niedermann/nextcloud-deck/issues/478
- if (viewModel.getFullCard() == null) {
- DeckLog.logError(new IllegalStateException("Cannot populate " + CardProjectResourcesDialog.class.getSimpleName() + " because viewModel.getFullCard() is null"));
- return binding.getRoot();
- }
-
final CardProjectResourceAdapter adapter = new CardProjectResourceAdapter(viewModel.getAccount(), resources);
- binding.projectName.setText(projectName);
- binding.recyclerView.setAdapter(adapter);
- return binding.getRoot();
+ AlertDialog.Builder dialogBuilder = new BrandedAlertDialogBuilder(requireContext());
+
+ binding.getRoot().setAdapter(adapter);
+ return dialogBuilder
+ .setTitle(projectName)
+ .setView(binding.getRoot())
+ .setNeutralButton(android.R.string.cancel, null)
+ .create();
}
@Override
diff --git a/app/src/main/res/layout/dialog_project_resources.xml b/app/src/main/res/layout/dialog_project_resources.xml
index 8edf7b366..3de37db8b 100644
--- a/app/src/main/res/layout/dialog_project_resources.xml
+++ b/app/src/main/res/layout/dialog_project_resources.xml
@@ -1,28 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <TextView
- android:id="@+id/projectName"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/spacer_4x"
- android:layout_marginTop="@dimen/spacer_2x"
- android:layout_marginEnd="0dp"
- android:layout_marginBottom="@dimen/spacer_1x"
- android:paddingStart="@dimen/icon_size_details"
- android:paddingEnd="0dp"
- android:textAppearance="?attr/textAppearanceBody1"
- tools:text="@tools:sample/lorem" />
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/recycler_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/projectName"
- app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
- tools:listitem="@layout/item_project_resource" />
-</RelativeLayout> \ No newline at end of file
+ android:layout_height="wrap_content"
+ android:layout_below="@id/projectName"
+ android:paddingTop="@dimen/spacer_1x"
+ app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
+ tools:listitem="@layout/item_project_resource" /> \ No newline at end of file