]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
Created intent for restarting the timer, and called this intent from a
authorisaac.jones <isaac.jones@72b678ce-9140-0410-bee8-679b907dd61a>
Sun, 18 Jan 2009 01:12:55 +0000 (01:12 +0000)
committerisaac.jones <isaac.jones@72b678ce-9140-0410-bee8-679b907dd61a>
Sun, 18 Jan 2009 01:12:55 +0000 (01:12 +0000)
few places within the code, notibly on PassList and CategoryList when
items were selected or edited.

This stops the timer from timing out surprisingly while the user is
editing stuff.

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

AndroidManifest.xml
res/values/strings.xml
src/org/openintents/intents/CryptoIntents.java
src/org/openintents/safe/CategoryList.java
src/org/openintents/safe/FrontDoor.java
src/org/openintents/safe/PassList.java
src/org/openintents/safe/service/ServiceDispatch.aidl
src/org/openintents/safe/service/ServiceDispatchImpl.java

index 28e173a0874c8e2c9b0051be076f8a8f75278542..8c7e872cbe16c7edfbd9b862a735b0ffac491ed3 100644 (file)
                 <action android:name="org.openintents.action.SET_PASSWORD" />
                 <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
-            
+            <intent-filter android:label="@string/intent_restart_timer">
+                <action android:name="org.openintents.action.RESTART_TIMER" />
+                <category android:name="android.intent.category.DEFAULT" />
+               </intent-filter>
             
         </activity>
         <activity class=".PassGen" android:name="PassGen" android:label="@string/app_name" />
index 77631be5c89029a58fb5ef185d0b79d2204126bf..bae48981c59f14217e3b600179f5ec0d5fae3631 100644 (file)
        <string name="intent_encrypt">Encrypt (OI Safe)</string>\r
        <string name="intent_get_password">Get password (OI Safe)</string>\r
        <string name="intent_set_password">Set password (OI Safe)</string>\r
+       <string name="intent_restart_timer">Restart timer (OI Safe)</string>\r
        <string name="open_safe">Open OI Safe</string>\r
        <string name="lock">Lock</string>\r
        <string name="continue_text">Continue</string>\r
index 6f5ba4b7a3e01b4fb0567d2fde49415d4653ccf9..a5b0e6eb990c9af9afdbc4d242488484f5fbb2af 100644 (file)
@@ -62,6 +62,16 @@ public class CryptoIntents {
         * <p>Constant Value: "org.openintents.action.SET_PASSWORD"</p>\r
         */\r
        public static final String ACTION_SET_PASSWORD = "org.openintents.action.SET_PASSWORD";\r
+       \r
+       /**\r
+        * Activity Action: Restarts the timer for the Crypto intent service.\r
+        * The timer gets reset when using GET or set password anyway, but this is\r
+        * a way to reset the timer for other kinds of actions. Use sparingly since\r
+        * we do actually want the timer to time out eventually!\r
+        * \r
+        * <p>Constant Value: "org.openintents.action.RESTART_TIMER"</p>\r
+        */\r
+       public static final String ACTION_RESTART_TIMER = "org.openintents.action.RESTART_TIMER";\r
 \r
        /**\r
         * Broadcast Action: Sent when the user got logged out of the\r
index b3fe460122152d040637533013b43eacf184d8d6..554372479b2058bcb6e97dd88d0f591e8f32899b 100644 (file)
@@ -119,6 +119,7 @@ public class CategoryList extends ListActivity {
     private static String masterKey;                   
 
     private List<CategoryEntry> rows;
+    private Intent restartTimerIntent;
     
     BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
@@ -187,6 +188,8 @@ public class CategoryList extends ListActivity {
 
                if (debug) Log.d(TAG,"onCreate()");
 
+               restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+               
                if (!isSignedIn()) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
                        startActivity(frontdoor);               
@@ -239,7 +242,7 @@ public class CategoryList extends ListActivity {
     @Override
     protected void onPause() {
                super.onPause();
-               
+
                if (debug) Log.d(TAG,"onPause()");
                
                if ((importThread != null) && (importThread.isAlive())) {
@@ -466,7 +469,8 @@ public class CategoryList extends ListActivity {
     }
 
     public boolean onOptionsItemSelected(MenuItem item) {
-       
+               startActivity (restartTimerIntent);
+
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
                int position=-1;
                if (info==null) {
@@ -597,7 +601,8 @@ public class CategoryList extends ListActivity {
     
     protected void onListItemClick(ListView l, View v, int position, long id) {
                super.onListItemClick(l, v, position, id);
-               
+
+               startActivity (restartTimerIntent);
                launchPassList(rows.get(position).id);
     }
 
@@ -623,7 +628,8 @@ public class CategoryList extends ListActivity {
        if (debug) Log.d(TAG,"addCategory("+name+")");
        if ((name==null) || (name=="")) return -1;
                CategoryEntry entry =  new CategoryEntry();
-       
+
+               startActivity (restartTimerIntent);
                String namePlain = name;
 
                try {
index a15ff769614c18831d10c71d2f376e1e2e230415..aa747ffd5ddfb55dbdc5d497d8c002d7a3327b79 100644 (file)
@@ -148,7 +148,17 @@ public class FrontDoor extends Activity {
         } else if (externalAccess){\r
 \r
                // which action?\r
-               if (action.equals (CryptoIntents.ACTION_ENCRYPT)) {\r
+                if (action.equals (CryptoIntents.ACTION_RESTART_TIMER)) {\r
+                        if (service != null) {\r
+                                try {\r
+                                               service.restartTimer();\r
+                                               callbackResult = RESULT_OK;\r
+                                       } catch (RemoteException e) {\r
+                                               // TODO Auto-generated catch block\r
+                                               Log.e (TAG, "remoteException in Restart Timer");\r
+                                       }\r
+                        }\r
+               } else if (action.equals (CryptoIntents.ACTION_ENCRYPT)) {\r
                        callbackResult = encryptIntent(thisIntent, callbackIntent);\r
                } else if (action.equals (CryptoIntents.ACTION_DECRYPT)) {\r
                        callbackResult = decryptIntent(thisIntent, callbackIntent);\r
index d142576353c35e641271a61a9fb10ccbae14e0d6..f97f4353e316f8155398566d83367ee0cfaade23 100644 (file)
@@ -24,6 +24,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
 
+import org.openintents.intents.CryptoIntents;
+
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.ListActivity;
@@ -72,6 +74,7 @@ public class PassList extends ListActivity {
     private CryptoHelper ch;
     private DBHelper dbHelper=null;
     private static Long CategoryId=null;
+    private Intent restartTimerIntent;
 
     private static String masterKey;                   
 
@@ -85,6 +88,7 @@ public class PassList extends ListActivity {
                super.onCreate(icicle);
                
                if (debug) Log.d(TAG,"onCreate()");
+               restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
                setContentView(R.layout.pass_list);
                
                if (dbHelper==null) {
@@ -343,7 +347,7 @@ public class PassList extends ListActivity {
     }
     
     public boolean onOptionsItemSelected(MenuItem item) {
-       
+               startActivity (restartTimerIntent);
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
                int position=-1;
                if (info==null) {
index ba0600843eb1d6c4b598103e44ace16e5bb2d4e4..631be0dcb2f28ed9127b76d0dd1c49129f48a3ec 100644 (file)
@@ -22,4 +22,5 @@ interface ServiceDispatch {
   String encrypt (String clearText);\r
   String decrypt (String cryptoText);\r
   void setTimeoutMinutes(int timeoutMinutesIn);\r
+  void restartTimer();\r
 }\r
index 39c5835ed49561530450361a0246f66ec10d0a46..8b9033d451c0efc5d3067a866fae23cd0a0da87b 100644 (file)
@@ -84,13 +84,6 @@ public class ServiceDispatchImpl extends Service {
                Log.d(TAG, "Timer started with: " + timeoutUntilStop );
     }
     
-    private void restartTimer () {
-       // must be started with startTimer first.
-       if (t != null) {
-               t.cancel();
-               t.start();
-       }
-    }
 
     /**
      * The ServiceDispatch is defined through IDL
@@ -139,6 +132,14 @@ public class ServiceDispatchImpl extends Service {
                        timeoutUntilStop = timeoutMinutes * 60000;
                        Log.d(TAG,"set timeout to "+timeoutMinutes);
                }
+               
+               public void restartTimer () {
+               // must be started with startTimer first.
+               if (t != null) {
+                       t.cancel();
+                       t.start();
+               }
+           }
     };
 
 }