Skip to content

Commit abb0eff

Browse files
committed
Added please wait indicator while decrypting
1 parent fa005bf commit abb0eff

File tree

2 files changed

+77
-61
lines changed

2 files changed

+77
-61
lines changed

App/src/main/java/org/astonbitecode/rustkeylock/fragments/EnterPassword.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with rust-keylock. If not, see <http://www.gnu.org/licenses/>.
1616
package org.astonbitecode.rustkeylock.fragments;
1717

18+
import android.widget.ProgressBar;
1819
import org.astonbitecode.rustkeylock.R;
1920
import org.astonbitecode.rustkeylock.api.InterfaceWithRust;
2021
import org.astonbitecode.rustkeylock.handlers.back.BackButtonHandler;
@@ -29,11 +30,15 @@
2930
import android.widget.Button;
3031
import android.widget.EditText;
3132

33+
import static android.view.View.VISIBLE;
34+
3235
public class EnterPassword extends Fragment implements OnClickListener, BackButtonHandler {
3336
private static final long serialVersionUID = -9046678064745197531L;
3437
private final String TAG = getClass().getName();
3538
private transient EditText passwordText;
3639
private transient EditText numberText;
40+
private transient ProgressBar progressBarDecrypting;
41+
private transient Button buttonDecrypt;
3742

3843
public EnterPassword() {
3944
}
@@ -61,8 +66,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6166
this.passwordText = passwordText;
6267
EditText numberText = rootView.findViewById(R.id.editFavoriteNumber);
6368
this.numberText = numberText;
64-
Button b = (Button) rootView.findViewById(R.id.buttonDecrypt);
69+
Button b = rootView.findViewById(R.id.buttonDecrypt);
6570
b.setOnClickListener(this);
71+
this.progressBarDecrypting = rootView.findViewById(R.id.progressBar_decrypting);
72+
this.buttonDecrypt = rootView.findViewById(R.id.buttonDecrypt);
6673

6774
return rootView;
6875
}
@@ -81,6 +88,8 @@ public void onClick(View view) {
8188
} else {
8289
try {
8390
int num = Integer.parseInt(numString);
91+
this.progressBarDecrypting.setVisibility(VISIBLE);
92+
this.buttonDecrypt.setEnabled(false);
8493
InterfaceWithRust.INSTANCE.set_password(pass, num);
8594
} catch (Exception error) {
8695
String message = "Incorrect number";
Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,92 @@
11
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
3-
android:id="@+id/PasswordLayout"
4-
android:layout_width="match_parent"
5-
android:layout_height="match_parent"
6-
android:gravity="center|top"
7-
android:orientation="vertical"
8-
android:paddingBottom="@dimen/activity_vertical_margin"
9-
android:paddingLeft="@dimen/activity_horizontal_margin"
10-
android:paddingRight="@dimen/activity_horizontal_margin"
11-
android:paddingTop="@dimen/activity_vertical_margin"
12-
tools:context="org.astonbitecode.rustkeylock.MainActivity" >
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/PasswordLayout"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:gravity="center|top"
7+
android:orientation="vertical"
8+
android:paddingBottom="@dimen/activity_vertical_margin"
9+
android:paddingLeft="@dimen/activity_horizontal_margin"
10+
android:paddingRight="@dimen/activity_horizontal_margin"
11+
android:paddingTop="@dimen/activity_vertical_margin"
12+
tools:context="org.astonbitecode.rustkeylock.MainActivity">
1313

1414
<TextView
15-
android:id="@+id/welcomeLabel"
16-
android:layout_width="wrap_content"
17-
android:layout_height="wrap_content"
18-
android:text="Welcome to rust-keylock"
19-
android:textAppearance="?android:attr/textAppearanceLarge" />
15+
android:id="@+id/welcomeLabel"
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:text="Welcome to rust-keylock"
19+
android:textAppearance="?android:attr/textAppearanceLarge"/>
2020

2121
<ScrollView
22-
android:id="@+id/scrollViewChangePassword"
23-
android:layout_width="match_parent"
24-
android:layout_height="wrap_content"
25-
android:gravity="center|top" >
26-
27-
<LinearLayout
22+
android:id="@+id/scrollViewChangePassword"
2823
android:layout_width="match_parent"
2924
android:layout_height="wrap_content"
30-
android:gravity="center|top"
31-
android:orientation="vertical" >
25+
android:gravity="center|top">
3226

33-
<TextView
34-
android:id="@+id/passwordLabel"
35-
android:layout_width="wrap_content"
27+
<LinearLayout
28+
android:layout_width="match_parent"
3629
android:layout_height="wrap_content"
37-
android:layout_marginTop="100sp"
38-
android:text="Please provide your Password"
39-
android:textAppearance="?android:attr/textAppearanceSmall" />
30+
android:gravity="center|top"
31+
android:orientation="vertical">
32+
33+
<TextView
34+
android:id="@+id/passwordLabel"
35+
android:layout_width="wrap_content"
36+
android:layout_height="wrap_content"
37+
android:layout_marginTop="100sp"
38+
android:text="Please provide your Password"
39+
android:textAppearance="?android:attr/textAppearanceSmall"/>
4040

4141
<EditText
42-
android:id="@+id/editPassword"
43-
android:layout_width="match_parent"
44-
android:layout_height="wrap_content"
45-
android:inputType="textPassword"
46-
tools:ignore="Autofill" >
42+
android:id="@+id/editPassword"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:inputType="textPassword"
46+
tools:ignore="Autofill">
4747

48-
<requestFocus />
48+
<requestFocus/>
4949
</EditText>
5050

5151
<TextView
52-
android:id="@+id/favoriteNumberLabel"
53-
android:layout_width="wrap_content"
54-
android:layout_height="wrap_content"
55-
android:layout_marginTop="33sp"
56-
android:text="What is your favorite number?"
57-
android:textAppearance="?android:attr/textAppearanceSmall" />
52+
android:id="@+id/favoriteNumberLabel"
53+
android:layout_width="wrap_content"
54+
android:layout_height="wrap_content"
55+
android:layout_marginTop="33sp"
56+
android:text="What is your favorite number?"
57+
android:textAppearance="?android:attr/textAppearanceSmall"/>
5858

5959
<EditText
60-
android:id="@+id/editFavoriteNumber"
61-
android:layout_width="match_parent"
62-
android:layout_height="wrap_content"
63-
android:inputType="numberPassword"
64-
tools:ignore="Autofill" />
60+
android:id="@+id/editFavoriteNumber"
61+
android:layout_width="match_parent"
62+
android:layout_height="wrap_content"
63+
android:inputType="numberPassword"
64+
tools:ignore="Autofill"/>
6565

6666
<Button
67-
android:id="@+id/buttonDecrypt"
68-
android:layout_width="wrap_content"
69-
android:layout_height="wrap_content"
70-
android:layout_gravity="right"
71-
android:layout_marginTop="33sp"
72-
android:background="@android:color/transparent"
73-
android:drawableTop="@drawable/arrow_right"
74-
android:text="Decrypt" />
67+
android:id="@+id/buttonDecrypt"
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:layout_gravity="right"
71+
android:layout_marginTop="33sp"
72+
android:background="@android:color/transparent"
73+
android:drawableTop="@drawable/arrow_right"
74+
android:text="Decrypt"/>
7575

7676
<ImageView
77-
android:id="@+id/changableImage"
78-
android:layout_width="wrap_content"
79-
android:layout_height="wrap_content"
80-
android:src="@drawable/ic_launcher"
81-
android:contentDescription="rust-keylock" />
77+
android:id="@+id/changableImage"
78+
android:layout_width="wrap_content"
79+
android:layout_height="wrap_content"
80+
android:src="@drawable/ic_launcher"
81+
android:contentDescription="rust-keylock"/>
8282
</LinearLayout>
8383
</ScrollView>
84+
<ProgressBar
85+
android:id="@+id/progressBar_decrypting"
86+
android:layout_width="wrap_content"
87+
android:layout_height="wrap_content"
88+
android:minHeight="33dp"
89+
android:minWidth="33dp"
90+
android:visibility="invisible"/>
8491

8592
</LinearLayout>

0 commit comments

Comments
 (0)