Skip to content

Commit

Permalink
Introduce ProgressDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Reco1I committed Dec 17, 2024
1 parent 4d26bc1 commit d7d67c2
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
64 changes: 64 additions & 0 deletions res/layout/dialog_progress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frg_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000"
android:elevation="1dp">

<LinearLayout
android:id="@+id/frg_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:background="@drawable/rounded_rect"
android:backgroundTint="#1E1E2E"
android:divider="@drawable/divider"
android:gravity="center"
android:minWidth="200dp"
android:orientation="vertical"
android:showDividers="middle">

<TextView
android:id="@+id/title"
style="@style/settings_tab_divider"
android:paddingVertical="12dp"
android:text="Title" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="12dp">

<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:padding="10dp"
app:indicatorColor="@color/colorAccent"
app:indicatorDirectionCircular="counterclockwise"
app:trackCornerRadius="12dp"
tools:indeterminate="false"
tools:progress="50" />

<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:maxWidth="400dp"
android:textColor="#FFF"
tools:text="Message" />

</LinearLayout>

</LinearLayout>

</RelativeLayout>
80 changes: 80 additions & 0 deletions src/com/reco1l/osu/ui/ProgressDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.reco1l.osu.ui

import com.google.android.material.progressindicator.CircularProgressIndicator
import ru.nsu.ccfit.zuev.osuplus.R


class ProgressDialog : MessageDialog() {


override val layoutID = R.layout.dialog_progress


/**
* The progress of the dialog.
*/
var progress: Int = 0
set(value) {
field = value
if (isCreated) {
findViewById<CircularProgressIndicator>(R.id.progress)!!.progress = value
}
}

/**
* Whether the progress is indeterminate or not.
*/
var indeterminate: Boolean = false
set(value) {
field = value
if (isCreated) {
findViewById<CircularProgressIndicator>(R.id.progress)!!.isIndeterminate = value
}
}

/**
* The maximum value of the progress.
*/
var max: Int = 0
set(value) {
field = value
if (isCreated) {
findViewById<CircularProgressIndicator>(R.id.progress)!!.max = value
}
}


override fun onLoadView() {
super.onLoadView()

max = max
progress = progress
indeterminate = indeterminate
}


/**
* Sets the progress of the dialog.
*/
fun setProgress(value: Int): ProgressDialog {
progress = value
return this
}

/**
* Sets whether the progress is indeterminate or not.
*/
fun setIndeterminate(value: Boolean): ProgressDialog {
indeterminate = value
return this
}

/**
* Sets the maximum value of the progress.
*/
fun setMax(value: Int): ProgressDialog {
max = value
return this
}

}

0 comments on commit d7d67c2

Please sign in to comment.