mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
handle widget properly too
This commit is contained in:
@ -45,7 +45,9 @@ public class CalendarImpl implements DBHelper.DBOperationsListener {
|
|||||||
final List<Day> days = new ArrayList<>(DAYS_CNT);
|
final List<Day> days = new ArrayList<>(DAYS_CNT);
|
||||||
|
|
||||||
final int currMonthDays = mTargetDate.dayOfMonth().getMaximumValue();
|
final int currMonthDays = mTargetDate.dayOfMonth().getMaximumValue();
|
||||||
final int firstDayIndex = mTargetDate.withDayOfMonth(1).getDayOfWeek() - 1;
|
int firstDayIndex = mTargetDate.withDayOfMonth(1).getDayOfWeek();
|
||||||
|
if (!Config.newInstance(mContext).getIsSundayFirst())
|
||||||
|
firstDayIndex -= 1;
|
||||||
final int prevMonthDays = mTargetDate.minusMonths(1).dayOfMonth().getMaximumValue();
|
final int prevMonthDays = mTargetDate.minusMonths(1).dayOfMonth().getMaximumValue();
|
||||||
|
|
||||||
boolean isThisMonth = false;
|
boolean isThisMonth = false;
|
||||||
|
@ -182,10 +182,18 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLabelColor() {
|
private void updateLabelColor() {
|
||||||
|
final boolean mSundayFirst = Config.newInstance(mContext).getIsSundayFirst();
|
||||||
final String packageName = mContext.getPackageName();
|
final String packageName = mContext.getPackageName();
|
||||||
|
int letters[] = Utils.getLetterIDs();
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
final int id = mRes.getIdentifier("label_" + i, "id", packageName);
|
final int id = mRes.getIdentifier("label_" + i, "id", packageName);
|
||||||
mRemoteViews.setInt(id, "setTextColor", mWeakTextColor);
|
mRemoteViews.setInt(id, "setTextColor", mWeakTextColor);
|
||||||
|
|
||||||
|
int index = i;
|
||||||
|
if (!mSundayFirst)
|
||||||
|
index = (index + 1) % letters.length;
|
||||||
|
|
||||||
|
mRemoteViews.setTextViewText(id, mContext.getResources().getString(letters[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,4 +42,9 @@ public class Utils {
|
|||||||
final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, notifInMs, pendingIntent);
|
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, notifInMs, pendingIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int[] getLetterIDs() {
|
||||||
|
return new int[]{R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter,
|
||||||
|
R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,8 +223,7 @@ public class MainActivity extends SimpleActivity implements Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupLabels() {
|
private void setupLabels() {
|
||||||
int letters[] = {R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter,
|
int letters[] = Utils.getLetterIDs();
|
||||||
R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter};
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("label_" + i, "id", mPackageName));
|
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("label_" + i, "id", mPackageName));
|
||||||
|
@ -11,48 +11,55 @@
|
|||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/monday_letter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_1"
|
android:id="@+id/label_1"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/tuesday_letter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_2"
|
android:id="@+id/label_2"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/wednesday_letter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_3"
|
android:id="@+id/label_3"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/thursday_letter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_4"
|
android:id="@+id/label_4"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/friday_letter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_5"
|
android:id="@+id/label_5"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/saturday_letter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_6"
|
android:id="@+id/label_6"
|
||||||
style="@style/DayView"
|
style="@style/DayView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/sunday_letter"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Reference in New Issue
Block a user