Skip to content

Commit cf5587c

Browse files
committed
Added reveal password on tap functionality.
1 parent 3896c5d commit cf5587c

File tree

3 files changed

+68
-72
lines changed

3 files changed

+68
-72
lines changed

java/pom.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<android.maven.plugin.version>4.5.0</android.maven.plugin.version>
1616
<android.plugin.version>4.1.1.4</android.plugin.version>
1717
<junit.version>3.8.1</junit.version>
18-
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
18+
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
1919
</properties>
2020

2121
<repositories>
@@ -77,28 +77,11 @@
7777
<artifactId>maven-compiler-plugin</artifactId>
7878
<version>${maven.compiler.plugin.version}</version>
7979
<configuration>
80+
<!--<release>11</release>-->
8081
<source>1.7</source>
8182
<target>1.7</target>
8283
</configuration>
8384
</plugin>
84-
<plugin>
85-
<groupId>org.apache.maven.plugins</groupId>
86-
<artifactId>maven-dependency-plugin</artifactId>
87-
<executions>
88-
<execution>
89-
<id>resource-dependencies</id>
90-
<phase>process-sources</phase>
91-
<goals>
92-
<goal>unpack-dependencies</goal>
93-
</goals>
94-
<configuration>
95-
<includeArtifactIds>android-arm</includeArtifactIds>
96-
<includes>libjnidispatch.so</includes>
97-
<outputDirectory>libs/armeabi</outputDirectory>
98-
</configuration>
99-
</execution>
100-
</executions>
101-
</plugin>
10285
</plugins>
10386
<pluginManagement>
10487
<plugins>

java/res/layout/fragment_show_entry.xml

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,88 +45,84 @@
4545
android:layout_height="wrap_content"
4646
android:inputType="text"/>
4747

48-
<LinearLayout
49-
android:layout_width="match_parent"
50-
android:layout_height="match_parent"
51-
android:orientation="horizontal"
52-
android:layout_marginTop="20sp"
53-
android:layout_gravity="center">
54-
<TextView
55-
android:id="@+id/urlLabel"
56-
android:layout_width="wrap_content"
48+
<TextView
49+
android:id="@+id/urlLabel"
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:text="URL"
53+
android:textAppearance="?android:attr/textAppearanceSmall"/>
54+
55+
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
56+
<EditText
57+
android:id="@+id/editUrl"
58+
android:layout_width="match_parent"
5759
android:layout_height="wrap_content"
58-
android:text="URL"
59-
android:textAppearance="?android:attr/textAppearanceSmall"/>
60+
android:inputType="text"/>
61+
6062
<ImageButton
6163
android:id="@+id/copyUrlButton"
6264
android:layout_width="wrap_content"
6365
android:layout_height="wrap_content"
6466
android:src="@drawable/copy"
67+
android:layout_alignParentRight="true"
68+
android:layout_centerVertical="true"
6569
android:layout_marginLeft="10sp"
6670
android:background="@null"/>
67-
</LinearLayout>
71+
</RelativeLayout>
6872

69-
<EditText
70-
android:id="@+id/editUrl"
71-
android:layout_width="match_parent"
73+
<TextView
74+
android:id="@+id/userLabel"
75+
android:layout_width="wrap_content"
7276
android:layout_height="wrap_content"
73-
android:inputType="text"/>
77+
android:layout_marginTop="10sp"
78+
android:text="Username"
79+
android:textAppearance="?android:attr/textAppearanceSmall"/>
7480

75-
<LinearLayout
76-
android:layout_width="match_parent"
77-
android:layout_height="match_parent"
78-
android:orientation="horizontal"
79-
android:layout_marginTop="20sp"
80-
android:layout_gravity="center">
81-
<TextView
82-
android:id="@+id/userLabel"
83-
android:layout_width="wrap_content"
81+
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
82+
83+
<EditText
84+
android:id="@+id/editUser"
85+
android:layout_width="match_parent"
8486
android:layout_height="wrap_content"
85-
android:layout_marginTop="10sp"
86-
android:text="Username"
87-
android:textAppearance="?android:attr/textAppearanceSmall"/>
87+
android:inputType="text"/>
88+
8889
<ImageButton
8990
android:id="@+id/copyUsernameButton"
9091
android:layout_width="wrap_content"
9192
android:layout_height="wrap_content"
9293
android:src="@drawable/copy"
94+
android:layout_alignParentRight="true"
95+
android:layout_centerVertical="true"
9396
android:layout_marginLeft="10sp"
9497
android:background="@null"/>
95-
</LinearLayout>
98+
</RelativeLayout>
9699

97-
<EditText
98-
android:id="@+id/editUser"
99-
android:layout_width="match_parent"
100+
<TextView
101+
android:id="@+id/passwordLabel"
102+
android:layout_width="wrap_content"
100103
android:layout_height="wrap_content"
101-
android:inputType="text"/>
104+
android:layout_marginTop="10sp"
105+
android:text="Password"
106+
android:textAppearance="?android:attr/textAppearanceSmall"/>
102107

103-
<LinearLayout
104-
android:layout_width="match_parent"
105-
android:layout_height="match_parent"
106-
android:orientation="horizontal"
107-
android:layout_marginTop="20sp"
108-
android:layout_gravity="center">
109-
<TextView
110-
android:id="@+id/passwordLabel"
111-
android:layout_width="wrap_content"
108+
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
109+
110+
<EditText
111+
android:id="@+id/editPassword"
112+
android:layout_width="match_parent"
112113
android:layout_height="wrap_content"
113-
android:layout_marginTop="10sp"
114-
android:text="Password"
115-
android:textAppearance="?android:attr/textAppearanceSmall"/>
114+
android:inputType="text"/>
115+
116116
<ImageButton
117117
android:id="@+id/copyPasswordButton"
118118
android:layout_width="wrap_content"
119119
android:layout_height="wrap_content"
120120
android:src="@drawable/copy"
121+
android:layout_alignParentRight="true"
122+
android:layout_centerVertical="true"
121123
android:layout_marginLeft="10sp"
122124
android:background="@null"/>
123-
</LinearLayout>
124-
125-
<EditText
126-
android:id="@+id/editPassword"
127-
android:layout_width="match_parent"
128-
android:layout_height="wrap_content"
129-
android:inputType="text"/>
125+
</RelativeLayout>
130126

131127
<TextView
132128
android:id="@+id/nameDescription"

java/src/main/java/org/astonbitecode/rustkeylock/fragments/ShowEntry.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
import android.content.Context;
2222
import android.os.Bundle;
2323
import android.text.method.PasswordTransformationMethod;
24+
import android.text.method.TransformationMethod;
2425
import android.util.Log;
2526
import android.view.LayoutInflater;
27+
import android.view.MotionEvent;
2628
import android.view.View;
2729
import android.view.View.OnClickListener;
2830
import android.view.ViewGroup;
@@ -39,7 +41,7 @@
3941
import java.net.MalformedURLException;
4042
import java.net.URL;
4143

42-
public class ShowEntry extends Fragment implements OnClickListener, BackButtonHandler {
44+
public class ShowEntry extends Fragment implements OnClickListener, BackButtonHandler, View.OnTouchListener {
4345
private static final long serialVersionUID = 163106573370997557L;
4446
private final String TAG = getClass().getName();
4547
private transient JavaEntry entry;
@@ -163,6 +165,11 @@ private void addToClipboard(String data) {
163165
}
164166

165167
private void prepareUiElements(View v) {
168+
if (!(edit || delete)) {
169+
TextView passTitle = (TextView) v.findViewById(R.id.passwordLabel);
170+
passTitle.append(" (tap here to reveal)");
171+
passTitle.setOnTouchListener(this);
172+
}
166173
Button eb = (Button) v.findViewById(R.id.editButton);
167174
eb.setOnClickListener(this);
168175
eb.setVisibility((edit || delete) ? View.GONE : View.VISIBLE);
@@ -243,4 +250,14 @@ private void restore(Bundle state) {
243250
this.delete = delete;
244251
}
245252
}
253+
254+
@Override
255+
public boolean onTouch(View view, MotionEvent motionEvent) {
256+
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
257+
passwordText.setTransformationMethod(null);
258+
} else {
259+
passwordText.setTransformationMethod(PasswordTransformationMethod.getInstance());
260+
}
261+
return true;
262+
}
246263
}

0 commit comments

Comments
 (0)