Skip to content

Commit

Permalink
Android: Fixed bugs when the cloud isn't available for resuming playb…
Browse files Browse the repository at this point in the history
…ack. Fixed layout for StartResumePlayback.
  • Loading branch information
ycastonguay committed Nov 10, 2013
1 parent 19107c0 commit ec027ba
Show file tree
Hide file tree
Showing 10 changed files with 717 additions and 555 deletions.
1 change: 1 addition & 0 deletions MPfm/MPfm.Android/Classes/Application.cs
Expand Up @@ -174,6 +174,7 @@ private void BootstrapApp()
container.Register<ISyncMenuView, SyncMenuActivity>().AsMultiInstance();
container.Register<ISyncWebBrowserView, SyncWebBrowserActivity>().AsMultiInstance();
container.Register<ISyncCloudView, SyncCloudActivity>().AsMultiInstance();
container.Register<ICloudConnectView, CloudConnectFragment>().AsMultiInstance();
container.Register<IEqualizerPresetsView, EqualizerPresetsActivity>().AsMultiInstance();
container.Register<IEqualizerPresetDetailsView, EqualizerPresetDetailsActivity>().AsMultiInstance();
container.Register<IPreferencesView, PreferencesActivity>().AsMultiInstance();
Expand Down
89 changes: 89 additions & 0 deletions MPfm/MPfm.Android/Classes/Fragments/CloudConnectFragment.cs
@@ -0,0 +1,89 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 Android.App;
using Android.Content;
using Android.OS;
using Android.Views;
using MPfm.Android.Classes.Fragments.Base;
using MPfm.MVP.Models;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments
{
public class CloudConnectFragment : BaseDialogFragment, ICloudConnectView, View.IOnClickListener
{
private View _view;

// Leave an empty constructor or the application will crash at runtime
public CloudConnectFragment() : base() { }

//public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
//{
// _view = inflater.Inflate(Resource.Layout.SyncManualConnect, container, false);
// return _view;
//}

public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(Activity, Resource.Style.DialogTheme));
LayoutInflater inflater = Activity.LayoutInflater;
builder.SetView(inflater.Inflate(Resource.Layout.CloudConnect, null));
builder.SetTitle("Connect to Dropbox");
builder.SetPositiveButton("Connect", PositiveButtonHandler);
builder.SetNegativeButton("Cancel", NegativeButtonHandler);
return builder.Create();
}

public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//SetStyle((int)DialogFragmentStyle.Normal, (int)Resource.Style.DialogTheme);
}

private void NegativeButtonHandler(object sender, DialogClickEventArgs dialogClickEventArgs)
{

}

private void PositiveButtonHandler(object sender, DialogClickEventArgs dialogClickEventArgs)
{

}

public void OnClick(View v)
{

}

#region ICloudConnectView implementation

public Action OnCheckIfAccountIsLinked { get; set; }

public void CloudConnectError(Exception ex)
{
}

public void RefreshStatus(CloudConnectEntity entity)
{
}

#endregion

}
}
17 changes: 16 additions & 1 deletion MPfm/MPfm.Android/Classes/Fragments/CloudPreferencesFragment.cs
Expand Up @@ -19,6 +19,7 @@
using Android.App;
using Android.Content;
using Android.OS;
using Android.Preferences;
using Android.Views;
using Android.Widget;
using MPfm.Android;
Expand Down Expand Up @@ -68,7 +69,21 @@ public override void OnPause()

public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
{
Tracing.Log("GeneralPreferencesFragment - OnSharedPreferenceChanged - key: {0}", key);
Tracing.Log("CloudPreferencesFragment - OnSharedPreferenceChanged - key: {0}", key);
}

public override bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
{
if (preference.Key == "dropbox_login")
{
OnDropboxLoginLogout();
}
else if (preference.Key == "dropbox_resume_playback_enabled")
{

}

return base.OnPreferenceTreeClick(preferenceScreen, preference);
}

#region ICloudPreferencesView implementation
Expand Down
Expand Up @@ -78,16 +78,16 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
Dismiss();
};

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

return _view;
}

public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetStyle((int)DialogFragmentStyle.Normal, (int)Resource.Style.DialogTheme);

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

#region IStartResumePlaybackView implementation
Expand Down
4 changes: 4 additions & 0 deletions MPfm/MPfm.Android/MPfm.Android.csproj
Expand Up @@ -123,6 +123,7 @@
<Compile Include="Classes\Fragments\AddMarkerFragment.cs" />
<Compile Include="Classes\Fragments\Base\BasePreferenceFragment.cs" />
<Compile Include="Classes\Fragments\CloudPreferencesFragment.cs" />
<Compile Include="Classes\Fragments\CloudConnectFragment.cs" />
<Compile Include="Classes\Fragments\StartResumePlaybackFragment.cs" />
<Compile Include="Classes\Fragments\SelectFoldersFragment.cs" />
<Compile Include="Classes\Fragments\SelectPlaylistFragment.cs" />
Expand Down Expand Up @@ -324,6 +325,9 @@
<AndroidResource Include="Resources\layout\StartResumePlayback.axml">
<SubType>Designer</SubType>
</AndroidResource>
<AndroidResource Include="Resources\layout\CloudConnect.axml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\Values\Strings.xml" />
Expand Down
25 changes: 25 additions & 0 deletions MPfm/MPfm.Android/Resources/Layout/CloudConnect.axml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="56dp"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="12dp"
android:text="Connecting to Dropbox..."
android:textColor="#AAAAAA"
android:textSize="14dp" />
<Button
android:id="@+id/cloudConnect_btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/selectimage"
android:drawablePadding="2dp"
android:background="@drawable/dialogbutton"
android:text="Resume from this device"
android:textColor="@color/dialogbutton_text"
android:textSize="14dp"
android:padding="6dp" />
</LinearLayout>
46 changes: 27 additions & 19 deletions MPfm/MPfm.Android/Resources/Layout/StartResumePlayback.axml
Expand Up @@ -23,8 +23,8 @@
android:gravity="center_vertical"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="8dp"
android:paddingBottom="2dp"
android:paddingTop="4dp"
android:paddingBottom="0dp"
android:text="Yanick Castonguay's iPad Air"
android:textColor="#FFFFFF"
android:textSize="20dp" />
Expand All @@ -35,8 +35,8 @@
android:gravity="center_vertical"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="2dp"
android:paddingBottom="4dp"
android:paddingTop="0dp"
android:paddingBottom="2dp"
android:text="On-the-fly Playlist"
android:textColor="#FFFFFF"
android:textSize="18dp" />
Expand Down Expand Up @@ -65,7 +65,10 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="4dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="I Love You But I've Chosen Darkness"
android:textColor="#FFFFFF"
android:textSize="16dp" />
Expand All @@ -74,7 +77,10 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="4dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="I Love You But I've Chosen Darkness"
android:textColor="#EEEEEE"
android:textSize="14dp" />
Expand All @@ -83,7 +89,10 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="4dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="I Love You But I've Chosen Darkness"
android:textColor="#DDDDDD"
android:textSize="13dp" />
Expand All @@ -105,30 +114,29 @@
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/startResumePlayback_btnCancel"
android:layout_width="0dp"
android:id="@+id/startResumePlayback_btnResume"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/actionbar_cancel"
android:drawableLeft="@drawable/selectimage"
android:drawablePadding="2dp"
android:background="@drawable/dialogbutton"
android:text="No, thanks"
android:text="Resume from this device"
android:textColor="@color/dialogbutton_text"
android:textSize="14dp"
android:padding="6dp" />
<Button
android:id="@+id/startResumePlayback_btnResume"
android:layout_width="0dp"
android:id="@+id/startResumePlayback_btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/selectimage"
android:drawableLeft="@drawable/actionbar_cancel"
android:drawablePadding="2dp"
android:background="@drawable/dialogbutton"
android:text="Resume from this device"
android:text="No, thanks"
android:textColor="@color/dialogbutton_text"
android:textSize="14dp"
android:padding="6dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

0 comments on commit ec027ba

Please sign in to comment.