Exemple #1
0
        public bool LoadFragment(int item)
        {
            Fragment aFragment = null;

            switch (item)
            {
            case Resource.Id.navigation_home:
                aFragment = new HomeFragment();
                break;

            case Resource.Id.navigation_dashboard:
                aFragment = new DashboardFragment();
                break;

            case Resource.Id.navigation_notifications:
                aFragment = new NotificationFragment();
                break;
            }

            if (aFragment != null)
            {
                this.FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, aFragment).Commit();
            }

            return(false);
        }
        private AndroidX.Fragment.App.Fragment CreateFragment(string tag)
        {
            AndroidX.Fragment.App.Fragment result = null;
            switch (tag)
            {
            case "clock_fragment":

                if (clockFragment == null)
                {
                    clockFragment = new ClockFragment();
                }
                result = clockFragment;
                break;

            case "notification_fragment":
                if (notificationFragment == null)
                {
                    notificationFragment = new NotificationFragment();
                }
                result = notificationFragment;
                break;

            case "music_fragment":
                if (musicFragment == null)
                {
                    musicFragment = new MusicFragment();
                }
                result = musicFragment;
                break;
            }
            Log.Debug("LiveDisplay", "create: " + result.ToString());
            return(result);
        }
        private async void GetDrawerInfo()
        {
            var profile = await _profileDrawerControllerService.GetUserProfile();

            RunOnUiThread(() =>
            {
                if (profile != null)
                {
                    //set up profile picture, logout button and favorites if the user is logged in
                    LoggedIn = true;
                    NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Gone;
                    NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Visible;
                    var authHeader        = NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader);
                    authHeader.Visibility = ViewStates.Visible;
                    Picasso.With(this).Load(profile.ProfileImageUrl)
                    .Into(authHeader.FindViewById <ImageView>(Resource.Id.drawerAuthenticatedHeader_Avatar));

                    authHeader.Tag = profile.ProfileId;
                    authHeader.SetOnClickListener(this);

                    authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Fullname).Text =
                        profile.ProfileFirstName + " " + profile.ProfileLastName;
                    authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Handle).Text = profile.ProfileHandle;

                    //Setting up auth tab layout
                    //MainTabLayout.Visibility = ViewStates.Visible;
                    Fab.Visibility = ViewStates.Visible;
                    //TODO: Change these to real fragments later
                    if (Fragments.Count == 1)
                    {
                        Fragments.Add(NotificationFragment.NewInstance());
                        Fragments.Add(NotificationFragment.NewInstance());
                    }
                    MainFragAdapter.NotifyDataSetChanged();
                    SetTabIcons();
                }
                else
                {
                    //set up icon and hide tab layout when user is not logged in
                    LoggedIn       = false;
                    Fab.Visibility = ViewStates.Gone;
                    NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Gone;
                    NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Visible;
                    NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader).Visibility    = ViewStates.Gone;

                    NavView.FindViewById <ImageView>(Resource.Id.drawerNonAuthenticatedHeader_Avatar)
                    .SetImageDrawable(
                        ViewUtil.GetSVGDrawable(this, "profile_empty", 200, Resource.Color.Upward_dark_grey));


                    MainTabLayout.Visibility = ViewStates.Gone;
                }
                PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).Edit()
                .PutBoolean(Constants.PREF_SIGNED_IN_KEY, LoggedIn).Commit();
            });
        }
Exemple #4
0
        //Open Notification Page
        private void NotificationIconOnClick(object sender, EventArgs e)
        {
            try
            {
                GlobalContext.ShowOrHideBadgeViewIcon();

                NotificationFragment notificationFragment = new NotificationFragment();
                GlobalContext.FragmentBottomNavigator.DisplayFragment(notificationFragment);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Exemple #5
0
        void LoadFragment(int id)
        {
            try
            {
                Android.Support.V4.App.Fragment fragment = null;
                switch (id)
                {
                case Resource.Id.navigation_home:
                    fragment = HomeFragment.NewInstance();
                    break;

                case Resource.Id.navigation_credit:
                    fragment = CreditFragment.NewInstance();
                    break;

                case Resource.Id.navigation_debit:
                    fragment = DebitFragment.NewInstance();
                    break;

                case Resource.Id.navigation_notifications:
                    fragment = NotificationFragment.NewInstance();
                    break;
                }

                if (fragment == null)
                {
                    return;
                }

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            catch (Exception ex)
            {
                clsGLB.ShowMessage(ex.Message, this, MessageTitle.ERROR);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LockScreen);
            ThreadPool.QueueUserWorkItem(isApphealthy =>
            {
                if (Checkers.IsNotificationListenerEnabled() == false || Checkers.ThisAppCanDrawOverlays() == false || Checkers.IsThisAppADeviceAdministrator() == false)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(Application.Context, "You dont have the required permissions", ToastLength.Long).Show();
                        Finish();
                    }
                                  );
                }
            });

            //Views
            //wallpaperView = FindViewById<ImageView>(Resource.Id.wallpaper);
            //unlocker = FindViewById<ImageView>(Resource.Id.unlocker);
            startCamera          = FindViewById <Button>(Resource.Id.btnStartCamera);
            startDialer          = FindViewById <Button>(Resource.Id.btnStartPhone);
            clearAll             = FindViewById <Button>(Resource.Id.btnClearAllNotifications);
            lockscreen           = FindViewById <LinearLayout>(Resource.Id.contenedorPrincipal);
            viewPropertyAnimator = Window.DecorView.Animate();
            viewPropertyAnimator.SetListener(new LockScreenAnimationHelper(Window));
            livedisplayinfo = FindViewById <TextView>(Resource.Id.livedisplayinfo);

            fadeoutanimation = AnimationUtils.LoadAnimation(Application.Context, Resource.Animation.abc_fade_out);
            fadeoutanimation.AnimationEnd += Fadeoutanimation_AnimationEnd;

            notificationFragment = new NotificationFragment();
            musicFragment        = new MusicFragment();
            clockFragment        = new ClockFragment();
            weatherFragment      = new WeatherFragment();
            clearAll.Click      += BtnClearAll_Click;
            //unlocker.Touch += Unlocker_Touch;
            startCamera.Click += StartCamera_Click;
            startDialer.Click += StartDialer_Click;
            lockscreen.Touch  += Lockscreen_Touch;

            watchDog = new System.Timers.Timer
            {
                AutoReset = false
            };
            watchDog.Elapsed += WatchdogInterval_Elapsed;

            halfscreenheight = Resources.DisplayMetrics.HeightPixels / 2;

            WallpaperPublisher.NewWallpaperIssued += Wallpaper_NewWallpaperIssued;

            //CatcherHelper events
            CatcherHelper.NotificationListSizeChanged += CatcherHelper_NotificationListSizeChanged;

            using (recycler = FindViewById <RecyclerView>(Resource.Id.NotificationListRecyclerView))
            {
                using (layoutManager = new LinearLayoutManager(Application.Context))
                {
                    recycler.SetLayoutManager(layoutManager);
                    recycler.SetAdapter(CatcherHelper.notificationAdapter);
                }
            }

            LoadClockFragment();

            LoadNotificationFragment();

            LoadConfiguration();

            OnActivityStateChanged += LockScreenActivity_OnActivityStateChanged;
            WallpaperPublisher.CurrentWallpaperCleared += WallpaperPublisher_CurrentWallpaperCleared;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LockScreen);
            Window.DecorView.SetBackgroundColor(Color.Black);
            ThreadPool.QueueUserWorkItem(isApphealthy =>
            {
                bool canDrawOverlays = true;
                if (Build.VERSION.SdkInt > BuildVersionCodes.LollipopMr1) //In Lollipop and less this permission is granted at Install time.
                {
                    canDrawOverlays = Checkers.ThisAppCanDrawOverlays();
                }

                if (Checkers.IsNotificationListenerEnabled() == false || canDrawOverlays == false || Checkers.IsThisAppADeviceAdministrator() == false)
                {
                    RunOnUiThread(() =>
                                  Toast.MakeText(Application.Context, "You dont have the required permissions", ToastLength.Long).Show()
                                  );
                    Finish();
                }
            });

            //Views
            wallpaper   = FindViewById <ImageView>(Resource.Id.wallpaper);
            unlocker    = FindViewById <ImageView>(Resource.Id.unlocker);
            startCamera = FindViewById <Button>(Resource.Id.btnStartCamera);
            startDialer = FindViewById <Button>(Resource.Id.btnStartPhone);
            clearAll    = FindViewById <Button>(Resource.Id.btnClearAllNotifications);
            lockscreen  = FindViewById <LinearLayout>(Resource.Id.contenedorPrincipal);
            weatherandclockcontainer = FindViewById <FrameLayout>(Resource.Id.weatherandcLockplaceholder);

            fadeoutanimation = AnimationUtils.LoadAnimation(Application.Context, Resource.Animation.abc_fade_out);
            fadeoutanimation.AnimationEnd += Fadeoutanimation_AnimationEnd;

            notificationFragment = new NotificationFragment();
            musicFragment        = new MusicFragment();
            clockFragment        = new ClockFragment();
            weatherFragment      = new WeatherFragment();
            clearAll.Click      += BtnClearAll_Click;
            unlocker.Touch      += Unlocker_Touch;
            startCamera.Click   += StartCamera_Click;
            startDialer.Click   += StartDialer_Click;
            lockscreen.Touch    += Lockscreen_Touch;
            weatherandclockcontainer.LongClick += Weatherandclockcontainer_LongClick;

            watchDog           = new System.Timers.Timer();
            watchDog.AutoReset = false;
            watchDog.Elapsed  += WatchdogInterval_Elapsed;

            WallpaperPublisher.NewWallpaperIssued += Wallpaper_NewWallpaperIssued;

            //CatcherHelper events
            CatcherHelper.NotificationListSizeChanged += CatcherHelper_NotificationListSizeChanged;

            //Load RecyclerView

            using (recycler = FindViewById <RecyclerView>(Resource.Id.NotificationListRecyclerView))
            {
                using (layoutManager = new LinearLayoutManager(Application.Context))
                {
                    recycler.SetLayoutManager(layoutManager);
                    recycler.SetAdapter(CatcherHelper.notificationAdapter);
                }
            }

            LoadClockFragment();

            LoadNotificationFragment();

            //Load User Configs.
            LoadConfiguration();

            CheckNotificationListSize();
        }