Search in sources :

Example 1 with DropboxParseException

use of com.dropbox.core.android.DropboxParseException in project dropbox-sdk-java by dropbox.

the class OpenWithActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_with);
    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    Button generateIntentButton = (Button) findViewById(R.id.generate_intent);
    generateIntentButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EditText editText = (EditText) findViewById(R.id.editText);
            String path = editText.getText().toString();
            // fake OpenWithIntent with some dummy parameters
            Intent fakeOpenWithIntent = generateOpenWithIntent(path);
            // encode the fake OpenWithIntent into UtmContent
            String encodedFakeIntent = encodeOpenWithIntent(fakeOpenWithIntent);
            try {
                // test that decoding utmcontent works
                Intent decodedIntent = DbxOfficialAppConnector.generateOpenWithIntentFromUtmContent(encodedFakeIntent);
                // start that fake OpenWithIntent. This will lead us to a new OpenWithActivity.
                startActivity(decodedIntent);
            } catch (DropboxParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    Button mInstalled = (Button) findViewById(R.id.is_installed);
    mInstalled.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DbxOfficialAppConnector.DbxOfficialAppInstallInfo installInfo = DbxOfficialAppConnector.isInstalled(OpenWithActivity.this);
            showToast((installInfo != null) ? installInfo.toString() : "Not installed!");
        }
    });
    Button mGenLinked = (Button) findViewById(R.id.is_linked_any_button);
    mGenLinked.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isSigned = DbxOfficialAppConnector.isAnySignedIn(OpenWithActivity.this);
            showToast("Any Signed in?:" + isSigned);
        }
    });
    Button mSpecLinked = (Button) findViewById(R.id.is_linked_spec_button);
    mSpecLinked.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isSigned = mDoac.isSignedIn(OpenWithActivity.this);
            showToast("Signed in?:" + isSigned);
        }
    });
    Button mPreview = (Button) findViewById(R.id.preview_button);
    mPreview.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EditText editText = (EditText) findViewById(R.id.editText);
            String path = editText.getText().toString();
            Intent pIntent = mDoac.getPreviewFileIntent(OpenWithActivity.this, path, "");
            startActivity(pIntent);
        }
    });
    Button mUpgrade = (Button) findViewById(R.id.upgrade_button);
    mUpgrade.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent uIntent = mDoac.getUpgradeAccountIntent(OpenWithActivity.this);
            startActivity(uIntent);
        }
    });
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) DropboxParseException(com.dropbox.core.android.DropboxParseException) Intent(android.content.Intent) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 Toolbar (androidx.appcompat.widget.Toolbar)1 DropboxParseException (com.dropbox.core.android.DropboxParseException)1