forked from jamesmontemagno/MonoDroid.ActionBar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code clean up, uniforming licensing.
- Loading branch information
1 parent
995ab9f
commit 8b522b3
Showing
15 changed files
with
1,883 additions
and
1,935 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -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; } | ||
} | ||
} |
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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Oops, something went wrong.