Exemplo n.º 1
0
        protected override void LoadData()
        {
            try
            {
                String uid = Auth.Uid;
                if (uid == null)
                {
                    var prefs = GetSharedPreferences("naxam-dropbox-sample", FileCreationMode.Private);
                    uid = prefs.GetString("user-id", null);
                }
                this.mDoac = new DbxOfficialAppConnector(uid);
            }
            catch (DropboxUidNotInitializedException e)
            {
                e.PrintStackTrace();
                return;
            }

            HandleFakeOpenWithIntent(Intent);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_open_with);

            var toolbar = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.app_bar);

            SetSupportActionBar(toolbar);

            var generateIntentButton = (Button)FindViewById(Resource.Id.generate_intent);

            generateIntentButton.Click += (sender, e) =>
            {
                var    editText = (EditText)FindViewById(Resource.Id.editText);
                string path     = editText.Text;
                //fake OpenWithIntent with some dummy parameters
                var fakeOpenWithIntent = GenerateOpenWithIntent(path);
                //encode the fake OpenWithIntent into UtmContent
                var encodedFakeIntent = EncodeOpenWithIntent(fakeOpenWithIntent);
                try
                {
                    //test that decoding utmcontent works
                    var decodedIntent = DbxOfficialAppConnector.GenerateOpenWithIntentFromUtmContent(encodedFakeIntent);
                    //start that fake OpenWithIntent. This will lead us to a new OpenWithActivity.
                    StartActivity(decodedIntent);
                }
                catch (DropboxParseException ex)
                {
                    // TODO Auto-generated catch block
                    ex.PrintStackTrace();
                }
            };

            Button mInstalled = (Button)FindViewById(Resource.Id.is_installed);

            mInstalled.Click += (s, e) =>
            {
                var installInfo = DbxOfficialAppConnector.IsInstalled(this);
                ShowToast((installInfo != null) ? installInfo.ToString() : "Not installed!");
            };

            Button mGenLinked = (Button)FindViewById(Resource.Id.is_linked_any_button);

            mGenLinked.Click += (s, e) =>
            {
                var isSigned = DbxOfficialAppConnector.IsAnySignedIn(this);
                ShowToast("Any Signed in?:" + isSigned);
            };

            Button mSpecLinked = (Button)FindViewById(Resource.Id.is_linked_spec_button);

            mSpecLinked.Click += (s, e) =>
            {
                var isSigned = mDoac.IsSignedIn(this);
                ShowToast("Signed in?:" + isSigned);
            };

            Button mPreview = (Button)FindViewById(Resource.Id.preview_button);

            mPreview.Click += (s, e) =>
            {
                var editText = (EditText)FindViewById(Resource.Id.editText);
                var path     = editText.Text;
                var pIntent  = mDoac.GetPreviewFileIntent(this, path, "");

                if (pIntent == null)
                {
                    Toast.MakeText(this, "Couldn't create preview intent", ToastLength.Short)
                    .Show();

                    return;
                }

                StartActivity(pIntent);
            };

            Button mUpgrade = (Button)FindViewById(Resource.Id.upgrade_button);

            mUpgrade.Click += (s, e) =>
            {
                var uIntent = mDoac.GetUpgradeAccountIntent(this);
                StartActivity(uIntent);
            };
        }