Port Checklist Feature
BIN
Habitica/res/drawable-hdpi/ic_action_delete.png
Normal file
|
After Width: | Height: | Size: 160 B |
BIN
Habitica/res/drawable-hdpi/ic_action_list.png
Normal file
|
After Width: | Height: | Size: 126 B |
BIN
Habitica/res/drawable-mdpi/ic_action_delete.png
Normal file
|
After Width: | Height: | Size: 112 B |
BIN
Habitica/res/drawable-mdpi/ic_action_list.png
Normal file
|
After Width: | Height: | Size: 116 B |
BIN
Habitica/res/drawable-xhdpi/ic_action_delete.png
Normal file
|
After Width: | Height: | Size: 156 B |
BIN
Habitica/res/drawable-xhdpi/ic_action_list.png
Normal file
|
After Width: | Height: | Size: 118 B |
BIN
Habitica/res/drawable-xxhdpi/ic_action_delete.png
Normal file
|
After Width: | Height: | Size: 201 B |
BIN
Habitica/res/drawable-xxhdpi/ic_action_list.png
Normal file
|
After Width: | Height: | Size: 175 B |
BIN
Habitica/res/drawable-xxxhdpi/ic_action_delete.png
Normal file
|
After Width: | Height: | Size: 245 B |
BIN
Habitica/res/drawable-xxxhdpi/ic_action_list.png
Normal file
|
After Width: | Height: | Size: 139 B |
|
|
@ -1,104 +1,129 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/background_light">
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin">
|
||||
<TextView
|
||||
android:id="@+id/TV_taskText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_text"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
<EditText
|
||||
android:id="@+id/ET_taskText"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:hint="@string/create_task_hint"
|
||||
android:inputType="textCapSentences|textNoSuggestions"
|
||||
android:singleLine="true" />
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/background_light"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin" >
|
||||
<TextView
|
||||
android:id="@+id/TV_taskNote"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_note"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ET_taskNote"
|
||||
android:layout_width="0dip"
|
||||
<TextView
|
||||
android:id="@+id/TV_taskText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_text"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
|
||||
<com.rengwuxian.materialedittext.MaterialEditText
|
||||
android:id="@+id/ET_taskText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
||||
android:ems="10"
|
||||
|
||||
android:hint="@string/create_task_hint"
|
||||
android:inputType="textCapSentences|textNoSuggestions"
|
||||
android:singleLine="true"
|
||||
|
||||
app:met_floatingLabel="normal" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/BT_checklist"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="right"
|
||||
android:background="@color/transparent"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_action_list" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minLines="2"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:hint="@string/task_note_hint">
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin">
|
||||
|
||||
</EditText>
|
||||
<TextView
|
||||
android:id="@+id/TV_taskNote"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_note"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ET_taskNote"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:hint="@string/task_note_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:minLines="2">
|
||||
|
||||
</EditText>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/repeat_days"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin">
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin"
|
||||
android:visibility="gone">
|
||||
<!-- Day buttons are put here programatically -->
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin">
|
||||
<TextView
|
||||
android:id="@+id/TV_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_value"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
<EditText
|
||||
android:id="@+id/ET_taskValue"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:hint="@string/task_value_hint"
|
||||
android:singleLine="true"
|
||||
android:inputType="number|phone"
|
||||
android:digits="1234567890"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TV_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_value"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ET_taskValue"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:digits="1234567890"
|
||||
android:ems="10"
|
||||
android:hint="@string/task_value_hint"
|
||||
android:inputType="number|phone"
|
||||
android:singleLine="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/due_date"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -106,21 +131,22 @@
|
|||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="@dimen/activity_horizontal_margin"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin">
|
||||
<TextView
|
||||
android:id="@+id/TV_due_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_duedate"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
<TextView
|
||||
style="?android:attr/spinnerStyle"
|
||||
android:id="@+id/due_date_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
android:paddingLeft="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_vertical_margin"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TV_due_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_duedate"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/due_date_spinner"
|
||||
style="?android:attr/spinnerStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
|||
47
Habitica/res/layout/checklist_dialog.xml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/background_light">
|
||||
<RelativeLayout
|
||||
android:id="@+id/RL_addItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/BT_addItem"
|
||||
android:padding="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_menu_send"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
<com.rengwuxian.materialedittext.MaterialEditText
|
||||
android:id="@+id/ET_addItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/checklist.item.hint"
|
||||
|
||||
android:layout_toLeftOf="@id/BT_addItem"
|
||||
|
||||
android:layout_centerVertical="true"
|
||||
|
||||
android:ems="10"
|
||||
android:singleLine="true"
|
||||
|
||||
app:met_floatingLabel="normal" />
|
||||
|
||||
</RelativeLayout>
|
||||
<ListView
|
||||
android:id="@+id/LV_checklist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</ListView>
|
||||
</LinearLayout>
|
||||
46
Habitica/res/layout/checklist_dialog_list_item.xml
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/CardText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/row_size"
|
||||
android:background="@drawable/item_background"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="0dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingTop="0dp">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/plus"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:gravity="center" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/BT_delete"
|
||||
android:layout_width="@dimen/row_size"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@color/transparent"
|
||||
android:src="@drawable/ic_action_delete"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<CheckedTextView
|
||||
android:id="@+id/TV_title"
|
||||
style="@style/CardText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center|left"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_toLeftOf="@id/BT_delete"
|
||||
android:layout_toRightOf="@id/plus"
|
||||
android:gravity="left" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -1,29 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="8dip"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="10dip">
|
||||
android:paddingRight="10dip"
|
||||
android:paddingTop="8dip">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ET_prefs_customText"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/SP_address_hint"
|
||||
android:inputType="textUri" />
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ET_prefs_customText"
|
||||
android:layout_width="0dip"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/SP_address_hint"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textUri"
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/custom_list_view_row_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false" />
|
||||
<RadioButton
|
||||
android:id="@+id/custom_list_view_row_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -24,13 +24,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- <View -->
|
||||
<!-- android:id="@+id/V_color_indic" -->
|
||||
<!-- android:layout_width="50dp" -->
|
||||
<!-- android:layout_height="10dp" -->
|
||||
<!-- android:layout_marginRight="30dp" -->
|
||||
<!-- android:background="@color/bad" -->
|
||||
<!-- android:layout_gravity="top|right" /> -->
|
||||
<ImageView
|
||||
android:id="@+id/IV_task_color"
|
||||
android:layout_width="30dp"
|
||||
|
|
@ -47,6 +40,16 @@
|
|||
android:layout_marginLeft="10dp"
|
||||
android:gravity="left" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/BT_checklist"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@color/transparent"
|
||||
android:layout_marginRight="30dp"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_action_list" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</com.habitrpg.android.habitica.CheckableLinearLayout>
|
||||
|
|
@ -4,121 +4,116 @@
|
|||
<string name="app_name">Habitica</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="action_refresh">Refresh</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="plus_sign">+</string>
|
||||
<string name="minus_sign">-</string>
|
||||
<string name="XP_default">XP</string>
|
||||
<string name="HP_default">HP</string>
|
||||
<string name="format_todo_date">%1$d-%2$d-%3$d</string>
|
||||
<string name="new_task_added_message">A new task have been added</string>
|
||||
<string name="lvlup">LVL UP!</string>
|
||||
<string name="action_barcode">Scan a barcode</string>
|
||||
<string name="ERR_pb_barcode">Prefs couldn\'t be loaded from the barcode</string>
|
||||
<string name="settings_changed">Settings were successfully updated!</string>
|
||||
<string name="pref_dialog_title">HabitRPG settings</string>
|
||||
<string name="string_pref_dialog_positive">OK</string>
|
||||
<!-- Prefs -->
|
||||
<string name="PS_param_title">Params</string>
|
||||
<string name="PS_param_summary">Server config</string>
|
||||
<string name="SP_address">ServerAdress</string>
|
||||
<string name="SP_address_title">Server Address</string>
|
||||
<string name="SP_address_summary">Enter the address of the server</string>
|
||||
<string name="SP_address_default">https://habitrpg.com/</string>
|
||||
<string name="SP_address_hint">Your custom server</string>
|
||||
<string name="SP_userID">UserID</string>
|
||||
<string name="SP_userID_title">User ID</string>
|
||||
<string name="SP_userID_summary">Your User ID</string>
|
||||
<string name="SP_APIToken">APIToken</string>
|
||||
<string name="SP_APIToken_title">API Token</string>
|
||||
<string name="SP_APIToken_summary">Your API Token</string>
|
||||
<string name="PS_contact_title">Contact me</string>
|
||||
<string name="SP_open_twitter">\@MagicMicky</string>
|
||||
<string name="SP_open_twitter_summary">Contact me via Twitter</string>
|
||||
<string name="SP_licences">Licence notices</string>
|
||||
<string name="SP_licences_summary">Information about softwares that helped me develop this software</string>
|
||||
<string name="pb_settings">There was a problem with the settings</string>
|
||||
<string name="go_to_preferences">Please fill the settings.</string>
|
||||
<string name="unknown_error">An error happened…</string>
|
||||
<!-- Adding tasks -->
|
||||
<string name="task_note_hint">Add a note</string>
|
||||
<string name="new_task">Creation of a new %s</string>
|
||||
<string name="task_text">Task:</string>
|
||||
<string name="task_note">Note:</string>
|
||||
<string name="task_duedate">Due date:</string>
|
||||
<string name="task_value">Value:</string>
|
||||
<string name="task_up">Up</string>
|
||||
<string name="task_down">Down</string>
|
||||
<string name="dialog_confirm_button">OK</string>
|
||||
<string name="dialog_cancel_button">Cancel</string>
|
||||
<string name="task_value_hint">20</string>
|
||||
<string name="task_creation_fail">Task creation has failed: you need to provide a title</string>
|
||||
<!--<string name="UpdateToPremiumMsg">If you like this application,\n think about upgrading to premium!</string>
|
||||
<string name="premium_failed">Too bad, you didn\'t buy the premium package!</string>
|
||||
<string name="premium_thanks">Thanks for buying the premium version!</string>
|
||||
<string name="SP_is_premium">is_premium</string>
|
||||
<string name="UpdateToPremium_list_item">Premium mode</string>
|
||||
<string name="UpdateToPremium_list_item_details">Unlock exclusive features</string>
|
||||
<string name="action_premium">Upgrade to premium</string>-->
|
||||
<string name="drawer_open">Open drawer</string>
|
||||
<string name="drawer_close">close drawer</string>
|
||||
<!--<string name="premium_only">Feature reserved to premium users</string>-->
|
||||
<string name="missing_tags">…</string>
|
||||
<string name="tags_section_title">Tags</string>
|
||||
<string name="XP_default">XP</string>
|
||||
<string name="HP_default">HP</string>
|
||||
<string name="format_todo_date">%1$d-%2$d-%3$d</string>
|
||||
<string name="new_task_added_message">A new task have been added</string>
|
||||
<string name="lvlup">LVL UP!</string>
|
||||
<string name="action_barcode">Scan a barcode</string>
|
||||
<string name="ERR_pb_barcode">Prefs couldn\'t be loaded from the barcode</string>
|
||||
<string name="settings_changed">Settings were successfully updated!</string>
|
||||
<string name="pref_dialog_title">HabitRPG settings</string>
|
||||
<string name="string_pref_dialog_positive">OK</string>
|
||||
|
||||
<!-- Prefs -->
|
||||
<string name="PS_param_title">Params</string>
|
||||
<string name="PS_param_summary">Server config</string>
|
||||
<string name="SP_address">ServerAdress</string>
|
||||
<string name="SP_address_title">Server Address</string>
|
||||
<string name="SP_address_summary">Enter the address of the server</string>
|
||||
<string name="SP_address_default">https://habitrpg.com/</string>
|
||||
<string name="SP_address_hint">Your custom server</string>
|
||||
<string name="SP_userID">UserID</string>
|
||||
<string name="SP_userID_title">User ID</string>
|
||||
<string name="SP_userID_summary">Your User ID</string>
|
||||
<string name="SP_APIToken">APIToken</string>
|
||||
<string name="SP_APIToken_title">API Token</string>
|
||||
<string name="SP_APIToken_summary">Your API Token</string>
|
||||
<string name="PS_contact_title">Contact me</string>
|
||||
<string name="SP_open_twitter">\@MagicMicky</string>
|
||||
<string name="SP_open_twitter_summary">Contact me via Twitter</string>
|
||||
<string name="SP_licences">Licence notices</string>
|
||||
<string name="SP_licences_summary">Information about softwares that helped me develop this software</string>
|
||||
<string name="pb_settings">There was a problem with the settings</string>
|
||||
<string name="go_to_preferences">Please fill the settings.</string>
|
||||
<string name="unknown_error">An error happened…</string>
|
||||
|
||||
<!-- Adding tasks -->
|
||||
<string name="task_note_hint">Add a note</string>
|
||||
<string name="new_task">Creation of a new %s</string>
|
||||
<string name="task_text">Task:</string>
|
||||
<string name="task_note">Note:</string>
|
||||
<string name="task_duedate">Due date:</string>
|
||||
<string name="task_value">Value:</string>
|
||||
<string name="task_up">Up</string>
|
||||
<string name="task_down">Down</string>
|
||||
<string name="dialog_confirm_button">OK</string>
|
||||
<string name="dialog_cancel_button">Cancel</string>
|
||||
<string name="task_value_hint">20</string>
|
||||
<string name="task_creation_fail">Task creation has failed: you need to provide a title</string>
|
||||
|
||||
<string name="drawer_open">Open drawer</string>
|
||||
<string name="drawer_close">close drawer</string>
|
||||
<string name="missing_tags">…</string>
|
||||
<string name="tags_section_title">Tags</string>
|
||||
<string name="QRCode">To simplify everything you can scan the QRCode to connect to HabitRPG. To
|
||||
start the scanning mode, use the button in the menu.
|
||||
</string>
|
||||
<string name="SP_acknowledge_qrcode">acknowledge_qrcode_omg</string>
|
||||
<string name="create_todo_hint">New todo</string>
|
||||
<string name="create_reward_hint">New reward</string>
|
||||
<string name="create_daily_hint">New daily</string>
|
||||
<string name="create_habit_hint">New habit</string>
|
||||
<string name="create_task_hint">New task</string>
|
||||
<string name="task_deleted">The task %s was deleted successfully</string>
|
||||
<string name="action_edit">Edit</string>
|
||||
<string name="action_delete">Delete</string>
|
||||
<string name="cab_selected">%d tasks selected</string>
|
||||
<string name="action_cancel">Cancel</string>
|
||||
<string name="task_edited">A task were successfully updated</string>
|
||||
<string name="item_bought">You just bought a shinny new %s!</string>
|
||||
<string name="userToken">User Token</string>
|
||||
<string name="apiToken">API Token</string>
|
||||
<string name="login_btn">Login (normal)</string>
|
||||
<string name="register_btn">Register</string>
|
||||
<string name="username">Username</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="emailAddress">Email address</string>
|
||||
<string name="confirmpassword">Confirm password</string>
|
||||
<string name="login_tokens_btn">Login (via tokens)</string>
|
||||
<string name="SP_acknowledge_qrcode">acknowledge_qrcode_omg</string>
|
||||
<string name="create_todo_hint">New todo</string>
|
||||
<string name="create_reward_hint">New reward</string>
|
||||
<string name="create_daily_hint">New daily</string>
|
||||
<string name="create_habit_hint">New habit</string>
|
||||
<string name="create_task_hint">New task</string>
|
||||
<string name="task_deleted">The task %s was deleted successfully</string>
|
||||
<string name="action_edit">Edit</string>
|
||||
<string name="action_delete">Delete</string>
|
||||
<string name="cab_selected">%d tasks selected</string>
|
||||
<string name="action_cancel">Cancel</string>
|
||||
<string name="task_edited">A task were successfully updated</string>
|
||||
<string name="item_bought">You just bought a shinny new %s!</string>
|
||||
<string name="userToken">User Token</string>
|
||||
<string name="apiToken">API Token</string>
|
||||
<string name="login_btn">Login (normal)</string>
|
||||
<string name="register_btn">Register</string>
|
||||
<string name="username">Username</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="emailAddress">Email address</string>
|
||||
<string name="confirmpassword">Confirm password</string>
|
||||
<string name="login_tokens_btn">Login (via tokens)</string>
|
||||
<string name="fb_login_message">If you registered via facebook, please use the QRCode, or login
|
||||
using your API/USER tokens
|
||||
</string>
|
||||
<string name="ERR_pb_accountCreation">An error happened. Please try to connect</string>
|
||||
<string name="ERR_pb_connection">Error: your credentials couldn\'t be saved!</string>
|
||||
<string name="logout">Logout</string>
|
||||
<string name="LoginActivityName">Login</string>
|
||||
<string name="ERR_pb_accountCreation">An error happened. Please try to connect</string>
|
||||
<string name="ERR_pb_connection">Error: your credentials couldn\'t be saved!</string>
|
||||
<string name="logout">Logout</string>
|
||||
<string name="LoginActivityName">Login</string>
|
||||
<string name="helpString">To use this application, you need to have an account on http://habitrpg.com. You can register using the register button in this application.\n\n
|
||||
If you already have an account, use the connect buttons, or the QRCode scanner. If you created your account using Facebook on the website, you will need to use the QRcode scanner or connect using your API and User token that you can find on http://habitrpg.com.</string>
|
||||
<string name="action_info">Help</string>
|
||||
<string name="user_dead_title">You\'re dead!</string>
|
||||
<string name="action_info">Help</string>
|
||||
<string name="user_dead_title">You\'re dead!</string>
|
||||
<string name="user_dead_mess">You weren\'t vigilant enough, and get lost between some bad habits and some difficult dailies.
|
||||
You are going to revive, but will loose a level, your gold and a random piece of equipment.
|
||||
Try to be more careful with your dailies, and manage those bad habits!
|
||||
</string>
|
||||
<string name="string_revive">Revive</string>
|
||||
|
||||
|
||||
<string name="string_revive">Revive</string>
|
||||
<string name="refreshing_widget">Refreshing widget…</string>
|
||||
<string name="please_connect">Please connect through the application before using a widget</string>
|
||||
<!--<string name="upgrade_premium_widget">To use the widget, please upgrade to premium.</string>-->
|
||||
<string name="title_changelog">Change log</string>
|
||||
<string name="changelog_close">Close</string>
|
||||
|
||||
<string name="close">Close</string>
|
||||
<string name="SP_last_seen_version">SP_last_version</string>
|
||||
<string name="SP_see_changelog">See the changelog</string>
|
||||
<string name="MP_default">MP</string>
|
||||
|
||||
<!-- Premium - ->
|
||||
<string name="premium_sku">premium</string>
|
||||
<string name="appPublicKey">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqxsCCpTSRrjW/vQoc1oSjFyaDqVqQIreY1+i5npLKbWbcwovdF4MbyFjIQzRBiGvbxPRYNlApmoDNIeHjr7qJrprsuPwSMThFLRv3unsGJws7/vxdbcp6YTpmyJODk2zSmRvI5OTu+hfB+SESzrfE1K960+mawCI+N7ee5xIg1sEZmV6e8mQ33f+gE3yaivPw6FYBnqSO6V0bq+k6nUyuN5Hk7wQKOXlZ4quJy1IsI/LhGl7ZSxx0fPoMe0QdjZpvW0leEpdXLU0LUpGR0fm2Ui2qj0gJP5OyDwo2EbF7PLDIz0zmisHWpV/vHKljGHCKzBZu46YgQZRn+zueqVjywIDAQAB</string>
|
||||
<string name="adKey">ca-app-pub-3124440915077289/1083610578</string>
|
||||
<string name="action_premium">Upgrade to premium</string>-->
|
||||
<string name="MP_default">MP</string>
|
||||
<string name="update_btn">Update</string>
|
||||
|
||||
<string name="about.title">About</string>
|
||||
<string name="about.changelog">Changelog</string>
|
||||
|
||||
<string name="checklist.title.add">Add checklist</string>
|
||||
<string name="checklist.title.edit">Edit checklist</string>
|
||||
<string name="checklist.item.hint">Add item…</string>
|
||||
</resources>
|
||||
|
|
@ -2,12 +2,14 @@ package com.habitrpg.android.habitica;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DatePickerDialog.OnDateSetListener;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.util.Log;
|
||||
|
|
@ -18,12 +20,15 @@ import android.view.ViewGroup;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.habitrpg.android.habitica.ChecklistDialog.CheckListUpdater;
|
||||
import com.habitrpg.android.habitica.ui.fragments.DatePickerFragment;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Checklist;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Daily;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Habit;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitItem;
|
||||
|
|
@ -32,52 +37,64 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.Reward;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ToDo;
|
||||
import com.magicmicky.habitrpgwrapper.lib.utils.DaysUtils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import static com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitType.*;
|
||||
import static com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitType.habit;
|
||||
|
||||
public class AddTaskDialog extends DialogFragment implements OnDateSetListener{
|
||||
private EditText taskText, taskNote, taskValue;
|
||||
private boolean[] repeat = {false, false, false, false, false, false, false};
|
||||
private boolean[] down_up= {true,true};
|
||||
private String toDoDate;
|
||||
private HabitType hType;
|
||||
/**
|
||||
* Updated by Negue on 21/06/15
|
||||
*/
|
||||
public class AddTaskDialog extends DialogFragment implements OnDateSetListener, CheckListUpdater {
|
||||
private EditText taskText, taskNote, taskValue;
|
||||
private boolean[] repeat = {false, false, false, false, false, false, false};
|
||||
private boolean[] down_up = {true, true};
|
||||
private String toDoDate;
|
||||
private HabitType hType;
|
||||
|
||||
private String[] mShortWeekDayStrings = {"Mo","Tu","We","Th","Fr","Sa","Su"};
|
||||
private int colorDesactivated;
|
||||
private int colorActivated;
|
||||
private Typeface mRobotoBold;
|
||||
private Typeface mRobotoNormal;
|
||||
private ToggleButton[] buttons;
|
||||
private ViewGroup[] buttonsHolder = new ViewGroup[7];
|
||||
private LayoutInflater inflater;
|
||||
private TextView spinner;
|
||||
|
||||
private OnTaskCreationListener mListener;
|
||||
private boolean mEditMode=false;
|
||||
private String mEditingId;
|
||||
private Double oldValue=null;
|
||||
private String[] mShortWeekDayStrings = {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"};
|
||||
private int colorDesactivated;
|
||||
private int colorActivated;
|
||||
private Typeface mRobotoBold;
|
||||
private Typeface mRobotoNormal;
|
||||
private ToggleButton[] buttons;
|
||||
private ViewGroup[] buttonsHolder = new ViewGroup[7];
|
||||
private LayoutInflater inflater;
|
||||
private TextView spinner;
|
||||
|
||||
@Override
|
||||
private OnTaskCreationListener mListener;
|
||||
private boolean mEditMode = false;
|
||||
private String mEditingId;
|
||||
private Double oldValue = null;
|
||||
private Checklist mChecklist = new Checklist() {
|
||||
@Override
|
||||
protected HabitType getType() {
|
||||
return daily;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
try {
|
||||
try {
|
||||
mListener = (OnTaskCreationListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
this.dismiss();
|
||||
e.printStackTrace();
|
||||
this.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
//getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
}
|
||||
|
||||
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Use the Builder class for convenient dialog construction
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
this.inflater = getActivity().getLayoutInflater();
|
||||
View mainView =inflater.inflate(R.layout.add_task_dialog, null);
|
||||
this.inflater = getActivity().getLayoutInflater();
|
||||
View mainView = inflater.inflate(R.layout.add_task_dialog, null);
|
||||
builder.setView(mainView);
|
||||
this.colorActivated = this.getResources().getColor(R.color.days_black);
|
||||
this.colorDesactivated = this.getResources().getColor(R.color.days_gray);
|
||||
|
|
@ -87,75 +104,79 @@ public class AddTaskDialog extends DialogFragment implements OnDateSetListener{
|
|||
this.taskText = (EditText) mainView.findViewById(R.id.ET_taskText);
|
||||
this.taskValue = (EditText) mainView.findViewById(R.id.ET_taskValue);
|
||||
|
||||
Bundle b = this.getArguments();
|
||||
Bundle b = this.getArguments();
|
||||
int pos = b.getInt("pos", -1);
|
||||
String type;
|
||||
String text;
|
||||
if(pos != -1) {
|
||||
this.mEditMode=true;
|
||||
}
|
||||
String type;
|
||||
String text;
|
||||
if (pos != -1) {
|
||||
this.mEditMode = true;
|
||||
}
|
||||
|
||||
type = b.getString("type");
|
||||
text = b.getString("text");
|
||||
|
||||
this.taskText.setText(text);
|
||||
Log.d("AddTaskDialog", "type=" + type);
|
||||
hType = type.equals(daily.toString()) ?
|
||||
daily : type.equals(reward.toString()) ?
|
||||
reward : type.equals(todo.toString()) ?
|
||||
todo : habit;
|
||||
LinearLayout specialView = (LinearLayout) mainView.findViewById(R.id.repeat_days);
|
||||
if (hType == daily) {
|
||||
this.initializeSpecialButtons(specialView, mShortWeekDayStrings, repeat);
|
||||
|
||||
showChecklistButton(mainView);
|
||||
|
||||
} else if (hType == habit) {
|
||||
String[] texts = {getString(R.string.minus_sign), getString(R.string.plus_sign)};
|
||||
this.initializeSpecialButtons(specialView, texts, this.down_up);
|
||||
} else if (hType == todo) {
|
||||
LinearLayout dueDate = (LinearLayout) mainView.findViewById(R.id.due_date);
|
||||
this.initializeDatePicker(dueDate);
|
||||
|
||||
|
||||
type = b.getString("type");
|
||||
text = b.getString("text");
|
||||
showChecklistButton(mainView);
|
||||
|
||||
this.taskText.setText(text);
|
||||
Log.d("AddTaskDialog","type="+type);
|
||||
hType = type.equals(daily.toString()) ?
|
||||
daily : type.equals(reward.toString()) ?
|
||||
reward : type.equals(todo.toString()) ?
|
||||
todo : habit;
|
||||
LinearLayout specialView = (LinearLayout) mainView.findViewById(R.id.repeat_days);
|
||||
if(hType == daily) {
|
||||
this.initializeSpecialButtons(specialView, mShortWeekDayStrings, repeat);
|
||||
}
|
||||
else if(hType== habit) {
|
||||
String[] texts = {getString(R.string.minus_sign),getString(R.string.plus_sign)};
|
||||
this.initializeSpecialButtons(specialView, texts, this.down_up);
|
||||
}
|
||||
else if(hType== todo) {
|
||||
LinearLayout dueDate = (LinearLayout) mainView.findViewById(R.id.due_date);
|
||||
this.initializeDatePicker(dueDate);
|
||||
} else if(hType== reward) {
|
||||
LinearLayout value = (LinearLayout) mainView.findViewById(R.id.value);
|
||||
value.setVisibility(View.VISIBLE);
|
||||
} else if (hType == reward) {
|
||||
LinearLayout value = (LinearLayout) mainView.findViewById(R.id.value);
|
||||
value.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(mEditMode) {
|
||||
if (mEditMode) {
|
||||
// this.reconstructObjectFrom(json);
|
||||
switch(hType) {
|
||||
switch (hType) {
|
||||
case todo:
|
||||
this.populate(((MainActivity)getActivity()).getTodo(pos));
|
||||
this.populate(((MainActivity) getActivity()).getTodo(pos));
|
||||
break;
|
||||
case daily:
|
||||
this.populate(((MainActivity)getActivity()).getDaily(pos));
|
||||
this.populate(((MainActivity) getActivity()).getDaily(pos));
|
||||
break;
|
||||
case reward:
|
||||
this.populate(((MainActivity)getActivity()).getReward(pos));
|
||||
this.populate(((MainActivity) getActivity()).getReward(pos));
|
||||
break;
|
||||
case habit:
|
||||
this.populate(((MainActivity)getActivity()).getHabit(pos));
|
||||
this.populate(((MainActivity) getActivity()).getHabit(pos));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.setTitle(getString(R.string.new_task, hType.toString()))
|
||||
.setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
.setPositiveButton(R.string.dialog_confirm_button, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
if (AddTaskDialog.this.taskText.getText().length() > 0) {
|
||||
if (AddTaskDialog.this.taskText.getText().length() > 0) {
|
||||
|
||||
mListener.onTaskCreation(AddTaskDialog.this.createTask(), mEditMode);
|
||||
} else {
|
||||
mListener.onTaskCreationFail(getActivity().getString(R.string.task_creation_fail));
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// User cancelled the dialog
|
||||
}
|
||||
});
|
||||
mListener.onTaskCreation(AddTaskDialog.this.createTask(), mEditMode);
|
||||
} else {
|
||||
mListener.onTaskCreationFail(getActivity().getString(R.string.task_creation_fail));
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel_button, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// User cancelled the dialog
|
||||
}
|
||||
});
|
||||
// Create the AlertDialog object and return it
|
||||
Dialog d = builder.create();
|
||||
d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
|
@ -163,31 +184,45 @@ public class AddTaskDialog extends DialogFragment implements OnDateSetListener{
|
|||
return d;
|
||||
}
|
||||
|
||||
private void showChecklistButton(View mainView) {
|
||||
ImageButton btn = (ImageButton) mainView.findViewById(R.id.BT_checklist);
|
||||
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
|
||||
private void initializeDatePicker(LinearLayout specialView) {
|
||||
specialView.setVisibility(ViewGroup.VISIBLE);
|
||||
this.spinner = (TextView) specialView.findViewById(R.id.due_date_spinner);
|
||||
spinner.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogFragment newFragment = new DatePickerFragment();
|
||||
newFragment.setTargetFragment(AddTaskDialog.this, 0);
|
||||
newFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
|
||||
}
|
||||
});
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
|
||||
public void onClick(View v) {
|
||||
ChecklistDialog dialog = new ChecklistDialog(getActivity(), AddTaskDialog.this, null, mChecklist, mEditMode);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeDatePicker(LinearLayout specialView) {
|
||||
specialView.setVisibility(ViewGroup.VISIBLE);
|
||||
this.spinner = (TextView) specialView.findViewById(R.id.due_date_spinner);
|
||||
spinner.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogFragment newFragment = new DatePickerFragment();
|
||||
newFragment.setTargetFragment(AddTaskDialog.this, 0);
|
||||
newFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initializeSpecialButtons(LinearLayout specialView, String[] texts, final boolean[] resArray) {
|
||||
int length = texts.length;
|
||||
this.buttonsHolder = new ViewGroup[length];
|
||||
this.buttons = new ToggleButton[length];
|
||||
specialView.setVisibility(ViewGroup.VISIBLE);
|
||||
private void initializeSpecialButtons(LinearLayout specialView, String[] texts, final boolean[] resArray) {
|
||||
int length = texts.length;
|
||||
this.buttonsHolder = new ViewGroup[length];
|
||||
this.buttons = new ToggleButton[length];
|
||||
specialView.setVisibility(ViewGroup.VISIBLE);
|
||||
for (int i = 0; i < length; i++) {
|
||||
final ViewGroup viewgroup = (ViewGroup) inflater.inflate(R.layout.button_day_of_week,
|
||||
specialView, false);
|
||||
specialView, false);
|
||||
final ToggleButton button = (ToggleButton) viewgroup.getChildAt(0);
|
||||
button.setText(texts[i]);
|
||||
button.setTextOn(texts[i]);
|
||||
|
|
@ -195,164 +230,181 @@ public class AddTaskDialog extends DialogFragment implements OnDateSetListener{
|
|||
specialView.addView(viewgroup);
|
||||
this.buttonsHolder[i] = viewgroup;
|
||||
this.buttons[i] = button;
|
||||
if(i<5) {
|
||||
buttonOn(i);
|
||||
resArray[i] = true;
|
||||
if (i < 5) {
|
||||
buttonOn(i);
|
||||
resArray[i] = true;
|
||||
}
|
||||
}
|
||||
for(int i=0;i<length;i++) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
final int buttonIndex = i;
|
||||
this.buttonsHolder[i].setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
buttons[buttonIndex].toggle();
|
||||
this.buttonsHolder[i].setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
buttons[buttonIndex].toggle();
|
||||
final boolean checked = buttons[buttonIndex].isChecked();
|
||||
if (checked) {
|
||||
buttonOn(buttonIndex);
|
||||
resArray[buttonIndex] = true;
|
||||
buttonOn(buttonIndex);
|
||||
resArray[buttonIndex] = true;
|
||||
} else {
|
||||
buttonOff(buttonIndex);
|
||||
resArray[buttonIndex] = false;
|
||||
buttonOff(buttonIndex);
|
||||
resArray[buttonIndex] = false;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void buttonOff(int index) {
|
||||
buttons[index].setChecked(false);
|
||||
buttons[index].setTextColor(this.colorDesactivated);
|
||||
buttons[index].setTypeface(this.mRobotoNormal);
|
||||
}
|
||||
private void buttonOn(int index) {
|
||||
buttons[index].setChecked(true);
|
||||
buttons[index].setTextColor(this.colorActivated);
|
||||
buttons[index].setTypeface(this.mRobotoBold);
|
||||
}
|
||||
public HabitItem createTask() {
|
||||
HabitItem h=null;
|
||||
}
|
||||
|
||||
String notes = this.taskNote.getText().toString();
|
||||
String text = this.taskText.getText().toString();
|
||||
if(text != null) {
|
||||
switch(this.hType) {
|
||||
case daily:
|
||||
Daily.Days d = DaysUtils.getDaysFromBooleans(repeat);
|
||||
h = new Daily(null, notes, null, text, oldValue!=null?oldValue:0, false, d);
|
||||
break;
|
||||
case habit:
|
||||
h = new Habit(null, notes, null, text, oldValue!=null?oldValue:0, this.down_up[1], this.down_up[0 ]);
|
||||
break;
|
||||
case todo:
|
||||
h = new ToDo(null, notes, null, text, oldValue!=null?oldValue:0, false, toDoDate);
|
||||
break;
|
||||
case reward:
|
||||
int value=20;
|
||||
try {
|
||||
value = Double.valueOf(this.taskValue.getText().toString()).intValue();
|
||||
} catch(Exception e) {
|
||||
private void buttonOff(int index) {
|
||||
buttons[index].setChecked(false);
|
||||
buttons[index].setTextColor(this.colorDesactivated);
|
||||
buttons[index].setTypeface(this.mRobotoNormal);
|
||||
}
|
||||
|
||||
private void buttonOn(int index) {
|
||||
buttons[index].setChecked(true);
|
||||
buttons[index].setTextColor(this.colorActivated);
|
||||
buttons[index].setTypeface(this.mRobotoBold);
|
||||
}
|
||||
|
||||
public HabitItem createTask() {
|
||||
HabitItem h = null;
|
||||
|
||||
String notes = this.taskNote.getText().toString();
|
||||
String text = this.taskText.getText().toString();
|
||||
if (text != null) {
|
||||
switch (this.hType) {
|
||||
case daily:
|
||||
Daily.Days d = DaysUtils.getDaysFromBooleans(repeat);
|
||||
h = new Daily(null, notes, null, text, oldValue != null ? oldValue : 0, false, d);
|
||||
break;
|
||||
case habit:
|
||||
h = new Habit(null, notes, null, text, oldValue != null ? oldValue : 0, this.down_up[1], this.down_up[0]);
|
||||
break;
|
||||
case todo:
|
||||
h = new ToDo(null, notes, null, text, oldValue != null ? oldValue : 0, false, toDoDate);
|
||||
break;
|
||||
case reward:
|
||||
int value = 20;
|
||||
try {
|
||||
value = Double.valueOf(this.taskValue.getText().toString()).intValue();
|
||||
} catch (Exception e) {
|
||||
Crashlytics.logException(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
h = new Reward(null, notes, null, text, value);
|
||||
}
|
||||
if(mEditMode) {
|
||||
h.setId(this.mEditingId);
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
h = new Reward(null, notes, null, text, value);
|
||||
}
|
||||
if (mEditMode) {
|
||||
h.setId(this.mEditingId);
|
||||
}
|
||||
|
||||
return h;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int monthOfYear,
|
||||
int dayOfMonth) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(year, monthOfYear, dayOfMonth);
|
||||
Date d = c.getTime();
|
||||
String date = android.text.format.DateFormat.getMediumDateFormat(getActivity()).format(d);
|
||||
int month = (c.get(Calendar.MONTH)+1)%12;
|
||||
this.toDoDate = getString(R.string.format_todo_date, month, c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.YEAR));
|
||||
Log.v("AddTaskDialog","modifying todoDate to:" + toDoDate);
|
||||
if(this.spinner!=null)
|
||||
this.spinner.setText(date);
|
||||
}
|
||||
if (h instanceof Checklist) {
|
||||
Checklist checklist = (Checklist) h;
|
||||
|
||||
|
||||
private void populate(ToDo result) {
|
||||
populate((HabitItem) result);
|
||||
if(result.getDate()!=null) {
|
||||
String[] newDate = result.getDate().split("-");
|
||||
if(newDate.length!=3) {
|
||||
checklist.addItems(mChecklist);
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int monthOfYear,
|
||||
int dayOfMonth) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(year, monthOfYear, dayOfMonth);
|
||||
Date d = c.getTime();
|
||||
String date = android.text.format.DateFormat.getMediumDateFormat(getActivity()).format(d);
|
||||
int month = (c.get(Calendar.MONTH) + 1) % 12;
|
||||
this.toDoDate = getString(R.string.format_todo_date, month, c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.YEAR));
|
||||
Log.v("AddTaskDialog", "modifying todoDate to:" + toDoDate);
|
||||
if (this.spinner != null)
|
||||
this.spinner.setText(date);
|
||||
}
|
||||
|
||||
|
||||
private void populate(ToDo result) {
|
||||
populate((HabitItem) result);
|
||||
mChecklist = result;
|
||||
if (result.getDate() != null) {
|
||||
String[] newDate = result.getDate().split("-");
|
||||
if (newDate.length != 3) {
|
||||
newDate = result.getDate().split("/");
|
||||
}
|
||||
if(newDate.length==3) {
|
||||
if (newDate.length == 3) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Log.e("date", "date is here!!!" + result.getDate());
|
||||
c.set(Integer.valueOf(newDate[2]), (Integer.valueOf(newDate[0])+11)%12, Integer.valueOf(newDate[1]));
|
||||
c.set(Integer.valueOf(newDate[2]), (Integer.valueOf(newDate[0]) + 11) % 12, Integer.valueOf(newDate[1]));
|
||||
Date d = c.getTime();
|
||||
String date = android.text.format.DateFormat.getMediumDateFormat(getActivity()).format(d);
|
||||
int month = c.get(Calendar.MONTH);
|
||||
this.toDoDate = getString(R.string.format_todo_date,month, c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.YEAR));
|
||||
if(this.spinner!=null)
|
||||
this.toDoDate = getString(R.string.format_todo_date, month, c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.YEAR));
|
||||
if (this.spinner != null)
|
||||
this.spinner.setText(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void populate(Reward result) {
|
||||
populate((HabitItem) result);
|
||||
this.taskValue.setText(Double.valueOf(result.getValue()).intValue() + "");
|
||||
}
|
||||
private void populate(Reward result) {
|
||||
populate((HabitItem) result);
|
||||
this.taskValue.setText(Double.valueOf(result.getValue()).intValue() + "");
|
||||
}
|
||||
|
||||
private void populate(Habit result) {
|
||||
populate((HabitItem) result);
|
||||
if(result.isUp() ){
|
||||
buttonOn(1);
|
||||
down_up[1]=true;
|
||||
} else {
|
||||
buttonOff(1);
|
||||
down_up[1]=false;
|
||||
private void populate(Habit result) {
|
||||
populate((HabitItem) result);
|
||||
if (result.isUp()) {
|
||||
buttonOn(1);
|
||||
down_up[1] = true;
|
||||
} else {
|
||||
buttonOff(1);
|
||||
down_up[1] = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(result.isDown() ){
|
||||
buttonOn(0);
|
||||
down_up[0]=true;
|
||||
if (result.isDown()) {
|
||||
buttonOn(0);
|
||||
down_up[0] = true;
|
||||
|
||||
} else {
|
||||
buttonOff(0);
|
||||
down_up[0]=false;
|
||||
} else {
|
||||
buttonOff(0);
|
||||
down_up[0] = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void populate(Daily result) {
|
||||
populate((HabitItem) result);
|
||||
int length = buttons.length;
|
||||
if(result.getRepeat()!=null) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if(DaysUtils.getBooleansFromDays(result.getRepeat())[i]) {
|
||||
buttonOn(i);
|
||||
repeat[i] = true;
|
||||
private void populate(Daily result) {
|
||||
populate((HabitItem) result);
|
||||
mChecklist = result;
|
||||
int length = buttons.length;
|
||||
if (result.getRepeat() != null) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (DaysUtils.getBooleansFromDays(result.getRepeat())[i]) {
|
||||
buttonOn(i);
|
||||
repeat[i] = true;
|
||||
|
||||
} else {
|
||||
buttonOff(i);
|
||||
repeat[i] = false;
|
||||
} else {
|
||||
buttonOff(i);
|
||||
repeat[i] = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void populate(HabitItem result) {
|
||||
if(this.taskNote!=null)
|
||||
this.taskNote.setText(result.getNotes());
|
||||
if(this.taskText!=null)
|
||||
this.taskText.setText(result.getText());
|
||||
this.mEditingId = result.getId();
|
||||
this.oldValue = result.getValue();
|
||||
}
|
||||
private void populate(HabitItem result) {
|
||||
if (this.taskNote != null)
|
||||
this.taskNote.setText(result.getNotes());
|
||||
if (this.taskText != null)
|
||||
this.taskText.setText(result.getText());
|
||||
this.mEditingId = result.getId();
|
||||
this.oldValue = result.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChecklistChosen(Checklist list) {
|
||||
this.mChecklist = list;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
211
Habitica/src/com/habitrpg/android/habitica/ChecklistDialog.java
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Checklist;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Daily;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitType;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ToDo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit.Callback;
|
||||
import retrofit.RetrofitError;
|
||||
import retrofit.client.Response;
|
||||
|
||||
|
||||
/**
|
||||
* Created by MagicMicky on 30/04/14.
|
||||
* Updated by Negue on 21/06/15
|
||||
*/
|
||||
public class ChecklistDialog<THabitItem extends Checklist> implements DialogInterface.OnClickListener {
|
||||
private final Context mContext;
|
||||
private Checklist checklist;
|
||||
private THabitItem item;
|
||||
private Callback<THabitItem> updateCallback;
|
||||
private final LayoutInflater mInflater;
|
||||
private final APIHelper mAPIHelper;
|
||||
private CheckListUpdater checklistUpdater;
|
||||
private boolean mEditMode;
|
||||
|
||||
public ChecklistDialog(Context act, APIHelper apiHelper, THabitItem todo, Checklist checklist) {
|
||||
this.mContext = act;
|
||||
this.item = todo;
|
||||
|
||||
this.checklist = todo != null ? todo : checklist;
|
||||
this.mInflater = LayoutInflater.from(mContext);
|
||||
this.mAPIHelper = apiHelper;
|
||||
this.checklistUpdater = null;
|
||||
mEditMode = false;
|
||||
}
|
||||
|
||||
public ChecklistDialog(Context context, CheckListUpdater checkListUpdater, THabitItem todo, Checklist checklist, boolean editMode) {
|
||||
this(context, null, todo, checklist);
|
||||
|
||||
this.checklistUpdater = checkListUpdater;
|
||||
this.mEditMode = editMode;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
View convertView = mInflater.inflate(R.layout.checklist_dialog, null);
|
||||
AlertDialog d = new AlertDialog.Builder(mContext)
|
||||
.setTitle(item != null ? item.getText() : mEditMode
|
||||
? mContext.getString(R.string.checklist_title_edit)
|
||||
: mContext.getString(R.string.checklist_title_add))
|
||||
.setView(convertView)
|
||||
.setPositiveButton(mContext.getString(R.string.update_btn), this)
|
||||
.setNegativeButton(mContext.getString(R.string.dialog_cancel_button), null)
|
||||
.create();
|
||||
ListView lv = (ListView) convertView.findViewById(R.id.LV_checklist);
|
||||
|
||||
final CheckListAdapter adapter = new CheckListAdapter(mContext, checklist);
|
||||
|
||||
lv.setAdapter(adapter);
|
||||
d.show();
|
||||
|
||||
if (mAPIHelper == null) {
|
||||
convertView.findViewById(R.id.RL_addItem).setVisibility(View.VISIBLE);
|
||||
ImageButton btn = (ImageButton) convertView.findViewById(R.id.BT_addItem);
|
||||
final EditText addItem = (EditText) convertView.findViewById(R.id.ET_addItem);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (addItem.getText() != null && addItem.getText().length() > 0) {
|
||||
Checklist.ChecklistItem item = new Checklist.ChecklistItem();
|
||||
item.setText(addItem.getText().toString());
|
||||
adapter.addItem(item);
|
||||
adapter.notifyDataSetChanged();
|
||||
addItem.setText("");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (checklistUpdater != null) {
|
||||
checklistUpdater.onChecklistChosen(checklist);
|
||||
} else {
|
||||
if (item instanceof ToDo) {
|
||||
mAPIHelper.updateTask((ToDo) item, new Callback<ToDo>() {
|
||||
@Override
|
||||
public void success(ToDo toDo, Response response) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (item instanceof Daily) {
|
||||
mAPIHelper.updateTask((Daily) item, new Callback<Daily>() {
|
||||
@Override
|
||||
public void success(Daily daily, Response response) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CheckListAdapter extends BaseAdapter {
|
||||
|
||||
private final Checklist checklist;
|
||||
private final Context mContext;
|
||||
|
||||
public CheckListAdapter(Context context, Checklist list) {
|
||||
this.checklist = list;
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return checklist.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Checklist.ChecklistItem getItem(int position) {
|
||||
return checklist.getItems().get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (convertView == null) {
|
||||
convertView = inflator.inflate(R.layout.checklist_dialog_list_item, parent, false);
|
||||
}
|
||||
CheckBox completed = (CheckBox) convertView.findViewById(R.id.plus);
|
||||
TextView text = (TextView) convertView.findViewById(R.id.TV_title);
|
||||
Checklist.ChecklistItem currentItem = this.getItem(position);
|
||||
text.setText(currentItem.getText());
|
||||
convertView.setId(position);
|
||||
completed.setChecked(currentItem.isCompleted());
|
||||
completed.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getParent() != null) {
|
||||
getItem(((View) v.getParent()).getId()).setCompleted(((CheckBox) v).isChecked());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ImageButton delete = (ImageButton) convertView.findViewById(R.id.BT_delete);
|
||||
|
||||
if(mAPIHelper == null) {
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
}
|
||||
delete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v .getParent() != null){
|
||||
removeItem(((View)v.getParent()).getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private void removeItem(int pos) {
|
||||
this.checklist.getItems().remove(pos);
|
||||
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addItem(Checklist.ChecklistItem item) {
|
||||
this.checklist.addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
public interface CheckListUpdater {
|
||||
void onChecklistChosen(Checklist list);
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
|
|||
import com.habitrpg.android.habitica.ui.adapter.HabitItemAdapter;
|
||||
import com.habitrpg.android.habitica.ui.fragments.DailyFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.RewardFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.TagAdapter;
|
||||
import com.habitrpg.android.habitica.ui.adapter.TagAdapter;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Daily;
|
||||
|
|
@ -110,10 +110,11 @@ public class MainActivity extends ActionBarActivity implements OnTaskCreationLis
|
|||
finish();
|
||||
} else {
|
||||
if(this.isThisFirstTimeSinceUpdate()) {
|
||||
ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this);
|
||||
_ChangelogDialog.show();
|
||||
// ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this);
|
||||
// _ChangelogDialog.show(getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve all the views
|
||||
*/
|
||||
|
|
@ -392,6 +393,9 @@ public class MainActivity extends ActionBarActivity implements OnTaskCreationLis
|
|||
case R.id.action_showTestActivity:
|
||||
startActivity(new Intent(this, MainActivityNew.class));
|
||||
break;
|
||||
case R.id.action_showChangelogActivity:
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
break;
|
||||
case R.id.action_settings:
|
||||
startActivity(new Intent(this, PrefsActivity.class));
|
||||
break;
|
||||
|
|
@ -570,7 +574,9 @@ public class MainActivity extends ActionBarActivity implements OnTaskCreationLis
|
|||
public Habit getHabit(int pos) {
|
||||
return user.getHabits().get(pos);
|
||||
}
|
||||
|
||||
public ToDo getTodo(int pos) {
|
||||
|
||||
return user.getTodos().get(pos);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public abstract class CardFragment extends Fragment implements OnTasksChanged {
|
|||
private List<HabitItem> tmpTasks= new ArrayList<HabitItem>();
|
||||
protected MyAdapter mAdapter;
|
||||
private ListView mListView;
|
||||
private APIHelper mAPIHelper;
|
||||
protected APIHelper mAPIHelper;
|
||||
private List<String> tmpTags = new ArrayList<String>();
|
||||
private ActionMode mActionMode;
|
||||
private static final String API_KEY ="b89ef880-7e07-4d13-8a5f-b6be25437fd8";
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.ChecklistDialog;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Daily;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitItem;
|
||||
|
|
@ -75,6 +77,9 @@ public class DailyFragment extends CardFragment {
|
|||
CheckBox completed = (CheckBox) convertView.findViewById(R.id.plus);
|
||||
completed.setOnClickListener(this.getOnClickListener());
|
||||
TextView text = (TextView) convertView.findViewById(R.id.TV_title);
|
||||
|
||||
ImageButton checklist = (ImageButton) convertView.findViewById(R.id.BT_checklist);
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.HOUR_OF_DAY, -getDayStart());
|
||||
int index = c.get(Calendar.DAY_OF_WEEK)-2;
|
||||
|
|
@ -101,6 +106,16 @@ public class DailyFragment extends CardFragment {
|
|||
text.setText(currentItem.getText());
|
||||
completed.setChecked(isChecked(currentItem));
|
||||
convertView.setLongClickable(true);
|
||||
|
||||
List<com.magicmicky.habitrpgwrapper.lib.models.tasks.Checklist.ChecklistItem> items =currentItem.getItems();
|
||||
|
||||
if (items != null && !items.isEmpty()) {
|
||||
checklist.setVisibility(View.VISIBLE);
|
||||
checklist.setOnClickListener(openChecklist);
|
||||
} else {
|
||||
checklist.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(isItemChecked(position)) {
|
||||
convertView.setBackgroundResource(R.drawable.list_focused_holo);
|
||||
} else {
|
||||
|
|
@ -136,7 +151,21 @@ public class DailyFragment extends CardFragment {
|
|||
return !isChecked ? "down" : "up";
|
||||
|
||||
}
|
||||
private View.OnClickListener openChecklist = new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
public void onClick(View v) {
|
||||
|
||||
if(v.getParent() != null && v.getParent().getParent() != null) {
|
||||
|
||||
int position = ((View) v.getParent().getParent()).getId();
|
||||
|
||||
ChecklistDialog dialog = new ChecklistDialog(getActivity(),mAPIHelper,(Daily) getItem(position), null);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int getDayStart() {
|
||||
|
|
|
|||
|
|
@ -9,89 +9,124 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.ChecklistDialog;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Daily;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitItem;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.HabitType;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ToDo;
|
||||
|
||||
public class ToDoFragment extends CardFragment {
|
||||
private static final String TITLE = "To do";
|
||||
private ToDoAdapter adapter = null;
|
||||
|
||||
@Override
|
||||
public MyAdapter instantiateAdapter(Context c) {
|
||||
if(adapter == null) {
|
||||
List<HabitItem> todos = new ArrayList<HabitItem>();
|
||||
this.adapter = new ToDoAdapter(c,todos);
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
private static final String TITLE = "To do";
|
||||
private ToDoAdapter adapter = null;
|
||||
|
||||
@Override
|
||||
protected HabitType getTaskType() {
|
||||
return HabitType.todo;
|
||||
}
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return ToDoFragment.TITLE;
|
||||
}
|
||||
@Override
|
||||
public MyAdapter instantiateAdapter(Context c) {
|
||||
if (adapter == null) {
|
||||
List<HabitItem> todos = new ArrayList<HabitItem>();
|
||||
this.adapter = new ToDoAdapter(c, todos);
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<HabitItem> filterData(List<HabitItem> items) {
|
||||
List<HabitItem> res = new ArrayList<HabitItem>();
|
||||
for(HabitItem it:items) {
|
||||
if(it instanceof ToDo) {
|
||||
if(((ToDo) it).isCompleted()) {
|
||||
|
||||
} else {
|
||||
res.add(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@Override
|
||||
protected HabitType getTaskType() {
|
||||
return HabitType.todo;
|
||||
}
|
||||
|
||||
protected class ToDoAdapter extends MyAdapter {
|
||||
public ToDoAdapter(Context c, List<HabitItem> todos) {
|
||||
super(c,todos);
|
||||
}
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return ToDoFragment.TITLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflator = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (convertView == null){
|
||||
convertView = inflator.inflate(R.layout.todo, parent, false);
|
||||
}
|
||||
convertView.setId(position);
|
||||
ToDo currentItem = (ToDo) this.getItem(position);
|
||||
ImageView color_indic = (ImageView) convertView.findViewById(R.id.IV_task_color);
|
||||
color_indic.setImageDrawable(getResources().getDrawable(getColorRes(currentItem.getValue())));
|
||||
CheckBox completed = (CheckBox) convertView.findViewById(R.id.plus);
|
||||
completed.setOnClickListener(this.getOnClickListener());
|
||||
TextView text = (TextView) convertView.findViewById(R.id.TV_title);
|
||||
text.setText(currentItem.getText());
|
||||
completed.setChecked(currentItem.isCompleted());
|
||||
convertView.setLongClickable(true);
|
||||
if(isItemChecked(position)) {
|
||||
convertView.setBackgroundResource(R.drawable.list_focused_holo);
|
||||
} else {
|
||||
convertView.setBackgroundResource(R.drawable.item_background);
|
||||
}
|
||||
@Override
|
||||
protected List<HabitItem> filterData(List<HabitItem> items) {
|
||||
List<HabitItem> res = new ArrayList<HabitItem>();
|
||||
for (HabitItem it : items) {
|
||||
if (it instanceof ToDo) {
|
||||
if (((ToDo) it).isCompleted()) {
|
||||
|
||||
return convertView;
|
||||
} else {
|
||||
res.add(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected String upOrDown(View v, HabitItem h) {
|
||||
boolean isChecked = ((CheckBox) v).isChecked();
|
||||
((ToDo) h).setCompleted(isChecked);
|
||||
return !isChecked ? "down" : "up";
|
||||
|
||||
}
|
||||
}
|
||||
protected class ToDoAdapter extends MyAdapter {
|
||||
public ToDoAdapter(Context c, List<HabitItem> todos) {
|
||||
super(c, todos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflator = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (convertView == null) {
|
||||
convertView = inflator.inflate(R.layout.todo, parent, false);
|
||||
}
|
||||
convertView.setId(position);
|
||||
ToDo currentItem = (ToDo) this.getItem(position);
|
||||
ImageView color_indic = (ImageView) convertView.findViewById(R.id.IV_task_color);
|
||||
color_indic.setImageDrawable(getResources().getDrawable(getColorRes(currentItem.getValue())));
|
||||
CheckBox completed = (CheckBox) convertView.findViewById(R.id.plus);
|
||||
completed.setOnClickListener(this.getOnClickListener());
|
||||
TextView text = (TextView) convertView.findViewById(R.id.TV_title);
|
||||
text.setText(currentItem.getText());
|
||||
completed.setChecked(currentItem.isCompleted());
|
||||
convertView.setLongClickable(true);
|
||||
|
||||
ImageButton checklist = (ImageButton) convertView.findViewById(R.id.BT_checklist);
|
||||
|
||||
List<com.magicmicky.habitrpgwrapper.lib.models.tasks.Checklist.ChecklistItem> items =currentItem.getItems();
|
||||
|
||||
|
||||
if (items != null && !items.isEmpty()) {
|
||||
checklist.setVisibility(View.VISIBLE);
|
||||
checklist.setOnClickListener(openChecklist);
|
||||
} else {
|
||||
checklist.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
if (isItemChecked(position)) {
|
||||
convertView.setBackgroundResource(R.drawable.list_focused_holo);
|
||||
} else {
|
||||
convertView.setBackgroundResource(R.drawable.item_background);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String upOrDown(View v, HabitItem h) {
|
||||
boolean isChecked = ((CheckBox) v).isChecked();
|
||||
((ToDo) h).setCompleted(isChecked);
|
||||
return !isChecked ? "down" : "up";
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener openChecklist = new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
public void onClick(View v) {
|
||||
|
||||
if (v.getParent() != null && v.getParent().getParent() != null) {
|
||||
|
||||
int position = ((View) v.getParent().getParent()).getId();
|
||||
|
||||
ChecklistDialog dialog = new ChecklistDialog(getActivity(), mAPIHelper, (ToDo) getItem(position), null);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ public abstract class Checklist extends HabitItem{
|
|||
}
|
||||
}
|
||||
|
||||
public void addItems(Checklist list){
|
||||
for (ChecklistItem l : list.getItems())
|
||||
{
|
||||
this.checklist.add(l);
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(ChecklistItem item) {
|
||||
this.checklist.add(item);
|
||||
|
|
|
|||