mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Allow user to reverse the order of days
This commit is contained in:
@@ -20,8 +20,10 @@
|
||||
package org.isoron.uhabits.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -39,6 +41,9 @@ import java.util.GregorianCalendar;
|
||||
|
||||
public class ListHabitsHelper
|
||||
{
|
||||
private static final int CHECKMARK_LEFT_TO_RIGHT = 0;
|
||||
private static final int CHECKMARK_RIGHT_TO_LEFT = 1;
|
||||
|
||||
private final int lowContrastColor;
|
||||
private final int mediumContrastColor;
|
||||
|
||||
@@ -80,8 +85,12 @@ public class ListHabitsHelper
|
||||
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
int position = i;
|
||||
|
||||
TextView tvCheck = (TextView) llButtons.getChildAt(i);
|
||||
if(getCheckmarkOrder() == CHECKMARK_RIGHT_TO_LEFT)
|
||||
position = m - i - 1;
|
||||
|
||||
TextView tvCheck = (TextView) llButtons.getChildAt(position);
|
||||
tvCheck.setTag(R.string.habit_key, habitId);
|
||||
tvCheck.setTag(R.string.offset_key, i);
|
||||
if(isChecked.length > i)
|
||||
@@ -217,11 +226,15 @@ public class ListHabitsHelper
|
||||
|
||||
for (int i = 0; i < getButtonCount(); i++)
|
||||
{
|
||||
int position = 0;
|
||||
|
||||
if(getCheckmarkOrder() == CHECKMARK_LEFT_TO_RIGHT)
|
||||
position = i;
|
||||
|
||||
View tvDay = inflater.inflate(R.layout.list_habits_header_check, null);
|
||||
TextView btCheck = (TextView) tvDay.findViewById(R.id.tvCheck);
|
||||
btCheck.setText(DateHelper.formatHeaderDate(day));
|
||||
header.addView(tvDay);
|
||||
|
||||
header.addView(tvDay, position);
|
||||
day.add(GregorianCalendar.DAY_OF_MONTH, -1);
|
||||
}
|
||||
}
|
||||
@@ -282,4 +295,11 @@ public class ListHabitsHelper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCheckmarkOrder()
|
||||
{
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean reverse = prefs.getBoolean("pref_checkmark_reverse_order", false);
|
||||
return reverse ? CHECKMARK_RIGHT_TO_LEFT : CHECKMARK_LEFT_TO_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +110,10 @@ public class ReminderHelper
|
||||
return ringtoneUri;
|
||||
}
|
||||
|
||||
public static void parseRingtoneData(Context context, Intent data)
|
||||
public static void parseRingtoneData(Context context, @Nullable Intent data)
|
||||
{
|
||||
if(data == null) return;
|
||||
|
||||
Uri ringtoneUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
|
||||
if (ringtoneUri != null)
|
||||
|
||||
@@ -159,9 +159,11 @@
|
||||
|
||||
<string name="help_translate">Help translate this app</string>
|
||||
<string name="night_mode">Night mode</string>
|
||||
<string name="use_pure_black">Pure black for night mode</string>
|
||||
<string name="pure_black_description">Use pure black instead of grey backgrounds in night mode. Reduces battery usage in phones with AMOLED display.</string>
|
||||
<string name="use_pure_black">Use pure black in night mode</string>
|
||||
<string name="pure_black_description">Replaces gray backgrounds with pure black in night mode. Reduces battery usage in phones with AMOLED display.</string>
|
||||
<string name="interface_preferences">Interface</string>
|
||||
<string name="reverse_days">Reverse order of days</string>
|
||||
<string name="reverse_days_description">Show days in reverse order on the main screen</string>
|
||||
|
||||
<string name="day">Day</string>
|
||||
<string name="week">Week</string>
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
android:summary="@string/pref_toggle_description"
|
||||
android:title="@string/pref_toggle_title"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_checkmark_reverse_order"
|
||||
android:summary="@string/reverse_days_description"
|
||||
android:title="@string/reverse_days"/>
|
||||
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_pure_black"
|
||||
|
||||
Reference in New Issue
Block a user