-
-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to export the list of transactions (#305)
* added export feature for chucker formatting * addressing review comments * addressing indentation issues addressing indentation issues * updating failing test * renaming methods in filefactory to make it more generic * refactored exportTransactions() to make it easy to read * updated coroutines with viewmodelscope. * removed runblocking and added lifecycle-runtime extension. * updated share compat to remove error log * removed thread switching and added suspend modifier for getStringFromTransactions method Co-authored-by: Karthik R <karthr@paypal.com>
- Loading branch information
Showing
17 changed files
with
280 additions
and
26 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
8 changes: 8 additions & 0 deletions
8
library/src/main/java/com/chuckerteam/chucker/internal/data/model/DialogData.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,8 @@ | ||
package com.chuckerteam.chucker.internal.data.model | ||
|
||
internal data class DialogData( | ||
val title: String, | ||
val message: String, | ||
val postiveButtonText: String?, | ||
val negativeButtonText: String? | ||
) |
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
22 changes: 22 additions & 0 deletions
22
library/src/main/java/com/chuckerteam/chucker/internal/support/ContextExt.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,22 @@ | ||
package com.chuckerteam.chucker.internal.support | ||
|
||
import android.content.Context | ||
import com.chuckerteam.chucker.internal.data.model.DialogData | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
|
||
internal fun Context.showDialog( | ||
dialogData: DialogData, | ||
onPositiveClick: (() -> Unit)?, | ||
onNegativeClick: (() -> Unit)? | ||
) { | ||
MaterialAlertDialogBuilder(this) | ||
.setTitle(dialogData.title) | ||
.setMessage(dialogData.message) | ||
.setPositiveButton(dialogData.postiveButtonText) { _, _ -> | ||
onPositiveClick?.invoke() | ||
} | ||
.setNegativeButton(dialogData.negativeButtonText) { _, _ -> | ||
onNegativeClick?.invoke() | ||
} | ||
.show() | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ import java.io.File | |
|
||
internal interface FileFactory { | ||
fun create(): File | ||
fun create(filename: String): File | ||
} |
19 changes: 19 additions & 0 deletions
19
library/src/main/java/com/chuckerteam/chucker/internal/support/ShareUtils.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,19 @@ | ||
package com.chuckerteam.chucker.internal.support | ||
|
||
import android.content.Context | ||
import com.chuckerteam.chucker.R | ||
import com.chuckerteam.chucker.internal.data.entity.HttpTransaction | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
|
||
internal object ShareUtils { | ||
suspend fun getStringFromTransactions(transactions: List<HttpTransaction>, context: Context): String { | ||
return withContext(Dispatchers.Default) { | ||
transactions.joinToString( | ||
separator = "\n${context.getString(R.string.chucker_export_separator)}\n", | ||
prefix = "${context.getString(R.string.chucker_export_prefix)}\n", | ||
postfix = "\n${context.getString(R.string.chucker_export_postfix)}\n" | ||
) { FormatUtils.getShareText(context, it, false) } | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<paths> | ||
<cache-path name="export" path="."/> | ||
</paths> |
Oops, something went wrong.