summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorMohamed Zenadi <mohamed@zenadi.com>2015-04-19 21:02:42 +0200
committerMohamed Zenadi <mohamed@zenadi.com>2015-04-19 21:02:42 +0200
commit9ee99fc2266be570b259a1774edbc2756e2803b1 (patch)
tree2964f2e2f841eb8e06c1fdd0d17e373ede236d46 /app/src/main/java
parent771d8a9415831b5d6fe9cebf574fbf7e5eacd373 (diff)
use a FAB to add passwords
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java13
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java24
2 files changed, 16 insertions, 21 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
index b2e06a1b..48e33892 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
@@ -1,31 +1,25 @@
package com.zeapo.pwdstore;
import android.app.Activity;
-import android.content.Intent;
+import android.app.Fragment;
import android.content.SharedPreferences;
-import android.net.Uri;
import android.os.Bundle;
-import android.app.Fragment;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity;
-import android.support.v7.internal.widget.AdapterViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
-import android.view.ContextMenu;
import android.view.LayoutInflater;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import com.melnykov.fab.FloatingActionButton;
import com.zeapo.pwdstore.utils.PasswordItem;
import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter;
import com.zeapo.pwdstore.utils.PasswordRepository;
import java.io.File;
import java.util.ArrayList;
-import java.util.List;
import java.util.Stack;
/**
@@ -84,6 +78,9 @@ public class PasswordFragment extends Fragment{
// // Set the adapter
recyclerView.setAdapter(recyclerAdapter);
+ FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
+ fab.attachToRecyclerView(recyclerView);
+
registerForContextMenu(recyclerView);
return view;
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index b3d3beee..40667564 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -123,19 +123,6 @@ public class PasswordStore extends ActionBarActivity {
e.printStackTrace();
}
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:
if (!PasswordRepository.isInitialized()) {
initBefore.show();
@@ -348,6 +335,17 @@ public class PasswordStore extends ActionBarActivity {
}
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();
Log.i("PWDSTR", "Adding file to : " + this.currentDir.getAbsolutePath());