update day labels based on settings
This commit is contained in:
parent
7f783da9c5
commit
9d62e7710c
|
@ -54,6 +54,7 @@ public class MainActivity extends SimpleActivity implements Calendar {
|
||||||
private int mWeakTextColor;
|
private int mWeakTextColor;
|
||||||
private int mTextColorWithEvent;
|
private int mTextColorWithEvent;
|
||||||
private int mWeakTextColorWithEvent;
|
private int mWeakTextColorWithEvent;
|
||||||
|
private boolean mSundayFirst;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -69,6 +70,7 @@ public class MainActivity extends SimpleActivity implements Calendar {
|
||||||
mWeakTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.LOW_ALPHA);
|
mWeakTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.LOW_ALPHA);
|
||||||
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
mSundayFirst = mConfig.getIsSundayFirst();
|
||||||
|
|
||||||
mPackageName = getPackageName();
|
mPackageName = getPackageName();
|
||||||
mDayTextSize /= mRes.getDisplayMetrics().density;
|
mDayTextSize /= mRes.getDisplayMetrics().density;
|
||||||
|
@ -85,6 +87,10 @@ public class MainActivity extends SimpleActivity implements Calendar {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mCalendar.updateCalendar(new DateTime());
|
mCalendar.updateCalendar(new DateTime());
|
||||||
|
if (mConfig.getIsSundayFirst() != mSundayFirst) {
|
||||||
|
mSundayFirst = mConfig.getIsSundayFirst();
|
||||||
|
setupLabels();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -217,11 +223,20 @@ 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,
|
||||||
|
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));
|
||||||
if (dayTV != null) {
|
if (dayTV != null) {
|
||||||
dayTV.setTextSize(mDayTextSize);
|
dayTV.setTextSize(mDayTextSize);
|
||||||
dayTV.setTextColor(mWeakTextColor);
|
dayTV.setTextColor(mWeakTextColor);
|
||||||
|
|
||||||
|
int index = i;
|
||||||
|
if (!mSundayFirst)
|
||||||
|
index = (index + 1) % letters.length;
|
||||||
|
|
||||||
|
dayTV.setText(getString(letters[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,55 +11,48 @@
|
||||||
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/wednesday_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>
|
||||||
|
|
Loading…
Reference in New Issue