Java Code Examples for info.guardianproject.panic.Panic#isTriggerIntent()

The following examples show how to use info.guardianproject.panic.Panic#isTriggerIntent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RouterActivity.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mApp = (ImApp)getApplication();

    mHandler = new MyHandler(this);

    Intent intent = getIntent();

    mDoLock = ACTION_LOCK_APP.equals(intent.getAction());

    if (mDoLock) {
        shutdownAndLock(this);

        return;
    } else if (Panic.isTriggerIntent(intent)) {
        if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
            if (Preferences.uninstallApp()) {
                // lock and delete first for rapid response, then uninstall
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
                Intent uninstall = new Intent(Intent.ACTION_DELETE);
                uninstall.setData(Uri.parse("package:" + getPackageName()));
                startActivity(uninstall);
            } else if (Preferences.clearAppData()) {
                // lock first for rapid response, then delete
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
            } else if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
            // TODO add other responses here, paying attention to if/else order
        } else if (PanicResponder.shouldUseDefaultResponseToTrigger(this)) {
            if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
        }
        // this Intent should not trigger any more processing
        finish();
        return;
    }

    mSignInHelper = new SignInHelper(this, mHandler);
    mDoSignIn = intent.getBooleanExtra(EXTRA_DO_SIGNIN, false);

    AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);

    mCacheWord = new CacheWordHandler(this, (ICacheWordSubscriber)this);
    mCacheWord.connectToService();

    // if we have an incoming contact, send it to the right place
    String scheme = intent.getScheme();
    if(TextUtils.equals(scheme, "keanu"))
    {
        intent.setClass(this, AddContactActivity.class);
        startActivity(intent);
        finish();
        return;
    }

}
 
Example 2
Source File: RouterActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mApp = (ImApp)getApplication();

    mHandler = new MyHandler(this);

    Intent intent = getIntent();

    mDoLock = ACTION_LOCK_APP.equals(intent.getAction());

    if (mDoLock) {
        shutdownAndLock(this);

        return;
    } else if (Panic.isTriggerIntent(intent)) {
        if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
            if (Preferences.uninstallApp()) {
                // lock and delete first for rapid response, then uninstall
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
                Intent uninstall = new Intent(Intent.ACTION_DELETE);
                uninstall.setData(Uri.parse("package:" + getPackageName()));
                startActivity(uninstall);
            } else if (Preferences.clearAppData()) {
                // lock first for rapid response, then delete
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
            } else if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
            // TODO add other responses here, paying attention to if/else order
        } else if (PanicResponder.shouldUseDefaultResponseToTrigger(this)) {
            if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
        }
        // this Intent should not trigger any more processing
        finish();
        return;
    }

    mSignInHelper = new SignInHelper(this, mHandler);
    mDoSignIn = intent.getBooleanExtra(EXTRA_DO_SIGNIN, true);

    AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

    mCacheWord = new CacheWordHandler(this, (ICacheWordSubscriber)this);
    mCacheWord.connectToService();

    // if we have an incoming contact, send it to the right place
    String scheme = intent.getScheme();
    if(TextUtils.equals(scheme, "xmpp"))
    {
        intent.setClass(this, AddContactActivity.class);
        startActivity(intent);
        finish();
        return;
    }
}