Skip to content

Commit 46dd38b

Browse files
committed
percentage display added.
1 parent d599f03 commit 46dd38b

File tree

5 files changed

+64
-59
lines changed

5 files changed

+64
-59
lines changed

mobile/src/main/java/io/syslogic/github/dialog/ProgressDialogFragment.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.syslogic.github.dialog;
22

3-
import android.annotation.SuppressLint;
43
import android.os.Bundle;
54
import android.util.Log;
65
import android.view.LayoutInflater;
@@ -12,6 +11,8 @@
1211

1312
import org.eclipse.jgit.lib.ProgressMonitor;
1413

14+
import java.util.Locale;
15+
1516
import io.syslogic.github.databinding.DialogProgressBinding;
1617
import io.syslogic.github.R;
1718

@@ -32,12 +33,13 @@ public class ProgressDialogFragment extends BaseDialogFragment implements Progre
3233
DialogProgressBinding mDataBinding;
3334

3435
private String repoName = null;
35-
3636
private boolean taskCancelled = false;
37-
private int totalTasks = 4;
37+
private int totalTasks = 6;
3838
private int currentTask = 0;
3939
private int totalWork = 0;
4040
private int currentWork = 0;
41+
42+
/** Constructor */
4143
public ProgressDialogFragment() {}
4244

4345
/** Inflate the data-binding */
@@ -62,7 +64,6 @@ public void start(int totalTasks) {
6264
}
6365

6466
/** ProgressMonitor: Begin processing a single task. */
65-
@SuppressLint("SetTextI18n")
6667
@Override
6768
public void beginTask(String title, int totalWork) {
6869
this.totalWork = totalWork;
@@ -78,15 +79,23 @@ public void beginTask(String title, int totalWork) {
7879
}
7980

8081
/** ProgressMonitor: Denote that some work units have been completed. */
81-
@SuppressLint("SetTextI18n")
8282
@Override
8383
public void update(int completed) {
8484
this.currentWork += completed;
85+
8586
String message = this.currentWork + " / " + this.totalWork;
87+
String percentage;
8688
// if (mDebug) {Log.d(LOG_TAG, "items complete: " + message);}
89+
if (this.totalWork == 0) {
90+
percentage = "0.00%";
91+
} else {
92+
percentage = String.format(Locale.ROOT,"%.02f", (float) (this.currentWork / this.totalWork * 100)) + "%";
93+
}
94+
8795
requireActivity().runOnUiThread(() -> {
8896
this.mDataBinding.progressIndicator.setProgress(this.currentWork);
8997
this.mDataBinding.textTaskStatus.setText(message);
98+
this.mDataBinding.textTaskPercentage.setText(percentage);
9099
});
91100
}
92101

@@ -97,9 +106,8 @@ public void endTask() {
97106
// if (this.currentTask == this.totalTasks) {this.dismiss();} // TODO: comparison doesn't work.
98107

99108
/* Reset the progress indicator */
100-
requireActivity().runOnUiThread(() -> {
101-
this.mDataBinding.progressIndicator.setProgress(0);
102-
});
109+
requireActivity().runOnUiThread(() ->
110+
this.mDataBinding.progressIndicator.setProgress(0));
103111
}
104112

105113
/** Interface: ProgressMonitor. Check for user task cancellation. */

mobile/src/main/java/io/syslogic/github/fragment/RepositoryFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void gitClone(@NonNull File destination, @Nullable String branch) {
209209
cmd.setBranch(branch);
210210
}
211211

212-
if (mDebug) {Log.d(LOG_TAG, "Cloning into " + getRepoName() + "...");}
212+
if (mDebug) {Log.d(LOG_TAG, "Cloning git repository " + getRepoName() + "...");}
213213
try {
214214
cmd.call();
215215
} catch (GitAPIException | JGitInternalException | NoSuchMethodError e) {

mobile/src/main/res/layout/dialog_progress.xml

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
<com.google.android.material.textview.MaterialTextView
2020
android:layout_gravity="center_horizontal"
21-
android:layout_width="wrap_content"
21+
android:layout_width="match_parent"
2222
android:layout_height="wrap_content"
23+
android:textAlignment="center"
2324
android:textStyle="bold"
2425
android:textSize="22sp"
2526
android:textColor="@color/design_default_color_secondary_variant"
@@ -32,8 +33,9 @@
3233
<com.google.android.material.textview.MaterialTextView
3334
android:id="@+id/repository_name"
3435
android:layout_gravity="center_horizontal"
35-
android:layout_width="wrap_content"
36+
android:layout_width="match_parent"
3637
android:layout_height="wrap_content"
38+
android:textAlignment="center"
3739
android:textStyle="bold"
3840
android:textSize="20sp"
3941
tools:text="@string/tools_full_name"/>
@@ -42,54 +44,49 @@
4244
android:layout_width="match_parent"
4345
android:layout_height="8dp"/>
4446

45-
<androidx.appcompat.widget.LinearLayoutCompat
46-
android:layout_width="match_parent"
47-
android:layout_height="wrap_content"
48-
android:layout_margin="0dp"
49-
android:orientation="vertical">
50-
51-
<androidx.appcompat.widget.AppCompatTextView
52-
android:id="@+id/text_task_title"
53-
android:layout_width="match_parent"
54-
android:layout_height="wrap_content"
55-
android:padding="4dp"
56-
android:textAlignment="center"
57-
android:textColor="#546E7A"
58-
android:textSize="20sp"
59-
app:fontFamily="monospace"
60-
tools:text="@string/tools_task_title"/>
61-
62-
<com.google.android.material.progressindicator.LinearProgressIndicator
63-
android:id="@+id/progressIndicator"
64-
android:layout_width="fill_parent"
65-
android:layout_height="12dp"
66-
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
67-
tools:background="@color/colorAccent"/>
68-
69-
70-
<androidx.appcompat.widget.AppCompatTextView
71-
android:id="@+id/text_task_status"
72-
android:layout_width="match_parent"
73-
android:layout_height="wrap_content"
74-
android:padding="4dp"
75-
android:textAlignment="center"
76-
android:textColor="#546E7A"
77-
android:textSize="20sp"
78-
app:fontFamily="monospace"
79-
tools:text="@string/tools_task_progress"/>
47+
<com.google.android.material.progressindicator.LinearProgressIndicator
48+
android:id="@+id/progressIndicator"
49+
android:layout_width="fill_parent"
50+
android:layout_height="20dp"
51+
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
52+
tools:background="@color/colorAccent"/>
8053

81-
<androidx.appcompat.widget.AppCompatTextView
82-
android:id="@+id/text_task_percentage"
83-
android:layout_width="match_parent"
84-
android:layout_height="wrap_content"
85-
android:padding="4dp"
86-
android:textAlignment="center"
87-
android:textColor="#546E7A"
88-
android:textSize="20sp"
89-
app:fontFamily="monospace"
90-
tools:text="@string/tools_task_percentage"/>
54+
<Space
55+
android:layout_width="match_parent"
56+
android:layout_height="8dp"/>
9157

92-
</androidx.appcompat.widget.LinearLayoutCompat>
58+
<androidx.appcompat.widget.AppCompatTextView
59+
android:id="@+id/text_task_title"
60+
android:layout_width="match_parent"
61+
android:layout_height="wrap_content"
62+
android:padding="4dp"
63+
android:textAlignment="center"
64+
android:textColor="#546E7A"
65+
android:textSize="14sp"
66+
app:fontFamily="monospace"
67+
tools:text="@string/tools_task_title"/>
68+
69+
<androidx.appcompat.widget.AppCompatTextView
70+
android:id="@+id/text_task_status"
71+
android:layout_width="match_parent"
72+
android:layout_height="wrap_content"
73+
android:padding="4dp"
74+
android:textAlignment="center"
75+
android:textColor="#546E7A"
76+
android:textSize="14sp"
77+
app:fontFamily="monospace"
78+
tools:text="@string/tools_task_progress"/>
79+
80+
<androidx.appcompat.widget.AppCompatTextView
81+
android:id="@+id/text_task_percentage"
82+
android:layout_width="match_parent"
83+
android:layout_height="wrap_content"
84+
android:padding="4dp"
85+
android:textAlignment="center"
86+
android:textColor="#546E7A"
87+
android:textSize="18sp"
88+
app:fontFamily="monospace"
89+
tools:text="@string/tools_task_percentage"/>
9390

9491
<Space
9592
android:layout_width="match_parent"

mobile/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@
5555
<string name="hint_query_string_operand">Comparison Value</string>
5656
<string name="hint_query_string_is_raw">Raw Query</string>
5757

58-
<string name="text_cloning_repository">Cloning into…</string>
58+
<string name="text_cloning_repository">Cloning git repository…</string>
5959

6060
</resources>

mobile/src/main/res/values/tools.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<string name="tools_workflow_name">android.yml</string>
2323

2424
<!-- dialog progress -->
25-
<string name="tools_task_title">Enumerating objects</string>
25+
<string name="tools_task_title">remote: Enumerating objects</string>
2626
<string name="tools_task_progress">2056 / 5793</string>
2727
<string name="tools_task_percentage">93%</string>
2828

0 commit comments

Comments
 (0)