mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-04-05 14:01:06 +02:00
toggle week number visibility depending on settings, close #31
This commit is contained in:
parent
5392ea00d4
commit
2f94fb6dda
app/src/main
java/com/simplemobiletools/calendar
kotlin/com/simplemobiletools/calendar/fragments
res/layout
@ -17,6 +17,7 @@ import android.graphics.LightingColorFilter;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.UnderlineSpan;
|
import android.text.style.UnderlineSpan;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
import com.simplemobiletools.calendar.activities.DayActivity;
|
import com.simplemobiletools.calendar.activities.DayActivity;
|
||||||
@ -129,14 +130,17 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateDays(List<Day> days) {
|
public void updateDays(List<Day> days) {
|
||||||
|
final boolean displayWeekNumbers = Config.newInstance(mContext).getDisplayWeekNumbers();
|
||||||
final int len = days.size();
|
final int len = days.size();
|
||||||
final String packageName = mContext.getPackageName();
|
final String packageName = mContext.getPackageName();
|
||||||
mRemoteViews.setInt(R.id.week_num, "setTextColor", mWeakTextColor);
|
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++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
final int id = mRes.getIdentifier("week_num_" + i, "id", packageName);
|
final int id = mRes.getIdentifier("week_num_" + i, "id", packageName);
|
||||||
mRemoteViews.setTextViewText(id, days.get(i * 7).getWeekOfYear() + ":");
|
mRemoteViews.setTextViewText(id, days.get(i * 7).getWeekOfYear() + ":");
|
||||||
mRemoteViews.setInt(id, "setTextColor", mWeakTextColor);
|
mRemoteViews.setInt(id, "setTextColor", mWeakTextColor);
|
||||||
|
mRemoteViews.setViewVisibility(id, displayWeekNumbers ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
@ -17,6 +17,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.simplemobiletools.calendar.Calendar;
|
import com.simplemobiletools.calendar.Calendar;
|
||||||
import com.simplemobiletools.calendar.CalendarImpl;
|
import com.simplemobiletools.calendar.CalendarImpl;
|
||||||
|
import com.simplemobiletools.calendar.Config;
|
||||||
import com.simplemobiletools.calendar.Constants;
|
import com.simplemobiletools.calendar.Constants;
|
||||||
import com.simplemobiletools.calendar.MyWidgetProvider;
|
import com.simplemobiletools.calendar.MyWidgetProvider;
|
||||||
import com.simplemobiletools.calendar.R;
|
import com.simplemobiletools.calendar.R;
|
||||||
@ -184,13 +185,18 @@ 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++) {
|
if (Config.newInstance(getApplicationContext()).getDisplayWeekNumbers()) {
|
||||||
final TextView weekIdTV = (TextView) findViewById(mRes.getIdentifier("week_num_" + i, "id", mPackageName));
|
final TextView weekNum = (TextView) findViewById(R.id.week_num);
|
||||||
weekIdTV.setText(mDays.get(i * 7).getWeekOfYear() + ":");
|
weekNum.setTextColor(mWeakTextColor);
|
||||||
weekIdTV.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++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
@ -160,13 +160,17 @@ class MonthFragment : Fragment(), Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDays(days: List<Day>) {
|
private fun updateDays(days: List<Day>) {
|
||||||
|
val displayWeekNumbers = mConfig.displayWeekNumbers
|
||||||
val len = days.size
|
val len = days.size
|
||||||
|
|
||||||
week_num.setTextColor(mWeakTextColor)
|
week_num.setTextColor(mWeakTextColor)
|
||||||
|
week_num.visibility = if (displayWeekNumbers) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
for (i in 0..5) {
|
for (i in 0..5) {
|
||||||
val weekIdTV = mHolder.findViewById(mRes.getIdentifier("week_num_" + i, "id", mPackageName)) as TextView
|
val weekIdTV = mHolder.findViewById(mRes.getIdentifier("week_num_" + i, "id", mPackageName)) as TextView
|
||||||
weekIdTV.text = "${days[i * 7].weekOfYear}:"
|
weekIdTV.text = "${days[i * 7].weekOfYear}:"
|
||||||
weekIdTV.setTextColor(mWeakTextColor)
|
weekIdTV.setTextColor(mWeakTextColor)
|
||||||
|
weekIdTV.visibility = if (displayWeekNumbers) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in 0..len - 1) {
|
for (i in 0..len - 1) {
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
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="#"/>
|
android:text="#"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_0"
|
android:id="@+id/label_0"
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
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:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_0"
|
android:id="@+id/day_0"
|
||||||
@ -95,7 +96,8 @@
|
|||||||
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:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_7"
|
android:id="@+id/day_7"
|
||||||
@ -158,7 +160,8 @@
|
|||||||
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:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_14"
|
android:id="@+id/day_14"
|
||||||
@ -221,7 +224,8 @@
|
|||||||
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:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_21"
|
android:id="@+id/day_21"
|
||||||
@ -284,7 +288,8 @@
|
|||||||
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:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_28"
|
android:id="@+id/day_28"
|
||||||
@ -347,7 +352,8 @@
|
|||||||
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:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_35"
|
android:id="@+id/day_35"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user