Added progress bar to popup, to better indicate loading
All checks were successful
Android Release Build / build (push) Successful in 7s
All checks were successful
Android Release Build / build (push) Successful in 7s
This commit is contained in:
parent
0a6df829d4
commit
240f95eba2
4 changed files with 57 additions and 10 deletions
|
@ -11,8 +11,8 @@ android {
|
|||
applicationId = "partisan.weforge.xyz.pulse"
|
||||
minSdk = 29
|
||||
targetSdk = 34
|
||||
versionCode = 11
|
||||
versionName = "1.3.2"
|
||||
versionCode = 12
|
||||
versionName = "1.4.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import android.view.LayoutInflater
|
|||
import android.view.WindowManager
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.widget.TextView
|
||||
import android.animation.ObjectAnimator
|
||||
import android.widget.ProgressBar
|
||||
import androidx.annotation.RequiresPermission
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
|
@ -81,6 +83,7 @@ class PopupWindow(
|
|||
service.cancelCall()
|
||||
}, prefs.redirectionDelay)
|
||||
setDescription(destinationId)
|
||||
startProgressAnimation(prefs.redirectionDelay)
|
||||
if (!add()) {
|
||||
timer?.cancel()
|
||||
service.placeCallUnmodified()
|
||||
|
@ -94,6 +97,15 @@ class PopupWindow(
|
|||
)
|
||||
}
|
||||
|
||||
private fun startProgressAnimation(duration: Long) {
|
||||
val bar = view.findViewById<ProgressBar>(R.id.progress)
|
||||
bar.max = 100
|
||||
bar.progress = 0
|
||||
val animator = ObjectAnimator.ofInt(bar, "progress", 100)
|
||||
animator.duration = duration
|
||||
animator.start()
|
||||
}
|
||||
|
||||
@RequiresPermission(Manifest.permission.CALL_PHONE)
|
||||
private fun call(data: Uri) {
|
||||
Intent(Intent.ACTION_VIEW).apply {
|
||||
|
|
17
app/src/main/res/drawable/progress_drawable.xml
Normal file
17
app/src/main/res/drawable/progress_drawable.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#22000000" />
|
||||
<corners android:radius="999dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?attr/colorPrimary" />
|
||||
<corners android:radius="999dp" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -10,14 +10,32 @@
|
|||
app:cardBackgroundColor="?attr/colorSurface"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/colorOnSurface"
|
||||
android:textSize="16sp"
|
||||
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||
android:textAlignment="center"
|
||||
tools:text="Popup text" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/colorOnSurface"
|
||||
android:textSize="16sp"
|
||||
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||
android:textAlignment="center"
|
||||
tools:text="Popup text" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:indeterminate="false"
|
||||
android:max="100"
|
||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||
android:progressDrawable="@drawable/progress_drawable"/>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue