-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REM-809 - Update reminder list item design
- Loading branch information
Showing
37 changed files
with
1,017 additions
and
859 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/elementary/tasks/core/views/recyclerview/SpaceBetweenItemDecoration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.elementary.tasks.core.views.recyclerview | ||
|
||
import android.graphics.Rect | ||
import android.view.View | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
class SpaceBetweenItemDecoration( | ||
private val space: Int | ||
) : RecyclerView.ItemDecoration() { | ||
|
||
override fun getItemOffsets( | ||
outRect: Rect, | ||
view: View, | ||
parent: RecyclerView, | ||
state: RecyclerView.State | ||
) { | ||
// Add Top space to each next list item | ||
if (parent.getChildAdapterPosition(view) > 0) { | ||
outRect.top = space | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...y/tasks/core/views/SpaceItemDecoration.kt → ...views/recyclerview/SpaceItemDecoration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
.../main/java/com/elementary/tasks/reminder/build/formatter/factory/PlaceFormatterFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.elementary.tasks.reminder.build.formatter.factory | ||
|
||
import com.elementary.tasks.reminder.build.formatter.PlaceFormatter | ||
|
||
class PlaceFormatterFactory( | ||
private val radiusFormatterFactory: RadiusFormatterFactory | ||
) { | ||
|
||
fun create(): PlaceFormatter { | ||
return PlaceFormatter(radiusFormatterFactory.create()) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...main/java/com/elementary/tasks/reminder/build/formatter/factory/RadiusFormatterFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.elementary.tasks.reminder.build.formatter.factory | ||
|
||
import android.content.Context | ||
import com.elementary.tasks.core.utils.params.Prefs | ||
import com.elementary.tasks.core.utils.ui.radius.DefaultRadiusFormatter | ||
|
||
class RadiusFormatterFactory( | ||
private val context: Context, | ||
private val prefs: Prefs | ||
) { | ||
|
||
fun create(): DefaultRadiusFormatter { | ||
return DefaultRadiusFormatter( | ||
context = context, | ||
useMetric = prefs.useMetric | ||
) | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
app/src/main/java/com/elementary/tasks/reminder/lists/ReminderActionResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package com.elementary.tasks.reminder.lists | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import com.elementary.tasks.R | ||
import com.elementary.tasks.core.os.PermissionFlow | ||
import com.elementary.tasks.core.os.Permissions | ||
import com.elementary.tasks.core.os.startActivity | ||
import com.elementary.tasks.core.utils.Constants | ||
import com.elementary.tasks.core.utils.ui.Dialogues | ||
import com.elementary.tasks.reminder.ReminderBuilderLauncher | ||
import com.elementary.tasks.reminder.lists.data.UiReminderListActions | ||
import com.elementary.tasks.reminder.preview.ReminderPreviewActivity | ||
|
||
class ReminderActionResolver( | ||
private val context: Context, | ||
private val dialogues: Dialogues, | ||
private val reminderBuilderLauncher: ReminderBuilderLauncher, | ||
private val permissionFlow: PermissionFlow, | ||
private val deleteAction: (id: String) -> Unit, | ||
private val toggleAction: (id: String) -> Unit, | ||
private val skipAction: (id: String) -> Unit | ||
) { | ||
|
||
fun resolveItemClick( | ||
id: String, | ||
isRemoved: Boolean | ||
) { | ||
if (isRemoved) { | ||
editReminder(id) | ||
} else { | ||
previewReminder(id) | ||
} | ||
} | ||
|
||
fun resolveItemMore( | ||
view: View, | ||
id: String, | ||
isRemoved: Boolean, | ||
actions: UiReminderListActions | ||
) { | ||
if (isRemoved) { | ||
showDeletedActionDialog(view, id) | ||
} else { | ||
showActionDialog(view, actions, id) | ||
} | ||
} | ||
|
||
fun resolveItemToggle( | ||
id: String, | ||
isGps: Boolean | ||
) { | ||
if (isGps) { | ||
permissionFlow.askPermission(Permissions.FOREGROUND_SERVICE) { | ||
toggleAction(id) | ||
} | ||
} else { | ||
toggleAction(id) | ||
} | ||
} | ||
|
||
private fun showDeletedActionDialog(view: View, id: String) { | ||
val items = arrayOf( | ||
context.getString(R.string.open), | ||
context.getString(R.string.edit), | ||
context.getString(R.string.delete) | ||
) | ||
Dialogues.showPopup(view, { item -> | ||
when (item) { | ||
0 -> previewReminder(id) | ||
1 -> editReminder(id) | ||
2 -> askConfirmation(items[item]) { | ||
if (it) { | ||
deleteAction(id) | ||
} | ||
} | ||
} | ||
}, *items) | ||
} | ||
|
||
private fun showActionDialog( | ||
view: View, | ||
actions: UiReminderListActions, | ||
id: String | ||
) { | ||
val items = if (actions.canSkip) { | ||
arrayOf( | ||
context.getString(R.string.open), | ||
context.getString(R.string.edit), | ||
context.getString(R.string.move_to_trash), | ||
context.getString(R.string.skip_event) | ||
) | ||
} else { | ||
arrayOf( | ||
context.getString(R.string.open), | ||
context.getString(R.string.edit), | ||
context.getString(R.string.move_to_trash) | ||
) | ||
} | ||
Dialogues.showPopup(view, { item -> | ||
when (item) { | ||
0 -> previewReminder(id) | ||
1 -> editReminder(id) | ||
2 -> askConfirmation(items[item]) { | ||
if (it) { | ||
deleteAction(id) | ||
} | ||
} | ||
|
||
3 -> skipAction(id) | ||
} | ||
}, *items) | ||
} | ||
|
||
private fun askConfirmation(title: String, onAction: (Boolean) -> Unit) { | ||
dialogues.askConfirmation(context, title, onAction) | ||
} | ||
|
||
private fun editReminder(id: String) { | ||
reminderBuilderLauncher.openLogged(context) { | ||
putExtra(Constants.INTENT_ID, id) | ||
} | ||
} | ||
|
||
private fun previewReminder(id: String) { | ||
context.startActivity(ReminderPreviewActivity::class.java) { | ||
putExtra(Constants.INTENT_ID, id) | ||
} | ||
} | ||
} |
Oops, something went wrong.