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(); }