protected override void SetupPageTransition(Android.Support.V4.App.FragmentTransaction transaction, bool isPush)
        {
            switch (_transitionType)
            {
            case TransitionType.None:
                return;

            case TransitionType.Default:
                return;

            case TransitionType.Fade:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_right, Resource.Animation.exit_left,
                                                    Resource.Animation.enter_left, Resource.Animation.exit_right);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_left, Resource.Animation.exit_right,
                                                    Resource.Animation.enter_right, Resource.Animation.exit_left);
                }
                break;

            default:
                return;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Switches the fragment to the selected listview item.
 /// </summary>
 /// <param name="frag">Frag.</param>
 /// <param name="resource">Resource.</param>
 /// <param name="tag">Tag.</param>
 private void switchFragment(Android.Support.V4.App.Fragment frag, int resource, string tag)
 {
     Android.Support.V4.App.FragmentTransaction fragmentTransaction = this.Activity.SupportFragmentManager.BeginTransaction(); //begin the fragment transaction
     fragmentTransaction.SetCustomAnimations(Resource.Layout.EnterAnimation, Resource.Layout.ExitAnimation);                   //add animation to slide new fragment to the left
     fragmentTransaction.AddToBackStack("UserActivity");
     fragmentTransaction.Replace(resource, frag, tag);
     fragmentTransaction.Commit(); //commit the transaction
 }
        protected override void SetupPageTransition(Android.Support.V4.App.FragmentTransaction transaction, bool isPush)
        {
            switch (_transitionType)
            {
            case TransitionType.Fade:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.fade_in, Resource.Animation.fade_out,
                                                    Resource.Animation.fade_out, Resource.Animation.fade_in);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.fade_in, Resource.Animation.fade_out,
                                                    Resource.Animation.fade_out, Resource.Animation.fade_in);
                }
                break;

            case TransitionType.Flip:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.flip_in, Resource.Animation.flip_out,
                                                    Resource.Animation.fade_out, Resource.Animation.flip_in);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.flip_in, Resource.Animation.flip_out,
                                                    Resource.Animation.flip_out, Resource.Animation.flip_in);
                }
                break;

            case TransitionType.Scale:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.scale_in, Resource.Animation.scale_out,
                                                    Resource.Animation.scale_out, Resource.Animation.scale_in);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.scale_in, Resource.Animation.scale_out,
                                                    Resource.Animation.scale_out, Resource.Animation.scale_in);
                }
                break;

            case TransitionType.SlideFromLeft:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_left, Resource.Animation.exit_right,
                                                    Resource.Animation.enter_right, Resource.Animation.exit_left);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_right, Resource.Animation.exit_left,
                                                    Resource.Animation.enter_left, Resource.Animation.exit_right);
                }
                break;

            case TransitionType.SlideFromRight:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_right, Resource.Animation.exit_left,
                                                    Resource.Animation.enter_left, Resource.Animation.exit_right);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_left, Resource.Animation.exit_right,
                                                    Resource.Animation.enter_right, Resource.Animation.exit_left);
                }
                break;

            case TransitionType.SlideFromTop:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_top, Resource.Animation.exit_bottom,
                                                    Resource.Animation.enter_bottom, Resource.Animation.exit_top);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_bottom, Resource.Animation.exit_top,
                                                    Resource.Animation.enter_top, Resource.Animation.exit_bottom);
                }
                break;

            case TransitionType.SlideFromBottom:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_bottom, Resource.Animation.exit_top,
                                                    Resource.Animation.enter_top, Resource.Animation.exit_bottom);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.enter_top, Resource.Animation.exit_bottom,
                                                    Resource.Animation.enter_bottom, Resource.Animation.exit_top);
                }
                break;

            default:
                break;
            }
        }
        protected override void SetupPageTransition(Android.Support.V4.App.FragmentTransaction transaction, bool isPush)
        {
            switch (_transitionType)
            {
            case TransitionType.None:
                transaction.SetCustomAnimations(Resource.Animation.EnterFromLeft, Resource.Animation.ExitToRight,
                                                Resource.Animation.EnterFromRight, Resource.Animation.ExitToLeft);
                break;

            case TransitionType.Default:
                transaction.SetCustomAnimations(Resource.Animation.EnterFromLeft, Resource.Animation.ExitToRight,
                                                Resource.Animation.EnterFromRight, Resource.Animation.ExitToLeft);
                break;

            case TransitionType.Fade:
                transaction.SetCustomAnimations(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out,
                                                Resource.Animation.abc_fade_out, Resource.Animation.abc_fade_in);
                break;

            case TransitionType.Flip:
                transaction.SetCustomAnimations(Resource.Animation.design_bottom_sheet_slide_in, Resource.Animation.design_bottom_sheet_slide_out,
                                                Resource.Animation.design_bottom_sheet_slide_out, Resource.Animation.design_bottom_sheet_slide_in);
                break;

            case TransitionType.Scale:
                transaction.SetCustomAnimations(Resource.Animation.abc_grow_fade_in_from_bottom, Resource.Animation.abc_shrink_fade_out_from_bottom,
                                                Resource.Animation.abc_shrink_fade_out_from_bottom, Resource.Animation.abc_grow_fade_in_from_bottom);
                break;

            case TransitionType.SlideFromLeft:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.EnterFromLeft, Resource.Animation.ExitToRight,
                                                    Resource.Animation.EnterFromRight, Resource.Animation.ExitToLeft);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.EnterFromRight, Resource.Animation.ExitToLeft,
                                                    Resource.Animation.EnterFromLeft, Resource.Animation.ExitToRight);
                }
                break;

            case TransitionType.SlideFromRight:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.EnterFromRight, Resource.Animation.ExitToLeft,
                                                    Resource.Animation.EnterFromLeft, Resource.Animation.ExitToRight);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.EnterFromLeft, Resource.Animation.ExitToRight,
                                                    Resource.Animation.EnterFromRight, Resource.Animation.ExitToLeft);
                }
                break;

            case TransitionType.SlideFromTop:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.tooltip_enter, Resource.Animation.tooltip_exit,
                                                    Resource.Animation.tooltip_exit, Resource.Animation.tooltip_enter);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.tooltip_enter, Resource.Animation.tooltip_exit,
                                                    Resource.Animation.tooltip_exit, Resource.Animation.tooltip_enter);
                }
                break;

            case TransitionType.SlideFromBottom:
                if (isPush)
                {
                    transaction.SetCustomAnimations(Resource.Animation.design_snackbar_in, Resource.Animation.design_snackbar_out,
                                                    Resource.Animation.design_snackbar_out, Resource.Animation.design_snackbar_in);
                }
                else
                {
                    transaction.SetCustomAnimations(Resource.Animation.design_bottom_sheet_slide_in, Resource.Animation.design_bottom_sheet_slide_out,
                                                    Resource.Animation.design_bottom_sheet_slide_out, Resource.Animation.design_bottom_sheet_slide_in);
                }
                break;

            default:
                return;
            }
        }
        async void ListView_OnItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            ResetUIToBeginState(false);


            SslValidator.CertificateErrorRaised = false;

            //Set selected local box
            Waardes.Instance.GeselecteerdeBox = foundLocalBoxes[e.Position].Id;

            //Reset certificate validation check to default behavior

            /*
             * ServicePointManager.ServerCertificateValidationCallback = null;
             *
             * if (foundLocalBoxes[e.Position].OriginalSslCertificate != null) { //Selected localbox does have a ssl certificate
             *      //Set ssl validator for selected LocalBox
             *      SslValidator sslValidator = new SslValidator ();
             *      ServicePointManager.ServerCertificateValidationCallback = sslValidator.ValidateServerCertficate;
             * }*/

            //Change action bar color to color of selected localbox
            if (DataLayer.Instance.GetSelectedOrDefaultBox().BackColor != null &&
                DataLayer.Instance.GetSelectedOrDefaultBox().BackColor.StartsWith("#"))
            {
                HomeActivity.colorOfSelectedLocalBox = DataLayer.Instance.GetSelectedOrDefaultBox().BackColor;
            }
            else
            {
                HomeActivity.colorOfSelectedLocalBox = Constants.lightblue;
            }
            SetCustomActionBarColor();

            //Change logo image to logo of selected local box
            if (DataLayer.Instance.GetSelectedOrDefaultBox().LogoUrl != null)
            {
                string logoUrl = DataLayer.Instance.GetSelectedOrDefaultBox().LogoUrl;

                string documentsPath = DocumentConstants.DocumentsPath;
                string pathToLogo    = System.IO.Path.Combine(documentsPath, logoUrl.Substring(logoUrl.LastIndexOf("/") + 1));

                if (File.Exists(pathToLogo))
                {                 //Verander logo
                    Android.Net.Uri uriLogo = Android.Net.Uri.Parse(pathToLogo);
                    //imageViewLogo.SetImageURI (uriLogo);
                }
                else                 //Default logo
                {
                    //imageViewLogo.SetImageResource (Resource.Drawable.beeldmerk_belastingdienst);
                }
            }

            //Update fragment data
            Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction();
            fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit);

            //Show progress dialog while loading
            ShowProgressDialog(Activity, null);

            try {
                HomeActivity homeActivity = (HomeActivity)Activity;

                ExplorerFragment explorerFragment = new ExplorerFragment(await DataLayer.Instance.GetFolder("/"), homeActivity);

                HomeActivity.openedExplorerFragments = new List <ExplorerFragment>();
                HomeActivity.openedExplorerFragments.Add(explorerFragment);

                //Add new directory to opened directories list
                ExplorerFragment.openedDirectories = new List <string>();
                ExplorerFragment.openedDirectories.Add("/");

                fragmentTransaction.Replace(Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment");

                //Clear fragment back stack
                int entryCount = Activity.SupportFragmentManager.BackStackEntryCount;

                while (entryCount > 0)
                {
                    Activity.SupportFragmentManager.PopBackStackImmediate();
                    entryCount = Activity.SupportFragmentManager.BackStackEntryCount;
                }

                //Add fragment to stack - needed for back button functionality
                fragmentTransaction.AddToBackStack(null);

                // Start the animated transition.
                fragmentTransaction.Commit();

                //Show hidden buttons
                RelativeLayout fragmentContainerExplorerBottom = Activity.FindViewById <RelativeLayout> (Resource.Id.fragment_container_explorer_blank);
                fragmentContainerExplorerBottom.Visibility = ViewStates.Visible;

                //Show shadow
                View shadowContainerExplorer = Activity.FindViewById <View> (Resource.Id.shadow_container_explorer);
                shadowContainerExplorer.Visibility = ViewStates.Visible;

                //Hide back button
                ImageButton buttonBackExplorer = Activity.FindViewById <ImageButton> (Resource.Id.button_back_explorer);
                buttonBackExplorer.Visibility = ViewStates.Invisible;

                HideProgressDialog();
            }
            catch (Exception ex) {
                Insights.Report(ex);
                HideProgressDialog();
                Toast.MakeText(Activity, "Er is iets fout gegaan", ToastLength.Short).Show();
            }
        }
        async void ListView_OnItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            try {
                TreeNode clickedItem = foundTreeNodeChildren [e.Position];

                //Hide bottom menu for favorite file

                if (favoriteFolderOpened)
                {
                    parentActivity.HideBottomExplorerMenuItems();
                }
                else
                {
                    parentActivity.ShowBottomExplorerMenuItems();
                }

                //Show progress dialog while loading
                parentActivity.ShowProgressDialog(null);


                if (clickedItem.IsDirectory == true)                  //Folder aangeklikt (NIET "Lokale favorieten")
                {
                    Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction();
                    fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit);

                    ExplorerFragment explorerFragment = new ExplorerFragment(await DataLayer.Instance.GetFolder(clickedItem.Path), parentActivity);
                    HomeActivity.openedExplorerFragments.Add(explorerFragment);
                    fragmentTransaction.Replace(Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment");

                    //Add new directory to opened directories list
                    ExplorerFragment.openedDirectories.Add(clickedItem.Path);

                    //Used to determine custom context menu
                    if (ExplorerFragment.openedDirectories.Count == 2)
                    {
                        if (clickedItem.IsShare)
                        {
                            openedFolderIsShare = true;
                        }
                        else
                        {
                            openedFolderIsShare = false;
                        }
                    }

                    //Used to determine upload action and icon in listview item (encrypted or unencrypted folder)
                    if (ExplorerFragment.openedDirectories.Count == 2)
                    {
                        if (clickedItem.HasKeys)
                        {
                            openedFolderIsUnencrypted = false;
                        }
                        else
                        {
                            openedFolderIsUnencrypted = true;
                        }
                    }

                    //Add fragment to stack - needed for back button functionality
                    fragmentTransaction.AddToBackStack(null);

                    // Start the animated transition.
                    fragmentTransaction.Commit();

                    //Show hidden buttons
                    ImageButton buttonBackExplorer = Activity.FindViewById <ImageButton> (Resource.Id.button_back_explorer);
                    buttonBackExplorer.Visibility = ViewStates.Visible;
                }
                else if (clickedItem.Type.Equals("favorite"))                   //List item "Lokale favorieten" aangeklikt
                {
                    //Hide bottom menu for favorite folder
                    parentActivity.HideBottomExplorerMenuItems();

                    Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction();
                    fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit);

                    List <TreeNode> favorites = DataLayer.Instance.GetFavorites();

                    ExplorerFragment explorerFragment = new ExplorerFragment(favorites, parentActivity);
                    HomeActivity.openedExplorerFragments.Add(explorerFragment);
                    fragmentTransaction.Replace(Resource.Id.fragment_container_explorer, explorerFragment, "explorerFragment");

                    //Add new directory to opened directories list
                    ExplorerFragment.openedDirectories.Add(clickedItem.Path);

                    //Add fragment to stack - needed for back button functionality
                    fragmentTransaction.AddToBackStack(null);

                    // Start the animated transition.
                    fragmentTransaction.Commit();

                    //Show hidden buttons
                    ImageButton buttonBackExplorer = Activity.FindViewById <ImageButton> (Resource.Id.button_back_explorer);
                    buttonBackExplorer.Visibility = ViewStates.Visible;
                }
                else                    //Bestand aangeklikt
                //Afbeeldingen openen in webview - andere typen bestanden openen middels content provider

                {
                    string mimeTypeOfClickedItem = MimeTypeHelper.GetMimeType(clickedItem.Path);
                    clickedItem.Type = mimeTypeOfClickedItem;

                    if (mimeTypeOfClickedItem.Equals("image/jpeg") ||
                        mimeTypeOfClickedItem.Equals("image/png") ||
                        mimeTypeOfClickedItem.Equals("application/pdf") ||
                        mimeTypeOfClickedItem.Equals("application/vnd.oasis.opendocument.text") ||
                        mimeTypeOfClickedItem.Equals("text/html"))
                    {
                        lastShownTreeNodeId = clickedItem.Id;

                        Android.Support.V4.App.FragmentTransaction fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction();
                        fragmentTransaction.SetCustomAnimations(Resource.Animation.enter, Resource.Animation.exit);

                        DocumentFragment documentFragment = new DocumentFragment(await DataLayer.Instance.GetFilePath(clickedItem.Path), clickedItem.Name);
                        fragmentTransaction.Replace(Resource.Id.fragment_container_document, documentFragment, "documentFragment");

                        // Start the animated transition.
                        fragmentTransaction.Commit();
                    }
                    else if (mimeTypeOfClickedItem.Equals("video/mp4"))
                    {
                        var    videoPlayerActivity = new Intent(Activity, typeof(VideoPlayerActivity));
                        string pathToVideo         = await DataLayer.Instance.GetFilePath(clickedItem.Path);

                        videoPlayerActivity.PutExtra("PathToVideo", pathToVideo);

                        StartActivity(videoPlayerActivity);
                    }

                    //Disabled - reason: no license for PDFTron

                    /*else if(mimeTypeOfClickedItem.Equals("application/pdf")){
                     *
                     *      var pdfIntent = new Intent (Activity, typeof(PdfActivity));
                     *
                     *      string absolutePathOfPDF = await DataLayer.Instance.GetFilePath (clickedItem.Path);
                     *      pdfIntent.PutExtra ("absolutePathOfPDF", absolutePathOfPDF);
                     *      pdfIntent.PutExtra ("relativePathOfPDF", clickedItem.Path);
                     *      pdfIntent.PutExtra ("fileName", clickedItem.Name);
                     *
                     *      StartActivity (pdfIntent);
                     * }*/

                    else
                    {
                        //Open bestand in andere app
                        OpenFileIn(clickedItem);
                    }
                }
            } catch (Exception ex) {
                Insights.Report(ex);
                parentActivity.HideProgressDialog();
                Toast.MakeText(Activity, "Het openen is mislukt. Probeer het a.u.b. opnieuw", ToastLength.Short).Show();
            }
            parentActivity.HideProgressDialog();
        }