move note dialog to native view binding

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-02-10 23:29:22 +01:00
parent 65300c35df
commit 1a8434dd45
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 15 additions and 28 deletions

View file

@ -21,7 +21,6 @@
package com.owncloud.android.ui.dialog;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -30,9 +29,8 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.owncloud.android.R;
import com.owncloud.android.databinding.NoteDialogBinding;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.ui.activity.ComponentsGetter;
import com.owncloud.android.utils.DisplayUtils;
@ -42,9 +40,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* Dialog to input a multiline note for a share
@ -56,13 +51,7 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
public static final String NOTE_FRAGMENT = "NOTE_FRAGMENT";
private OCShare share;
private Unbinder unbinder;
@BindView(R.id.user_input_container)
public TextInputLayout noteEditTextInputLayout;
@BindView(R.id.user_input)
public TextInputEditText noteEditText;
private NoteDialogBinding binding;
public static NoteDialogFragment newInstance(OCShare share) {
NoteDialogFragment frag = new NoteDialogFragment();
@ -103,15 +92,14 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
// Inflate the layout for the dialog
LayoutInflater inflater = requireActivity().getLayoutInflater();
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.note_dialog, null, false);
unbinder = ButterKnife.bind(this, view);
binding = NoteDialogBinding.inflate(inflater, null, false);
View view = binding.getRoot();
// Setup layout
noteEditText.setText(share.getNote());
noteEditText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
noteEditText.requestFocus();
ThemeUtils.colorTextInputLayout(noteEditTextInputLayout, accentColor);
binding.noteText.setText(share.getNote());
binding.noteText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
binding.noteText.requestFocus();
ThemeUtils.colorTextInputLayout(binding.noteContainer, accentColor);
// Build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
@ -138,8 +126,8 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
if (componentsGetter != null) {
String note = "";
if (noteEditText.getText() != null) {
note = noteEditText.getText().toString().trim();
if (binding.noteText.getText() != null) {
note = binding.noteText.getText().toString().trim();
}
componentsGetter.getFileOperationsHelper().updateNoteToShare(share, note);
@ -150,9 +138,8 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
}
@Override
public void onStop() {
unbinder.unbind();
super.onStop();
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
}

View file

@ -27,14 +27,14 @@
android:padding="@dimen/standard_padding">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/user_input_container"
android:id="@+id/note_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextInputLayout"
android:hint="@string/hint_note">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/user_input"
android:id="@+id/note_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"