-
Notifications
You must be signed in to change notification settings - Fork 144
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
19 changed files
with
128 additions
and
32 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
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
24 changes: 24 additions & 0 deletions
24
app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/ThumbnailTransformation.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,24 @@ | ||
package org.koitharu.kotatsu.core.ui.image | ||
|
||
import android.graphics.Bitmap | ||
import android.media.ThumbnailUtils | ||
import coil.size.Size | ||
import coil.size.pxOrElse | ||
import coil.transform.Transformation | ||
|
||
class ThumbnailTransformation : Transformation { | ||
|
||
override val cacheKey: String = javaClass.name | ||
|
||
override suspend fun transform(input: Bitmap, size: Size): Bitmap { | ||
return ThumbnailUtils.extractThumbnail( | ||
input, | ||
size.width.pxOrElse { input.width }, | ||
size.height.pxOrElse { input.height }, | ||
) | ||
} | ||
|
||
override fun equals(other: Any?) = other is ThumbnailTransformation | ||
|
||
override fun hashCode() = javaClass.hashCode() | ||
} |
50 changes: 50 additions & 0 deletions
50
app/src/main/kotlin/org/koitharu/kotatsu/core/util/AcraScreenLogger.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,50 @@ | ||
package org.koitharu.kotatsu.core.util | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks | ||
import org.acra.ACRA | ||
import org.koitharu.kotatsu.core.ui.DefaultActivityLifecycleCallbacks | ||
import java.text.DateFormat | ||
import java.text.SimpleDateFormat | ||
import java.util.Date | ||
import java.util.Locale | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class AcraScreenLogger @Inject constructor() : FragmentLifecycleCallbacks(), DefaultActivityLifecycleCallbacks { | ||
|
||
private val timeFormat = SimpleDateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.ROOT) | ||
|
||
override fun onFragmentAttached(fm: FragmentManager, f: Fragment, context: Context) { | ||
super.onFragmentAttached(fm, f, context) | ||
ACRA.errorReporter.putCustomData(f.key(), "${time()}: ${f.arguments}") | ||
} | ||
|
||
override fun onFragmentDetached(fm: FragmentManager, f: Fragment) { | ||
super.onFragmentDetached(fm, f) | ||
ACRA.errorReporter.removeCustomData(f.key()) | ||
} | ||
|
||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { | ||
super.onActivityCreated(activity, savedInstanceState) | ||
ACRA.errorReporter.putCustomData(activity.key(), "${time()}: ${activity.intent}") | ||
(activity as? FragmentActivity)?.supportFragmentManager?.registerFragmentLifecycleCallbacks(this, true) | ||
} | ||
|
||
override fun onActivityDestroyed(activity: Activity) { | ||
super.onActivityDestroyed(activity) | ||
ACRA.errorReporter.removeCustomData(activity.key()) | ||
} | ||
|
||
private fun Activity.key() = "Activity[${javaClass.simpleName}]" | ||
|
||
private fun Fragment.key() = "Fragment[${javaClass.simpleName}]" | ||
|
||
private fun time() = timeFormat.format(Date()) | ||
} |
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
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
Oops, something went wrong.