diff --git a/src/.idea/compiler.xml b/src/.idea/compiler.xml index 659bf43..fb7f4a8 100644 --- a/src/.idea/compiler.xml +++ b/src/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/.idea/gradle.xml b/src/.idea/gradle.xml index 18de3ac..f667072 100644 --- a/src/.idea/gradle.xml +++ b/src/.idea/gradle.xml @@ -1,5 +1,6 @@ + diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml index df8860d..860da66 100644 --- a/src/.idea/misc.xml +++ b/src/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/src/.idea/runConfigurations.xml b/src/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/src/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/src/CalendarView/.gitignore b/src/CalendarView/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/src/CalendarView/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/src/CalendarView/build.gradle b/src/CalendarView/build.gradle new file mode 100644 index 0000000..8bc4f08 --- /dev/null +++ b/src/CalendarView/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'com.android.library' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + minSdkVersion 29 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + 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 + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.3.0' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} \ No newline at end of file diff --git a/src/CalendarView/consumer-rules.pro b/src/CalendarView/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/src/CalendarView/proguard-rules.pro b/src/CalendarView/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/src/CalendarView/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/src/CalendarView/src/androidTest/java/com/idealist/calendarview/ExampleInstrumentedTest.java b/src/CalendarView/src/androidTest/java/com/idealist/calendarview/ExampleInstrumentedTest.java new file mode 100644 index 0000000..f2ba98f --- /dev/null +++ b/src/CalendarView/src/androidTest/java/com/idealist/calendarview/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.idealist.calendarview; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.idealist.calendarview.test", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/src/CalendarView/src/main/AndroidManifest.xml b/src/CalendarView/src/main/AndroidManifest.xml new file mode 100644 index 0000000..3e39193 --- /dev/null +++ b/src/CalendarView/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/src/CalendarView/src/main/java/com/idealist/calendarview/CalendarAttr.java b/src/CalendarView/src/main/java/com/idealist/calendarview/CalendarAttr.java new file mode 100644 index 0000000..d38df74 --- /dev/null +++ b/src/CalendarView/src/main/java/com/idealist/calendarview/CalendarAttr.java @@ -0,0 +1,86 @@ +package com.idealist.calendarview; + + +public class CalendarAttr { + + static int RecTop; + + private int mItemHeight; + + private int mRowCount; + + private int mViewHeight; + + private int mCalendarType; + + private int mTextSize; + + private int mScrollLevel; + + private int TouchSlop; + + public CalendarAttr() { + mItemHeight = State.DEFAULT_ITEM_HEIGHT; + mTextSize = State.DEFAULT_TEXT_SIZE; + } + + public int getRowCount() { + return mRowCount; + } + + private void setRowCount(int mRowCount) { + this.mRowCount = mRowCount; + mViewHeight = mItemHeight * mRowCount; + } + + public int getItemHeight() { + return mItemHeight; + } + + public void setItemHeight(int mItemHeight) { + this.mItemHeight = mItemHeight; + mViewHeight = mRowCount * mItemHeight; + } + + public int getViewHeight() { + return mViewHeight; + } + + public void setViewHeight(int mViewHeight) { + this.mViewHeight = mViewHeight; + mItemHeight = mViewHeight / mRowCount; + } + + public int getTextSize() { + return mTextSize; + } + + public void setTextSize(int mTextSize) { + this.mTextSize = mTextSize; + } + + public int getCalendarType() { + return mCalendarType; + } + + public void setCalendarType(int mCalendarType) { + this.mCalendarType = mCalendarType; + setRowCount((mCalendarType == State.VIEW_WEEK) ? 1 : 6); + } + + public static int getRecTop() { + return RecTop; + } + + public static void setRecTop(int recTop) { + RecTop = recTop; + } + + public int getScrollLevel() { + return mScrollLevel; + } + + public void setScrollLevel(int mScrollLevel) { + this.mScrollLevel = mScrollLevel; + } +} diff --git a/src/CalendarView/src/main/java/com/idealist/calendarview/CalendarDay.java b/src/CalendarView/src/main/java/com/idealist/calendarview/CalendarDay.java new file mode 100644 index 0000000..dfaf9f0 --- /dev/null +++ b/src/CalendarView/src/main/java/com/idealist/calendarview/CalendarDay.java @@ -0,0 +1,97 @@ +package com.idealist.calendarview; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public class CalendarDay { + private int year; + + private int month; + + private int day; + + private boolean isCurrDay; + + private boolean markSchedule; + + private int mMonthState; + + private int mSelectState; + + public CalendarDay() { + ; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public int getMonth() { + return month; + } + + public void setMonth(int month) { + this.month = month; + } + + public int getDay() { + return day; + } + + public void setDay(int day) { + this.day = day; + } + + public boolean isCurrDay() { + return isCurrDay; + } + + public void setCurrDay(boolean currDay) { + this.isCurrDay = currDay; + } + + public int getMonthState() { + return mMonthState; + } + + public void setMonthState(int mMonthState) { + this.mMonthState = mMonthState; + } + + public int getSelectState() { + return mSelectState; + } + + public void setSelectState(int mSelectState) { + this.mSelectState = mSelectState; + } + + public boolean isMarkSchedule() { + return markSchedule; + } + + public void setMarkSchedule(boolean markSchedule) { + this.markSchedule = markSchedule; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj instanceof CalendarDay) { + return ((CalendarDay) obj).day == this.day && ((CalendarDay) obj).month == this.month && + ((CalendarDay) obj).year == this.year; + } + return super.equals(obj); + } + + @NonNull + @Override + public String toString() { + return this.year + "-" + this.month + "-" + this.day; + } + + +} diff --git a/src/CalendarView/src/main/java/com/idealist/calendarview/State.java b/src/CalendarView/src/main/java/com/idealist/calendarview/State.java new file mode 100644 index 0000000..eb6cefb --- /dev/null +++ b/src/CalendarView/src/main/java/com/idealist/calendarview/State.java @@ -0,0 +1,36 @@ +package com.idealist.calendarview; + +public final class State { + + public static final int DAY_UN_SELECT = 0; + + public static final int DAY_SELECT = 1; + + public static final int DAY_CURR_MONTH = 0; + + public static final int DAY_PAST_MONTH = -1; + + public static final int DAY_NEXT_MONTH = 1; + + public static final int VIEW_WEEK = 1; + + public static final int VIEW_MONTH = 2; + + public static final int VIEW_FULL = 3; + + public static final int LEVEL_TOP = 1; + + public static final int LEVEL_MEDIUM = 2; + + public static final int LEVEL_BOTTOM = 3; + + public static final int DEFAULT_ITEM_HEIGHT = 180; + + public static final int DEFAULT_TEXT_SIZE = 80; + + public static int DEFAULT_ITEM_HEIGHT_FULL; + + public static void setDefaultItemHeightFull(int defaultItemHeightFull) { + DEFAULT_ITEM_HEIGHT_FULL = defaultItemHeightFull; + } +} diff --git a/src/CalendarView/src/test/java/com/idealist/calendarview/ExampleUnitTest.java b/src/CalendarView/src/test/java/com/idealist/calendarview/ExampleUnitTest.java new file mode 100644 index 0000000..1511aba --- /dev/null +++ b/src/CalendarView/src/test/java/com/idealist/calendarview/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.idealist.calendarview; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/src/settings.gradle b/src/settings.gradle index 8cedfc0..577b904 100644 --- a/src/settings.gradle +++ b/src/settings.gradle @@ -1,2 +1,3 @@ include ':app' -rootProject.name = "My Application" \ No newline at end of file +rootProject.name = "My Application" +include ':CalendarView'