use a FAB to add passwords

This commit is contained in:
Mohamed Zenadi 2015-04-19 21:02:42 +02:00
parent 771d8a9415
commit 9ee99fc226
5 changed files with 40 additions and 32 deletions

View file

@ -33,6 +33,7 @@ dependencies {
compile 'com.jcraft:jsch:0.1.52' compile 'com.jcraft:jsch:0.1.52'
compile 'org.apache.commons:commons-io:1.3.2' compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.jayway.android.robotium:robotium-solo:5.3.1' compile 'com.jayway.android.robotium:robotium-solo:5.3.1'
compile 'com.melnykov:floatingactionbutton:1.2.0'
} }
tasks.findAll { // make all tasks whose name starts with 'assemble'... tasks.findAll { // make all tasks whose name starts with 'assemble'...
it.name.startsWith 'assemble' it.name.startsWith 'assemble'

View file

@ -1,31 +1,25 @@
package com.zeapo.pwdstore; package com.zeapo.pwdstore;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.app.Fragment; import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.support.v7.internal.widget.AdapterViewCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.melnykov.fab.FloatingActionButton;
import com.zeapo.pwdstore.utils.PasswordItem; import com.zeapo.pwdstore.utils.PasswordItem;
import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter; import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter;
import com.zeapo.pwdstore.utils.PasswordRepository; import com.zeapo.pwdstore.utils.PasswordRepository;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Stack; import java.util.Stack;
/** /**
@ -84,6 +78,9 @@ public class PasswordFragment extends Fragment{
// // Set the adapter // // Set the adapter
recyclerView.setAdapter(recyclerAdapter); recyclerView.setAdapter(recyclerAdapter);
FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
fab.attachToRecyclerView(recyclerView);
registerForContextMenu(recyclerView); registerForContextMenu(recyclerView);
return view; return view;
} }

View file

@ -123,19 +123,6 @@ public class PasswordStore extends ActionBarActivity {
e.printStackTrace(); e.printStackTrace();
} }
return true; return true;
case R.id.menu_add_password:
if (!PasswordRepository.isInitialized()) {
initBefore.show();
break;
}
createPassword(getCurrentFocus());
break;
// case R.id.menu_add_category:
// break;
case R.id.git_push: case R.id.git_push:
if (!PasswordRepository.isInitialized()) { if (!PasswordRepository.isInitialized()) {
initBefore.show(); initBefore.show();
@ -348,6 +335,17 @@ public class PasswordStore extends ActionBarActivity {
} }
public void createPassword(View v) { public void createPassword(View v) {
if (!PasswordRepository.isInitialized()) {
new AlertDialog.Builder(this)
.setMessage(this.getResources().getString(R.string.creation_dialog_text))
.setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}).show();
return;
}
this.currentDir = getCurrentDir(); this.currentDir = getCurrentDir();
Log.i("PWDSTR", "Adding file to : " + this.currentDir.getAbsolutePath()); Log.i("PWDSTR", "Adding file to : " + this.currentDir.getAbsolutePath());

View file

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="vertical" android:orientation="vertical"
tools:context="com.zeapo.pwdstore.PasswordFragment"> tools:context="com.zeapo.pwdstore.PasswordFragment">
@ -12,5 +11,23 @@
android:id="@+id/pass_recycler" android:id="@+id/pass_recycler"
android:scrollbars="vertical" android:scrollbars="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"
</LinearLayout> android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:src="@drawable/ic_action_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/activity_vertical_margin"
android:onClick="createPassword"
fab:fab_colorNormal="@color/blue_grey_500"
fab:fab_colorPressed="@color/blue_grey_800"
fab:fab_colorRipple="@color/blue_grey_50"/>
</RelativeLayout>

View file

@ -9,11 +9,6 @@
pwstore:showAsAction="ifRoom|collapseActionView" pwstore:showAsAction="ifRoom|collapseActionView"
pwstore:actionViewClass="android.support.v7.widget.SearchView" /> pwstore:actionViewClass="android.support.v7.widget.SearchView" />
<item android:id="@+id/menu_add_password"
android:icon="@drawable/ic_action_new"
pwstore:showAsAction="ifRoom"
android:title="New password"/>
<!--<item android:id="@+id/menu_add_category"--> <!--<item android:id="@+id/menu_add_category"-->
<!--android:title="New category"/>--> <!--android:title="New category"/>-->