package epson.print.storage.evernote;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.epson.iprint.storage.StorageSignInActivity;

import epson.print.Util.EPLog;

public class EvernoteSignInActivity extends StorageSignInActivity {
    private static final String TAG = "EvernoteSignInActivity";

    public StorageSignInActivity.BasicSignIn getBasicSignIn() {
        return null;
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        EvernoteClient.getEvernoteSession(this).authenticate((Activity) this);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        if (i == 14390) {
            if (i2 != -1 || !EvernoteClient.getEvernoteSession(this).isLoggedIn()) {
                showLoginErrorAndFinish();
                return;
            }
            EPLog.i(TAG, "REQUEST_CODE_OAUTH RESULT_OK");
            finish();
        }
    }

    protected void onDestroy() {
        super.onDestroy();
    }

    public void onBackPressed() {
        revokeUserData();
        finish();
    }

    private void revokeUserData() {
        EvernoteClient.logout(this);
    }
}
