Browse Source

Merge branch 'master' of https://github.com/afollestad/material-dialogs

plusCubed 10 years ago
parent
commit
5a0f2ac47a

+ 6 - 0
README.md

@@ -725,6 +725,12 @@ new MaterialDialog.Builder(this)
         }).show();
 ```
 
+Note that the dialog will force the positive action button to be visible, when it's pressed the input
+is submitted to the callback.
+
+The input dialog will automatically handle focusing the EditText and displaying the keyboard to allow
+the user to immediate enter input. When the dialog is closed, the keyboard will be automatically dismissed.
+
 #### Coloring the EditText
 
 Like action buttons and many other elements of the Material dialog, you can customize the color of a

+ 1 - 35
library/src/main/java/com/afollestad/materialdialogs/DialogBase.java

@@ -6,16 +6,13 @@ import android.content.DialogInterface;
 import android.os.Message;
 import android.view.ContextThemeWrapper;
 import android.view.View;
-import android.view.ViewGroup;
 
 /**
  * @author Aidan Follestad (afollestad)
  */
-class DialogBase extends AlertDialog implements DialogInterface.OnShowListener, DialogInterface.OnDismissListener, DialogInterface.OnCancelListener {
+class DialogBase extends AlertDialog implements DialogInterface.OnShowListener {
 
     private OnShowListener mShowListener;
-    private OnDismissListener mDismissListener;
-    private OnCancelListener mCancelListener;
     protected ContextThemeWrapper mThemedContext;
 
     protected DialogBase(ContextThemeWrapper context) {
@@ -81,24 +78,6 @@ class DialogBase extends AlertDialog implements DialogInterface.OnShowListener,
         super.setOnShowListener(this);
     }
 
-    @Override
-    public void setOnDismissListener(OnDismissListener listener) {
-        mDismissListener = listener;
-    }
-
-    public final void setOnDismissListenerInternal() {
-        super.setOnDismissListener(this);
-    }
-
-    @Override
-    public void setOnCancelListener(OnCancelListener listener) {
-        mCancelListener = listener;
-    }
-
-    public final void setOnCancelListenerInternal() {
-        super.setOnCancelListener(this);
-    }
-
     protected final void setViewInternal(View view) {
         super.setView(view);
     }
@@ -108,17 +87,4 @@ class DialogBase extends AlertDialog implements DialogInterface.OnShowListener,
         if (mShowListener != null)
             mShowListener.onShow(dialog);
     }
-
-    @Override
-    public void onDismiss(DialogInterface dialog) {
-        if (mDismissListener != null)
-            mDismissListener.onDismiss(dialog);
-    }
-
-
-    @Override
-    public void onCancel(DialogInterface dialog) {
-        if (mCancelListener != null)
-            mCancelListener.onCancel(dialog);
-    }
 }

+ 5 - 7
library/src/main/java/com/afollestad/materialdialogs/DialogInit.java

@@ -1,7 +1,6 @@
 package com.afollestad.materialdialogs;
 
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.graphics.Color;
@@ -11,7 +10,6 @@ import android.text.method.LinkMovementMethod;
 import android.view.ContextThemeWrapper;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
@@ -283,7 +281,7 @@ class DialogInit {
         // Setup progress dialog stuff if needed
         setupProgressDialog(dialog);
 
-        // Setup inputu dialog stuff if needed
+        // Setup input dialog stuff if needed
         setupInputDialog(dialog);
 
         // Setup custom views
@@ -293,7 +291,7 @@ class DialogInit {
             View innerView = builder.customView;
             if (builder.wrapCustomViewInScroll) {
                 /* Apply the frame padding to the content, this allows the ScrollView to draw it's
-                   overscroll glow without clipping */
+                   over scroll glow without clipping */
                 final Resources r = dialog.getThemedContext().getResources();
                 final int framePadding = r.getDimensionPixelSize(R.dimen.md_dialog_frame_margin);
                 final ScrollView sv = new ScrollView(dialog.getThemedContext());
@@ -317,6 +315,9 @@ class DialogInit {
                     ViewGroup.LayoutParams.WRAP_CONTENT));
         }
 
+        // Setup internal show listener
+        dialog.setOnShowListenerInternal();
+
         // Setup user listeners
         if (builder.showListener != null)
             dialog.setOnShowListener(builder.showListener);
@@ -329,9 +330,6 @@ class DialogInit {
 
         // Other internal initialization
         dialog.invalidateList();
-        dialog.setOnShowListenerInternal();
-        dialog.setOnDismissListenerInternal();
-        dialog.setOnCancelListenerInternal();
         dialog.setViewInternal(dialog.view);
         dialog.checkIfListInitScroll();
     }

+ 2 - 9
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -1323,15 +1323,8 @@ public class MaterialDialog extends DialogBase implements
     }
 
     @Override
-    public final void onCancel(DialogInterface dialog) {
-        super.onCancel(dialog);
-        if (input != null)
-            DialogUtils.hideKeyboard(this, mBuilder);
-    }
-
-    @Override
-    public final void onDismiss(DialogInterface dialog) {
-        super.onDismiss(dialog);
+    protected void onStop() {
+        super.onStop();
         if (input != null)
             DialogUtils.hideKeyboard(this, mBuilder);
     }

+ 1 - 1
sample/src/main/java/com/afollestad/materialdialogssample/FolderSelectorDialog.java

@@ -39,7 +39,7 @@ public class FolderSelectorDialog extends DialogFragment implements MaterialDial
         }
     };
 
-    public static interface FolderSelectCallback {
+    public interface FolderSelectCallback {
         void onFolderSelection(File folder);
     }