Skip to content

Commit ac20c00

Browse files
committed
Added a Home button to the Passwords menu
1 parent cf5587c commit ac20c00

File tree

2 files changed

+71
-49
lines changed

2 files changed

+71
-49
lines changed
Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,61 @@
11
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
3-
android:id="@+id/ListEntriesLayout"
4-
android:layout_width="fill_parent"
5-
android:layout_height="fill_parent"
6-
android:layout_gravity="center"
7-
android:gravity="top"
8-
android:orientation="vertical"
9-
android:paddingBottom="@dimen/activity_vertical_margin"
10-
android:paddingLeft="@dimen/activity_horizontal_margin"
11-
android:paddingRight="@dimen/activity_horizontal_margin"
12-
android:paddingTop="@dimen/activity_vertical_margin"
13-
tools:context="org.astonbitecode.rustkeylock.MainActivity" >
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/ListEntriesLayout"
4+
android:layout_width="fill_parent"
5+
android:layout_height="fill_parent"
6+
android:layout_gravity="center"
7+
android:gravity="top"
8+
android:orientation="vertical"
9+
android:paddingBottom="16dp"
10+
android:paddingLeft="16dp"
11+
android:paddingRight="16dp"
12+
android:paddingTop="16dp"
13+
tools:context="org.astonbitecode.rustkeylock.MainActivity">
1414

15-
<TextView
16-
android:id="@+id/listMenuLabel"
17-
android:layout_width="wrap_content"
18-
android:layout_height="wrap_content"
19-
android:text="Passwords"
20-
android:textAppearance="?android:attr/textAppearanceLarge" />
15+
<RelativeLayout
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content"
18+
android:orientation="horizontal"
19+
android:weightSum="3">
20+
<Button
21+
android:id="@+id/mainMenuButton"
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:layout_alignParentLeft="true"
25+
android:background="@android:color/transparent"
26+
android:drawableTop="@drawable/home"
27+
android:text="Home"/>
2128

22-
<Button
23-
android:id="@+id/addNewButton"
24-
android:layout_width="wrap_content"
25-
android:layout_height="wrap_content"
26-
android:layout_gravity="right"
27-
android:background="@android:color/transparent"
28-
android:drawableTop="@drawable/newimage"
29-
android:text="New" />
29+
<TextView
30+
android:id="@+id/listMenuLabel"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="Passwords"
34+
android:layout_centerInParent="true"
35+
android:textAppearance="?android:attr/textAppearanceLarge"/>
36+
37+
<Button
38+
android:id="@+id/addNewButton"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:layout_alignParentRight="true"
42+
android:background="@android:color/transparent"
43+
android:drawableTop="@drawable/newimage"
44+
android:text="New"/>
45+
</RelativeLayout>
3046

3147
<EditText
32-
android:id="@+id/editFilter"
33-
android:layout_width="match_parent"
34-
android:layout_height="wrap_content"
35-
android:layout_columnSpan="2"
36-
android:hint="Filter the displayed passwords..."
37-
android:inputType="text" />
48+
android:id="@+id/editFilter"
49+
android:layout_width="match_parent"
50+
android:layout_height="wrap_content"
51+
android:layout_columnSpan="2"
52+
android:hint="Filter the displayed passwords..."
53+
android:inputType="text"/>
3854

3955
<ListView
40-
android:id="@android:id/list"
41-
android:layout_width="fill_parent"
42-
android:layout_height="fill_parent" >
56+
android:id="@android:id/list"
57+
android:layout_width="fill_parent"
58+
android:layout_height="fill_parent">
4359
</ListView>
4460

4561
</LinearLayout>

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

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

18-
import java.util.ArrayList;
19-
import java.util.List;
20-
import java.util.Timer;
21-
import java.util.TimerTask;
22-
23-
import org.astonbitecode.rustkeylock.R;
24-
import org.astonbitecode.rustkeylock.adapters.EntriesAdapter;
25-
import org.astonbitecode.rustkeylock.api.InterfaceWithRust;
26-
import org.astonbitecode.rustkeylock.api.JavaEntry;
27-
import org.astonbitecode.rustkeylock.handlers.back.BackButtonHandler;
28-
import org.astonbitecode.rustkeylock.utils.Defs;
29-
3018
import android.app.ListFragment;
3119
import android.content.Context;
3220
import android.os.Bundle;
@@ -41,6 +29,17 @@
4129
import android.widget.Button;
4230
import android.widget.EditText;
4331
import android.widget.ListView;
32+
import org.astonbitecode.rustkeylock.R;
33+
import org.astonbitecode.rustkeylock.adapters.EntriesAdapter;
34+
import org.astonbitecode.rustkeylock.api.InterfaceWithRust;
35+
import org.astonbitecode.rustkeylock.api.JavaEntry;
36+
import org.astonbitecode.rustkeylock.handlers.back.BackButtonHandler;
37+
import org.astonbitecode.rustkeylock.utils.Defs;
38+
39+
import java.util.ArrayList;
40+
import java.util.List;
41+
import java.util.Timer;
42+
import java.util.TimerTask;
4443

4544
public class ListEntries extends ListFragment implements OnClickListener, BackButtonHandler {
4645
private static final long serialVersionUID = 8765819759487480794L;
@@ -67,6 +66,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6766
View rootView = inflater.inflate(R.layout.fragment_list_entries, container, false);
6867
Button nb = (Button) rootView.findViewById(R.id.addNewButton);
6968
nb.setOnClickListener(this);
69+
Button mmb = (Button) rootView.findViewById(R.id.mainMenuButton);
70+
mmb.setOnClickListener(this);
7071

7172
EditText filterText = (EditText) rootView.findViewById(R.id.editFilter);
7273
filterText.setText(filter);
@@ -126,8 +127,13 @@ public void onListItemClick(ListView l, View v, int pos, long id) {
126127

127128
@Override
128129
public void onClick(View view) {
129-
Log.d(TAG, "Clicked add new entry");
130-
InterfaceWithRust.INSTANCE.go_to_menu(Defs.MENU_NEW_ENTRY);
130+
if (view.getId() == R.id.mainMenuButton) {
131+
Log.d(TAG, "Clicked go to the Main menu");
132+
InterfaceWithRust.INSTANCE.go_to_menu(Defs.MENU_MAIN);
133+
} else if (view.getId() == R.id.addNewButton) {
134+
Log.d(TAG, "Clicked add new entry");
135+
InterfaceWithRust.INSTANCE.go_to_menu(Defs.MENU_NEW_ENTRY);
136+
}
131137
}
132138

133139
@Override

0 commit comments

Comments
 (0)