package com.ghzmdr.panicbutton;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.InputType;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;

/**
 * Created by ghzmdr on 19/01/15.
 */
public class PersonAddNumberDialog {
    private AlertDialog dialog;

    public PersonAddNumberDialog(final Context context, final ListView toUpdate) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context);

        LinearLayout root = new LinearLayout(context);
        root.setOrientation(LinearLayout.VERTICAL);

        final EditText textName = new EditText(context);
        textName.setHint("Name");

        final EditText textNumber = new EditText(context);
        textNumber.setHint("Number");
        textNumber.setInputType(InputType.TYPE_CLASS_NUMBER);

        root.addView(textName);
        root.addView(textNumber);

        dialog = builder.setTitle("Input data")
                .setView(root)
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        String name = textName.getText().toString(), number = textNumber.getText().toString();
                        if (name != null && !name.equals(""))
                            if (number != null && !number.equals("")) {
                                Person p = new Person(number, name);
                                PersonManager.savePerson(p, context);
                                toUpdate.setAdapter(new PersonAdapter(context, PersonManager.getSavedPersons(context)));
                            }
                    }
                })
                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .create();
    }

    public void show() {
        dialog.show();
    }
}

@@ -986,32 +986,12 @@
 lder
-.setTitle(%22Input data%22)%0A
+%0A   
     
@@ -998,24 +998,25 @@
             
+ 
 .setView(roo
@@ -1018,16 +1018,20 @@
 w(root)%0A
+    
         
@@ -1115,32 +1115,36 @@
                 
+    
 @Override%0A      
@@ -1129,32 +1129,36 @@
       @Override%0A
+    
                 
@@ -1242,16 +1242,20 @@
         
+    
 String n
@@ -1353,24 +1353,28 @@
             
+   
+ 
 if (name != 
@@ -1399,16 +1399,20 @@
 ls(%22%22))%0A
+    
         
@@ -1503,24 +1503,28 @@
             
+ 
+   
 Person p = n
@@ -1544,24 +1544,28 @@
 ber, name);%0A
+    
             
@@ -1614,32 +1614,36 @@
 on(p, context);%0A
+    
                 
@@ -1767,34 +1767,42 @@
                 
+  
-%7D%0A
+  %7D%0A    
                 
@@ -1815,35 +1815,42 @@
                 
-%7D)%0A
+    %7D)%0A   
                 
@@ -1845,24 +1845,25 @@
             
+ 
 .setNegative
@@ -1931,32 +1931,36 @@
                 
+    
 @Override%0A      
@@ -1965,32 +1965,36 @@
                 
+  
+  
 public void onCl
@@ -2026,32 +2026,36 @@
 g, int which) %7B%0A
+    
                 
@@ -2092,34 +2092,42 @@
                 
-%7D%0A
+    %7D%0A    
                 
@@ -2121,32 +2121,36 @@
              %7D)%0A
+    
                 

Remove title from contact dialog