Search in sources :

Example 1 with AndroidAuthSession

use of com.dropbox.client2.android.AndroidAuthSession in project Aegis by Decad3nce.

the class BackupDropboxAccountsActivity method buildSession.

private AndroidAuthSession buildSession() {
    AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET);
    AndroidAuthSession session;
    String[] stored = getStoredKeys();
    if (stored != null) {
        Log.e(TAG, "Auth keys were stored, recovering");
        AccessTokenPair accessToken = new AccessTokenPair(stored[0], stored[1]);
        session = new AndroidAuthSession(appKeyPair, ACCESS_TYPE, accessToken);
    } else {
        Log.e(TAG, "Auth keys were not stored");
        session = new AndroidAuthSession(appKeyPair, ACCESS_TYPE);
    }
    return session;
}
Also used : AndroidAuthSession(com.dropbox.client2.android.AndroidAuthSession) AccessTokenPair(com.dropbox.client2.session.AccessTokenPair) AppKeyPair(com.dropbox.client2.session.AppKeyPair)

Example 2 with AndroidAuthSession

use of com.dropbox.client2.android.AndroidAuthSession in project Aegis by Decad3nce.

the class BackupDropboxAccountsActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.backup_layout);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setVisibility(View.VISIBLE);
    cr = getContentResolver();
    context = this;
    Intent intent;
    AndroidAuthSession session = buildSession();
    mDBApi = new DropboxAPI<AndroidAuthSession>(session);
    try {
        intent = getIntent();
        if (intent.hasExtra("fromReceiver")) {
            address = intent.getStringExtra("fromReceiver");
            Log.i(TAG, "Backup intent from receiver");
            recoverData();
        } else {
            Log.i(TAG, "Backup intent from elsewhere");
            DialogFragment dialog = new BackupAccountsDialogFragment();
            dialog.show(getFragmentManager(), "BackupAccountsDialogFragment");
        }
    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
}
Also used : AndroidAuthSession(com.dropbox.client2.android.AndroidAuthSession) BackupAccountsDialogFragment(com.decad3nce.aegis.Fragments.BackupAccountsDialogFragment) DialogFragment(android.app.DialogFragment) BackupAccountsDialogFragment(com.decad3nce.aegis.Fragments.BackupAccountsDialogFragment) Intent(android.content.Intent) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) DropboxUnlinkedException(com.dropbox.client2.exception.DropboxUnlinkedException) DropboxException(com.dropbox.client2.exception.DropboxException)

Aggregations

AndroidAuthSession (com.dropbox.client2.android.AndroidAuthSession)2 DialogFragment (android.app.DialogFragment)1 Intent (android.content.Intent)1 BackupAccountsDialogFragment (com.decad3nce.aegis.Fragments.BackupAccountsDialogFragment)1 DropboxException (com.dropbox.client2.exception.DropboxException)1 DropboxUnlinkedException (com.dropbox.client2.exception.DropboxUnlinkedException)1 AccessTokenPair (com.dropbox.client2.session.AccessTokenPair)1 AppKeyPair (com.dropbox.client2.session.AppKeyPair)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1