Skip to content

Commit

Permalink
Android: More bug fixes when resuming playback at app start. New spla…
Browse files Browse the repository at this point in the history
…sh screen layout; missing image but now displaying a nicer loading screen.
  • Loading branch information
ycastonguay committed Nov 4, 2013
1 parent f2e1603 commit e10681d
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 142 deletions.
26 changes: 1 addition & 25 deletions MPfm/MPfm.Android/Classes/Activities/LaunchActivity.cs
Expand Up @@ -30,7 +30,7 @@

namespace MPfm.Android
{
[Activity(Label = "Sessions Beta", ScreenOrientation = ScreenOrientation.Sensor, Theme = "@style/MyAppTheme", ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation | ConfigChanges.ScreenSize, WindowSoftInputMode = SoftInput.StateHidden, NoHistory = true, MainLauncher = true)]
[Activity(Label = "Sessions", ScreenOrientation = ScreenOrientation.Sensor, Theme = "@style/MyAppTheme", ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation | ConfigChanges.ScreenSize, WindowSoftInputMode = SoftInput.StateHidden, NoHistory = true, MainLauncher = true)]
public class LaunchActivity : Activity
{
private AndroidNavigationManager _navigationManager;
Expand All @@ -46,30 +46,6 @@ protected override void OnCreate(Bundle bundle)
_navigationManager.LaunchActivity = this;
_navigationManager.Start();
Finish();

//AppConfigManager.Instance.Load();
//Console.WriteLine("LaunchActivity - OnCreate - isFirstRun: {0} resumePlayback.currentAudioFileId: {1} resumePlayback.currentPlaylistId: {2}", AppConfigManager.Instance.Root.IsFirstRun, AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId, AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId);
//if (AppConfigManager.Instance.Root.IsFirstRun)
//{
// Tracing.Log("LaunchActivity - First run of the application; launching FirstRun activity...");
// var intent = new Intent(this, typeof(FirstRunActivity));
// StartActivity(intent);
// Finish();
//}
//else if (!string.IsNullOrEmpty(AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId))
//{
// Tracing.Log("LaunchActivity - Resume playback is available; launching Player activity... - audioFileId: {0} playlistId: {1}", AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId, AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId);
// var intent = new Intent(this, typeof(PlayerActivity));
// StartActivity(intent);
// Finish();
//}
//else
//{
// Tracing.Log("LaunchActivity - Resume playback is not available; launching Main activity...");
// var intent = new Intent(this, typeof(MainActivity));
// StartActivity(intent);
// Finish();
//}
}

protected override void OnStart()
Expand Down
39 changes: 9 additions & 30 deletions MPfm/MPfm.Android/Classes/Activities/SplashActivity.cs
Expand Up @@ -20,49 +20,29 @@
using Android.Content.PM;
using Android.Views;
using Android.OS;
using Android.Widget;
using MPfm.Android.Classes.Navigation;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;
using MPfm.MVP.Views;

namespace MPfm.Android
{
[Activity(Label = "Sessions Splash", ScreenOrientation = ScreenOrientation.Sensor, Theme = "@style/MyAppTheme", ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation | ConfigChanges.ScreenSize, WindowSoftInputMode = SoftInput.StateHidden, NoHistory = true)]
[Activity(Label = "Sessions", ScreenOrientation = ScreenOrientation.Sensor, Theme = "@style/MyAppTheme", ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation | ConfigChanges.ScreenSize, WindowSoftInputMode = SoftInput.StateHidden, NoHistory = true)]
public class SplashActivity : BaseActivity, ISplashView
{
private TextView _textView;

protected override void OnCreate(Bundle bundle)
{
Console.WriteLine("SplashActivity - OnCreate");
base.OnCreate(bundle);

SetContentView(Resource.Layout.Splash);
_textView = FindViewById<TextView>(Resource.Id.splash_text);

var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
navigationManager.BindSplashView(this);

//AppConfigManager.Instance.Load();
//Console.WriteLine("LaunchActivity - OnCreate - isFirstRun: {0} resumePlayback.currentAudioFileId: {1} resumePlayback.currentPlaylistId: {2}", AppConfigManager.Instance.Root.IsFirstRun, AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId, AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId);
//if (AppConfigManager.Instance.Root.IsFirstRun)
//{
// Tracing.Log("LaunchActivity - First run of the application; launching FirstRun activity...");
// var intent = new Intent(this, typeof(FirstRunActivity));
// StartActivity(intent);
// Finish();
//}
//else if (!string.IsNullOrEmpty(AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId))
//{
// Tracing.Log("LaunchActivity - Resume playback is available; launching Player activity... - audioFileId: {0} playlistId: {1}", AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId, AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId);
// var intent = new Intent(this, typeof(PlayerActivity));
// StartActivity(intent);
// Finish();
//}
//else
//{
// Tracing.Log("LaunchActivity - Resume playback is not available; launching Main activity...");
// var intent = new Intent(this, typeof(MainActivity));
// StartActivity(intent);
// Finish();
//}
}

protected override void OnStart()
Expand Down Expand Up @@ -105,11 +85,10 @@ protected override void OnDestroy()

public void RefreshStatus(string message)
{
//Console.WriteLine("SplashFragment - RefreshStatus");
//Activity.RunOnUiThread(() =>
//{
// //_textView.Text = message;
//});
RunOnUiThread(() =>
{
_textView.Text = message;
});
}

public void InitDone(bool isFirstAppStart)
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.Android/Classes/Application.cs
Expand Up @@ -156,7 +156,7 @@ private void BootstrapApp()
container.Register<IAppConfigProvider, AndroidAppConfigProvider>().AsSingleton();
container.Register<MobileNavigationManager, AndroidNavigationManager>().AsSingleton();
container.Register<IMobileOptionsMenuView, MainActivity>().AsMultiInstance();
container.Register<ISplashView, SplashFragment>().AsMultiInstance();
container.Register<ISplashView, SplashActivity>().AsMultiInstance();
container.Register<IMobileMainView, MainActivity>().AsMultiInstance();
container.Register<IPlayerView, PlayerActivity>().AsMultiInstance();
container.Register<IPlayerMetadataView, PlayerMetadataFragment>().AsMultiInstance();
Expand Down
74 changes: 0 additions & 74 deletions MPfm/MPfm.Android/Classes/Fragments/SplashFragment.cs

This file was deleted.

14 changes: 13 additions & 1 deletion MPfm/MPfm.Android/Classes/Providers/AndroidAppConfigProvider.cs
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Reflection;
using Android.Content;
using Android.Preferences;
Expand Down Expand Up @@ -73,9 +74,15 @@ private void LoadRecursive(IAppConfig config, string keyPreset)
propertyInfo.SetValue(config, sharedPreferences.GetFloat(fullName, 0));
}
else if (propertyType == typeof(string))
{
{
propertyInfo.SetValue(config, sharedPreferences.GetString(fullName, string.Empty));
}
else if (propertyType == typeof(DateTime))
{
long ticks = sharedPreferences.GetLong(fullName, 0);
DateTime dateTime = new DateTime(ticks);
propertyInfo.SetValue(config, dateTime);
}
else if (typeof(IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo()))
{
var subConfig = (IAppConfig)propertyInfo.GetValue(config);
Expand Down Expand Up @@ -115,6 +122,11 @@ private void SaveRecursive(IAppConfig config, string keyPreset)
string stringValue = value == null ? string.Empty : (string)value;
editor.PutString(fullName, stringValue);
}
else if (propertyType == typeof(DateTime))
{
DateTime dateTime = (DateTime) value;
editor.PutLong(fullName, dateTime.Ticks);
}
else if (typeof(IAppConfig).GetTypeInfo().IsAssignableFrom(propertyType.GetTypeInfo()))
{
var subConfig = (IAppConfig)propertyInfo.GetValue(config);
Expand Down
1 change: 0 additions & 1 deletion MPfm/MPfm.Android/MPfm.Android.csproj
Expand Up @@ -129,7 +129,6 @@
<Compile Include="Classes\Fragments\LoopsFragment.cs" />
<Compile Include="Classes\Fragments\TimeShiftingFragment.cs" />
<Compile Include="Classes\Fragments\PitchShiftingFragment.cs" />
<Compile Include="Classes\Fragments\SplashFragment.cs" />
<Compile Include="Classes\Fragments\LibraryPreferencesFragment.cs" />
<Compile Include="Classes\Fragments\GeneralPreferencesFragment.cs" />
<Compile Include="Classes\Fragments\UpdateLibraryFragment.cs" />
Expand Down
58 changes: 50 additions & 8 deletions MPfm/MPfm.Android/Resources/Layout/Splash.axml
@@ -1,18 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splash_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/background">
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/splash_progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
style="@android:style/Widget.ProgressBar.Small"
android:indeterminate="true" />
<TextView
android:id="@+id/splash_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:text="Loading..."
android:textSize="18dp"
android:textColor="#000000"
android:gravity="center_horizontal"
android:padding="12dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:text="Sessions is © 2011-2013 Yanick Castonguay"
android:textSize="14dp"
android:textColor="#000000"
android:gravity="center_horizontal"
android:padding="2dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:text="The BASS audio library is © 1999-2013 Un4seen Developments"
android:textSize="14dp"
android:textColor="#000000"
android:gravity="center_horizontal"
android:padding="2dp" />
<TextView
android:id="@+id/splash_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:text="Loading..."
android:textSize="16dp"
android:textColor="#ffffffff"
android:text="The BASS.NET audio library is © 2005-2013 Bernd Niedergesäß"
android:textSize="14dp"
android:textColor="#000000"
android:gravity="center_horizontal"
android:padding="12dp" />
android:padding="2dp" />
</LinearLayout>
2 changes: 1 addition & 1 deletion MPfm/MPfm.Android/Resources/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -157,12 +157,14 @@ private void ContinueAfterSplash()
var syncDeviceSpecs = Bootstrapper.GetContainer().Resolve<ISyncDeviceSpecifications>();

// Compare timestamps from cloud vs local
_splashView.RefreshStatus("Fetching device information from the cloud...");
var infos = cloudLibraryService.PullDeviceInfos().OrderByDescending(x => x.Timestamp).ToList();
CloudDeviceInfo cloudDeviceInfo = null;
AudioFile audioFileCloud = null;
AudioFile audioFileLocal = null;
string localDeviceName = syncDeviceSpecs.GetDeviceName();
DateTime localTimestamp = AppConfigManager.Instance.Root.ResumePlayback.Timestamp;
//DateTime localTimestamp = AppConfigManager.Instance.Root.ResumePlayback.Timestamp;
DateTime localTimestamp = DateTime.MinValue; // Temporary for testing purposes
foreach (var deviceInfo in infos)
{
// Make sure the timestamp is earlier than local, and that this isn't actually the same device!
Expand Down

0 comments on commit e10681d

Please sign in to comment.