From 1c2c907768b245b144ac6816581ed16dd3cc8f77 Mon Sep 17 00:00:00 2001 From: Alexander Surinov Date: Tue, 14 May 2019 17:16:58 +0300 Subject: [PATCH] Add `calendar` prefix for all library resources to avoid collisions with resources from other clients modules --- crunchycalendar/build.gradle | 5 +++++ .../ru/cleverpumpkin/calendar/CalendarView.kt | 8 ++++---- .../java/ru/cleverpumpkin/calendar/DaysBarView.kt | 2 +- .../cleverpumpkin/calendar/YearSelectionView.kt | 12 ++++++------ .../calendar/adapter/CalendarAdapter.kt | 2 +- .../calendar/extension/ContextExtenison.kt | 7 +++++++ ...in_bottom.xml => calendar_slide_in_bottom.xml} | 4 ++-- ...slide_in_top.xml => calendar_slide_in_top.xml} | 4 ++-- ...t_bottom.xml => calendar_slide_out_bottom.xml} | 4 ++-- ...ide_out_top.xml => calendar_slide_out_top.xml} | 4 ++-- ...w.xml => calendar_days_of_week_bar_shadow.xml} | 0 ...w_left_24dp.xml => calendar_ic_arrow_left.xml} | 0 ...right_24dp.xml => calendar_ic_arrow_right.xml} | 0 ...ew_days_bar.xml => calendar_days_bar_view.xml} | 3 ++- .../{item_month.xml => calendar_item_month.xml} | 8 ++++---- .../{view_calendar.xml => calendar_view.xml} | 14 +++++++------- ...ction.xml => calendar_year_selection_view.xml} | 15 ++++++++------- .../src/main/res/values-ldrtl/integers.xml | 2 +- crunchycalendar/src/main/res/values/dimens.xml | 4 ++-- crunchycalendar/src/main/res/values/integers.xml | 4 ++-- crunchycalendar/src/main/res/values/styles.xml | 14 +++++++------- 21 files changed, 65 insertions(+), 51 deletions(-) rename crunchycalendar/src/main/res/anim/{slide_in_bottom.xml => calendar_slide_in_bottom.xml} (67%) rename crunchycalendar/src/main/res/anim/{slide_in_top.xml => calendar_slide_in_top.xml} (68%) rename crunchycalendar/src/main/res/anim/{slide_out_bottom.xml => calendar_slide_out_bottom.xml} (67%) rename crunchycalendar/src/main/res/anim/{slide_out_top.xml => calendar_slide_out_top.xml} (68%) rename crunchycalendar/src/main/res/drawable/{shadow.xml => calendar_days_of_week_bar_shadow.xml} (100%) rename crunchycalendar/src/main/res/drawable/{ic_keyboard_arrow_left_24dp.xml => calendar_ic_arrow_left.xml} (100%) rename crunchycalendar/src/main/res/drawable/{ic_keyboard_arrow_right_24dp.xml => calendar_ic_arrow_right.xml} (100%) rename crunchycalendar/src/main/res/layout/{view_days_bar.xml => calendar_days_bar_view.xml} (92%) rename crunchycalendar/src/main/res/layout/{item_month.xml => calendar_item_month.xml} (66%) rename crunchycalendar/src/main/res/layout/{view_calendar.xml => calendar_view.xml} (63%) rename crunchycalendar/src/main/res/layout/{view_year_selection.xml => calendar_year_selection_view.xml} (73%) diff --git a/crunchycalendar/build.gradle b/crunchycalendar/build.gradle index 1075141..6d39187 100644 --- a/crunchycalendar/build.gradle +++ b/crunchycalendar/build.gradle @@ -53,6 +53,11 @@ android { } } +android { + // Use resource prefix to avoid collisions with resources from other modules. + resourcePrefix 'calendar_' +} + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) diff --git a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/CalendarView.kt b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/CalendarView.kt index a2b39b6..2e49e8f 100644 --- a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/CalendarView.kt +++ b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/CalendarView.kt @@ -244,11 +244,11 @@ class CalendarView @JvmOverloads constructor( * Init block where we read custom attributes and set up internal views. */ init { - LayoutInflater.from(context).inflate(R.layout.view_calendar, this, true) + LayoutInflater.from(context).inflate(R.layout.calendar_view, this, true) - yearSelectionView = findViewById(R.id.year_selection_view) - daysBarView = findViewById(R.id.days_bar_view) - recyclerView = findViewById(R.id.recycler_view) + yearSelectionView = findViewById(R.id.calendar_year_selection_view) + daysBarView = findViewById(R.id.calendar_days_bar_view) + recyclerView = findViewById(R.id.calendar_recycler_view) if (attrs != null) { CalendarStyleAttributesReader.readStyleAttributes( diff --git a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/DaysBarView.kt b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/DaysBarView.kt index 12a0994..cb275ee 100644 --- a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/DaysBarView.kt +++ b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/DaysBarView.kt @@ -26,7 +26,7 @@ internal class DaysBarView @JvmOverloads constructor( } init { - LayoutInflater.from(context).inflate(R.layout.view_days_bar, this, true) + LayoutInflater.from(context).inflate(R.layout.calendar_days_bar_view, this, true) } fun applyStyle(styleAttributes: CalendarStyleAttributes) { diff --git a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/YearSelectionView.kt b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/YearSelectionView.kt index 78c6531..e42ca2f 100644 --- a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/YearSelectionView.kt +++ b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/YearSelectionView.kt @@ -5,13 +5,13 @@ import android.content.res.ColorStateList import android.util.AttributeSet import android.view.LayoutInflater import android.view.View.OnClickListener -import android.view.animation.AnimationUtils import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextSwitcher import android.widget.TextView import androidx.annotation.AttrRes import androidx.core.widget.ImageViewCompat +import ru.cleverpumpkin.calendar.extension.loadAnim import ru.cleverpumpkin.calendar.style.CalendarStyleAttributes import java.text.SimpleDateFormat import java.util.* @@ -35,10 +35,10 @@ internal class YearSelectionView @JvmOverloads constructor( private val arrowNextView: ImageView private val textSwitcher: TextSwitcher - private val slideInBottomAnim = AnimationUtils.loadAnimation(context, R.anim.slide_in_bottom) - private val slideInTopAnim = AnimationUtils.loadAnimation(context, R.anim.slide_in_top) - private val slideOutBottomAnim = AnimationUtils.loadAnimation(context, R.anim.slide_out_bottom) - private val slideOutTopAnim = AnimationUtils.loadAnimation(context, R.anim.slide_out_top) + private val slideInBottomAnim = context.loadAnim(R.anim.calendar_slide_in_bottom) + private val slideInTopAnim = context.loadAnim(R.anim.calendar_slide_in_top) + private val slideOutBottomAnim = context.loadAnim(R.anim.calendar_slide_out_bottom) + private val slideOutTopAnim = context.loadAnim(R.anim.calendar_slide_out_top) private val yearFormatter = SimpleDateFormat(YEAR_FORMAT, Locale.getDefault()) private var minMaxDatesRange = NullableDatesRange() @@ -60,7 +60,7 @@ internal class YearSelectionView @JvmOverloads constructor( var onYearClickListener: ((Int) -> Unit)? = null init { - LayoutInflater.from(context).inflate(R.layout.view_year_selection, this, true) + LayoutInflater.from(context).inflate(R.layout.calendar_year_selection_view, this, true) arrowPrevView = findViewById(R.id.arrow_prev) arrowNextView = findViewById(R.id.arrow_next) diff --git a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/adapter/CalendarAdapter.kt b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/adapter/CalendarAdapter.kt index d1e02aa..d34e497 100644 --- a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/adapter/CalendarAdapter.kt +++ b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/adapter/CalendarAdapter.kt @@ -101,7 +101,7 @@ internal class CalendarAdapter( } private fun createMonthItemViewHolder(parent: ViewGroup): MonthItemViewHolder { - val view = LayoutInflater.from(parent.context).inflate(R.layout.item_month, parent, false) + val view = LayoutInflater.from(parent.context).inflate(R.layout.calendar_item_month, parent, false) return MonthItemViewHolder(view as TextView) } diff --git a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/extension/ContextExtenison.kt b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/extension/ContextExtenison.kt index 1b9ddf9..92bead8 100644 --- a/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/extension/ContextExtenison.kt +++ b/crunchycalendar/src/main/java/ru/cleverpumpkin/calendar/extension/ContextExtenison.kt @@ -2,6 +2,9 @@ package ru.cleverpumpkin.calendar.extension import android.content.Context import android.util.TypedValue +import android.view.animation.Animation +import android.view.animation.AnimationUtils +import androidx.annotation.AnimRes import androidx.annotation.ColorInt import androidx.annotation.ColorRes import androidx.core.content.ContextCompat @@ -17,4 +20,8 @@ fun Context.dpToPix(dpValue: Float): Float { @ColorInt fun Context.getColorInt(@ColorRes colorRes: Int): Int { return ContextCompat.getColor(this, colorRes) +} + +fun Context.loadAnim(@AnimRes animResId: Int): Animation { + return AnimationUtils.loadAnimation(this, animResId) } \ No newline at end of file diff --git a/crunchycalendar/src/main/res/anim/slide_in_bottom.xml b/crunchycalendar/src/main/res/anim/calendar_slide_in_bottom.xml similarity index 67% rename from crunchycalendar/src/main/res/anim/slide_in_bottom.xml rename to crunchycalendar/src/main/res/anim/calendar_slide_in_bottom.xml index 651929f..64fa784 100644 --- a/crunchycalendar/src/main/res/anim/slide_in_bottom.xml +++ b/crunchycalendar/src/main/res/anim/calendar_slide_in_bottom.xml @@ -2,12 +2,12 @@ diff --git a/crunchycalendar/src/main/res/anim/slide_in_top.xml b/crunchycalendar/src/main/res/anim/calendar_slide_in_top.xml similarity index 68% rename from crunchycalendar/src/main/res/anim/slide_in_top.xml rename to crunchycalendar/src/main/res/anim/calendar_slide_in_top.xml index 216cdd3..68cdfb6 100644 --- a/crunchycalendar/src/main/res/anim/slide_in_top.xml +++ b/crunchycalendar/src/main/res/anim/calendar_slide_in_top.xml @@ -2,12 +2,12 @@ diff --git a/crunchycalendar/src/main/res/anim/slide_out_bottom.xml b/crunchycalendar/src/main/res/anim/calendar_slide_out_bottom.xml similarity index 67% rename from crunchycalendar/src/main/res/anim/slide_out_bottom.xml rename to crunchycalendar/src/main/res/anim/calendar_slide_out_bottom.xml index 3d57c5f..13932ce 100644 --- a/crunchycalendar/src/main/res/anim/slide_out_bottom.xml +++ b/crunchycalendar/src/main/res/anim/calendar_slide_out_bottom.xml @@ -2,12 +2,12 @@ diff --git a/crunchycalendar/src/main/res/anim/slide_out_top.xml b/crunchycalendar/src/main/res/anim/calendar_slide_out_top.xml similarity index 68% rename from crunchycalendar/src/main/res/anim/slide_out_top.xml rename to crunchycalendar/src/main/res/anim/calendar_slide_out_top.xml index 0e93d45..c208bdf 100644 --- a/crunchycalendar/src/main/res/anim/slide_out_top.xml +++ b/crunchycalendar/src/main/res/anim/calendar_slide_out_top.xml @@ -2,12 +2,12 @@ diff --git a/crunchycalendar/src/main/res/drawable/shadow.xml b/crunchycalendar/src/main/res/drawable/calendar_days_of_week_bar_shadow.xml similarity index 100% rename from crunchycalendar/src/main/res/drawable/shadow.xml rename to crunchycalendar/src/main/res/drawable/calendar_days_of_week_bar_shadow.xml diff --git a/crunchycalendar/src/main/res/drawable/ic_keyboard_arrow_left_24dp.xml b/crunchycalendar/src/main/res/drawable/calendar_ic_arrow_left.xml similarity index 100% rename from crunchycalendar/src/main/res/drawable/ic_keyboard_arrow_left_24dp.xml rename to crunchycalendar/src/main/res/drawable/calendar_ic_arrow_left.xml diff --git a/crunchycalendar/src/main/res/drawable/ic_keyboard_arrow_right_24dp.xml b/crunchycalendar/src/main/res/drawable/calendar_ic_arrow_right.xml similarity index 100% rename from crunchycalendar/src/main/res/drawable/ic_keyboard_arrow_right_24dp.xml rename to crunchycalendar/src/main/res/drawable/calendar_ic_arrow_right.xml diff --git a/crunchycalendar/src/main/res/layout/view_days_bar.xml b/crunchycalendar/src/main/res/layout/calendar_days_bar_view.xml similarity index 92% rename from crunchycalendar/src/main/res/layout/view_days_bar.xml rename to crunchycalendar/src/main/res/layout/calendar_days_bar_view.xml index c587a0f..aa80722 100644 --- a/crunchycalendar/src/main/res/layout/view_days_bar.xml +++ b/crunchycalendar/src/main/res/layout/calendar_days_bar_view.xml @@ -1,5 +1,6 @@ - \ No newline at end of file diff --git a/crunchycalendar/src/main/res/layout/view_calendar.xml b/crunchycalendar/src/main/res/layout/calendar_view.xml similarity index 63% rename from crunchycalendar/src/main/res/layout/view_calendar.xml rename to crunchycalendar/src/main/res/layout/calendar_view.xml index d1e2ddf..c90f35d 100644 --- a/crunchycalendar/src/main/res/layout/view_calendar.xml +++ b/crunchycalendar/src/main/res/layout/calendar_view.xml @@ -5,26 +5,26 @@ android:layout_height="match_parent"> + android:layout_below="@id/calendar_year_selection_view" /> + android:layout_below="@id/calendar_days_bar_view" /> + android:layout_below="@id/calendar_days_bar_view" + android:background="@drawable/calendar_days_of_week_bar_shadow" /> \ No newline at end of file diff --git a/crunchycalendar/src/main/res/layout/view_year_selection.xml b/crunchycalendar/src/main/res/layout/calendar_year_selection_view.xml similarity index 73% rename from crunchycalendar/src/main/res/layout/view_year_selection.xml rename to crunchycalendar/src/main/res/layout/calendar_year_selection_view.xml index 4c96358..d4805e0 100644 --- a/crunchycalendar/src/main/res/layout/view_year_selection.xml +++ b/crunchycalendar/src/main/res/layout/calendar_year_selection_view.xml @@ -1,5 +1,6 @@ - @@ -37,10 +38,10 @@ \ No newline at end of file diff --git a/crunchycalendar/src/main/res/values-ldrtl/integers.xml b/crunchycalendar/src/main/res/values-ldrtl/integers.xml index aa87cda..f511566 100644 --- a/crunchycalendar/src/main/res/values-ldrtl/integers.xml +++ b/crunchycalendar/src/main/res/values-ldrtl/integers.xml @@ -1,4 +1,4 @@ - 180 + 180 \ No newline at end of file diff --git a/crunchycalendar/src/main/res/values/dimens.xml b/crunchycalendar/src/main/res/values/dimens.xml index e3f4c43..96593dd 100644 --- a/crunchycalendar/src/main/res/values/dimens.xml +++ b/crunchycalendar/src/main/res/values/dimens.xml @@ -1,7 +1,7 @@ - 8dp - 16dp + 8dp + 16dp 24dp 21sp diff --git a/crunchycalendar/src/main/res/values/integers.xml b/crunchycalendar/src/main/res/values/integers.xml index 86d10c5..444be49 100644 --- a/crunchycalendar/src/main/res/values/integers.xml +++ b/crunchycalendar/src/main/res/values/integers.xml @@ -1,5 +1,5 @@ - 0 - 300 + 0 + 300 \ No newline at end of file diff --git a/crunchycalendar/src/main/res/values/styles.xml b/crunchycalendar/src/main/res/values/styles.xml index 412b916..f20b703 100644 --- a/crunchycalendar/src/main/res/values/styles.xml +++ b/crunchycalendar/src/main/res/values/styles.xml @@ -16,30 +16,30 @@ center - - - - -