-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0562cdb
commit 67b8659
Showing
25 changed files
with
331 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'com.arjungupta08.horizontal_calendar_date' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
minSdk 24 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.12.0' | ||
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0') | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.11.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...src/androidTest/java/com/arjungupta08/horizontal_calendar_date/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.arjungupta08.horizontal_calendar_date | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.arjungupta08.horizontal_calendar_date.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
80 changes: 80 additions & 0 deletions
80
..._calendar_date/src/main/java/com/arjungupta08/horizontal_calendar_date/CalendarAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.arjungupta08.horizontal_calendar_date | ||
|
||
import android.os.Build | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import androidx.annotation.RequiresApi | ||
import androidx.core.content.ContextCompat | ||
import androidx.recyclerview.widget.RecyclerView | ||
import kotlin.collections.ArrayList | ||
|
||
class CalendarAdapter(private val listener: (calendarDateModel: CalendarDateModel, position: Int) -> Unit): | ||
RecyclerView.Adapter<CalendarAdapter.CalendarViewHolder>(){ | ||
|
||
private var list = ArrayList<CalendarDateModel>() | ||
private var adapterPosition = -1 | ||
|
||
|
||
interface OnItemClickListener{ | ||
fun onItemClick(text: String, date: String, day: String) | ||
} | ||
|
||
private var mListener: OnItemClickListener? = null | ||
|
||
fun setOnItemClickListener(listener: OnItemClickListener){ | ||
mListener = listener | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CalendarViewHolder { | ||
val inflater : LayoutInflater = LayoutInflater.from(parent.context) | ||
val view: View = inflater.inflate(R.layout.date_layout,parent,false) | ||
return CalendarViewHolder(view) | ||
} | ||
|
||
|
||
@RequiresApi(Build.VERSION_CODES.O) | ||
override fun onBindViewHolder(holder: CalendarViewHolder, position: Int) { | ||
val itemList = list[position] | ||
holder.calendarDay.text = itemList.calendarDay | ||
holder.calendarDate.text = itemList.calendarDate | ||
|
||
holder.itemView.setOnClickListener { | ||
adapterPosition = position | ||
notifyItemRangeChanged(0, list.size) | ||
|
||
val text = itemList.calendarYear | ||
val date = itemList.calendarDate | ||
val day = itemList.calendarDay | ||
mListener?.onItemClick(text,date,day) | ||
} | ||
if (position == adapterPosition){ | ||
holder.calendarDay.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.white)) | ||
holder.calendarDate.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.white)) | ||
holder.linear.setBackgroundResource(R.drawable.rectangle_fill) | ||
}else { | ||
holder.calendarDay.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black)) | ||
holder.calendarDate.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.black)) | ||
holder.linear.setBackgroundResource(R.drawable.rectangle_outline) | ||
} | ||
} | ||
override fun getItemCount(): Int { | ||
return list.size | ||
} | ||
|
||
class CalendarViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
val calendarDay : TextView= itemView.findViewById(R.id.tv_calendar_day) | ||
val calendarDate : TextView= itemView.findViewById(R.id.tv_calendar_date) | ||
val linear : LinearLayout= itemView.findViewById(R.id.linear_calendar) | ||
} | ||
|
||
fun setData(calendarList: ArrayList<CalendarDateModel>) { | ||
list.clear() | ||
list.addAll(calendarList) | ||
notifyDataSetChanged() | ||
} | ||
} | ||
|
||
|
20 changes: 20 additions & 0 deletions
20
...alendar_date/src/main/java/com/arjungupta08/horizontal_calendar_date/CalendarDateModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.arjungupta08.horizontal_calendar_date | ||
|
||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
data class CalendarDateModel(var data: Date, var isSelected: Boolean = true) { | ||
|
||
val calendarDay: String | ||
get() = SimpleDateFormat("EE", Locale.getDefault()).format(data) | ||
|
||
val calendarYear: String | ||
get() = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format(data) | ||
|
||
val calendarDate: String | ||
get() { | ||
val cal = Calendar.getInstance() | ||
cal.time = data | ||
return cal[Calendar.DAY_OF_MONTH].toString() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
horizontal_calendar_date/src/main/res/drawable/left_arrow.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:autoMirrored="true" android:height="24dp" | ||
android:tint="#000000" android:viewportHeight="24" | ||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M15.41,16.59L10.83,12l4.58,-4.59L14,6l-6,6 6,6 1.41,-1.41z"/> | ||
</vector> |
8 changes: 8 additions & 0 deletions
8
horizontal_calendar_date/src/main/res/drawable/rectangle_fill.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid android:color="#4A7AF7"/> | ||
<corners android:radius="15dp"/> | ||
|
||
</shape> |
8 changes: 8 additions & 0 deletions
8
horizontal_calendar_date/src/main/res/drawable/rectangle_outline.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid android:color="#E9F1EF"/> | ||
<corners android:radius="15dp"/> | ||
|
||
</shape> |
5 changes: 5 additions & 0 deletions
5
horizontal_calendar_date/src/main/res/drawable/right_arrow.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:autoMirrored="true" android:height="24dp" | ||
android:tint="#000000" android:viewportHeight="24" | ||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M8.59,16.59L13.17,12 8.59,7.41 10,6l6,6 -6,6 -1.41,-1.41z"/> | ||
</vector> |
27 changes: 27 additions & 0 deletions
27
horizontal_calendar_date/src/main/res/layout/date_layout.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="70dp" | ||
android:layout_height="95dp" | ||
android:id="@+id/linear_calendar" | ||
android:layout_margin="5dp" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
android:padding="15dp" | ||
android:background="@drawable/rectangle_outline" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<TextView | ||
android:id="@+id/tv_calendar_date" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="11" | ||
android:textSize="14sp" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_calendar_day" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Mon" | ||
android:textSize="14sp" /> | ||
|
||
</LinearLayout> |
16 changes: 16 additions & 0 deletions
16
horizontal_calendar_date/src/main/res/values-night/themes.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<resources xmlns:tools="http://schemas.android.com/tools"> | ||
<!-- Base application theme. --> | ||
<style name="Theme.HorizontalCalendarDate" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> | ||
<!-- Primary brand color. --> | ||
<item name="colorPrimary">@color/purple_200</item> | ||
<item name="colorPrimaryVariant">@color/purple_700</item> | ||
<item name="colorOnPrimary">@color/black</item> | ||
<!-- Secondary brand color. --> | ||
<item name="colorSecondary">@color/teal_200</item> | ||
<item name="colorSecondaryVariant">@color/teal_200</item> | ||
<item name="colorOnSecondary">@color/black</item> | ||
<!-- Status bar color. --> | ||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item> | ||
<!-- Customize your theme here. --> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="purple_200">#FFBB86FC</color> | ||
<color name="purple_500">#FF6200EE</color> | ||
<color name="purple_700">#FF3700B3</color> | ||
<color name="teal_200">#FF03DAC5</color> | ||
<color name="teal_700">#FF018786</color> | ||
<color name="black">#FF000000</color> | ||
<color name="white">#FFFFFFFF</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Horizontal CalendarDate</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<resources xmlns:tools="http://schemas.android.com/tools"> | ||
<!-- Base application theme. --> | ||
<style name="Theme.HorizontalCalendarDate" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> | ||
<!-- Primary brand color. --> | ||
<item name="colorPrimary">@color/purple_500</item> | ||
<item name="colorPrimaryVariant">@color/purple_700</item> | ||
<item name="colorOnPrimary">@color/white</item> | ||
<!-- Secondary brand color. --> | ||
<item name="colorSecondary">@color/teal_200</item> | ||
<item name="colorSecondaryVariant">@color/teal_700</item> | ||
<item name="colorOnSecondary">@color/black</item> | ||
<!-- Status bar color. --> | ||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item> | ||
<!-- Customize your theme here. --> | ||
</style> | ||
</resources> |
Oops, something went wrong.