public void persist() { Logger.d(LOG, "CLEANING UP AFTER DCIM OBSERVER"); for (IDCIMEntry entry : thumbnails) { informaCam.ioService.delete(entry.fileAsset.path, entry.fileAsset.source); informaCam.ioService.delete(entry.uri, Type.CONTENT_RESOLVER); } }
@Override public void onResume() { super.onResume(); informaCam = (InformaCam) getApplication(); informaCam.setStatusListener(this); // Log.d(LOG, "AND HELLO onResume()!!"); try { if (route != null) { routeByIntent(); } else { Log.d(LOG, "route is null now, please wait"); Log.d(LOG, "hasCredentialManager? " + String.valueOf(informaCam.hasCredentialManager())); if (informaCam.hasCredentialManager()) { Log.d(LOG, "NOW ASKING FOR CM STATUS..."); switch (informaCam.getCredentialManagerStatus()) { case org.witness.informacam.utils.Constants.Codes.Status.UNLOCKED: route = new Intent(this, HomeActivity.class); if (prefStealthIcon) route.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); routeCode = Home.ROUTE_CODE; break; case org.witness.informacam.utils.Constants.Codes.Status.LOCKED: route = new Intent(this, LoginActivity.class); routeCode = Login.ROUTE_CODE; break; } routeByIntent(); } else { Log.d(LOG, "no, not logged in"); } } } catch (NullPointerException e) { Logger.e(LOG, e); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { informaCam.setStatusListener(this); if (resultCode == Activity.RESULT_CANCELED) { if (informaCam.isOutsideTheLoop(init.getAction())) { // Logger.d(LOG, "coming back from VMM call WITH NOOOOO MEDIA, and i shoudl finish."); setResult(resultCode, getIntent()); finish(); return; } else if (data != null && data.hasExtra(Codes.Extras.LOGOUT_USER) && data.getBooleanExtra(Codes.Extras.LOGOUT_USER, false)) { Logger.d(LOG, "Logout the user and close."); informaCam.setStatusListener(null); // informaCam.stopInforma(); route = null; setResult(resultCode, getIntent()); finish(); if (data.hasExtra(Codes.Extras.PERFORM_WIPE) && data.getBooleanExtra(Codes.Extras.PERFORM_WIPE, false)) { wipe(); } return; } // XXX: DOES THIS BREAK LOGOUT? setResult(resultCode, data); finish(); } else if (resultCode == Activity.RESULT_OK) { Log.d(LOG, "returning with request code " + requestCode); /* if(informaCam.isOutsideTheLoop(init.getAction())) { Logger.d(LOG, "coming back from VMM call with SOME media, and i shoudl finish."); // TODO: immediately 1) chooser 2) encrypt (all? selected?) to org 3) start up a transport for each returned media finish(); return; } */ route = new Intent(this, HomeActivity.class); if (prefStealthIcon) route.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); routeCode = Home.ROUTE_CODE; switch (requestCode) { case Codes.Routes.CAMERA: route = new Intent(this, EditorActivity.class); routeCode = Editor.ROUTE_CODE; break; case Codes.Routes.EDITOR: break; case Codes.Routes.LOGIN: break; case Codes.Routes.HOME: if (data != null && data.hasExtra(Codes.Extras.CHANGE_LOCALE)) { route.putExtra(Codes.Extras.CHANGE_LOCALE, true); } break; case Codes.Routes.WIZARD: route = new Intent(this, HomeActivity.class); if (prefStealthIcon) route.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); routeCode = Home.ROUTE_CODE; route.putExtra(Codes.Extras.GENERATING_KEY, true); if (KeyUtility.initDevice()) { informaCam.user.hasCompletedWizard = true; informaCam.user.lastLogIn = System.currentTimeMillis(); informaCam.user.isLoggedIn = true; informaCam.saveState(informaCam.user); } break; } routeByIntent(); } else if (resultCode == Activity.RESULT_FIRST_USER) { if (data.hasExtra(Codes.Extras.CHANGE_LOCALE) && data.getBooleanExtra(Codes.Extras.CHANGE_LOCALE, false)) { route.putExtra(Codes.Extras.CHANGE_LOCALE, true); } } }