private void CatcherHelper_NotificationListSizeChanged(object sender, NotificationListSizeChangedEventArgs e) { RunOnUiThread(() => { if (e.ThereAreNotifications) { if (clearAll != null) { clearAll.Visibility = ViewStates.Visible; } } else { if (clearAll != null) { clearAll.Visibility = ViewStates.Invisible; } if (configurationManager.RetrieveAValue(ConfigurationParameters.TurnOffScreenAfterLastNotificationCleared) && ActivityLifecycleHelper.GetInstance().GetActivityState(typeof(LockScreenActivity)) == ActivityStates.Resumed) { AwakeHelper.TurnOffScreen(); } } }); }
private void WatchdogInterval_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //it works correctly, but I want to refactor this. (Regression) if (ActivityLifecycleHelper.GetInstance().GetActivityState(typeof(LockScreenActivity)) == ActivityStates.Resumed) { AwakeHelper.TurnOffScreen(); } }
private void WatchdogInterval_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //it works correctly, but I want to refactor this. (Regression) if (currentActivityState == ActivityStates.Resumed) { AwakeHelper.TurnOffScreen(); } }
public override bool OnOptionsItemSelected(IMenuItem item) { int id = item.ItemId; switch (id) { case Resource.Id.action_settings: using (Intent intent = new Intent(this, typeof(SettingsActivity))) { intent.AddFlags(ActivityFlags.NewDocument); StartActivity(intent); } return(true); case Resource.Id.action_sendtestnotification: if (isApplicationHealthy) { AwakeHelper.TurnOffScreen(); using (NotificationSlave slave = NotificationSlave.NotificationSlaveInstance()) { var notificationtext = Resources.GetString(Resource.String.testnotificationtext); if (Build.VERSION.SdkInt > BuildVersionCodes.NMr1) { slave.PostNotification(7, "LiveDisplay", notificationtext, true, NotificationImportance.Max); } else { slave.PostNotification(1, "LiveDisplay", notificationtext, true, NotificationPriority.Max); } //NotificationSlave.SendDumbNotification(); } using (Intent intent = new Intent(Application.Context, typeof(LockScreenActivity))) { StartActivity(intent); return(true); } } else { Toast.MakeText(Application.Context, "You dont have the required permissions yet", ToastLength.Long).Show(); } break; case Resource.Id.action_help: using (AlertDialog.Builder builder = new AlertDialog.Builder(this)) { builder.SetMessage(Resource.String.helptext); builder.SetPositiveButton("ok, cool", null as EventHandler <DialogClickEventArgs>); builder.Show(); } break; default: break; } return(base.OnOptionsItemSelected(item)); }
private void Lockscreen_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { if (firstTouchTime == -1) { firstTouchTime = e.Event.DownTime; } else if (firstTouchTime != -1) { finalTouchTime = e.Event.DownTime; if (firstTouchTime + threshold < finalTouchTime) { firstTouchTime = finalTouchTime; //Let's set the last tap as the first, so the user doesnt have to press twice again return; } else if (firstTouchTime + threshold > finalTouchTime) { //0 Equals: Normal Behavior if (doubletapbehavior == "0") { if (e.Event.RawY < halfscreenheight) { AwakeHelper.TurnOffScreen(); } else { if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { if (KeyguardHelper.IsDeviceCurrentlyLocked()) { KeyguardHelper.RequestDismissKeyguard(this); } } MoveTaskToBack(true); } } //The other value is "1" which means Inverted. else { if (e.Event.RawY < halfscreenheight) { if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { if (KeyguardHelper.IsDeviceCurrentlyLocked()) { KeyguardHelper.RequestDismissKeyguard(this); } } MoveTaskToBack(true); } else { AwakeHelper.TurnOffScreen(); } } } //Reset the values of touch firstTouchTime = -1; finalTouchTime = -1; } } }
private void Lockscreen_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { if (firstTouchTime == -1) { firstTouchTime = e.Event.DownTime; } else if (firstTouchTime != -1) { finalTouchTime = e.Event.DownTime; if (firstTouchTime + threshold < finalTouchTime) { firstTouchTime = finalTouchTime; //Let's set the last tap as the first, so the user doesnt have to press twice again return; } else if (firstTouchTime + threshold > finalTouchTime) { //0 Equals: Normal Behavior if (doubletapbehavior == "0") { if (e.Event.RawY < halfscreenheight) { AwakeHelper.TurnOffScreen(); } else { //Finish(); //using (Intent intent = new Intent(Application.Context, Java.Lang.Class.FromType(typeof(TransparentActivity)))) //{ // intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.); // StartActivity(intent); //} MoveTaskToBack(true); } } //The other value is "1" which means Inverted. else { if (e.Event.RawY < halfscreenheight) { //Finish(); //using (Intent intent = new Intent(Application.Context, Java.Lang.Class.FromType(typeof(TransparentActivity)))) //{ // intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.MultipleTask); // StartActivity(intent); //} MoveTaskToBack(true); } else { AwakeHelper.TurnOffScreen(); } } } //Reset the values of touch firstTouchTime = -1; finalTouchTime = -1; } } }