mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-27 16:50:08 +01:00
display week numbers at month views
This commit is contained in:
parent
71a8c74ff8
commit
1a1fde0d5f
@ -76,8 +76,9 @@ public class CalendarImpl implements DBHelper.DBOperationsListener {
|
|||||||
|
|
||||||
isToday = isThisMonth && isToday(mTargetDate, value);
|
isToday = isThisMonth && isToday(mTargetDate, value);
|
||||||
|
|
||||||
final String dayCode = Formatter.getDayCodeFromDateTime(curDay.withDayOfMonth(value));
|
final DateTime newDay = curDay.withDayOfMonth(value);
|
||||||
final Day day = new Day(value, isThisMonth, isToday, dayCode, hasEvent(dayCode));
|
final String dayCode = Formatter.getDayCodeFromDateTime(newDay);
|
||||||
|
final Day day = new Day(value, isThisMonth, isToday, dayCode, hasEvent(dayCode), newDay.getWeekOfWeekyear());
|
||||||
days.add(day);
|
days.add(day);
|
||||||
value++;
|
value++;
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,16 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateDays(List<Day> days) {
|
public void updateDays(List<Day> days) {
|
||||||
final String packageName = mContext.getPackageName();
|
|
||||||
final int len = days.size();
|
final int len = days.size();
|
||||||
|
final String packageName = mContext.getPackageName();
|
||||||
|
mRemoteViews.setInt(R.id.week_num, "setTextColor", mWeakTextColor);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
final int id = mRes.getIdentifier("week_num_" + i, "id", packageName);
|
||||||
|
mRemoteViews.setTextViewText(id, days.get(i * 7).getWeekOfYear() + ":");
|
||||||
|
mRemoteViews.setInt(id, "setTextColor", mWeakTextColor);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
final Day day = days.get(i);
|
final Day day = days.get(i);
|
||||||
final int id = mRes.getIdentifier("day_" + i, "id", packageName);
|
final int id = mRes.getIdentifier("day_" + i, "id", packageName);
|
||||||
|
@ -184,6 +184,15 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
|
|||||||
|
|
||||||
private void updateDays() {
|
private void updateDays() {
|
||||||
final int len = mDays.size();
|
final int len = mDays.size();
|
||||||
|
final TextView weekNum = (TextView) findViewById(R.id.week_num);
|
||||||
|
weekNum.setTextColor(mWeakTextColor);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
final TextView weekIdTV = (TextView) findViewById(mRes.getIdentifier("week_num_" + i, "id", mPackageName));
|
||||||
|
weekIdTV.setText(mDays.get(i * 7).getWeekOfYear() + ":");
|
||||||
|
weekIdTV.setTextColor(mWeakTextColor);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
final Day day = mDays.get(i);
|
final Day day = mDays.get(i);
|
||||||
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("day_" + i, "id", mPackageName));
|
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("day_" + i, "id", mPackageName));
|
||||||
|
@ -14,6 +14,7 @@ import android.widget.*
|
|||||||
import com.simplemobiletools.calendar.*
|
import com.simplemobiletools.calendar.*
|
||||||
import com.simplemobiletools.calendar.activities.DayActivity
|
import com.simplemobiletools.calendar.activities.DayActivity
|
||||||
import com.simplemobiletools.calendar.models.Day
|
import com.simplemobiletools.calendar.models.Day
|
||||||
|
import kotlinx.android.synthetic.main.first_row.*
|
||||||
import kotlinx.android.synthetic.main.month_fragment.view.*
|
import kotlinx.android.synthetic.main.month_fragment.view.*
|
||||||
import kotlinx.android.synthetic.main.top_navigation.view.*
|
import kotlinx.android.synthetic.main.top_navigation.view.*
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
@ -160,6 +161,13 @@ class MonthFragment : Fragment(), Calendar {
|
|||||||
|
|
||||||
private fun updateDays(days: List<Day>) {
|
private fun updateDays(days: List<Day>) {
|
||||||
val len = days.size
|
val len = days.size
|
||||||
|
week_num.setTextColor(mWeakTextColor)
|
||||||
|
|
||||||
|
for (i in 0..5) {
|
||||||
|
val weekIdTV = mHolder.findViewById(mRes.getIdentifier("week_num_" + i, "id", mPackageName)) as TextView
|
||||||
|
weekIdTV.text = "${days[i * 7].weekOfYear}:"
|
||||||
|
weekIdTV.setTextColor(mWeakTextColor)
|
||||||
|
}
|
||||||
|
|
||||||
for (i in 0..len - 1) {
|
for (i in 0..len - 1) {
|
||||||
val day = days[i]
|
val day = days[i]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.simplemobiletools.calendar.models
|
package com.simplemobiletools.calendar.models
|
||||||
|
|
||||||
class Day(val value: Int, val isThisMonth: Boolean, val isToday: Boolean, val code: String, val hasEvent: Boolean) {
|
class Day(val value: Int, val isThisMonth: Boolean, val isToday: Boolean, val code: String, val hasEvent: Boolean, val weekOfYear: Int) {
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "Day {value=$value, isThisMonth=$isThisMonth, itToday=$isToday, code=$code, hasEvent=$hasEvent}"
|
return "Day {value=$value, isThisMonth=$isThisMonth, itToday=$isToday, code=$code, hasEvent=$hasEvent, weekOfYear=$weekOfYear}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="#"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_0"
|
android:id="@+id/label_0"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
|
@ -27,6 +27,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num_0"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_0"
|
android:id="@+id/day_0"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
@ -83,6 +90,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num_1"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_7"
|
android:id="@+id/day_7"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
@ -139,6 +153,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num_2"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_14"
|
android:id="@+id/day_14"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
@ -195,6 +216,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num_3"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_21"
|
android:id="@+id/day_21"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
@ -251,6 +279,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num_4"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_28"
|
android:id="@+id/day_28"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
@ -307,6 +342,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/week_num_5"
|
||||||
|
style="@style/DayView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_35"
|
android:id="@+id/day_35"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user