Skip to content

Commit

Permalink
Merge pull request #56 from CarlosACepeda/Laboratory
Browse files Browse the repository at this point in the history
Version 0.9.5
  • Loading branch information
CarlosACepeda authored Feb 18, 2021
2 parents 1cd29cd + bbdf65f commit addbcf5
Show file tree
Hide file tree
Showing 26 changed files with 238 additions and 384 deletions.
6 changes: 0 additions & 6 deletions LiveDisplay/Activities/LockScreenActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ protected override void OnDestroy()
ActivityLifecycleHelper.GetInstance().NotifyActivityStateChange(typeof(LockScreenActivity), ActivityStates.Destroyed);
//Unbind events

//unlocker.Touch -= Unlocker_Touch;
clearAll.Click -= BtnClearAll_Click;
WallpaperPublisher.NewWallpaperIssued -= Wallpaper_NewWallpaperIssued;
CatcherHelper.NotificationListSizeChanged -= CatcherHelper_NotificationListSizeChanged;
Expand All @@ -332,16 +331,11 @@ protected override void OnDestroy()
//Dispose Views
//Views
recycler.Dispose();
//unlocker.Dispose();
clearAll.Dispose();
lockscreen.Dispose();
//wallpaperView.Background?.Dispose();
//wallpaperView = null;

viewPropertyAnimator.Dispose();

//Dispose Fragments
livedisplayinfo?.Dispose();
}

public override void OnBackPressed()
Expand Down
11 changes: 11 additions & 0 deletions LiveDisplay/Activities/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Android.Views;
using Android.Widget;
using AndroidX.AppCompat.App;
using AndroidX.Preference;
using LiveDisplay.BroadcastReceivers;
using LiveDisplay.Misc;
using LiveDisplay.Servicios;
Expand Down Expand Up @@ -48,9 +49,19 @@ protected override void OnResume()
CheckDeviceAdminAccess();
CheckDrawOverOtherAppsAccess();
IsApplicationHealthy();
LoadDefaultSettings();
base.OnResume();
}

private void LoadDefaultSettings()
{
PreferenceManager.SetDefaultValues(Application.Context, Resource.Xml.awake_prefs, true);
PreferenceManager.SetDefaultValues(Application.Context, Resource.Xml.lockscreen_prefs, true);
PreferenceManager.SetDefaultValues(Application.Context, Resource.Xml.music_widget_prefs, true);
PreferenceManager.SetDefaultValues(Application.Context, Resource.Xml.notification_prefs, true);
PreferenceManager.SetDefaultValues(Application.Context, "weatherpreferences", (int)FileCreationMode.Private, Resource.Xml.weather_widget_prefs, true);
}

private void WallpaperPublisher_NewWallpaperIssued(object sender, WallpaperChangedEventArgs e)
{
if (e.Wallpaper?.Bitmap != null)
Expand Down
6 changes: 0 additions & 6 deletions LiveDisplay/Fragments/ClockFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ private void LoadWeather()
lastupdated.Text = weatherlastupdated;
});
}

private void Weatherclockcontainer_Click(object sender, EventArgs e)
{
var view = sender as View;
}

public override void OnDestroyView()
{
base.OnDestroyView();
Expand Down
110 changes: 17 additions & 93 deletions LiveDisplay/Fragments/MusicFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MusicFragment : Fragment
private PendingIntent activityIntent; //A Pending intent if available to start the activity associated with this music fragent.
private BitmapDrawable CurrentAlbumArt;
private string openNotificationId; //Used if the button launch Notification is used.
private ConfigurationManager configurationManager = new ConfigurationManager(AppPreferences.Default);
private readonly ConfigurationManager configurationManager = new ConfigurationManager(AppPreferences.Default);

private bool timeoutStarted = false;
private bool initForFirstTime = true;
Expand Down Expand Up @@ -237,28 +237,12 @@ private void MusicPlayerContainer_Click(object sender, EventArgs e)

private void BtnSkipNext_LongClick(object sender, View.LongClickEventArgs e)
{
bool isNotKitkat = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch;
if (isNotKitkat)
{
Jukebox.FastFoward();
}
else
{
JukeboxKitkat.FastFoward();
}
Jukebox.FastFoward();
}

private void BtnSkipPrevious_LongClick(object sender, View.LongClickEventArgs e)
{
bool isNotKitkat = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch;
if (isNotKitkat)
{
Jukebox.Rewind();
}
else
{
JukeboxKitkat.Rewind();
}
Jukebox.Rewind();
}

private void MusicPlayerContainer_LongClick(object sender, View.LongClickEventArgs e)
Expand All @@ -275,24 +259,18 @@ private void MusicPlayerContainer_LongClick(object sender, View.LongClickEventAr

private void SkbSeekSongTime_StopTrackingTouch(object sender, SeekBar.StopTrackingTouchEventArgs e)
{
if (Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch)
//When user stop dragging then seek to the position previously saved in ProgressChangedEvent
Jukebox.SeekTo(e.SeekBar.Progress * 1000);

if (Build.VERSION.SdkInt > BuildVersionCodes.LollipopMr1)
{
//When user stop dragging then seek to the position previously saved in ProgressChangedEvent
Jukebox.SeekTo(e.SeekBar.Progress * 1000);
if (Build.VERSION.SdkInt > BuildVersionCodes.LollipopMr1)
{
skbSeekSongTime.SetProgress(e.SeekBar.Progress, true);
}
else
{
skbSeekSongTime.Progress = e.SeekBar.Progress;
}
skbSeekSongTime.SetProgress(e.SeekBar.Progress, true);
}
else
{
JukeboxKitkat.SeekTo(e.SeekBar.Progress);
skbSeekSongTime.Progress = e.SeekBar.Progress;
}

}

private void SkbSeekSongTime_ProgressChanged(object sender, SeekBar.ProgressChangedEventArgs e)
Expand All @@ -311,82 +289,35 @@ private void SkbSeekSongTime_ProgressChanged(object sender, SeekBar.ProgressChan

private void BtnSkipNext_Click(object sender, EventArgs e)
{
bool isNotKitkat = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch;
if (isNotKitkat)
{
Jukebox.SkipToNext();
}
else
{
JukeboxKitkat.SkipToNext();
}
Jukebox.SkipToNext();
}

private void BtnPlayPause_Click(object sender, EventArgs e)
{
bool isNotKitkat = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch;
switch (playbackState)
{
//If the media is paused, then Play.
case PlaybackStateCode.Paused:
if (isNotKitkat)
{
Jukebox.Play();
}
else
{
JukeboxKitkat.Play();
}
Jukebox.Play();
break;
//If the media is playing, then pause.
case PlaybackStateCode.Playing:
if (isNotKitkat)
{
Jukebox.Pause();
}
else
{
JukeboxKitkat.Pause();
}

Jukebox.Pause();
break;

case PlaybackStateCode.Stopped:
if (isNotKitkat)
{
Jukebox.Replay();
}
else
{
JukeboxKitkat.Replay();
}

Jukebox.Replay();
break;

default:
if (isNotKitkat)
{
Jukebox.Stop();
}
else
{
JukeboxKitkat.Stop();
}
Jukebox.Stop();
break;
}
}

private void BtnSkipPrevious_Click(object sender, EventArgs e)
{
bool isNotKitkat = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch;
if (isNotKitkat)
{
Jukebox.SkipToPrevious();
}
else
{
JukeboxKitkat.SkipToPrevious();
}
Jukebox.SkipToPrevious();
}

#endregion Fragment Views events
Expand Down Expand Up @@ -427,7 +358,7 @@ private void MusicControllerKitkat_MediaPlaybackChanged(object sender, MediaPlay
break;

case RemoteControlPlayState.Stopped:
btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_play_arrow_white_24dp, 0, 0);
btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_replay_white_24dp, 0, 0);
playbackState = PlaybackStateCode.Stopped;
MoveSeekbar(false);
break;
Expand Down Expand Up @@ -604,14 +535,7 @@ private void RetrieveMediaInformation()
//Syntactic sugar, cause a MediaMetadata and a Mediaplayback event to be fired in the Publisher class.
//(MusicController class)
//Or in Catcher class, if its Kitkat.
if (Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch)
{
Jukebox.RetrieveMediaInformation();
}
else
{
JukeboxKitkat.RetrieveMediaInformation();
}
Jukebox.RetrieveMediaInformation();
}

private void MoveSeekbar(bool move)
Expand Down
16 changes: 10 additions & 6 deletions LiveDisplay/Fragments/NotificationFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,23 @@ private void Notification_Drag(object sender, View.DragEventArgs e)

private void CatcherHelper_NotificationPosted(object sender, NotificationPostedEventArgs e)
{
ShowNotification(e.OpenNotification);
//if the incoming notification updates a previous notification, then verify if the current notification SHOWING is the same as the one
//we are trying to update, because if this check is not done, the updated notification will show even if the user is seeing another notification.
//the other case is simply when the notification is a new one.
if(e.UpdatesPreviousNotification && e.OpenNotification.GetCustomId()== _openNotification?.GetCustomId()
|| e.UpdatesPreviousNotification== false)
{
ShowNotification(e.OpenNotification);
}

if (e.ShouldCauseWakeUp && configurationManager.RetrieveAValue(ConfigurationParameters.TurnOnUserMovement))
if (e.ShouldCauseWakeUp && configurationManager.RetrieveAValue(ConfigurationParameters.TurnOnNewNotification))
AwakeHelper.TurnOnScreen();

if (configurationManager.RetrieveAValue(ConfigurationParameters.MusicWidgetMethod, "0") == "1") //1:"Use a notification to spawn the Music Widget"
{
if (e.OpenNotification.RepresentsMediaPlaying())
{
MusicController.StartPlayback(e.OpenNotification.GetMediaSessionToken(), _openNotification.GetCustomId());
MusicController.StartPlayback(e.OpenNotification.GetMediaSessionToken(), e.OpenNotification.GetCustomId());

maincontainer.Visibility = ViewStates.Invisible;
WidgetStatusPublisher.RequestShow(new WidgetStatusEventArgs { Show = false, WidgetName = "NotificationFragment" });
Expand Down Expand Up @@ -228,9 +235,6 @@ public void ShowNotification(OpenNotification openNotification)
+ _openNotification.GetGroupInfo()
, ToastLength.Short).Show();
}
//Determine if the notification to show updates the current view,(in case there's a notification currently owning this Widget)
bool updating = _openNotification.GetId() == openNotification.GetId();

switch (_openNotification.Style())
{
case BigPictureStyle:
Expand Down
Loading

0 comments on commit addbcf5

Please sign in to comment.