Skip to content

Commit

Permalink
Merge pull request #32 from recruit-mp/1.0.1
Browse files Browse the repository at this point in the history
[リリース] Version 1.0.1
  • Loading branch information
recruit-mahayash committed Jan 13, 2017
2 parents 7a97a1d + 94ec734 commit 79b96da
Show file tree
Hide file tree
Showing 54 changed files with 542 additions and 102 deletions.
29 changes: 22 additions & 7 deletions README.md
Expand Up @@ -52,13 +52,14 @@ Lightweight Calendar View can be easily customized by setting properties in the

The following properties are available:

| property name | type | description |
| -------------------------- | ----------------- | ------------------------------------- |
| app:lcv_weekDayTextSize | dimension | The text size of weekdays |
| app:lcv_dayTextSize | dimension | The text size of days |
| app:lcv_textColor | color or resource | The text color of weekdays and days |
| app:lcv_selectionColor | color or resource | The background color of selections |
| app:lcv_accentColor | color or resource | The color of accents |
| property name | type | description |
| -------------------------- | ----------------- | ------------------------------------------------------------------- |
| app:lcv_weekDayTextSize | dimension | The text size of weekdays |
| app:lcv_dayTextSize | dimension | The text size of days |
| app:lcv_textColor | color or resource | The text color of weekdays and days |
| app:lcv_selectionColor | color or resource | The background color of selections |
| app:lcv_accentColor | color or resource | The color of accents |
| app:lcv_firstDayOfWeek | integer | The first day of the week (0 = Sunday, 1 = Monday, ..., 6 = Friday) |

The customizations of text colors of selected days or today are done by setting <selector /> color resources to `app:lcv_textColor`, `app:lcv_selectionColor`, or `app:lcv_accentColor` with the following resource files for example.

Expand Down Expand Up @@ -138,6 +139,20 @@ calendarView.setOnStateUpdatedListener(object : LightCalendarView.OnStateUpdated
}
```

### Coloring Day of The Week

Use `LightCalendarView#setWeekDayFilterColor(weekDay: WeekDay, color: Int?)` and `LightCalendarView#setDayFilterColor(weekDay: WeekDay, color: Int?)` to set the color scheme of day of the week in WeekDayView (e.g. Sunday, Monday, ...) and DayView (e.g. 1, 2, ...) respectively.

```kotlin
// coloring "sunday" (day of the week) in red
calendarView.setWeekDayFilterColor(WeekDay.SUNDAY, Color.RED)

// coloring sundays (days) in red
calendarView.setDayFilterColor(WeekDay.SUNDAY, Color.RED)
```

Note the library internally uses these color as ColorFilter, meaning it is overlayed on top of the text color set through `LightCalendarView#setTextColor(color: Int)`.

### Further Customizations

See [the Wiki](https://github.com/recruit-mp/LightCalendarView/wiki) for more information and descriptions on futher customizations.
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions javasample/build.gradle
@@ -0,0 +1,33 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.1"

defaultConfig {
applicationId "jp.co.recruit.android.lightcalendarview.javasample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(":library")
testCompile 'junit:junit:4.12'
}
File renamed without changes.
16 changes: 16 additions & 0 deletions javasample/src/main/AndroidManifest.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.co.recruit_mp.android.lightcalendarview.javasample">

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
@@ -0,0 +1,86 @@
package jp.co.recruit_mp.android.lightcalendarview.javasample;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import org.jetbrains.annotations.NotNull;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

import jp.co.recruit_mp.android.lightcalendarview.LightCalendarView;
import jp.co.recruit_mp.android.lightcalendarview.MonthView;
import jp.co.recruit_mp.android.lightcalendarview.accent.Accent;
import jp.co.recruit_mp.android.lightcalendarview.accent.DotAccent;

public class MainActivity extends AppCompatActivity {

private SimpleDateFormat formatter = new SimpleDateFormat("MMMM yyyy", Locale.getDefault());

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Calendar calFrom = Calendar.getInstance();
Calendar calTo = Calendar.getInstance();
Calendar calNow = Calendar.getInstance();
calFrom.set(Calendar.MONTH, 0);
calTo.set(Calendar.MONTH, 11);

LightCalendarView calendarView = (LightCalendarView) findViewById(R.id.calendarView);
calendarView.setMonthFrom(calFrom.getTime());
calendarView.setMonthTo(calTo.getTime());
calendarView.setMonthCurrent(calNow.getTime());

// set the calendar view callbacks
calendarView.setOnStateUpdatedListener(new LightCalendarView.OnStateUpdatedListener() {

@Override
public void onMonthSelected(@NotNull Date date, @NotNull final MonthView view) {
getSupportActionBar().setTitle(formatter.format(date));

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Calendar cal = Calendar.getInstance();
List<Date> dates = new ArrayList<Date>();
for (int i = 0; i < 31; i++) {
if (i % 2 == 0) {
cal.set(view.getMonth().getYear() + 1900, view.getMonth().getMonth(), i);
dates.add(cal.getTime());
}
}
HashMap<Date, List<Accent>> map = new HashMap<>();
for (Date date : dates) {
List<Accent> accents = new ArrayList<>();
for (int i = 0; i <= (date.getDate() % 3); i++) {
accents.add(new DotAccent(10f, null, formatter.format(date) + "-" + i));
}
map.put(date, accents);
}
view.setAccents(map);
}
}, 1000);

Log.i("JavaMainActivity", "onMonthSelected: date = " + date);
}

@Override
public void onDateSelected(@NotNull Date date) {
Log.i("JavaMainActivity", "onDateSelected: date = " + date);
}
});

// change the actionbar title
getSupportActionBar().setTitle(formatter.format(calendarView.getMonthCurrent()));
}
}
7 changes: 7 additions & 0 deletions javasample/src/main/res/color/calendar_accent.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#EEEEEE" android:state_active="true" android:state_selected="true" />
<item android:color="#3d52f1" android:state_active="true" />
<item android:color="#EEEEEE" android:state_selected="true" />
<item android:color="#3d52f1" />
</selector>
7 changes: 7 additions & 0 deletions javasample/src/main/res/color/calendar_day_text.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FFFFFF" android:state_active="true" android:state_selected="true" />
<item android:color="#3d4ff1" android:state_active="true" />
<item android:color="#FFFFFF" android:state_selected="true" />
<item android:color="#8D8B95" />
</selector>
5 changes: 5 additions & 0 deletions javasample/src/main/res/color/calendar_selection.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#3d4cf1" android:state_active="true" android:state_selected="true" />
<item android:color="#8D8B95" android:state_selected="true" />
</selector>
Expand Up @@ -27,7 +27,8 @@
app:lcv_dayTextSize="18sp"
app:lcv_textColor="@color/calendar_day_text"
app:lcv_selectionColor="@color/calendar_selection"
app:lcv_accentColor="@color/calendar_accent"/>
app:lcv_accentColor="@color/calendar_accent"
app:lcv_firstDayOfWeek="@integer/lcv_monday"/>

</LinearLayout>
</ScrollView>
Expand Down
6 changes: 6 additions & 0 deletions javasample/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
File renamed without changes.
3 changes: 3 additions & 0 deletions javasample/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">LightCalendarViewJava</string>
</resources>
File renamed without changes.
1 change: 1 addition & 0 deletions kotlinsample/.gitignore
@@ -0,0 +1 @@
/build
2 changes: 1 addition & 1 deletion sample/build.gradle → kotlinsample/build.gradle
Expand Up @@ -6,7 +6,7 @@ android {
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "jp.co.recruit.android.lightcalendarview.sample"
applicationId ""
minSdkVersion 15
targetSdkVersion 23
versionCode 1
Expand Down
17 changes: 17 additions & 0 deletions kotlinsample/proguard-rules.pro
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/masayuki-recruit/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 *;
#}
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.co.recruit_mp.android.lightcalendarview.sample">
package="jp.co.recruit_mp.android.lightcalendarview.kotlinsample">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="jp.co.recruit_mp.android.lightcalendarview.sample.MainActivity">
<activity android:name="jp.co.recruit_mp.android.lightcalendarview.kotlinsample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
@@ -1,16 +1,13 @@
package jp.co.recruit_mp.android.lightcalendarview.sample
package jp.co.recruit_mp.android.lightcalendarview.kotlinsample

import android.os.Bundle
import android.os.Handler
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.Menu
import android.widget.Button
import jp.co.recruit_mp.android.lightcalendarview.LightCalendarView
import jp.co.recruit_mp.android.lightcalendarview.MonthView
import jp.co.recruit_mp.android.lightcalendarview.accent.Accent
import jp.co.recruit_mp.android.lightcalendarview.accent.DotAccent
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.*

Expand Down Expand Up @@ -65,9 +62,6 @@ class MainActivity : AppCompatActivity() {
})

// change the actionbar title
supportActionBar?.apply {
title = formatter.format(calendarView.let { it.getDateForPosition(it.currentItem) })
}

supportActionBar?.title = formatter.format(calendarView.monthCurrent)
}
}
36 changes: 36 additions & 0 deletions kotlinsample/src/main/res/layout/activity_main.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<jp.co.recruit_mp.android.lightcalendarview.LightCalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:lcv_weekDayTextSize="18sp"
app:lcv_dayTextSize="18sp"
app:lcv_textColor="@color/calendar_day_text"
app:lcv_selectionColor="@color/calendar_selection"
app:lcv_accentColor="@color/calendar_accent"
app:lcv_firstDayOfWeek="@integer/lcv_monday"/>

</LinearLayout>
</ScrollView>

</RelativeLayout>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions kotlinsample/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
File renamed without changes.
5 changes: 5 additions & 0 deletions kotlinsample/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
3 changes: 3 additions & 0 deletions kotlinsample/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">LightCalendarViewKotlin</string>
</resources>
11 changes: 11 additions & 0 deletions kotlinsample/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
@@ -0,0 +1,12 @@
package jp.co.recruit_mp.android.lightcalendarview

import java.util.*

/**
* Created by recruit-mahayash on 2017/01/13.
*/
class CalendarKt : GregorianCalendar() {
companion object {
fun getInstance(settings: CalendarSettings) = getInstance(settings.timeZone, settings.locale)
}
}

0 comments on commit 79b96da

Please sign in to comment.