Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7674b690 authored by Sam Blitzstein's avatar Sam Blitzstein
Browse files

Added in new time picker library.

Change-Id: Id252345cbb938870df02f1bb7f3dc6a65191298d
parent c2dd9594
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@ include $(CLEAR_VARS)
# Include res dir from chips
chips_dir := ../../../frameworks/ex/chips/res
color_picker_dir := ../../../frameworks/opt/colorpicker/res

res_dirs := $(chips_dir) $(color_picker_dir) res
datetimepicker_dir := ../../../frameworks/opt/datetimepicker/res
res_dirs := $(chips_dir) $(color_picker_dir) $(datetimepicker_dir) res
src_dirs := src

LOCAL_EMMA_COVERAGE_FILTER := +com.android.calendar.*
@@ -25,6 +25,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
        android-common \
        android-common-chips \
        colorpicker \
        android-opt-datetimepicker \
        android-support-v4 \
        calendar-common

@@ -34,11 +35,13 @@ LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs))

LOCAL_PACKAGE_NAME := Calendar

LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROGUARD_FLAG_FILES := proguard.flags \
                             ../../../frameworks/opt/datetimepicker/proguard.flags

LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages com.android.ex.chips
LOCAL_AAPT_FLAGS += --extra-packages com.android.colorpicker
LOCAL_AAPT_FLAGS += --extra-packages com.android.datetimepicker

include $(BUILD_PACKAGE)

+1 −0
Original line number Diff line number Diff line
@@ -16,3 +16,4 @@ android.library=false
android.library.reference.1=../../../frameworks/ex/chips
android.library.reference.2=../../../frameworks/opt/calendar
android.library.reference.3=../../../frameworks/opt/colorpicker
android.library.reference.4=../../../frameworks/opt/datetimepicker
+10 −1
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
    private boolean mIsReadOnly = false;
    public boolean mShowModifyDialogOnLaunch = false;

    private boolean mTimeSelectedWasStartTime;

    private InputMethodManager mInputMethodManager;

    private final Intent mIntent;
@@ -522,7 +524,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
        } else {
            view = inflater.inflate(R.layout.edit_event, null);
        }
        mView = new EditEventView(mContext, view, mOnDone);
        mView = new EditEventView(mContext, view, mOnDone, mTimeSelectedWasStartTime);
        startQuery();

        if (mUseCustomActionBar) {
@@ -569,6 +571,11 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
            if (savedInstanceState.containsKey(BUNDLE_KEY_READ_ONLY)) {
                mIsReadOnly = savedInstanceState.getBoolean(BUNDLE_KEY_READ_ONLY);
            }
            if (savedInstanceState.containsKey("EditEventView_timebuttonclicked")) {
                mTimeSelectedWasStartTime = savedInstanceState.getBoolean(
                        "EditEventView_timebuttonclicked");
            }

        }
    }

@@ -891,6 +898,8 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
        outState.putBoolean(BUNDLE_KEY_EDIT_ON_LAUNCH, mShowModifyDialogOnLaunch);
        outState.putSerializable(BUNDLE_KEY_EVENT, mEventBundle);
        outState.putBoolean(BUNDLE_KEY_READ_ONLY, mIsReadOnly);

        outState.putBoolean("EditEventView_timebuttonclicked", mView.mTimeSelectedWasStartTime);
    }

    @Override
+35 −8
Original line number Diff line number Diff line
@@ -21,10 +21,13 @@ import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.FragmentManager;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
import android.app.Service;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import com.android.datetimepicker.TimePickerDialog;
import com.android.datetimepicker.TimePickerDialog.OnTimeSetListener;
import com.android.datetimepicker.TimePicker;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -72,7 +75,6 @@ import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.TimePicker;

import com.android.calendar.CalendarEventModel;
import com.android.calendar.CalendarEventModel.Attendee;
@@ -111,6 +113,7 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa
    private static final String GOOGLE_SECONDARY_CALENDAR = "calendar.google.com";
    private static final String PERIOD_SPACE = ". ";
    static final String FRAG_TAG_RECUR_PICKER = "recurrencePickerDialogFragment";
    private static final String FRAG_TAG_TIME_PICKER = "timePickerDialogFragment";

    ArrayList<View> mEditOnlyList = new ArrayList<View>();
    ArrayList<View> mEditViewList = new ArrayList<View>();
@@ -172,6 +175,10 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa
    private Rfc822Validator mEmailValidator;
    private TimezoneAdapter mTimezoneAdapter;

    public boolean mTimeSelectedWasStartTime;

    private ArrayList<Integer> mRecurrenceIndexes = new ArrayList<Integer>(0);

    /**
     * Contents of the "minutes" spinner.  This has default values from the XML file, augmented
     * with any additional values that were already associated with the event.
@@ -285,10 +292,18 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa

        @Override
        public void onClick(View v) {
            TimePickerDialog tp = new TimePickerDialog(mActivity, new TimeListener(v), mTime.hour,
                    mTime.minute, DateFormat.is24HourFormat(mActivity));
            tp.setCanceledOnTouchOutside(true);
            tp.show();
            FragmentManager fm = mActivity.getFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();

            if (v == mStartTimeButton) {
                mTimeSelectedWasStartTime = true;
            } else {
                mTimeSelectedWasStartTime = false;
            }

            TimePickerDialog tp = TimePickerDialog.newInstance(new TimeListener(v),
                    mTime.hour, mTime.minute, DateFormat.is24HourFormat(mActivity));
            tp.show(ft, FRAG_TAG_TIME_PICKER);
        }
    }

@@ -743,7 +758,8 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa
        return true;
    }

    public EditEventView(Activity activity, View view, EditDoneRunnable done) {
    public EditEventView(Activity activity, View view, EditDoneRunnable done,
            boolean timeSelectedWasStartTime) {

        mActivity = activity;
        mView = view;
@@ -880,6 +896,17 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa
        if (rpd != null) {
            rpd.setOnRecurrenceSetListener(this);
        }
        TimePickerDialog tpd = (TimePickerDialog) fm.findFragmentByTag(FRAG_TAG_TIME_PICKER);
        if (tpd != null) {
            View v;
            mTimeSelectedWasStartTime = timeSelectedWasStartTime;
            if (timeSelectedWasStartTime) {
                v = mStartTimeButton;
            } else {
                v = mEndTimeButton;
            }
            tpd.setOnTimeSetListener(new TimeListener(v));
        }
    }