update day labels based on settings

This commit is contained in:
tibbi 2016-09-09 19:49:57 +02:00
parent 7f783da9c5
commit 9d62e7710c
2 changed files with 22 additions and 14 deletions

View File

@ -54,6 +54,7 @@ public class MainActivity extends SimpleActivity implements Calendar {
private int mWeakTextColor;
private int mTextColorWithEvent;
private int mWeakTextColorWithEvent;
private boolean mSundayFirst;
@Override
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);
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
mSundayFirst = mConfig.getIsSundayFirst();
mPackageName = getPackageName();
mDayTextSize /= mRes.getDisplayMetrics().density;
@ -85,6 +87,10 @@ public class MainActivity extends SimpleActivity implements Calendar {
protected void onResume() {
super.onResume();
mCalendar.updateCalendar(new DateTime());
if (mConfig.getIsSundayFirst() != mSundayFirst) {
mSundayFirst = mConfig.getIsSundayFirst();
setupLabels();
}
}
@Override
@ -217,11 +223,20 @@ public class MainActivity extends SimpleActivity implements Calendar {
}
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++) {
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("label_" + i, "id", mPackageName));
if (dayTV != null) {
dayTV.setTextSize(mDayTextSize);
dayTV.setTextColor(mWeakTextColor);
int index = i;
if (!mSundayFirst)
index = (index + 1) % letters.length;
dayTV.setText(getString(letters[index]));
}
}
}

View File

@ -11,55 +11,48 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/monday_letter"/>
android:layout_weight="1"/>
<TextView
android:id="@+id/label_1"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/tuesday_letter"/>
android:layout_weight="1"/>
<TextView
android:id="@+id/label_2"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/wednesday_letter"/>
android:layout_weight="1"/>
<TextView
android:id="@+id/label_3"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/wednesday_letter"/>
android:layout_weight="1"/>
<TextView
android:id="@+id/label_4"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/friday_letter"/>
android:layout_weight="1"/>
<TextView
android:id="@+id/label_5"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/saturday_letter"/>
android:layout_weight="1"/>
<TextView
android:id="@+id/label_6"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/sunday_letter"/>
android:layout_weight="1"/>
</LinearLayout>