]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: added counts to CategoryList, added supports-screens,
authorrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 13 Nov 2009 01:34:00 +0000 (01:34 +0000)
committerrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 13 Nov 2009 01:34:00 +0000 (01:34 +0000)
bumped version to 1.2.3

git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@2380 72b678ce-9140-0410-bee8-679b907dd61a

AndroidManifest.xml
default.properties
readme.txt
res/layout/cat_row.xml [new file with mode: 0644]
src/org/openintents/safe/CategoryEntry.java
src/org/openintents/safe/CategoryList.java
src/org/openintents/safe/CategoryListItemAdapter.java [new file with mode: 0644]
src/org/openintents/safe/DBHelper.java
src/org/openintents/safe/Passwords.java
src/org/openintents/safe/service/ServiceDispatchImpl.java

index 6d1fd7dfc8e311f5ecd556ca6d1f12431bac41fd..5cf938332b6ffe42c51aab52d26bf602a67c97f1 100644 (file)
@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.openintents.safe" \r
-    android:versionCode="11" android:versionName="1.2.2">\r
+    android:versionName="1.2.3" android:versionCode="12">\r
     <!-- History:
-    1.2.2 [11]: 2009-10-29
+    1.2.3 [12]: 2009-11-12\r
+    1.2.2 [11]: 2009-10-29\r
     1.2.1 [10]: 2009-10-23\r
     1.2.0 [9]: 2009-08-22\r
     1.1.1 [8]: 2009-05-30\r
     <uses-permission android:name="org.openintents.safe.ACCESS_INTENTS" />
     <uses-permission android:name="org.openintents.safe.ACCESS_SERVICE" />
     
-<uses-sdk android:minSdkVersion="3"></uses-sdk>
+<uses-sdk android:targetSdkVersion="4" android:minSdkVersion="3"></uses-sdk>
+<supports-screens android:normalScreens="true" android:smallScreens="true" android:largeScreens="true"></supports-screens>
 </manifest> 
index 0a007ab5e2f26540fa26b796c68f63b5249f688b..08ad68f119129febed3eb5a58b192c243b3acc92 100644 (file)
@@ -7,16 +7,8 @@
 # "build.properties", and override values to adapt the script to your
 # project structure.
 
+# Indicates whether an apk should be generated for each density.
+split.density=false
 # Project target.
-target=android-3
-# apk configurations. This property allows creation of APK files with limited
-# resources. For example, if your application contains many locales and
-# you wish to release multiple smaller apks instead of a large one, you can
-# define configuration to create apks with limited language sets.
-# Format is a comma separated list of configuration names. For each
-# configuration, a property will declare the resource configurations to
-# include. Example:
-#     apk-configurations=european,northamerica
-#     apk-config-european=en,fr,it,de,es
-#     apk-config-northamerica=en,es
+target=android-4
 apk-configurations=
index 14446f9b14aa85592c07f228526783de917366b8..c10f24defb6512248bb754f324547ac7f7deba79 100644 (file)
@@ -24,6 +24,12 @@ or decrypt data, and get or set passwords by connecting to OI Safe.
 To obtain the current release, visit\r
   http://www.openintents.org\r
 \r
+---------------------------------------------------------\r
+release: 1.2.3\r
+date: 2009-11-12\r
+- add counts to Category List\r
+- support small, normal, large screens\r
+\r
 ---------------------------------------------------------\r
 release: 1.2.2\r
 date: 2009-10-29\r
diff --git a/res/layout/cat_row.xml b/res/layout/cat_row.xml
new file mode 100644 (file)
index 0000000..9e124e9
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+* $Id$
+* 
+* Copyright 2009 OpenIntents.org
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+       android:layout_width="fill_parent"
+       android:layout_height="fill_parent">
+       <TextView
+               android:id="@+id/rowCount"
+               android:text="0"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:textAppearance="?android:attr/textAppearanceLarge"
+               android:gravity="center_vertical"
+               android:paddingLeft="6dip"
+               android:paddingRight="10dip"
+               android:minHeight="?android:attr/listPreferredItemHeight"
+               android:layout_alignParentRight="true"
+               />
+               
+       <TextView
+               android:id="@+id/rowName"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:textAppearance="?android:attr/textAppearanceLarge"
+               android:gravity="center_vertical"
+               android:paddingLeft="6dip"
+               android:minHeight="?android:attr/listPreferredItemHeight"
+               android:layout_alignParentLeft="@+id/rowCount"
+               />
+</RelativeLayout>
\ No newline at end of file
index 0202113821d2fa0688ace78be196a6ddde72236c..c04318b0cee61e1efe9c3683f575f4943d301ed3 100644 (file)
@@ -25,4 +25,32 @@ public class CategoryEntry extends Object {
     public boolean nameNeedsDecrypt;
     public String plainName;
     public boolean plainNameNeedsEncrypt=true;
+    int count=0;
+
+    public String getName() {
+               return name;
+       }
+       
+       public int getCount() {
+               return count;
+       }
+
+       public CategoryEntry () {
+               name = "";
+       }
+       
+       public CategoryEntry (String _name) {
+               name = _name;
+       }
+
+       public CategoryEntry (String _name, int _count) {
+               name = _name;
+               count = _count;
+       }
+       
+       @Override
+       public String toString() {
+               return name + " " + count;
+       }
+
 }
index faf01b071b0b93347513fad4b55091c87d64243a..dbc7848c1a1773dbd22beb3ef387d848561d7a36 100644 (file)
@@ -54,7 +54,6 @@ import android.view.MenuItem;
 import android.view.View;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.Toast;
@@ -121,6 +120,7 @@ public class CategoryList extends ListActivity {
     private static String masterKey;                   
 
     private List<CategoryEntry> rows=null;
+    private CategoryListItemAdapter catAdapter;
     private Intent restartTimerIntent=null;
     private int lastPosition=0;
     
@@ -391,15 +391,14 @@ public class CategoryList extends ListActivity {
      */
     private void fillData() {
        if (debug) Log.d(TAG,"fillData()");
-               List<String> categoryNames=Passwords.getCategoryNames();
                
                rows=Passwords.getCategoryEntries();
                if (debug) Log.d(TAG,"fillData: rows="+rows.size());
                
-               ArrayAdapter<String> entries = 
-                   new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
-                               categoryNames);
-               setListAdapter(entries);
+               catAdapter = 
+                   new CategoryListItemAdapter(this, R.layout.cat_row,
+                               rows);
+               setListAdapter(catAdapter);
                
     }
 
@@ -669,6 +668,10 @@ public class CategoryList extends ListActivity {
                        setSelection(lastPosition);
                }
        }
+       if (requestCode==REQUEST_OPEN_CATEGORY) {
+               // update in case passwords were added/deleted and caused the counts to update
+                       catAdapter.notifyDataSetChanged();
+       }
     }
 
     private void prePopulate() {
diff --git a/src/org/openintents/safe/CategoryListItemAdapter.java b/src/org/openintents/safe/CategoryListItemAdapter.java
new file mode 100644 (file)
index 0000000..a40dd34
--- /dev/null
@@ -0,0 +1,78 @@
+/* $Id$
+ * 
+ * Copyright 2009 OpenIntents.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openintents.safe;
+
+import java.util.List;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+/**
+ * @author Randy McEoin
+ *
+ * Many thanks to Professional Android Application Development by Reto Meier
+ * from which this adapter is based upon.
+ */
+public class CategoryListItemAdapter extends ArrayAdapter<CategoryEntry> {
+
+       private static boolean debug = false;
+       private static final String TAG = "CategoryListItemAdapter";
+       
+       int resource;
+       
+       public CategoryListItemAdapter(Context _context, int _resource,
+                       List<CategoryEntry> _items) {
+               super(_context, _resource, _items);
+               resource = _resource;
+       }
+       
+       @Override
+       public View getView(int position, View convertView, ViewGroup parent) {
+               LinearLayout categoryListView;
+               
+               CategoryEntry item = getItem(position);
+               
+               String name = item.plainName;
+               int count = item.count;
+               
+               if (convertView == null) {
+                       categoryListView = new LinearLayout(getContext());
+                       String inflater = Context.LAYOUT_INFLATER_SERVICE;
+                       LayoutInflater vi;
+                       vi = (LayoutInflater)getContext().getSystemService(inflater);
+                       vi.inflate(resource, categoryListView, true);
+               } else {
+                       categoryListView = (LinearLayout) convertView;
+               }
+               
+               TextView nameView = (TextView)categoryListView.findViewById(R.id.rowName);
+               TextView countView = (TextView)categoryListView.findViewById(R.id.rowCount);
+               
+               if (debug) Log.d(TAG, "count="+count);
+               nameView.setText(name);
+               countView.setText(Integer.toString(count));
+               
+               return categoryListView;
+       }
+}
+
index 40f575f76523d0628a65462a08625eab8042c019..b36b5e8ee87629d14345c1b9b889d2b68089da30 100644 (file)
@@ -414,6 +414,23 @@ public class DBHelper {
         return row;
     }
 
+    public int getCategoryCount(long Id) {
+        int count = 0;
+        try {
+               Cursor c =
+                   db.rawQuery("SELECT count(*) FROM "+TABLE_PASSWORDS+" WHERE category=" + Id, null);
+               if (c.getCount() > 0) {
+                   c.moveToFirst();
+                   count = c.getInt(0);
+               }
+               c.close();
+               } catch (SQLException e)
+               {
+                       Log.d(TAG,"SQLite exception: " + e.getLocalizedMessage());
+               }
+        return count;
+    }
+
     /**
      * 
      * @param Id
index 0b8beb621737b93341516e3f1f70d3e461e7204f..0f5292dd3d5a5e4e9f4395cc328b1c4c42e775a8 100644 (file)
 
 package org.openintents.safe;
 
+import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -234,6 +236,7 @@ public class Passwords {
                    catEntry.nameNeedsDecrypt=false;
                        categoryEntries.put(id, catEntry);
                }
+               catEntry.count=dbHelper.getCategoryCount(id);
                return catEntry;
        }
        
@@ -256,6 +259,14 @@ public class Passwords {
                return catEntry.id;
        }
        
+       public static void updateCategoryCount(long id) {
+               CategoryEntry catEntry=categoryEntries.get(id);
+               if (catEntry==null) {
+                       return;
+               }
+               catEntry.count=dbHelper.getCategoryCount(id);
+       }
+
        public static void deleteCategoryEntry(long id) {
                if (debug) Log.d(TAG,"deleteCategoryEntry("+id+")");
                dbHelper.deleteCategory(id);
@@ -399,8 +410,14 @@ public class Passwords {
                    }
                    passEntry.needsEncrypt=false;
                }
+               // Format the current time.
+               Date date = new Date();
+               DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.LONG);
+               passEntry.lastEdited=df.format(date);
+
                if (passEntry.id==0) {
                        passEntry.id=dbHelper.addPassword(passEntry);
+                       updateCategoryCount(passEntry.category);
                } else {
                        dbHelper.updatePassword(passEntry.id, passEntry);
                }
@@ -410,8 +427,14 @@ public class Passwords {
        
        public static void deletePassEntry(long id) {
                if (debug) Log.d(TAG,"deletePassEntry("+id+")");
+               PassEntry passEntry=getPassEntry(id, false, false);
+               if (passEntry==null) {
+                       return;
+               }
+               long categoryId=passEntry.category;
                dbHelper.deletePassword(id);
                passEntries.remove(id);
+               updateCategoryCount(categoryId);
        }
 
        public static void updatePassCategory(long passId, long categoryId) {
index 8acac9418a1d73caa8eead86bdc9a2a33858f0f0..98f20d625947bbe6b0aa2651b1522747acac31a4 100644 (file)
@@ -36,7 +36,7 @@ import android.util.Log;
 import android.os.CountDownTimer;
 
 public class ServiceDispatchImpl extends Service {
-       private static boolean debug = true;
+       private static boolean debug = false;
        private static String TAG = "ServiceDispatchIMPL";
        public static CryptoHelper ch;  // TODO Peli: Could clean this up by moving it into a singleton? Or at least a separate static class?
        private String salt;