Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Fixed grid view layout to fill the album art exactly 2 colum…
…ns to fit any device. It works now but as expected it creates a giant memory leak which will be fixed later. The wrong album art is also shown most of the time. Tried to setup an AlarmManager to update the widget more frequently but haven't found the right recipe yet. Related to issue #406.
- Loading branch information
1 parent
e0a4f51
commit e3a81c7
Showing
14 changed files
with
676 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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 System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Runtime; | ||
using Android.Util; | ||
using Android.Views; | ||
using Android.Widget; | ||
|
||
namespace org.sessionsapp.android | ||
{ | ||
public class SquareImageView : ImageView | ||
{ | ||
public SquareImageView(Context context) : base(context) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
public SquareImageView(Context context, IAttributeSet attrs) : base (context, attrs) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
public SquareImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
public SquareImageView(IntPtr javaReference, JniHandleOwnership transfer) | ||
: base(javaReference, transfer) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
private void Initialize() | ||
{ | ||
} | ||
|
||
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) | ||
{ | ||
base.OnMeasure(widthMeasureSpec, heightMeasureSpec); | ||
SetMeasuredDimension(MeasuredWidth, MeasuredWidth); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// 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.Appwidget; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Widget; | ||
using MPfm.Android.Classes.Services; | ||
|
||
namespace MPfm.Android.Classes.Widgets | ||
{ | ||
[BroadcastReceiver(Label = "Sessions")] | ||
[IntentFilter(new string[] { "android.appwidget.action.APPWIDGET_UPDATE" })] | ||
[MetaData("android.appwidget.provider", Resource = "@xml/widget_player")] | ||
public class PlayerWidgetProvider : AppWidgetProvider | ||
{ | ||
public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) | ||
{ | ||
Console.WriteLine("PlayerWidgetProvider - OnUpdate - appWidgetIds.length: {0}", appWidgetIds.Length); | ||
//context.StartService(new Intent(context, typeof(WidgetService))); | ||
//Intent intent = new Intent(context, typeof(WidgetService)); | ||
//PendingIntent pendingIntent = PendingIntent.GetService(context, 0, intent, 0); | ||
//AlarmManager alarmManager = (AlarmManager)context.GetSystemService(Context.AlarmService); | ||
//alarmManager.Cancel(pendingIntent); | ||
//alarmManager.SetRepeating(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime(), 1000, pendingIntent); | ||
|
||
for (int a = 0; a < appWidgetIds.Length; a++) | ||
{ | ||
int appWidgetId = appWidgetIds[a]; | ||
RemoteViews views = new RemoteViews(context.PackageName, Resource.Layout.WidgetPlayer); | ||
appWidgetManager.UpdateAppWidget(appWidgetId, views); | ||
} | ||
} | ||
|
||
public override void OnEnabled(Context context) | ||
{ | ||
Console.WriteLine("PlayerWidgetProvider - OnEnabled"); | ||
base.OnEnabled(context); | ||
} | ||
|
||
public override void OnDisabled(Context context) | ||
{ | ||
Console.WriteLine("PlayerWidgetProvider - OnDisabled"); | ||
base.OnDisabled(context); | ||
} | ||
|
||
public override void OnDeleted(Context context, int[] appWidgetIds) | ||
{ | ||
Console.WriteLine("PlayerWidgetProvider - OnDeleted"); | ||
base.OnDeleted(context, appWidgetIds); | ||
} | ||
|
||
//public override void OnReceive(Context context, Intent intent) | ||
//{ | ||
// Console.WriteLine("PlayerWidgetProvider - OnReceive"); | ||
// base.OnReceive(context, intent); | ||
// Console.WriteLine("PlayerWidgetProvider - OnReceive - intent.action: {0}", intent.Action); | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.