Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from Lennoard/FEATURE-redesign
Browse files Browse the repository at this point in the history
Feature redesign
  • Loading branch information
Lennoard authored May 30, 2021
2 parents 62c55fb + ed749fe commit 74fe24c
Show file tree
Hide file tree
Showing 504 changed files with 17,664 additions and 22,718 deletions.
15 changes: 8 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion

plugins {
id("com.android.application")
id("com.google.android.gms.oss-licenses-plugin")
kotlin("android")
id("kotlin-android-extensions")
}
Expand All @@ -12,8 +13,6 @@ android {
viewBinding = true
}

buildToolsVersion("29.0.3")

compileSdkVersion(29)
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -28,8 +27,8 @@ android {
applicationId = "com.androidvip.hebf"
minSdkVersion(16)
targetSdkVersion(29)
versionCode = 183
versionName = "2.5.1"
versionCode = 184
versionName = "3.0.0"
vectorDrawables.useSupportLibrary = true
resConfigs("en", "ar", "de", "es", "fr", "hi", "in", "it", "pt", "ru", "tr", "zh")
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -75,8 +74,8 @@ dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION))

implementation("androidx.appcompat:appcompat:1.2.0")
implementation("androidx.core:core-ktx:1.3.2")
implementation("androidx.appcompat:appcompat:1.3.0")
implementation("androidx.core:core-ktx:1.5.0")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
Expand All @@ -92,7 +91,9 @@ dependencies {
implementation("com.github.PhilJay:MPAndroidChart:v3.1.0")
implementation("com.github.topjohnwu.libsu:core:3.0.2")

implementation("com.google.android.material:material:1.3.0-alpha03")
implementation("com.airbnb.android:lottie:3.7.0")
implementation("com.google.android.material:material:1.4.0-beta01")
implementation("com.google.android.gms:play-services-oss-licenses:17.0.0")
implementation("com.google.code.gson:gson:2.8.6")
implementation("de.hdodenhof:circleimageview:3.1.0")
implementation("io.insert-koin:koin-android:3.0.1")
Expand Down
264 changes: 124 additions & 140 deletions app/src/main/AndroidManifest.xml

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions app/src/main/assets/translate/hebf_arrays.xml

This file was deleted.

568 changes: 0 additions & 568 deletions app/src/main/assets/translate/hebf_translate.xml

This file was deleted.

82 changes: 65 additions & 17 deletions app/src/main/java/com/androidvip/hebf/Extensions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.androidvip.hebf

import android.animation.ObjectAnimator
import android.app.Activity
import android.content.Context
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.drawable.Drawable
Expand All @@ -11,17 +13,21 @@ import android.os.Looper
import android.util.SparseArray
import android.util.TypedValue
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import android.widget.ProgressBar
import android.widget.Toast
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.annotation.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.ContextCompat
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat
import androidx.core.view.forEach
import androidx.core.widget.TextViewCompat
import androidx.fragment.app.Fragment
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.androidvip.hebf.fragments.BaseFragment
import com.androidvip.hebf.utils.Themes
import com.androidvip.hebf.ui.base.BaseFragment
import com.androidvip.hebf.utils.Utils
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.BaseTransientBottomBar
Expand Down Expand Up @@ -49,6 +55,34 @@ fun View.show() {
this.visibility = View.VISIBLE
}

fun ViewGroup.setContentEnabled(enabled: Boolean) {
setOnClickListener(null)
isEnabled = false
forEach { child ->
if (child is ViewGroup) {
child.setContentEnabled(enabled)
} else {
if (child is AppCompatTextView) {
child.isEnabled = false
child.setTextColor(ContextCompat.getColor(context, R.color.disabled))
TextViewCompat.setCompoundDrawableTintList(
child, ContextCompat.getColorStateList(context, R.color.disabled)
)
}
}
}
}

fun ProgressBar.animProgress(progress: Int) {
ObjectAnimator.ofInt(
this, "progress", this.progress, progress
).apply {
duration = 400
interpolator = DecelerateInterpolator()
start()
}
}

fun Context?.toast(messageRes: Int, short: Boolean = true) {
if (this == null) return
toast(getString(messageRes), short)
Expand Down Expand Up @@ -84,14 +118,15 @@ inline fun Context.confirm(
crossinline onConfirm: () -> Unit
) = MaterialAlertDialogBuilder(this).apply {
setTitle(android.R.string.dialog_alert_title)
setIcon(getThemedVectorDrawable(R.drawable.ic_warning))
setMessage(message)
setCancelable(false)
setNegativeButton(R.string.cancelar) { _, _ -> }
setPositiveButton(android.R.string.yes) { _, _ ->
onConfirm()
}
show()
applyAnim().also {
it.show()
}
}

fun Context.runOnMainThread(f: Context.() -> Unit) {
Expand All @@ -116,6 +151,12 @@ fun Context.getThemedVectorDrawable(@DrawableRes resId: Int): VectorDrawableComp
}
}

fun Context.getColoredVectorDrawable(@DrawableRes resId: Int): VectorDrawableCompat? {
return createVectorDrawable(resId)?.apply {
setTintCompat(getColorFromAttr(R.attr.colorPrimary))
}
}

fun Drawable.setTintCompat(color: Int, blendModeCompat: BlendModeCompat = BlendModeCompat.SRC_ATOP) {
colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
color, blendModeCompat
Expand All @@ -138,22 +179,27 @@ fun Int.toPx(context: Context): Int {
if (Utils.isInvalidContext(context)) return this
var px = this
runCatching {
px = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
this.toFloat(),
context.resources.displayMetrics
).toInt()
px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this.toFloat(), context.resources.displayMetrics).toInt()
}
return px
}

fun Double.roundTo2Decimals(decimals: Int): Double {
fun Double.roundDecimals(decimals: Int = 2): Double {
return BigDecimal(this).setScale(decimals, RoundingMode.HALF_UP).toDouble()
}

infix fun Number.percentOf(target: Number): Int = ((this.toDouble() * target.toDouble()) / 100).toInt()
infix fun Number.percentOf(other: Number): Double {
return (this.toDouble() / 100) * other.toDouble()
}
infix fun Number.isWhatPercentOf(other: Number): Double {
return (this.toDouble() / other.toDouble()) * 100
}

infix fun Int.isMultipleOf(target: Int): Boolean = this % target == 0

// dp to pixels
val Number.dp: Float get() = (this.toFloat() * Resources.getSystem().displayMetrics.density + 0.5F)

fun Int.findNearestPositiveMultipleOf(target: Int): Int {
if (this isMultipleOf target) return this

Expand Down Expand Up @@ -187,8 +233,10 @@ suspend fun String.getBitMapFromUrl() : Bitmap? {
}
}

fun Activity.setThemeFromPrefs() {
Themes.setTheme(this)
fun MaterialAlertDialogBuilder.applyAnim(
@StyleRes styleResId: Int = R.style.AppDialogAnimation
): AlertDialog = create().also {
it.window?.attributes?.windowAnimations = styleResId
}

fun Uri.readLines(context: Context?, forEachLine: (String) -> Unit) {
Expand Down
Loading

0 comments on commit 74fe24c

Please sign in to comment.