David 9 лет назад
Родитель
Сommit
df1b3cc3ef

+ 13 - 0
app/src/main/java/com/example/david/libretasker/InputSelector/Contact.java

@@ -62,6 +62,19 @@ public class Contact extends Fragment {
                 startActivityForResult(intent, REQUEST_CODE);
                 startActivityForResult(intent, REQUEST_CODE);
             }
             }
         });
         });
+
+        Button noContact = (Button)v.findViewById(R.id.noContact);
+        noContact.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                EditText tvName = (EditText) thisView.findViewById(R.id.contactName);
+                EditText tvNumber = (EditText) thisView.findViewById(R.id.contactNumber);
+
+                tvName.setText("");
+                tvNumber.setText("");
+            }
+        });
+
         return v;
         return v;
     }
     }
     @Override
     @Override

+ 18 - 34
app/src/main/java/com/example/david/libretasker/InputSelector/Text.java

@@ -7,9 +7,13 @@ import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.TextView;
 
 
 import com.example.david.libretasker.R;
 import com.example.david.libretasker.R;
 
 
+import static android.R.attr.key;
+
 /**
 /**
  * A simple {@link Fragment} subclass.
  * A simple {@link Fragment} subclass.
  * Activities that contain this fragment must implement the
  * Activities that contain this fragment must implement the
@@ -19,53 +23,39 @@ import com.example.david.libretasker.R;
  * create an instance of this fragment.
  * create an instance of this fragment.
  */
  */
 public class Text extends Fragment {
 public class Text extends Fragment {
-    // TODO: Rename parameter arguments, choose names that match
-    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
-    private static final String ARG_PARAM1 = "param1";
-    private static final String ARG_PARAM2 = "param2";
-
-    // TODO: Rename and change types of parameters
-    private String mParam1;
-    private String mParam2;
-
     private OnFragmentInteractionListener mListener;
     private OnFragmentInteractionListener mListener;
+    final static String ARG_KEY = "key";
+    String key;
 
 
     public Text() {
     public Text() {
         // Required empty public constructor
         // Required empty public constructor
     }
     }
 
 
-    /**
-     * Use this factory method to create a new instance of
-     * this fragment using the provided parameters.
-     *
-     * @param param1 Parameter 1.
-     * @param param2 Parameter 2.
-     * @return A new instance of fragment Text.
-     */
-    // TODO: Rename and change types and number of parameters
-    public static Text newInstance(String param1, String param2) {
-        Text fragment = new Text();
-        Bundle args = new Bundle();
-        args.putString(ARG_PARAM1, param1);
-        args.putString(ARG_PARAM2, param2);
-        fragment.setArguments(args);
-        return fragment;
+    public static Text newInstance(String key) {
+        Bundle b = new Bundle();
+        b.putString(ARG_KEY, key);
+        Text t = new Text();
+        t.setArguments(b);
+        return t;
     }
     }
 
 
     @Override
     @Override
     public void onCreate(Bundle savedInstanceState) {
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
         if (getArguments() != null) {
         if (getArguments() != null) {
-            mParam1 = getArguments().getString(ARG_PARAM1);
-            mParam2 = getArguments().getString(ARG_PARAM2);
+            key = getArguments().getString(ARG_KEY);
         }
         }
+
     }
     }
 
 
     @Override
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
                              Bundle savedInstanceState) {
         // Inflate the layout for this fragment
         // Inflate the layout for this fragment
-        return inflater.inflate(R.layout.fragment_text, container, false);
+        View v = inflater.inflate(R.layout.fragment_text, container, false);
+        TextView tv = (TextView) v.findViewById(R.id.textKey);
+        tv.setText(key);
+        return v;
     }
     }
 
 
     // TODO: Rename method, update argument and hook method into UI event
     // TODO: Rename method, update argument and hook method into UI event
@@ -78,12 +68,6 @@ public class Text extends Fragment {
     @Override
     @Override
     public void onAttach(Context context) {
     public void onAttach(Context context) {
         super.onAttach(context);
         super.onAttach(context);
-        /*if (context instanceof OnFragmentInteractionListener) {
-            mListener = (OnFragmentInteractionListener) context;
-        } else {
-            throw new RuntimeException(context.toString()
-                    + " must implement OnFragmentInteractionListener");
-        }*/
     }
     }
 
 
     @Override
     @Override

+ 8 - 1
app/src/main/java/com/example/david/libretasker/NewEventActivity.java

@@ -10,6 +10,7 @@ import android.widget.Spinner;
 
 
 import com.example.david.libretasker.InputSelector.Contact;
 import com.example.david.libretasker.InputSelector.Contact;
 import com.example.david.libretasker.InputSelector.MultiStateInRows;
 import com.example.david.libretasker.InputSelector.MultiStateInRows;
+import com.example.david.libretasker.InputSelector.Text;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
@@ -61,14 +62,20 @@ public class NewEventActivity extends AppCompatActivity {
 
 
                     ft.add(R.id.your_placeholder, MultiStateInRows.newInstance(a, true, "Hour", 2 ));
                     ft.add(R.id.your_placeholder, MultiStateInRows.newInstance(a, true, "Hour", 2 ));
 
 
-                    //Minutes
+                    //TODO: Minutes
 
 
 
 
                     ft.commit();
                     ft.commit();
                 } else if ( adapter.getItem(pos).equals("SMS") ) {
                 } else if ( adapter.getItem(pos).equals("SMS") ) {
                     ft.replace(R.id.your_placeholder, Contact.newInstance());
                     ft.replace(R.id.your_placeholder, Contact.newInstance());
+                    ft.add(R.id.your_placeholder, Text.newInstance("Body"));
                     ft.commit();
                     ft.commit();
                 } else if ( adapter.getItem(pos).equals("Phone") ) {
                 } else if ( adapter.getItem(pos).equals("Phone") ) {
+                    a = new String[]{"Ringing", "Idle", "Any"};
+                    ft.replace(R.id.your_placeholder, Contact.newInstance());
+                    ft.add(R.id.your_placeholder, MultiStateInRows.newInstance(a, false, "State", 1));
+                    ft.commit();
+
                 } else if ( adapter.getItem(pos).equals("Network") ) {
                 } else if ( adapter.getItem(pos).equals("Network") ) {
                 }
                 }
                 // or ft.add(R.id.your_placeholder, new FooFragment());
                 // or ft.add(R.id.your_placeholder, new FooFragment());

+ 18 - 4
app/src/main/res/layout/fragment_contact.xml

@@ -53,10 +53,24 @@
 
 
     </LinearLayout>
     </LinearLayout>
 
 
-    <Button
-        android:text="Pick contact"
+    <LinearLayout
+        android:orientation="horizontal"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:id="@+id/pickContact" />
+        android:layout_height="wrap_content">
+
+        <Button
+            android:text="Pick contact"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:id="@+id/pickContact"
+            android:layout_weight="1" />
+
+        <Button
+            android:text="No contact"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:id="@+id/noContact"
+            android:layout_weight="1" />
+    </LinearLayout>
 
 
 </LinearLayout>
 </LinearLayout>

+ 23 - 8
app/src/main/res/layout/fragment_text.xml

@@ -1,15 +1,30 @@
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="wrap_content"
     tools:context="com.example.david.libretasker.InputSelector.Text">
     tools:context="com.example.david.libretasker.InputSelector.Text">
 
 
     <!-- TODO: Update blank fragment layout -->
     <!-- TODO: Update blank fragment layout -->
-    <TextView
+
+    <LinearLayout
+        android:orientation="horizontal"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="209dp"
-        android:text="@string/hello_blank_fragment"
-        android:layout_gravity="bottom"
-        android:textAppearance="@style/TextAppearance.AppCompat.Display2" />
+        android:layout_height="match_parent">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/textKey"
+            android:layout_weight="3"
+            android:layout_gravity="center_vertical"/>
+
+        <EditText
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:inputType="textPersonName"
+            android:ems="10"
+            android:id="@+id/InputText"
+            android:layout_weight="1" />
+    </LinearLayout>
 
 
-</FrameLayout>
+</LinearLayout>