This repository was archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
27 additions
and
119 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
80 changes: 16 additions & 64 deletions
80
app/src/main/kotlin/top/yukonga/miuiStringToast/StringToastBundle.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 |
---|---|---|
@@ -1,95 +1,47 @@ | ||
package top.yukonga.miuiStringToast | ||
|
||
import android.app.PendingIntent | ||
import android.os.Bundle | ||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
class StringToastBundle { | ||
class StringToastBundle private constructor() { | ||
|
||
companion object { | ||
private var mBundle: Bundle = Bundle() | ||
} | ||
|
||
@Serializable | ||
class Builder { | ||
private var packageName: String? = null | ||
private var stringToastCategory: String? = null | ||
|
||
@Contextual | ||
private var target: PendingIntent? = null | ||
private var duration: Long = 0 | ||
private var param: String? = null | ||
private var duration: Long = 2500L | ||
private var level: Float = 0f | ||
private var rapidRate: Float = 0f | ||
private var charge: String? = null | ||
private var stringToastChargeFlag: Int = 0 | ||
private var param: String? = null | ||
private var statusBarStrongToast: String? = null | ||
|
||
fun setPackageName(name: String?): Builder { | ||
packageName = name | ||
return this | ||
} | ||
|
||
fun setStrongToastCategory(category: String?): Builder { | ||
this.stringToastCategory = category | ||
return this | ||
} | ||
|
||
fun setTarget(intent: PendingIntent?): Builder { | ||
target = intent | ||
return this | ||
} | ||
|
||
fun setDuration(duration: Long): Builder { | ||
this.duration = duration | ||
return this | ||
} | ||
|
||
fun setLevel(level: Float): Builder { | ||
this.level = level | ||
return this | ||
} | ||
|
||
fun setRapidRate(rate: Float): Builder { | ||
this.rapidRate = rate | ||
return this | ||
} | ||
|
||
fun setCharge(charge: String?): Builder { | ||
this.charge = charge | ||
return this | ||
} | ||
|
||
fun setStringToastChargeFlag(flag: Int): Builder { | ||
this.stringToastChargeFlag = flag | ||
return this | ||
} | ||
|
||
fun setParam(param: String?): Builder { | ||
this.param = param | ||
return this | ||
} | ||
|
||
fun setStatusBarStrongToast(status: String?): Builder { | ||
this.statusBarStrongToast = status | ||
return this | ||
} | ||
private var statusBarStrongToast: String? = "show_custom_strong_toast" | ||
|
||
fun setPackageName(packageName: String?) = apply { this.packageName = packageName } | ||
fun setStrongToastCategory(category: String) = apply { stringToastCategory = category } | ||
fun setTarget(target: PendingIntent?) = apply { this.target = target } | ||
fun setParam(param: String?) = apply { this.param = param } | ||
fun setDuration(duration: Long) = apply { this.duration = duration } | ||
fun setLevel(level: Float) = apply { this.level = level } | ||
fun setRapidRate(rapidRate: Float) = apply { this.rapidRate = rapidRate } | ||
fun setCharge(charge: String?) = apply { this.charge = charge } | ||
fun setStringToastChargeFlag(stringToastChargeFlag: Int) = apply { this.stringToastChargeFlag = stringToastChargeFlag } | ||
fun setStatusBarStrongToast(statusBarStrongToast: String?) = apply { this.statusBarStrongToast = statusBarStrongToast } | ||
|
||
fun onCreate(): Bundle { | ||
mBundle.putString("package_name", packageName) | ||
mBundle.putString("strong_toast_category", stringToastCategory) | ||
mBundle.putParcelable("target", target) | ||
mBundle.putString("param", param) | ||
mBundle.putLong("duration", duration) | ||
mBundle.putFloat("level", level) | ||
mBundle.putFloat("rapid_rate", rapidRate) | ||
mBundle.putString("charge", charge) | ||
mBundle.putInt("string_toast_charge_flag", stringToastChargeFlag) | ||
mBundle.putString("param", param) | ||
mBundle.putString("status_bar_strong_toast", statusBarStrongToast) | ||
return mBundle | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.