mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 20:12:39 +01:00
misc (#781)
* Rename image vars * Add black media option, resolves #726 * Update changelog * Fix menu parsin * Update changelog * Fix menu badges
This commit is contained in:
parent
ee4f2eab35
commit
6b85bc72a8
@ -86,28 +86,30 @@ class ImageActivity : KauBaseActivity() {
|
||||
private val L = KauLoggerExtension("Image", com.pitchedapps.frost.utils.L)
|
||||
}
|
||||
|
||||
val IMAGE_URL: String by lazy { intent.getStringExtra(ARG_IMAGE_URL).trim('"') }
|
||||
val imageUrl: String by lazy { intent.getStringExtra(ARG_IMAGE_URL).trim('"') }
|
||||
|
||||
private val TEXT: String? by lazy { intent.getStringExtra(ARG_TEXT) }
|
||||
private val imageText: String? by lazy { intent.getStringExtra(ARG_TEXT) }
|
||||
|
||||
// a unique image identifier based on the id (if it exists), and its hash
|
||||
private val IMAGE_HASH: String by lazy {
|
||||
"${Math.abs(FB_IMAGE_ID_MATCHER.find(IMAGE_URL)[1]?.hashCode()
|
||||
?: 0)}_${Math.abs(IMAGE_URL.hashCode())}"
|
||||
private val imageHash: String by lazy {
|
||||
"${Math.abs(FB_IMAGE_ID_MATCHER.find(imageUrl)[1]?.hashCode()
|
||||
?: 0)}_${Math.abs(imageUrl.hashCode())}"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
intent?.extras ?: return finish()
|
||||
L.i { "Displaying image" }
|
||||
L.v { "Displaying image $IMAGE_URL" }
|
||||
val layout = if (!TEXT.isNullOrBlank()) R.layout.activity_image else R.layout.activity_image_textless
|
||||
L.v { "Displaying image $imageUrl" }
|
||||
val layout = if (!imageText.isNullOrBlank()) R.layout.activity_image else R.layout.activity_image_textless
|
||||
setContentView(layout)
|
||||
container.setBackgroundColor(Prefs.bgColor.withMinAlpha(222))
|
||||
caption?.setTextColor(Prefs.textColor)
|
||||
caption?.setBackgroundColor(Prefs.bgColor.colorToForeground(0.2f).withAlpha(255))
|
||||
caption?.text = TEXT
|
||||
progress.tint(Prefs.accentColor)
|
||||
container.setBackgroundColor(if (Prefs.blackMediaBg) Color.BLACK
|
||||
else Prefs.bgColor.withMinAlpha(222))
|
||||
caption?.setTextColor(if (Prefs.blackMediaBg) Color.WHITE else Prefs.textColor)
|
||||
caption?.setBackgroundColor((if (Prefs.blackMediaBg) Color.BLACK else Prefs.bgColor)
|
||||
.colorToForeground(0.2f).withAlpha(255))
|
||||
caption?.text = imageText
|
||||
progress.tint(if (Prefs.blackMediaBg) Color.WHITE else Prefs.accentColor)
|
||||
panel?.addPanelSlideListener(object : SlidingUpPanelLayout.SimplePanelSlideListener() {
|
||||
override fun onPanelSlide(panel: View, slideOffset: Float) {
|
||||
if (slideOffset == 0f && !fab.isShown) fab.show()
|
||||
@ -120,7 +122,7 @@ class ImageActivity : KauBaseActivity() {
|
||||
override fun onImageLoadError(e: Exception?) {
|
||||
errorRef = e
|
||||
e.logFrostAnswers("Image load error")
|
||||
L.e { "Failed to load image $IMAGE_URL" }
|
||||
L.e { "Failed to load image $imageUrl" }
|
||||
tempFile?.delete()
|
||||
fabAction = FabStates.ERROR
|
||||
}
|
||||
@ -129,7 +131,7 @@ class ImageActivity : KauBaseActivity() {
|
||||
themeWindow = false
|
||||
}
|
||||
doAsync({
|
||||
L.e(it) { "Failed to load image $IMAGE_HASH" }
|
||||
L.e(it) { "Failed to load image $imageHash" }
|
||||
errorRef = it
|
||||
runOnUiThread { progress.fadeOut() }
|
||||
tempFile?.delete()
|
||||
@ -156,7 +158,7 @@ class ImageActivity : KauBaseActivity() {
|
||||
* Returns a file pointing to the image, or null if something goes wrong
|
||||
*/
|
||||
private inline fun loadImage(callback: (file: File?) -> Unit) {
|
||||
val local = File(tempDir, IMAGE_HASH)
|
||||
val local = File(tempDir, imageHash)
|
||||
if (local.exists() && local.length() > 1) {
|
||||
local.setLastModified(System.currentTimeMillis())
|
||||
L.d { "Loading from local cache ${local.absolutePath}" }
|
||||
@ -204,7 +206,7 @@ class ImageActivity : KauBaseActivity() {
|
||||
}
|
||||
|
||||
private fun getImageResponse() = Request.Builder()
|
||||
.url(IMAGE_URL)
|
||||
.url(imageUrl)
|
||||
.get()
|
||||
.call()
|
||||
.execute()
|
||||
@ -279,7 +281,7 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC
|
||||
if (activity.errorRef != null)
|
||||
L.e(activity.errorRef) { "ImageActivity error report" }
|
||||
activity.sendFrostEmail(R.string.debug_image_link_subject) {
|
||||
addItem("Url", activity.IMAGE_URL)
|
||||
addItem("Url", activity.imageUrl)
|
||||
addItem("Message", activity.errorRef?.message ?: "Null")
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ data class MenuItem(val id: String? = null,
|
||||
val name: String? = null,
|
||||
val pic: String? = null,
|
||||
val url: String? = null,
|
||||
val count: Int = 0,
|
||||
val badge: String? = null,
|
||||
val countDetails: String? = null) : MenuItemData {
|
||||
|
||||
@JsonCreator constructor(
|
||||
@ -133,10 +133,13 @@ data class MenuItem(val id: String? = null,
|
||||
@JsonProperty("name") name: String?,
|
||||
@JsonProperty("pic") pic: String?,
|
||||
@JsonProperty("url") url: String?,
|
||||
@JsonProperty("count") count: Int?,
|
||||
@JsonProperty("count") badge: String?,
|
||||
@JsonProperty("count_details") countDetails: String?,
|
||||
@JsonProperty("fake") fake: Boolean?
|
||||
) : this(id, name, pic?.formattedFbUrl, url?.formattedFbUrl, count ?: 0, countDetails)
|
||||
) : this(id, name, pic?.formattedFbUrl,
|
||||
url?.formattedFbUrl,
|
||||
if (badge == "0") null else badge,
|
||||
countDetails)
|
||||
|
||||
override val isValid: Boolean
|
||||
get() = !name.isNullOrBlank() && !url.isNullOrBlank()
|
||||
|
@ -48,10 +48,13 @@ class MenuContentIItem(val data: MenuItem)
|
||||
else
|
||||
icon.gone()
|
||||
content.text = item.data.name
|
||||
badge.text = item.data.badge
|
||||
}
|
||||
|
||||
override fun unbindView(item: MenuContentIItem) {
|
||||
badge.gone()
|
||||
GlideApp.with(itemView).clear(icon)
|
||||
content.text = null
|
||||
badge.text = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ abstract class RxFlyweight<in T : Any, C : Any, R : Any> {
|
||||
|
||||
val newSource = createNewSource(input).cache().doOnError { sources.remove(input) }
|
||||
|
||||
sources.put(input, newSource)
|
||||
sources[input] = newSource
|
||||
return newSource
|
||||
}
|
||||
}
|
||||
|
@ -157,4 +157,10 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
KPrefSeekbar.KPrefSeekbarBuilder(
|
||||
globalOptions,
|
||||
R.string.web_text_scaling, Prefs::webTextScaling, { Prefs.webTextScaling = it; setFrostResult(REQUEST_TEXT_ZOOM) })))
|
||||
|
||||
checkbox(R.string.enforce_black_media_bg, Prefs::blackMediaBg, {
|
||||
Prefs.blackMediaBg = it
|
||||
}) {
|
||||
descRes = R.string.enforce_black_media_bg_desc
|
||||
}
|
||||
}
|
@ -163,6 +163,8 @@ object Prefs : KPref() {
|
||||
|
||||
var mainActivityLayoutType: Int by kpref("main_activity_layout_type", 0)
|
||||
|
||||
var blackMediaBg: Boolean by kpref("black_media_bg", false)
|
||||
|
||||
inline val mainActivityLayout: MainActivityLayout
|
||||
get() = MainActivityLayout(mainActivityLayoutType)
|
||||
|
||||
|
@ -59,7 +59,11 @@ class FrostVideoViewer @JvmOverloads constructor(
|
||||
init {
|
||||
inflate(R.layout.view_video, true)
|
||||
alpha = 0f
|
||||
background.setBackgroundColor(if (Prefs.bgColor.isColorDark) Prefs.bgColor.withMinAlpha(200) else Color.BLACK)
|
||||
background.setBackgroundColor(
|
||||
if (!Prefs.blackMediaBg && Prefs.bgColor.isColorDark)
|
||||
Prefs.bgColor.withMinAlpha(200)
|
||||
else
|
||||
Color.BLACK)
|
||||
video.setViewerContract(this)
|
||||
video.pause()
|
||||
toolbar.inflateMenu(R.menu.menu_video)
|
||||
|
@ -26,4 +26,6 @@
|
||||
<string name="web_text_scaling">Web Text Scaling</string>
|
||||
<string name="web_text_scaling_desc">Text Scaling Example; Long press the percentage text to reset.</string>
|
||||
|
||||
<string name="enforce_black_media_bg">Enforce black media background</string>
|
||||
<string name="enforce_black_media_bg_desc">Make media backgrounds black; default is the selected background above</string>
|
||||
</resources>
|
@ -12,6 +12,9 @@
|
||||
<item text="Send feedback if no new notifications exist after manual refresh" />
|
||||
<item text="Automatically refresh if idled for a long time" />
|
||||
<item text="Clean up url queries" />
|
||||
<item text="Add option to force black background for media views" />
|
||||
<item text="Fix menu fragment parsing" />
|
||||
<item text="" />
|
||||
|
||||
<version title="v1.8.2" />
|
||||
<item text="Fix duplicate notification sounds" />
|
||||
|
@ -66,6 +66,7 @@ class FbRequestTest {
|
||||
val data = AUTH.getMenuData().invoke()
|
||||
assertNotNull(data)
|
||||
println(ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(data!!))
|
||||
assertTrue(data.data.isNotEmpty())
|
||||
assertTrue(data.footer.hasContent, "Footer may be badly parsed")
|
||||
val items = data.flatMapValid()
|
||||
assertTrue(items.size > 15, "Something may be badly parsed")
|
||||
|
@ -3,6 +3,11 @@
|
||||
## v1.8.3
|
||||
* Add full notification channel support
|
||||
* Fix sound spam for multiple notifications
|
||||
* Send feedback if no new notifications exist after manual refresh
|
||||
* Automatically refresh if idled for a long time
|
||||
* Clean up url queries
|
||||
* Add option to force black background for media views
|
||||
* Fix menu fragment parsing
|
||||
|
||||
## v1.8.2
|
||||
* Fix duplicate notification sounds
|
||||
|
Loading…
Reference in New Issue
Block a user