Skip to content

Commit

Permalink
Code clean up, uniforming licensing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheesebaron committed Jul 6, 2012
1 parent 995ab9f commit 8b522b3
Show file tree
Hide file tree
Showing 15 changed files with 1,883 additions and 1,935 deletions.
Binary file modified MonoDroid.ActionBar.suo
Binary file not shown.
812 changes: 401 additions & 411 deletions MonoDroid.ActionBar/ActionBar/ActionBar.cs

Large diffs are not rendered by default.

95 changes: 46 additions & 49 deletions MonoDroid.ActionBar/ActionBar/ActionBarAction.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,47 @@
/*
* Copyright (C) 2010 Johan Nilsson <http://markupartist.com>
*
* Original (https://github.com/johannilsson/android-actionbar) Ported to Mono for Android
* Copyright (C) 2012 Tomasz Cielecki <tomasz@ostebaronen.dk>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *Modified by James Montemagno Copyright 2012 http://www.montemagno.com
*/

using Android.Content;
using Android.Views;
using Android.Widget;

namespace MonoDroid.ActionBarSample
{
/**
* Definition of an action that could be performed, along with a icon to
* show.
*/
public abstract class ActionBarAction : Java.Lang.Object, IActionBarAction
{
protected int mDrawable;
protected Context mContext;
protected Intent mIntent;


public abstract int GetDrawable();

public abstract void PerformAction(View view);

public int CurrentPosition { get; set; }
public int PopUpMessage { get; set; }



public ActionType ActionType { get; set; }
}
/*
* Copyright (C) 2010 Johan Nilsson <http://markupartist.com>
*
* Original (https://github.com/johannilsson/android-actionbar) Ported to Mono for Android
* Copyright (C) 2012 Tomasz Cielecki <tomasz@ostebaronen.dk>
*
* Modified by James Montemagno Copyright 2012 http://www.montemagno.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using Android.Content;
using Android.Views;

namespace MonoDroid.ActionBarSample
{
/**
* Definition of an action that could be performed, along with a icon to
* show.
*/
public abstract class ActionBarAction : Java.Lang.Object, IActionBarAction
{
protected int mDrawable;
protected Context mContext;
protected Intent mIntent;

public abstract int GetDrawable();

public abstract void PerformAction(View view);

public int CurrentPosition { get; set; }
public int PopUpMessage { get; set; }

public ActionType ActionType { get; set; }
}
}
140 changes: 68 additions & 72 deletions MonoDroid.ActionBar/ActionBar/ActionBarUtils.cs
Original file line number Diff line number Diff line change
@@ -1,73 +1,69 @@
/*
* Copyright (C) 2012 James Montemagno <http://www.montemagno.com>
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Android.App;

namespace MonoDroid.ActionBarSample
{
public class ActionBarUtils
{
/// <summary>
/// determins if the action should be added and fits
/// based on stats from http://developer.android.com/design/patterns/actionbar.html
/// </summary>
/// <param name="activity">Current Activity, needed for orientation and density</param>
/// <param name="currentNumber">current position of the action</param>
/// <param name="hasMenuButton"></param>
/// <param name="actionType"></param>
/// <returns>If it will fit :)</returns>
public static bool ActionFits(Activity activity, int currentNumber, bool hasMenuButton, ActionType actionType)
{
if (actionType == ActionType.Always)
return true;

if (actionType == ActionType.Never)
return false;

if (activity == null)
return true;

var density = activity.Resources.DisplayMetrics.Density;
if (density == 0)
return true;
density = (int)(activity.Resources.DisplayMetrics.WidthPixels / density);//calculator DP of width.


int max = 5;
if(density < 360)
{
max = 2;
}
else if(density < 500)
{
max = 3;
}
else if(density < 598)//should be 600, but Galaxy nexus returns 598
{
max = 4;
}

if (hasMenuButton)
max--;

if (currentNumber < max)
return true;

return false;
}
}
/*
* Copyright (C) 2012 James Montemagno <http://www.montemagno.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Android.App;

namespace MonoDroid.ActionBarSample
{
public class ActionBarUtils
{
/// <summary>
/// determins if the action should be added and fits
/// based on stats from http://developer.android.com/design/patterns/actionbar.html
/// </summary>
/// <param name="activity">Current Activity, needed for orientation and density</param>
/// <param name="currentNumber">current position of the action</param>
/// <param name="hasMenuButton"></param>
/// <param name="actionType"></param>
/// <returns>If it will fit :)</returns>
public static bool ActionFits(Activity activity, int currentNumber, bool hasMenuButton, ActionType actionType)
{
if (actionType == ActionType.Always)
return true;

if (actionType == ActionType.Never)
return false;

if (activity == null)
return true;

var density = activity.Resources.DisplayMetrics.Density;
if (density == 0)
return true;
density = (int)(activity.Resources.DisplayMetrics.WidthPixels / density);//calculator DP of width.


var max = 5;
if(density < 360)
{
max = 2;
}
else if(density < 500)
{
max = 3;
}
else if(density < 598)//should be 600, but Galaxy nexus returns 598
{
max = 4;
}

if (hasMenuButton)
max--;

return currentNumber < max;
}
}
}
Loading

0 comments on commit 8b522b3

Please sign in to comment.