]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
Switched to using a BroadcastIntent for restarting the timer. Simplifies things a...
authorisaac.jones <isaac.jones@72b678ce-9140-0410-bee8-679b907dd61a>
Sun, 18 Jan 2009 01:43:08 +0000 (01:43 +0000)
committerisaac.jones <isaac.jones@72b678ce-9140-0410-bee8-679b907dd61a>
Sun, 18 Jan 2009 01:43:08 +0000 (01:43 +0000)
git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@1761 72b678ce-9140-0410-bee8-679b907dd61a

AndroidManifest.xml
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 8c7e872cbe16c7edfbd9b862a735b0ffac491ed3..1caa86910d453672031d420207229d053df2e417 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 554372479b2058bcb6e97dd88d0f591e8f32899b..bcd239b4bd5f55bbdf8437281c2a0ff609762546 100644 (file)
@@ -469,7 +469,7 @@ public class CategoryList extends ListActivity {
     }
 
     public boolean onOptionsItemSelected(MenuItem item) {
-               startActivity (restartTimerIntent);
+               sendBroadcast (restartTimerIntent);
 
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
                int position=-1;
@@ -602,7 +602,7 @@ public class CategoryList extends ListActivity {
     protected void onListItemClick(ListView l, View v, int position, long id) {
                super.onListItemClick(l, v, position, id);
 
-               startActivity (restartTimerIntent);
+               sendBroadcast (restartTimerIntent);
                launchPassList(rows.get(position).id);
     }
 
@@ -629,7 +629,7 @@ public class CategoryList extends ListActivity {
        if ((name==null) || (name=="")) return -1;
                CategoryEntry entry =  new CategoryEntry();
 
-               startActivity (restartTimerIntent);
+               sendBroadcast (restartTimerIntent);
                String namePlain = name;
 
                try {
index aa747ffd5ddfb55dbdc5d497d8c002d7a3327b79..a15ff769614c18831d10c71d2f376e1e2e230415 100644 (file)
@@ -148,17 +148,7 @@ public class FrontDoor extends Activity {
         } else if (externalAccess){\r
 \r
                // which action?\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
+               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 f97f4353e316f8155398566d83367ee0cfaade23..2e639cea07569094f7073470cf3ac3ade4998e67 100644 (file)
@@ -347,7 +347,7 @@ public class PassList extends ListActivity {
     }
     
     public boolean onOptionsItemSelected(MenuItem item) {
-               startActivity (restartTimerIntent);
+               sendBroadcast (restartTimerIntent);
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
                int position=-1;
                if (info==null) {
index 631be0dcb2f28ed9127b76d0dd1c49129f48a3ec..ba0600843eb1d6c4b598103e44ace16e5bb2d4e4 100644 (file)
@@ -22,5 +22,4 @@ interface ServiceDispatch {
   String encrypt (String clearText);\r
   String decrypt (String cryptoText);\r
   void setTimeoutMinutes(int timeoutMinutesIn);\r
-  void restartTimer();\r
 }\r
index 8b9033d451c0efc5d3067a866fae23cd0a0da87b..f7ffb302e35c736b7ee3c04565ae0389edfcfc8f 100644 (file)
@@ -26,7 +26,10 @@ import org.openintents.safe.CryptoHelperException;
 
 
 import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.IBinder;
 import android.util.Log;
 import android.os.CountDownTimer;
@@ -51,6 +54,18 @@ public class ServiceDispatchImpl extends Service {
     public void onCreate() {
       super.onCreate();
       
+      BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+          public void onReceive(Context context, Intent intent) {
+              if (intent.getAction().equals(CryptoIntents.ACTION_RESTART_TIMER)) {
+                       restartTimer();
+              }
+          }
+      };
+
+      IntentFilter filter = new IntentFilter();
+      filter.addAction (CryptoIntents.ACTION_RESTART_TIMER);
+      registerReceiver(mIntentReceiver, filter);
+      
          Log.d( TAG,"onCreate" );
     }
     
@@ -83,7 +98,15 @@ public class ServiceDispatchImpl extends Service {
        t.start();
                Log.d(TAG, "Timer started with: " + timeoutUntilStop );
     }
-    
+       
+       public void restartTimer () {
+       // must be started with startTimer first.
+               Log.d(TAG,"timer restarted");
+       if (t != null) {
+               t.cancel();
+               t.start();
+       }
+    }
 
     /**
      * The ServiceDispatch is defined through IDL
@@ -132,14 +155,7 @@ 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();
-               }
-           }
+
     };
 
 }