From fb6c739d86ffd10a02995a03bb0da6e62bbe1958 Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Mon, 7 Nov 2016 16:16:37 -0500 Subject: [PATCH 1/7] Updating gitignore. --- .gitignore | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index 9c4de58..c6179b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,21 @@ +# Generated files +bin/ +gen/ + +# Gradle files +.gradle/ +build/ +.idea/ +*.iml + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log .gradle /local.properties /.idea/workspace.xml From 63b85a9942d73c3ed70a289aeba345e6b26b2f2b Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Mon, 7 Nov 2016 18:36:42 -0500 Subject: [PATCH 2/7] Updating gradle, Creating shell in sublime options to allow user to define text labels for recurrence --- .../com/appeaser/sublimepicker/Sampler.java | 3 ++ build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- sublimepickerlibrary/build.gradle | 2 +- .../helpers/SublimeOptions.java | 46 +++++++++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/appeaser/sublimepicker/Sampler.java b/app/src/main/java/com/appeaser/sublimepicker/Sampler.java index 94efe41..d9ebd3a 100644 --- a/app/src/main/java/com/appeaser/sublimepicker/Sampler.java +++ b/app/src/main/java/com/appeaser/sublimepicker/Sampler.java @@ -325,6 +325,9 @@ Pair getOptions() { // Enable/disable the date range selection feature options.setCanPickDateRange(cbAllowDateRangeSelection.isChecked()); + //Optionally set custom labels on the Recurrence Picker... + options.setRecurrenceTextLabels("Only Once", null, null, null, null, "Pick Your Own..."); + // Example for setting date range: // Note that you can pass a date range as the initial date params // even if you have date-range selection disabled. In this case, diff --git a/build.gradle b/build.gradle index 2042ae6..d59ae71 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5' //classpath 'com.android.tools.build:gradle:1.5.0' //classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 07fc193..e3c51a6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Mon Nov 07 16:31:30 EST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/sublimepickerlibrary/build.gradle b/sublimepickerlibrary/build.gradle index ca60e34..2683e6e 100644 --- a/sublimepickerlibrary/build.gradle +++ b/sublimepickerlibrary/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' } } diff --git a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java index 9523414..a398601 100644 --- a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java +++ b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java @@ -19,6 +19,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.TextUtils; import com.appeaser.sublimepickerlibrary.datepicker.SelectedDate; @@ -58,6 +59,14 @@ public enum Picker {DATE_PICKER, TIME_PICKER, REPEAT_OPTION_PICKER, INVALID} = SublimeRecurrencePicker.RecurrenceOption.DOES_NOT_REPEAT; private String mRecurrenceRule = ""; + //Allow user to define custom recurrence text labels + private String doesntRepeatRecurrenceLabel = SublimeRecurrencePicker.RecurrenceOption.DOES_NOT_REPEAT.toString(); + private String dailyRecurrenceLabel = SublimeRecurrencePicker.RecurrenceOption.DAILY.toString(); + private String weeklyRecurrenceLabel = SublimeRecurrencePicker.RecurrenceOption.WEEKLY.toString(); + private String monthlyRecurrenceLabel = SublimeRecurrencePicker.RecurrenceOption.MONTHLY.toString(); + private String yearlyRecurrenceLabel = SublimeRecurrencePicker.RecurrenceOption.YEARLY.toString(); + private String customRecurrenceLabel = SublimeRecurrencePicker.RecurrenceOption.CUSTOM.toString(); + // Allow date range selection private boolean mCanPickDateRange; @@ -236,6 +245,31 @@ public boolean isRecurrencePickerActive() { return (mDisplayOptions & ACTIVATE_RECURRENCE_PICKER) == ACTIVATE_RECURRENCE_PICKER; } + public void setRecurrenceTextLabels(@Nullable String doesntRepeatRecurrenceLabel, @Nullable String dailyRecurrenceLabel, + @Nullable String weeklyRecurrenceLabel, @Nullable String monthlyRecurrenceLabel, + @Nullable String yearlyRecurrenceLabel, @Nullable String customRecurrenceLabel) { + + if (!TextUtils.isEmpty(doesntRepeatRecurrenceLabel)) { + this.doesntRepeatRecurrenceLabel = doesntRepeatRecurrenceLabel; + } + if (!TextUtils.isEmpty(dailyRecurrenceLabel)) { + this.dailyRecurrenceLabel = dailyRecurrenceLabel; + } + if (!TextUtils.isEmpty(weeklyRecurrenceLabel)) { + this.weeklyRecurrenceLabel = weeklyRecurrenceLabel; + } + if (!TextUtils.isEmpty(monthlyRecurrenceLabel)) { + this.monthlyRecurrenceLabel = monthlyRecurrenceLabel; + } + if (!TextUtils.isEmpty(yearlyRecurrenceLabel)) { + this.yearlyRecurrenceLabel = yearlyRecurrenceLabel; + } + if (!TextUtils.isEmpty(customRecurrenceLabel)) { + this.customRecurrenceLabel = customRecurrenceLabel; + } + + } + /*public int[] getDateParams() { if (mYear == -1 || mMonthOfYear == -1 || mDayOfMonth == -1) { Calendar cal = SUtils.getCalendarForLocale(null, Locale.getDefault()); @@ -332,6 +366,12 @@ private void readFromParcel(Parcel in) { mMinute = in.readInt(); mIs24HourView = in.readByte() != 0; mRecurrenceRule = in.readString(); + doesntRepeatRecurrenceLabel = in.readString(); + dailyRecurrenceLabel = in.readString(); + weeklyRecurrenceLabel = in.readString(); + monthlyRecurrenceLabel = in.readString(); + yearlyRecurrenceLabel = in.readString(); + customRecurrenceLabel = in.readString(); mCanPickDateRange = in.readByte() != 0; } @@ -350,6 +390,12 @@ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mMinute); dest.writeByte((byte) (mIs24HourView ? 1 : 0)); dest.writeString(mRecurrenceRule); + dest.writeString(doesntRepeatRecurrenceLabel); + dest.writeString(dailyRecurrenceLabel); + dest.writeString(weeklyRecurrenceLabel); + dest.writeString(monthlyRecurrenceLabel); + dest.writeString(yearlyRecurrenceLabel); + dest.writeString(customRecurrenceLabel); dest.writeByte((byte) (mCanPickDateRange ? 1 : 0)); } From 773cf7a88f900e7617fa7ae7740deda1f4b635cc Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Thu, 1 Dec 2016 11:17:28 -0500 Subject: [PATCH 3/7] =?UTF-8?q?Remove=20files=20that=20shouldn=E2=80=99t?= =?UTF-8?q?=20be=20checked=20in=20to=20VC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 20 ---- .idea/modules.xml | 10 -- SublimePicker.iml | 19 ---- app/app.iml | 88 ------------------ sublimepickerlibrary/sublimepickerlibrary.iml | 93 ------------------- 5 files changed, 230 deletions(-) delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/modules.xml delete mode 100644 SublimePicker.iml delete mode 100644 app/app.iml delete mode 100644 sublimepickerlibrary/sublimepickerlibrary.iml diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index a8fde51..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index a21bebf..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/SublimePicker.iml b/SublimePicker.iml deleted file mode 100644 index 693ce74..0000000 --- a/SublimePicker.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index 2e891d8..0000000 --- a/app/app.iml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sublimepickerlibrary/sublimepickerlibrary.iml b/sublimepickerlibrary/sublimepickerlibrary.iml deleted file mode 100644 index e0f496d..0000000 --- a/sublimepickerlibrary/sublimepickerlibrary.iml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From a682afd437cb5e34e1bb5f305b26c8df1f17a7ea Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Thu, 1 Dec 2016 11:18:46 -0500 Subject: [PATCH 4/7] Remove files not to be tracked in VC. --- .idea/.name | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .idea/.name diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 0f558a4..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -SublimePicker \ No newline at end of file From 42c3df0052f355e4789147d07b7f936e966e53c4 Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Fri, 2 Dec 2016 12:22:09 -0500 Subject: [PATCH 5/7] Allow the user to pass in custom strings to update the text labels on the Sublime Recurrence Picker. --- .../com/appeaser/sublimepicker/Sampler.java | 78 ++++++++++--------- .../sublimepickerlibrary/SublimePicker.java | 2 +- .../helpers/SublimeOptions.java | 24 ++++++ .../SublimeRecurrencePicker.java | 55 +++++++++---- 4 files changed, 104 insertions(+), 55 deletions(-) diff --git a/app/src/main/java/com/appeaser/sublimepicker/Sampler.java b/app/src/main/java/com/appeaser/sublimepicker/Sampler.java index d9ebd3a..fbd3c60 100644 --- a/app/src/main/java/com/appeaser/sublimepicker/Sampler.java +++ b/app/src/main/java/com/appeaser/sublimepicker/Sampler.java @@ -65,11 +65,11 @@ public class Sampler extends AppCompatActivity { tvMinute, tvRecurrenceOption, tvRecurrenceRule, tvStartDate, tvEndDate; RelativeLayout rlDateTimeRecurrenceInfo; - LinearLayout llDateHolder, llDateRangeHolder; + LinearLayout llDateHolder, llDateRangeHolder; // Chosen values SelectedDate mSelectedDate; - int mHour, mMinute; + int mHour, mMinute; String mRecurrenceOption, mRecurrenceRule; SublimePickerFragment.Callback mFragmentCallback = new SublimePickerFragment.Callback() { @@ -98,7 +98,7 @@ public void onDateTimeRecurrenceSet(SelectedDate selectedDate, @Override public void run() { svMainContainer.scrollTo(svMainContainer.getScrollX(), - cbAllowDateRangeSelection.getBottom()); + cbAllowDateRangeSelection.getBottom()); } }); } @@ -171,7 +171,7 @@ public void onClick(View v) { if (!optionsPair.first) { // If options are not valid Toast.makeText(Sampler.this, "No pickers activated", - Toast.LENGTH_SHORT).show(); + Toast.LENGTH_SHORT).show(); return; } @@ -190,7 +190,7 @@ public void onClick(View v) { @Override public void onClick(View v) { rbDatePicker.setVisibility(cbDatePicker.isChecked() ? - View.VISIBLE : View.GONE); + View.VISIBLE : View.GONE); onActivatedPickersChanged(); } }); @@ -200,7 +200,7 @@ public void onClick(View v) { @Override public void onClick(View v) { rbTimePicker.setVisibility(cbTimePicker.isChecked() ? - View.VISIBLE : View.GONE); + View.VISIBLE : View.GONE); onActivatedPickersChanged(); } }); @@ -210,7 +210,7 @@ public void onClick(View v) { @Override public void onClick(View v) { rbRecurrencePicker.setVisibility(cbRecurrencePicker.isChecked() ? - View.VISIBLE : View.GONE); + View.VISIBLE : View.GONE); onActivatedPickersChanged(); } }); @@ -243,11 +243,11 @@ void dealWithSavedInstanceState(Bundle savedInstanceState) { .setChecked(savedInstanceState.getBoolean(SS_ALLOW_DATE_RANGE_SELECTION)); rbDatePicker.setVisibility(cbDatePicker.isChecked() ? - View.VISIBLE : View.GONE); + View.VISIBLE : View.GONE); rbTimePicker.setVisibility(cbTimePicker.isChecked() ? - View.VISIBLE : View.GONE); + View.VISIBLE : View.GONE); rbRecurrencePicker.setVisibility(cbRecurrencePicker.isChecked() ? - View.VISIBLE : View.GONE); + View.VISIBLE : View.GONE); onActivatedPickersChanged(); @@ -257,12 +257,12 @@ void dealWithSavedInstanceState(Bundle savedInstanceState) { if (startYear != INVALID_VAL) { Calendar startCal = Calendar.getInstance(); startCal.set(startYear, savedInstanceState.getInt(SS_START_MONTH), - savedInstanceState.getInt(SS_START_DAY)); + savedInstanceState.getInt(SS_START_DAY)); Calendar endCal = Calendar.getInstance(); endCal.set(savedInstanceState.getInt(SS_END_YEAR), - savedInstanceState.getInt(SS_END_MONTH), - savedInstanceState.getInt(SS_END_DAY)); + savedInstanceState.getInt(SS_END_MONTH), + savedInstanceState.getInt(SS_END_DAY)); mSelectedDate = new SelectedDate(startCal, endCal); } @@ -281,7 +281,7 @@ void dealWithSavedInstanceState(Bundle savedInstanceState) { @Override public void run() { svMainContainer.scrollTo(svMainContainer.getScrollX(), - scrollY); + scrollY); } }); } @@ -325,7 +325,9 @@ Pair getOptions() { // Enable/disable the date range selection feature options.setCanPickDateRange(cbAllowDateRangeSelection.isChecked()); - //Optionally set custom labels on the Recurrence Picker... + /** + * Optionally set custom labels on the Recurrence Picker... + */ options.setRecurrenceTextLabels("Only Once", null, null, null, null, "Pick Your Own..."); // Example for setting date range: @@ -391,19 +393,19 @@ private void updateInfoView() { llDateHolder.setVisibility(View.VISIBLE); tvYear.setText(applyBoldStyle("YEAR: ") - .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.YEAR)))); + .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.YEAR)))); tvMonth.setText(applyBoldStyle("MONTH: ") - .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.MONTH)))); + .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.MONTH)))); tvDay.setText(applyBoldStyle("DAY: ") - .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.DAY_OF_MONTH)))); + .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.DAY_OF_MONTH)))); } else if (mSelectedDate.getType() == SelectedDate.Type.RANGE) { llDateHolder.setVisibility(View.GONE); llDateRangeHolder.setVisibility(View.VISIBLE); tvStartDate.setText(applyBoldStyle("START: ") - .append(DateFormat.getDateInstance().format(mSelectedDate.getStartDate().getTime()))); + .append(DateFormat.getDateInstance().format(mSelectedDate.getStartDate().getTime()))); tvEndDate.setText(applyBoldStyle("END: ") - .append(DateFormat.getDateInstance().format(mSelectedDate.getEndDate().getTime()))); + .append(DateFormat.getDateInstance().format(mSelectedDate.getEndDate().getTime()))); } } @@ -411,7 +413,7 @@ private void updateInfoView() { tvMinute.setText(applyBoldStyle("MINUTE: ").append(String.valueOf(mMinute))); tvRecurrenceOption.setText(applyBoldStyle("RECURRENCE OPTION: ") - .append(mRecurrenceOption)); + .append(mRecurrenceOption)); tvRecurrenceRule.setText(applyBoldStyle("RECURRENCE RULE: ").append( mRecurrenceRule)); @@ -422,27 +424,27 @@ private void updateInfoView() { private SpannableStringBuilder applyBoldStyle(String text) { SpannableStringBuilder ss = new SpannableStringBuilder(text); ss.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return ss; } // Keys for saving state - final String SS_DATE_PICKER_CHECKED = "saved.state.date.picker.checked"; - final String SS_TIME_PICKER_CHECKED = "saved.state.time.picker.checked"; - final String SS_RECURRENCE_PICKER_CHECKED = "saved.state.recurrence.picker.checked"; + final String SS_DATE_PICKER_CHECKED = "saved.state.date.picker.checked"; + final String SS_TIME_PICKER_CHECKED = "saved.state.time.picker.checked"; + final String SS_RECURRENCE_PICKER_CHECKED = "saved.state.recurrence.picker.checked"; final String SS_ALLOW_DATE_RANGE_SELECTION = "saved.state.allow.date.range.selection"; - final String SS_START_YEAR = "saved.state.start.year"; - final String SS_START_MONTH = "saved.state.start.month"; - final String SS_START_DAY = "saved.state.start.day"; - final String SS_END_YEAR = "saved.state.end.year"; - final String SS_END_MONTH = "saved.state.end.month"; - final String SS_END_DAY = "saved.state.end.day"; - final String SS_HOUR = "saved.state.hour"; - final String SS_MINUTE = "saved.state.minute"; - final String SS_RECURRENCE_OPTION = "saved.state.recurrence.option"; - final String SS_RECURRENCE_RULE = "saved.state.recurrence.rule"; - final String SS_INFO_VIEW_VISIBILITY = "saved.state.info.view.visibility"; - final String SS_SCROLL_Y = "saved.state.scroll.y"; + final String SS_START_YEAR = "saved.state.start.year"; + final String SS_START_MONTH = "saved.state.start.month"; + final String SS_START_DAY = "saved.state.start.day"; + final String SS_END_YEAR = "saved.state.end.year"; + final String SS_END_MONTH = "saved.state.end.month"; + final String SS_END_DAY = "saved.state.end.day"; + final String SS_HOUR = "saved.state.hour"; + final String SS_MINUTE = "saved.state.minute"; + final String SS_RECURRENCE_OPTION = "saved.state.recurrence.option"; + final String SS_RECURRENCE_RULE = "saved.state.recurrence.rule"; + final String SS_INFO_VIEW_VISIBILITY = "saved.state.info.view.visibility"; + final String SS_SCROLL_Y = "saved.state.scroll.y"; @Override protected void onSaveInstanceState(Bundle outState) { @@ -473,7 +475,7 @@ protected void onSaveInstanceState(Bundle outState) { outState.putString(SS_RECURRENCE_OPTION, mRecurrenceOption); outState.putString(SS_RECURRENCE_RULE, mRecurrenceRule); outState.putBoolean(SS_INFO_VIEW_VISIBILITY, - rlDateTimeRecurrenceInfo.getVisibility() == View.VISIBLE); + rlDateTimeRecurrenceInfo.getVisibility() == View.VISIBLE); outState.putInt(SS_SCROLL_Y, svMainContainer.getScrollY()); super.onSaveInstanceState(outState); diff --git a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/SublimePicker.java b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/SublimePicker.java index 9966947..ce47675 100644 --- a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/SublimePicker.java +++ b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/SublimePicker.java @@ -613,7 +613,7 @@ private void processOptions() { : SUtils.getCalendarForLocale(null, Locale.getDefault()); mSublimeRecurrencePicker.initializeData(mRepeatOptionSetListener, - mCurrentRecurrenceOption, mRecurrenceRule, + mCurrentRecurrenceOption, mRecurrenceRule, mOptions, cal.getTimeInMillis()); } else { removeView(mSublimeRecurrencePicker); diff --git a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java index a398601..137464f 100644 --- a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java +++ b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java @@ -245,6 +245,30 @@ public boolean isRecurrencePickerActive() { return (mDisplayOptions & ACTIVATE_RECURRENCE_PICKER) == ACTIVATE_RECURRENCE_PICKER; } + public String getDoesntRepeatRecurrenceLabel() { + return doesntRepeatRecurrenceLabel; + } + + public String getDailyRecurrenceLabel() { + return dailyRecurrenceLabel; + } + + public String getWeeklyRecurrenceLabel() { + return weeklyRecurrenceLabel; + } + + public String getMonthlyRecurrenceLabel() { + return monthlyRecurrenceLabel; + } + + public String getYearlyRecurrenceLabel() { + return yearlyRecurrenceLabel; + } + + public String getCustomRecurrenceLabel() { + return customRecurrenceLabel; + } + public void setRecurrenceTextLabels(@Nullable String doesntRepeatRecurrenceLabel, @Nullable String dailyRecurrenceLabel, @Nullable String weeklyRecurrenceLabel, @Nullable String monthlyRecurrenceLabel, @Nullable String yearlyRecurrenceLabel, @Nullable String customRecurrenceLabel) { diff --git a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java index db235bc..674104e 100644 --- a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java +++ b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java @@ -29,10 +29,10 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; +import android.support.v4.content.ContextCompat; import android.text.TextUtils; import android.text.format.Time; import android.util.AttributeSet; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; @@ -41,6 +41,7 @@ import android.widget.TextView; import com.appeaser.sublimepickerlibrary.R; +import com.appeaser.sublimepickerlibrary.helpers.SublimeOptions; import com.appeaser.sublimepickerlibrary.utilities.SUtils; import java.util.ArrayList; @@ -49,6 +50,8 @@ public class SublimeRecurrencePicker extends FrameLayout implements View.OnClickListener { + protected SublimeOptions mOptions; + // Pre-defined recurrence options that are shown in a menu // format. Choosing 'CUSTOM' takes the user // to 'RecurrenceOptionCreator'. @@ -116,16 +119,16 @@ public SublimeRecurrencePicker(Context context, AttributeSet attrs) { public SublimeRecurrencePicker(Context context, AttributeSet attrs, int defStyleAttr) { super(SUtils.createThemeWrapper(context, R.attr.sublimePickerStyle, - R.style.SublimePickerStyleLight, R.attr.spRecurrencePickerStyle, - R.style.SublimeRecurrencePickerStyle), attrs, defStyleAttr); + R.style.SublimePickerStyleLight, R.attr.spRecurrencePickerStyle, + R.style.SublimeRecurrencePickerStyle), attrs, defStyleAttr); initializeLayout(); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public SublimeRecurrencePicker(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(SUtils.createThemeWrapper(context, R.attr.sublimePickerStyle, - R.style.SublimePickerStyleLight, R.attr.spRecurrencePickerStyle, - R.style.SublimeRecurrencePickerStyle), attrs, defStyleAttr, defStyleRes); + R.style.SublimePickerStyleLight, R.attr.spRecurrencePickerStyle, + R.style.SublimeRecurrencePickerStyle), attrs, defStyleAttr, defStyleRes); initializeLayout(); } @@ -162,7 +165,7 @@ void initializeLayout() { SUtils.setViewBackground(this, pickerBgColor, SUtils.CORNERS_ALL); SUtils.setViewBackground(tvRecurrenceHeading, headingBgColor, - SUtils.CORNER_TOP_LEFT | SUtils.CORNER_TOP_RIGHT); + SUtils.CORNER_TOP_LEFT | SUtils.CORNER_TOP_RIGHT); // State colors mSelectedStateTextColor = a.getColor( @@ -179,8 +182,7 @@ void initializeLayout() { mCheckmarkDrawable = a.getDrawable(R.styleable.SublimeRecurrencePicker_spSelectedOptionDrawable); if (mCheckmarkDrawable == null) { - mCheckmarkDrawable = context.getResources() - .getDrawable(R.drawable.checkmark_medium_ff); + mCheckmarkDrawable = ContextCompat.getDrawable(context, R.drawable.checkmark_medium_ff); } // Android Studio recommends this check :-/ @@ -192,6 +194,7 @@ void initializeLayout() { } // Options/Views + //TODO set the text labels on these views based on options input. mRepeatOptionTextViews = new ArrayList<>(); mRepeatOptionTextViews.add( (TextView) findViewById(R.id.tvChosenCustomOption)); @@ -211,14 +214,15 @@ void initializeLayout() { // Set bg StateListDrawables for (View v : mRepeatOptionTextViews) { SUtils.setViewBackground(v, - createOptionBg(mPressedStateColor)); + createOptionBg(mPressedStateColor)); } } // Called by SublimePicker to initialize state & provide callback public void initializeData(OnRepeatOptionSetListener callback, RecurrenceOption initialOption, String recurrenceRule, - long currentlyChosenTime) { + SublimeOptions options, long currentlyChosenTime) { + mOptions = options; mCallback = callback; mRecurrenceRule = recurrenceRule; @@ -227,13 +231,31 @@ public void initializeData(OnRepeatOptionSetListener callback, // Initialize state for RecurrenceOptionCreator mRecurrenceOptionCreator.initializeData(mCurrentlyChosenTime, null, - mRecurrenceRule, mOnRecurrenceSetListener); + mRecurrenceRule, mOnRecurrenceSetListener); + updateView(); } // Controls the visibility of recurrence options menu // & recurrence option creator public void updateView() { if (mCurrentView == CurrentView.RECURRENCE_OPTIONS_MENU) { + TextView doesNotRepeatOption = (TextView) findViewById(R.id.tvDoesNotRepeat); + TextView dailyOption = (TextView) findViewById(R.id.tvDaily); + TextView weeklyOption = (TextView) findViewById(R.id.tvWeekly); + TextView monthlyOption = (TextView) findViewById(R.id.tvMonthly); + TextView yearlyOption = (TextView) findViewById(R.id.tvYearly); + TextView customOption = (TextView) findViewById(R.id.tvCustom); + + if(mOptions != null){ + //Update the text views with the passed in options. + doesNotRepeatOption.setText(mOptions.getDoesntRepeatRecurrenceLabel()); + dailyOption.setText(mOptions.getDailyRecurrenceLabel()); + weeklyOption.setText(mOptions.getWeeklyRecurrenceLabel()); + monthlyOption.setText(mOptions.getMonthlyRecurrenceLabel()); + yearlyOption.setText(mOptions.getYearlyRecurrenceLabel()); + customOption.setText(mOptions.getCustomRecurrenceLabel()); + } + mRecurrenceOptionCreator.setVisibility(View.GONE); llRecurrenceOptionsMenu.setVisibility(View.VISIBLE); @@ -311,7 +333,7 @@ void updateFlowLayout(RecurrenceOption recurrenceOption) { if (tv.getId() == viewIdToSelect) { // Set checkmark drawable & drawable-padding tv.setCompoundDrawablesWithIntrinsicBounds(null, null, - mCheckmarkDrawable, null); + mCheckmarkDrawable, null); tv.setCompoundDrawablePadding(mSelectedOptionDrawablePadding); tv.setTextColor(mSelectedStateTextColor); @@ -405,7 +427,7 @@ private Drawable createStateListDrawableForOption(int pressedBgColor) { StateListDrawable sld = new StateListDrawable(); sld.addState(new int[]{android.R.attr.state_pressed}, - new ColorDrawable(pressedBgColor)); + new ColorDrawable(pressedBgColor)); sld.addState(new int[]{}, new ColorDrawable(Color.TRANSPARENT)); return sld; @@ -420,7 +442,7 @@ private Drawable createRippleDrawableForOption(int pressedBgColor) { @Override protected Parcelable onSaveInstanceState() { return new SavedState(super.onSaveInstanceState(), mCurrentView, - mCurrentRecurrenceOption, mRecurrenceRule); + mCurrentRecurrenceOption, mRecurrenceRule); } @Override @@ -440,9 +462,9 @@ protected void onRestoreInstanceState(Parcelable state) { */ private static class SavedState extends View.BaseSavedState { - private final CurrentView sCurrentView; + private final CurrentView sCurrentView; private final RecurrenceOption sCurrentRecurrenceOption; - private final String sRecurrenceRule; + private final String sRecurrenceRule; /** * Constructor called from {@link SublimeRecurrencePicker#onSaveInstanceState()} @@ -503,6 +525,7 @@ public SavedState[] newArray(int size) { } public interface OnRepeatOptionSetListener { + /** * User has either selected one of the pre-defined * recurrence options or used RecurrenceOptionCreator From 91c0781cf23a91e8f50672c947630caaf2920801 Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Fri, 2 Dec 2016 12:22:31 -0500 Subject: [PATCH 6/7] Remove TODO --- .../recurrencepicker/SublimeRecurrencePicker.java | 1 - 1 file changed, 1 deletion(-) diff --git a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java index 674104e..105cc0e 100644 --- a/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java +++ b/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/recurrencepicker/SublimeRecurrencePicker.java @@ -194,7 +194,6 @@ void initializeLayout() { } // Options/Views - //TODO set the text labels on these views based on options input. mRepeatOptionTextViews = new ArrayList<>(); mRepeatOptionTextViews.add( (TextView) findViewById(R.id.tvChosenCustomOption)); From 273d4111af184b5d30fed7a7f3a454e1e23cd862 Mon Sep 17 00:00:00 2001 From: Christopher Corrado Date: Fri, 2 Dec 2016 12:40:45 -0500 Subject: [PATCH 7/7] Fix PR Quality issues --- .../com/appeaser/sublimepicker/Sampler.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/appeaser/sublimepicker/Sampler.java b/app/src/main/java/com/appeaser/sublimepicker/Sampler.java index fbd3c60..1c5c090 100644 --- a/app/src/main/java/com/appeaser/sublimepicker/Sampler.java +++ b/app/src/main/java/com/appeaser/sublimepicker/Sampler.java @@ -46,6 +46,24 @@ public class Sampler extends AppCompatActivity { + // Keys for saving state + protected final String SS_DATE_PICKER_CHECKED = "saved.state.date.picker.checked"; + protected final String SS_TIME_PICKER_CHECKED = "saved.state.time.picker.checked"; + protected final String SS_RECURRENCE_PICKER_CHECKED = "saved.state.recurrence.picker.checked"; + protected final String SS_ALLOW_DATE_RANGE_SELECTION = "saved.state.allow.date.range.selection"; + protected final String SS_START_YEAR = "saved.state.start.year"; + protected final String SS_START_MONTH = "saved.state.start.month"; + protected final String SS_START_DAY = "saved.state.start.day"; + protected final String SS_END_YEAR = "saved.state.end.year"; + protected final String SS_END_MONTH = "saved.state.end.month"; + protected final String SS_END_DAY = "saved.state.end.day"; + protected final String SS_HOUR = "saved.state.hour"; + protected final String SS_MINUTE = "saved.state.minute"; + protected final String SS_RECURRENCE_OPTION = "saved.state.recurrence.option"; + protected final String SS_RECURRENCE_RULE = "saved.state.recurrence.rule"; + protected final String SS_INFO_VIEW_VISIBILITY = "saved.state.info.view.visibility"; + protected final String SS_SCROLL_Y = "saved.state.scroll.y"; + private final int INVALID_VAL = -1; // Launches SublimePicker @@ -428,24 +446,6 @@ private SpannableStringBuilder applyBoldStyle(String text) { return ss; } - // Keys for saving state - final String SS_DATE_PICKER_CHECKED = "saved.state.date.picker.checked"; - final String SS_TIME_PICKER_CHECKED = "saved.state.time.picker.checked"; - final String SS_RECURRENCE_PICKER_CHECKED = "saved.state.recurrence.picker.checked"; - final String SS_ALLOW_DATE_RANGE_SELECTION = "saved.state.allow.date.range.selection"; - final String SS_START_YEAR = "saved.state.start.year"; - final String SS_START_MONTH = "saved.state.start.month"; - final String SS_START_DAY = "saved.state.start.day"; - final String SS_END_YEAR = "saved.state.end.year"; - final String SS_END_MONTH = "saved.state.end.month"; - final String SS_END_DAY = "saved.state.end.day"; - final String SS_HOUR = "saved.state.hour"; - final String SS_MINUTE = "saved.state.minute"; - final String SS_RECURRENCE_OPTION = "saved.state.recurrence.option"; - final String SS_RECURRENCE_RULE = "saved.state.recurrence.rule"; - final String SS_INFO_VIEW_VISIBILITY = "saved.state.info.view.visibility"; - final String SS_SCROLL_Y = "saved.state.scroll.y"; - @Override protected void onSaveInstanceState(Bundle outState) { // Save state of CheckBoxes