Search in sources :

Example 1 with AuthPreferences

use of com.zegoggles.smssync.preferences.AuthPreferences in project sms-backup-plus by jberkel.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportFragmentManager().addOnBackStackChangedListener(this);
    authPreferences = new AuthPreferences(this);
    oauth2Client = new OAuth2Client(authPreferences.getOAuth2ClientId());
    fallbackAuthIntent = new Intent(this, OAuth2WebAuthActivity.class).setData(oauth2Client.requestUrl());
    changeDefaultPackageIntent = new Intent(ACTION_CHANGE_DEFAULT).putExtra(EXTRA_PACKAGE_NAME, getPackageName());
    preferences = new Preferences(this);
    if (bundle == null) {
        showFragment(new MainSettings(), null);
    }
    if (preferences.shouldShowAboutDialog()) {
        showDialog(ABOUT);
    }
    checkDefaultSmsApp();
    requestPermissionsIfNeeded();
}
Also used : AuthPreferences(com.zegoggles.smssync.preferences.AuthPreferences) OAuth2Client(com.zegoggles.smssync.auth.OAuth2Client) MainSettings(com.zegoggles.smssync.activity.fragments.MainSettings) Intent(android.content.Intent) Preferences(com.zegoggles.smssync.preferences.Preferences) AuthPreferences(com.zegoggles.smssync.preferences.AuthPreferences) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with AuthPreferences

use of com.zegoggles.smssync.preferences.AuthPreferences in project sms-backup-plus by jberkel.

the class SmsRestoreService method handleIntent.

@Override
protected void handleIntent(final Intent intent) {
    if (isWorking())
        return;
    try {
        final boolean restoreCallLog = getPreferences().getDataTypePreferences().isRestoreEnabled(CALLLOG);
        final boolean restoreSms = getPreferences().getDataTypePreferences().isRestoreEnabled(SMS);
        if (restoreSms && !canWriteToSmsProvider()) {
            postError(new SmsProviderNotWritableException());
            return;
        }
        MessageConverter converter = new MessageConverter(service, getPreferences(), getAuthPreferences().getUserEmail(), new PersonLookup(getContentResolver()), new ContactAccessor());
        RestoreConfig config = new RestoreConfig(getBackupImapStore(), 0, restoreSms, restoreCallLog, getPreferences().isRestoreStarredOnly(), getPreferences().getMaxItemsPerRestore(), 0);
        final AuthPreferences authPreferences = new AuthPreferences(this);
        new RestoreTask(this, converter, getContentResolver(), new TokenRefresher(service, new OAuth2Client(authPreferences.getOAuth2ClientId()), authPreferences)).execute(config);
    } catch (MessagingException e) {
        postError(e);
    }
}
Also used : AuthPreferences(com.zegoggles.smssync.preferences.AuthPreferences) SmsProviderNotWritableException(com.zegoggles.smssync.service.exception.SmsProviderNotWritableException) TokenRefresher(com.zegoggles.smssync.auth.TokenRefresher) MessagingException(com.fsck.k9.mail.MessagingException) OAuth2Client(com.zegoggles.smssync.auth.OAuth2Client) ContactAccessor(com.zegoggles.smssync.contacts.ContactAccessor) MessageConverter(com.zegoggles.smssync.mail.MessageConverter) PersonLookup(com.zegoggles.smssync.mail.PersonLookup)

Example 3 with AuthPreferences

use of com.zegoggles.smssync.preferences.AuthPreferences in project sms-backup-plus by jberkel.

the class MainSettings method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle bundle, String rootKey) {
    super.onCreatePreferences(bundle, rootKey);
    authPreferences = new AuthPreferences(getContext());
}
Also used : AuthPreferences(com.zegoggles.smssync.preferences.AuthPreferences)

Aggregations

AuthPreferences (com.zegoggles.smssync.preferences.AuthPreferences)3 OAuth2Client (com.zegoggles.smssync.auth.OAuth2Client)2 Intent (android.content.Intent)1 Toolbar (android.support.v7.widget.Toolbar)1 MessagingException (com.fsck.k9.mail.MessagingException)1 MainSettings (com.zegoggles.smssync.activity.fragments.MainSettings)1 TokenRefresher (com.zegoggles.smssync.auth.TokenRefresher)1 ContactAccessor (com.zegoggles.smssync.contacts.ContactAccessor)1 MessageConverter (com.zegoggles.smssync.mail.MessageConverter)1 PersonLookup (com.zegoggles.smssync.mail.PersonLookup)1 Preferences (com.zegoggles.smssync.preferences.Preferences)1 SmsProviderNotWritableException (com.zegoggles.smssync.service.exception.SmsProviderNotWritableException)1