Merge branch 'Iamlooker:master' into better-readme

This commit is contained in:
MrWooltrest 2021-10-28 16:17:40 +03:00 committed by GitHub
commit d4e589bbba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 44 deletions

View File

@ -26,8 +26,8 @@ android {
applicationId = 'com.looker.droidify' applicationId = 'com.looker.droidify'
minSdk = 21 minSdk = 21
targetSdk = 31 targetSdk = 31
versionCode = 35 versionCode = 36
versionName = "0.3.5" versionName = "0.3.6"
} }
sourceSets.all { sourceSets.all {
@ -118,15 +118,15 @@ repositories {
dependencies { dependencies {
// Frontend // Frontend
implementation 'androidx.appcompat:appcompat:1.4.0-beta01' implementation 'androidx.appcompat:appcompat:1.4.0-rc01'
implementation 'androidx.viewpager2:viewpager2:1.0.0' implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'androidx.fragment:fragment-ktx:1.4.0-alpha10' implementation 'androidx.fragment:fragment-ktx:1.4.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'com.google.android.material:material:1.5.0-alpha04' implementation 'com.google.android.material:material:1.5.0-alpha05'
// Backend // Backend
implementation 'io.coil-kt:coil:1.4.0' implementation 'io.coil-kt:coil:1.4.0'
implementation 'androidx.core:core-ktx:1.6.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'io.reactivex.rxjava3:rxjava:3.1.1' implementation 'io.reactivex.rxjava3:rxjava:3.1.1'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0' implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'

View File

@ -0,0 +1,7 @@
- Added Icon for opening Details
- Top App Bar Differences made more prominent
- Root Permission will only be asked when used
- Switch Visibility fixes
- Added Arabic Translation
- Long press on source Icon to copy link
- Replace Toast with Snackbar

View File

@ -115,7 +115,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
private enum class LinkType( private enum class LinkType(
val iconResId: Int, val titleResId: Int, val iconResId: Int, val titleResId: Int,
val format: ((Context, String) -> String)? = null val format: ((Context, String) -> String)? = null,
) { ) {
AUTHOR(R.drawable.ic_person, R.string.author_website), AUTHOR(R.drawable.ic_person, R.string.author_website),
EMAIL(R.drawable.ic_email, R.string.author_email), EMAIL(R.drawable.ic_email, R.string.author_email),
@ -149,7 +149,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
class SwitchItem( class SwitchItem(
val switchType: SwitchType, val switchType: SwitchType,
val packageName: String, val packageName: String,
val versionCode: Long val versionCode: Long,
) : Item() { ) : Item() {
override val descriptor: String override val descriptor: String
get() = "switch.${switchType.name}" get() = "switch.${switchType.name}"
@ -160,7 +160,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
class SectionItem( class SectionItem(
val sectionType: SectionType, val expandType: ExpandType, val sectionType: SectionType, val expandType: ExpandType,
val items: List<Item>, val collapseCount: Int val items: List<Item>, val collapseCount: Int,
) : Item() { ) : Item() {
constructor(sectionType: SectionType) : this( constructor(sectionType: SectionType) : this(
sectionType, sectionType,
@ -255,7 +255,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
class PermissionsItem( class PermissionsItem(
val group: PermissionGroupInfo?, val group: PermissionGroupInfo?,
val permissions: List<PermissionInfo> val permissions: List<PermissionInfo>,
) : Item() { ) : Item() {
override val descriptor: String override val descriptor: String
get() = "permissions.${group?.name}.${permissions.joinToString(separator = ".") { it.name }}" get() = "permissions.${group?.name}.${permissions.joinToString(separator = ".") { it.name }}"
@ -266,7 +266,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
class ScreenshotItem( class ScreenshotItem(
val repository: Repository, val packageName: String, val repository: Repository, val packageName: String,
val screenshot: Product.Screenshot val screenshot: Product.Screenshot,
) : Item() { ) : Item() {
override val descriptor: String override val descriptor: String
get() = "screenshot.${repository.id}.${screenshot.identifier}" get() = "screenshot.${repository.id}.${screenshot.identifier}"
@ -277,7 +277,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
class ReleaseItem( class ReleaseItem(
val repository: Repository, val release: Release, val selectedRepository: Boolean, val repository: Repository, val release: Release, val selectedRepository: Boolean,
val showSignature: Boolean val showSignature: Boolean,
) : Item() { ) : Item() {
override val descriptor: String override val descriptor: String
get() = "release.${repository.id}.${release.identifier}" get() = "release.${repository.id}.${release.identifier}"
@ -603,7 +603,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
outRect: Rect, outRect: Rect,
parent: RecyclerView, parent: RecyclerView,
position: Int, position: Int,
count: Int count: Int,
) { ) {
val column = position % columns val column = position % columns
val rows = (count + columns - 1) / columns val rows = (count + columns - 1) / columns
@ -631,7 +631,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
outRect: Rect, outRect: Rect,
view: View, view: View,
parent: RecyclerView, parent: RecyclerView,
state: RecyclerView.State state: RecyclerView.State,
) { ) {
val holder = parent.getChildViewHolder(view) val holder = parent.getChildViewHolder(view)
if (holder is ScreenshotViewHolder) { if (holder is ScreenshotViewHolder) {
@ -664,7 +664,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
fun setProducts( fun setProducts(
context: Context, packageName: String, context: Context, packageName: String,
products: List<Pair<Product, Repository>>, installedItem: InstalledItem? products: List<Pair<Product, Repository>>, installedItem: InstalledItem?,
) { ) {
val productRepository = Product.findSuggested(products, installedItem) { it.first } val productRepository = Product.findSuggested(products, installedItem) { it.first }
items.clear() items.clear()
@ -759,9 +759,10 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
) else null ) else null
val item = Item.TextItem(TextType.DESCRIPTION, description) val item = Item.TextItem(TextType.DESCRIPTION, description)
if (cropped != null) { if (cropped != null) {
val croppedItem = Item.TextItem(TextType.DESCRIPTION, cropped)
items += listOf( items += listOf(
Item.TextItem(TextType.DESCRIPTION, cropped), croppedItem,
Item.ExpandItem(ExpandType.DESCRIPTION, true, listOf(item)) Item.ExpandItem(ExpandType.DESCRIPTION, true, listOf(item, croppedItem))
) )
} else { } else {
items += item items += item
@ -796,9 +797,10 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
if (ExpandType.CHANGES !in expanded) changes.lineCropped(12, 10) else null if (ExpandType.CHANGES !in expanded) changes.lineCropped(12, 10) else null
val item = Item.TextItem(TextType.CHANGES, changes) val item = Item.TextItem(TextType.CHANGES, changes)
if (cropped != null) { if (cropped != null) {
val croppedItem = Item.TextItem(TextType.CHANGES, cropped)
items += listOf( items += listOf(
Item.TextItem(TextType.CHANGES, cropped), croppedItem,
Item.ExpandItem(ExpandType.CHANGES, true, listOf(item)) Item.ExpandItem(ExpandType.CHANGES, true, listOf(item, croppedItem))
) )
} else { } else {
items += item items += item
@ -1011,7 +1013,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
override fun onCreateViewHolder( override fun onCreateViewHolder(
parent: ViewGroup, parent: ViewGroup,
viewType: ViewType viewType: ViewType,
): RecyclerView.ViewHolder { ): RecyclerView.ViewHolder {
return when (viewType) { return when (viewType) {
ViewType.HEADER -> HeaderViewHolder(parent.inflate(R.layout.product_header_item)).apply { ViewType.HEADER -> HeaderViewHolder(parent.inflate(R.layout.product_header_item)).apply {
@ -1073,25 +1075,41 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
itemView.setOnClickListener { itemView.setOnClickListener {
val position = adapterPosition val position = adapterPosition
val expandItem = items[position] as Item.ExpandItem val expandItem = items[position] as Item.ExpandItem
items.removeAt(position) if (expandItem.expandType !in expanded) {
expanded += expandItem.expandType expanded += expandItem.expandType
if (expandItem.replace) { if (expandItem.replace) {
expandItem.items.forEachIndexed { index, item -> items[position - 1] = expandItem.items[0]
items[position - expandItem.items.size + index] = item notifyItemRangeChanged(
position - expandItem.items.size,
expandItem.items.size
)
notifyItemChanged(position, Payload.REFRESH)
} else {
items.addAll(position, expandItem.items)
if (position > 0) {
// Update decorations
notifyItemChanged(position - 1, Payload.REFRESH)
}
notifyItemChanged(position, Payload.REFRESH)
notifyItemRangeInserted(position, expandItem.items.size)
} }
notifyItemRangeChanged(
position - expandItem.items.size,
expandItem.items.size
)
notifyItemRemoved(position)
} else { } else {
items.addAll(position, expandItem.items) expanded -= expandItem.expandType
if (position > 0) { if (expandItem.replace) {
// Update decorations items[position - 1] = expandItem.items[1]
notifyItemChanged(position - 1, Payload.REFRESH) notifyItemRangeChanged(
position - expandItem.items.size,
expandItem.items.size
)
notifyItemChanged(position, Payload.REFRESH)
} else {
items.removeAt(position - 1)
if (position > 0) {
// Update decorations
notifyItemRemoved(position - 1)
notifyItemChanged(position - 1, Payload.REFRESH)
}
} }
notifyItemRemoved(position)
notifyItemRangeInserted(position, expandItem.items.size)
} }
} }
} }
@ -1140,7 +1158,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
override fun onBindViewHolder( override fun onBindViewHolder(
holder: RecyclerView.ViewHolder, holder: RecyclerView.ViewHolder,
position: Int, position: Int,
payloads: List<Any> payloads: List<Any>,
) { ) {
val context = holder.itemView.context val context = holder.itemView.context
val item = items[position] val item = items[position]
@ -1304,12 +1322,14 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
ViewType.EXPAND -> { ViewType.EXPAND -> {
holder as ExpandViewHolder holder as ExpandViewHolder
item as Item.ExpandItem item as Item.ExpandItem
holder.text.setText( holder.text.text = if (item.expandType !in expanded) {
when (item.expandType) { when (item.expandType) {
ExpandType.VERSIONS -> R.string.show_older_versions ExpandType.VERSIONS -> context.getString(R.string.show_older_versions)
else -> R.string.show_more else -> context.getString(R.string.show_more)
} }
) } else {
"Show Less"
}
} }
ViewType.TEXT -> { ViewType.TEXT -> {
holder as TextViewHolder holder as TextViewHolder
@ -1483,7 +1503,8 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
holder.compatibility.setTextColor(context.getColorFromAttr(R.attr.colorError)) holder.compatibility.setTextColor(context.getColorFromAttr(R.attr.colorError))
holder.compatibility.text = when (incompatibility) { holder.compatibility.text = when (incompatibility) {
is Release.Incompatibility.MinSdk, is Release.Incompatibility.MinSdk,
is Release.Incompatibility.MaxSdk -> context.getString( is Release.Incompatibility.MaxSdk,
-> context.getString(
R.string.incompatible_with_FORMAT, R.string.incompatible_with_FORMAT,
Android.name Android.name
) )
@ -1580,14 +1601,14 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
text: CharSequence?, text: CharSequence?,
start: Int, start: Int,
end: Int, end: Int,
fm: Paint.FontMetricsInt? fm: Paint.FontMetricsInt?,
): Int { ): Int {
return paint.measureText(".").roundToInt() return paint.measureText(".").roundToInt()
} }
override fun draw( override fun draw(
canvas: Canvas, text: CharSequence?, start: Int, end: Int, canvas: Canvas, text: CharSequence?, start: Int, end: Int,
x: Float, top: Int, y: Int, bottom: Int, paint: Paint x: Float, top: Int, y: Int, bottom: Int, paint: Paint,
) { ) {
canvas.drawText(".", x, y.toFloat(), paint) canvas.drawText(".", x, y.toFloat(), paint)
} }