|
@@ -1,216 +0,0 @@
|
|
|
-package com.example.david.libretasker.InputSelector;
|
|
|
|
|
-
|
|
|
|
|
-import android.content.Context;
|
|
|
|
|
-import android.net.Uri;
|
|
|
|
|
-import android.os.Bundle;
|
|
|
|
|
-import android.support.v4.app.Fragment;
|
|
|
|
|
-import android.support.v4.app.FragmentTransaction;
|
|
|
|
|
-import android.util.AttributeSet;
|
|
|
|
|
-import android.view.LayoutInflater;
|
|
|
|
|
-import android.view.View;
|
|
|
|
|
-import android.view.ViewGroup;
|
|
|
|
|
-import android.widget.AdapterView;
|
|
|
|
|
-import android.widget.ArrayAdapter;
|
|
|
|
|
-import android.widget.LinearLayout;
|
|
|
|
|
-import android.widget.Spinner;
|
|
|
|
|
-import android.widget.TextView;
|
|
|
|
|
-
|
|
|
|
|
-import com.example.david.libretasker.Helpers;
|
|
|
|
|
-import com.example.david.libretasker.R;
|
|
|
|
|
-
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * A simple {@link Fragment} subclass.
|
|
|
|
|
- * Activities that contain this fragment must implement the
|
|
|
|
|
- * {@link Event.OnFragmentInteractionListener} interface
|
|
|
|
|
- * to handle interaction events.
|
|
|
|
|
- * Use the {@link Event#newInstance} factory method to
|
|
|
|
|
- * create an instance of this fragment.
|
|
|
|
|
- */
|
|
|
|
|
-public class Event 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";
|
|
|
|
|
- private LinearLayout fragmentContainer;
|
|
|
|
|
-
|
|
|
|
|
- // TODO: Rename and change types of parameters
|
|
|
|
|
- private String mParam1;
|
|
|
|
|
- private String mParam2;
|
|
|
|
|
-
|
|
|
|
|
- private OnFragmentInteractionListener mListener;
|
|
|
|
|
-
|
|
|
|
|
- public Event() {
|
|
|
|
|
- // 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 Event.
|
|
|
|
|
- */
|
|
|
|
|
- // TODO: Rename and change types and number of parameters
|
|
|
|
|
- public static Event newInstance(String param1, String param2) {
|
|
|
|
|
- Event fragment = new Event();
|
|
|
|
|
- Bundle args = new Bundle();
|
|
|
|
|
- args.putString(ARG_PARAM1, param1);
|
|
|
|
|
- args.putString(ARG_PARAM2, param2);
|
|
|
|
|
- fragment.setArguments(args);
|
|
|
|
|
- return fragment;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
|
|
- if (getArguments() != null) {
|
|
|
|
|
- mParam1 = getArguments().getString(ARG_PARAM1);
|
|
|
|
|
- mParam2 = getArguments().getString(ARG_PARAM2);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
|
|
- Bundle savedInstanceState) {
|
|
|
|
|
- // Inflate the layout for this fragment
|
|
|
|
|
- //View v = inflater.inflate(R.layout.fragment_event, container, false);
|
|
|
|
|
- LinearLayout root = new LinearLayout(getContext());
|
|
|
|
|
- LinearLayout spinnerContainer = new LinearLayout(getContext());
|
|
|
|
|
-
|
|
|
|
|
- root.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
-
|
|
|
|
|
- fragmentContainer = new LinearLayout(getContext());
|
|
|
|
|
- fragmentContainer.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
- fragmentContainer.setId(Helpers.globalID++);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Spinner spinner = new Spinner(getContext());
|
|
|
|
|
- spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
|
|
|
|
|
-
|
|
|
|
|
- TextView spinnerLabel = new TextView(getContext());
|
|
|
|
|
- spinnerLabel.setText("Event Type");
|
|
|
|
|
- spinnerLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 2f));
|
|
|
|
|
-
|
|
|
|
|
- spinnerContainer.addView(spinnerLabel);
|
|
|
|
|
- spinnerContainer.addView(spinner);
|
|
|
|
|
-
|
|
|
|
|
- root.addView(spinnerContainer);
|
|
|
|
|
- root.addView(fragmentContainer);
|
|
|
|
|
-// v.setLayoutParams(ll.getLayoutParams());
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //Spinner spinner = (Spinner) v.findViewById(R.id.spinner);
|
|
|
|
|
- List<String> l = Arrays.asList("Screen", "Time", "Network", "Phone", "SMS");
|
|
|
|
|
- final ArrayAdapter<CharSequence> adapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, l);
|
|
|
|
|
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
|
- // Apply the adapter to the spinner
|
|
|
|
|
- spinner.setAdapter(adapter);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //v.setLayoutParams(ll.getLayoutParams());
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) {
|
|
|
|
|
-
|
|
|
|
|
- String[] a;
|
|
|
|
|
- boolean multi;
|
|
|
|
|
- if ( adapter.getItem(pos) == null )
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- int fragmentID = fragmentContainer.getId();
|
|
|
|
|
- //R.id.your_placeholder;
|
|
|
|
|
- //v.findViewWithTag("container").getId(); //v.findViewById(R.id.your_placeholder).getId();
|
|
|
|
|
-
|
|
|
|
|
- FragmentTransaction ft = getFragmentManager().beginTransaction();
|
|
|
|
|
- if ( adapter.getItem(pos).equals("Screen")) {
|
|
|
|
|
- a = new String[]{"On", "Off", "Any"};
|
|
|
|
|
- ft.replace(fragmentID, MultiStateInRows.newInstance(a, false, "State", 1));
|
|
|
|
|
- ft.commit();
|
|
|
|
|
-
|
|
|
|
|
- } else if ( adapter.getItem(pos).equals("Time")) {
|
|
|
|
|
- a = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
|
|
|
|
- ft.replace(fragmentID, MultiStateInRows.newInstance(a, true, "Months", 2 ));
|
|
|
|
|
-
|
|
|
|
|
- a = new String[]{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
|
|
|
|
- ft.add(fragmentID, MultiStateInRows.newInstance(a, true, "DOW", 1 ));
|
|
|
|
|
-
|
|
|
|
|
- a = new String[31];
|
|
|
|
|
- for (int i = 0; i< a.length; i++)
|
|
|
|
|
- a[i]=Integer.toString(i+1);
|
|
|
|
|
- ft.add(fragmentID, MultiStateInRows.newInstance(a, true, "DOM", 4 ));
|
|
|
|
|
-
|
|
|
|
|
- a = new String[24];
|
|
|
|
|
- for (int i = 0; i< a.length; i++)
|
|
|
|
|
- a[i]=Integer.toString(i);
|
|
|
|
|
-
|
|
|
|
|
- ft.add(fragmentID, MultiStateInRows.newInstance(a, true, "Hour", 2 ));
|
|
|
|
|
-
|
|
|
|
|
- //TODO: Minutes
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- ft.commit();
|
|
|
|
|
- } else if ( adapter.getItem(pos).equals("SMS") ) {
|
|
|
|
|
- ft.replace(fragmentID, Contact.newInstance());
|
|
|
|
|
- ft.add(fragmentID, Text.newInstance("Body"));
|
|
|
|
|
- ft.commit();
|
|
|
|
|
- } else if ( adapter.getItem(pos).equals("Phone") ) {
|
|
|
|
|
- a = new String[]{"Ringing", "Idle", "Any"};
|
|
|
|
|
- ft.replace(fragmentID, Contact.newInstance());
|
|
|
|
|
- ft.add(fragmentID, MultiStateInRows.newInstance(a, false, "State", 1));
|
|
|
|
|
- ft.commit();
|
|
|
|
|
- } else if ( adapter.getItem(pos).equals("Network") ) {
|
|
|
|
|
- ft.replace(fragmentID, Network.newInstance());
|
|
|
|
|
- ft.commit();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onNothingSelected(AdapterView<?> adapterView) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- //return v;
|
|
|
|
|
- return root;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // TODO: Rename method, update argument and hook method into UI event
|
|
|
|
|
- public void onButtonPressed(Uri uri) {
|
|
|
|
|
- if (mListener != null) {
|
|
|
|
|
- mListener.onFragmentInteraction(uri);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onAttach(Context context) {
|
|
|
|
|
- super.onAttach(context);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDetach() {
|
|
|
|
|
- super.onDetach();
|
|
|
|
|
- mListener = null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * This interface must be implemented by activities that contain this
|
|
|
|
|
- * fragment to allow an interaction in this fragment to be communicated
|
|
|
|
|
- * to the activity and potentially other fragments contained in that
|
|
|
|
|
- * activity.
|
|
|
|
|
- * <p>
|
|
|
|
|
- * See the Android Training lesson <a href=
|
|
|
|
|
- * "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
|
|
|
- * >Communicating with Other Fragments</a> for more information.
|
|
|
|
|
- */
|
|
|
|
|
- public interface OnFragmentInteractionListener {
|
|
|
|
|
- // TODO: Update argument type and name
|
|
|
|
|
- void onFragmentInteraction(Uri uri);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|