Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Throwable related parts #338

Merged
merged 3 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions library-no-op/src/main/java/com/chuckerteam/chucker/api/Chucker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ import android.content.Intent
*/
object Chucker {

@Deprecated("This variable will be removed in 4.x release")
const val SCREEN_HTTP = 1
@Deprecated("This variable will be removed in 4.x release")
const val SCREEN_ERROR = 2

@Suppress("MayBeConst ") // https://github.com/ChuckerTeam/chucker/pull/169#discussion_r362341353
val isOp = false

@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.getLaunchIntent(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
fun getLaunchIntent(context: Context, screen: Int): Intent {
return Intent()
}
fun getLaunchIntent(context: Context, screen: Int): Intent = Intent()

@JvmStatic
fun getLaunchIntent(context: Context): Intent = Intent()

@JvmStatic
fun registerDefaultCrashHandler(collector: ChuckerCollector) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class ChuckerCollector @JvmOverloads constructor(
var retentionPeriod: RetentionManager.Period = RetentionManager.Period.ONE_WEEK
) {

@Deprecated(
"This fun will be removed in 4.x release as part of Throwable functionality removal.",
ReplaceWith(""),
DeprecationLevel.WARNING
)
fun onError(obj: Any?, obj2: Any?) {
// Empty method for the library-no-op artifact
}
Expand Down
42 changes: 41 additions & 1 deletion library/src/main/java/com/chuckerteam/chucker/api/Chucker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import com.chuckerteam.chucker.internal.ui.MainActivity
*/
object Chucker {

@Deprecated("This variable will be removed in 4.x release")
const val SCREEN_HTTP = 1
@Deprecated("This variable will be removed in 4.x release")
const val SCREEN_ERROR = 2

/**
Expand All @@ -28,11 +30,25 @@ object Chucker {
* @param screen The [Screen] to display: SCREEN_HTTP or SCREEN_ERROR.
* @return An Intent for the main Chucker Activity that can be started with [Context.startActivity].
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.getLaunchIntent(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
fun getLaunchIntent(context: Context, @Screen screen: Int): Intent {
return getLaunchIntent(context).putExtra(MainActivity.EXTRA_SCREEN, screen)
}

/**
* Get an Intent to launch the Chucker UI directly.
* @param context An Android [Context].
* @return An Intent for the main Chucker Activity that can be started with [Context.startActivity].
*/
@JvmStatic
fun getLaunchIntent(context: Context): Intent {
return Intent(context, MainActivity::class.java)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MainActivity.EXTRA_SCREEN, screen)
}

/**
Expand All @@ -41,6 +57,11 @@ object Chucker {
*
* @param collector the ChuckerCollector
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith(""),
DeprecationLevel.WARNING
)
@JvmStatic
fun registerDefaultCrashHandler(collector: ChuckerCollector) {
Thread.setDefaultUncaughtExceptionHandler(ChuckerCrashHandler(collector))
Expand All @@ -49,6 +70,11 @@ object Chucker {
/**
* Method to dismiss the Chucker notification of HTTP Transactions
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.dismissNotifications(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
fun dismissTransactionsNotification(context: Context) {
NotificationHelper(context).dismissTransactionsNotification()
Expand All @@ -57,14 +83,28 @@ object Chucker {
/**
* Method to dismiss the Chucker notification of Uncaught Errors.
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.dismissNotifications(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
fun dismissErrorsNotification(context: Context) {
NotificationHelper(context).dismissErrorsNotification()
}

/**
* Dismisses all previous Chucker notifications.
*/
@JvmStatic
fun dismissNotifications(context: Context) {
NotificationHelper(context).dismissNotifications()
}

/**
* Annotation used to specify which screen of Chucker should be launched.
*/
@Deprecated("This param will be removed in 4.x release")
@IntDef(value = [SCREEN_HTTP, SCREEN_ERROR])
annotation class Screen

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class ChuckerCollector @JvmOverloads constructor(
* @param tag A tag you choose
* @param throwable The triggered [Throwable]
*/
@Deprecated(
"This fun will be removed in 4.x release as part of Throwable functionality removal.",
ReplaceWith(""),
DeprecationLevel.WARNING
)
fun onError(tag: String, throwable: Throwable) {
val recordedThrowable = RecordedThrowable(tag, throwable)
CoroutineScope(Dispatchers.IO).launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal class NotificationHelper(val context: Context) {
PendingIntent.getActivity(
context,
TRANSACTION_NOTIFICATION_ID,
Chucker.getLaunchIntent(context, Chucker.SCREEN_HTTP),
Chucker.getLaunchIntent(context),
PendingIntent.FLAG_UPDATE_CURRENT
)
}
Expand Down Expand Up @@ -163,4 +163,9 @@ internal class NotificationHelper(val context: Context) {
fun dismissErrorsNotification() {
notificationManager.cancel(ERROR_NOTIFICATION_ID)
}

fun dismissNotifications() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fun is a subject to change after removing Throwable stuff.

notificationManager.cancel(TRANSACTION_NOTIFICATION_ID)
notificationManager.cancel(ERROR_NOTIFICATION_ID)
}
}