toggle week number visibility depending on settings, close #31

This commit is contained in:
tibbi 2016-10-05 00:01:20 +02:00
parent 5392ea00d4
commit 2f94fb6dda
5 changed files with 34 additions and 13 deletions

View File

@ -17,6 +17,7 @@ import android.graphics.LightingColorFilter;
import android.graphics.Paint;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
import android.view.View;
import android.widget.RemoteViews;
import com.simplemobiletools.calendar.activities.DayActivity;
@ -129,14 +130,17 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
}
public void updateDays(List<Day> days) {
final boolean displayWeekNumbers = Config.newInstance(mContext).getDisplayWeekNumbers();
final int len = days.size();
final String packageName = mContext.getPackageName();
mRemoteViews.setInt(R.id.week_num, "setTextColor", mWeakTextColor);
mRemoteViews.setViewVisibility(R.id.week_num, displayWeekNumbers ? View.VISIBLE : View.GONE);
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);
mRemoteViews.setViewVisibility(id, displayWeekNumbers ? View.VISIBLE : View.GONE);
}
for (int i = 0; i < len; i++) {

View File

@ -17,6 +17,7 @@ import android.widget.TextView;
import com.simplemobiletools.calendar.Calendar;
import com.simplemobiletools.calendar.CalendarImpl;
import com.simplemobiletools.calendar.Config;
import com.simplemobiletools.calendar.Constants;
import com.simplemobiletools.calendar.MyWidgetProvider;
import com.simplemobiletools.calendar.R;
@ -184,13 +185,18 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
private void updateDays() {
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);
if (Config.newInstance(getApplicationContext()).getDisplayWeekNumbers()) {
final TextView weekNum = (TextView) findViewById(R.id.week_num);
weekNum.setTextColor(mWeakTextColor);
weekNum.setVisibility(View.VISIBLE);
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);
weekIdTV.setVisibility(View.VISIBLE);
}
}
for (int i = 0; i < len; i++) {

View File

@ -160,13 +160,17 @@ class MonthFragment : Fragment(), Calendar {
}
private fun updateDays(days: List<Day>) {
val displayWeekNumbers = mConfig.displayWeekNumbers
val len = days.size
week_num.setTextColor(mWeakTextColor)
week_num.visibility = if (displayWeekNumbers) View.VISIBLE else View.GONE
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)
weekIdTV.visibility = if (displayWeekNumbers) View.VISIBLE else View.GONE
}
for (i in 0..len - 1) {

View File

@ -12,7 +12,8 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#"/>
android:text="#"
android:visibility="gone"/>
<TextView
android:id="@+id/label_0"

View File

@ -32,7 +32,8 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1"
android:visibility="gone"/>
<TextView
android:id="@+id/day_0"
@ -95,7 +96,8 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1"
android:visibility="gone"/>
<TextView
android:id="@+id/day_7"
@ -158,7 +160,8 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1"
android:visibility="gone"/>
<TextView
android:id="@+id/day_14"
@ -221,7 +224,8 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1"
android:visibility="gone"/>
<TextView
android:id="@+id/day_21"
@ -284,7 +288,8 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1"
android:visibility="gone"/>
<TextView
android:id="@+id/day_28"
@ -347,7 +352,8 @@
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1"
android:visibility="gone"/>
<TextView
android:id="@+id/day_35"