Permalink
Browse files

Change support-lib plugin to allow using binary from Google. Closes #285

.

Since its true inception (i.e., version 3), ActionBarSherlock has had one major criticism that created a reluctance for a lot of people to leverage it in their apps: its internalization and modification of the Google support library (compatibility package). This was deemed necessary since there is no reliable external way to dispatch anything to attached and visible fragments.

With this commit we introduce a new set of base classes which exist independent of the support library (and extend from it) in order to progressively add the action bar functionality.

 * `SherlockFragmentActivity` replaces `FragmentActivity` and has the job of marshalling our ABS menu classes into native wrappers which can be dispatched along the normal menu callbacks and thus into the appropriate fragments.
 * `SherlockFragment` (and `SherlockListFragment and `SherlockDialogFragment`) replace `Fragment` and unwrap the menu instances dispatched through the fragment manager so that we can use the ABS menu classes in new callbacks. The regular menu callbacks are finalized just like their activity counterparts so that only the correct ones can be overriden.
  • Loading branch information...
1 parent 5f395a3 commit e23de78b664be32bcc8888afe338e994bdac6403 @JakeWharton committed Feb 20, 2012
Showing with 6,745 additions and 4,422 deletions.
  1. +1 −1 checkstyle.xml
  2. +13 −0 plugins/support-lib/AndroidManifest.xml
  3. BIN plugins/support-lib/libs/android-support-v4.jar
  4. +1 −41 plugins/support-lib/pom.xml
  5. +13 −0 plugins/support-lib/project.properties
  6. +233 −0 plugins/support-lib/src/com/actionbarsherlock/app/MenuItemMule.java
  7. +149 −0 plugins/support-lib/src/com/actionbarsherlock/app/MenuMule.java
  8. +66 −0 plugins/support-lib/src/com/actionbarsherlock/app/SherlockDialogFragment.java
  9. +66 −0 plugins/support-lib/src/com/actionbarsherlock/app/SherlockFragment.java
  10. +329 −0 plugins/support-lib/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
  11. +66 −0 plugins/support-lib/src/com/actionbarsherlock/app/SherlockListFragment.java
  12. +0 −1,371 plugins/support-lib/src/main/java/android/support/v4/app/Fragment.java
  13. +0 −1,013 plugins/support-lib/src/main/java/android/support/v4/app/FragmentActivity.java
  14. +0 −1,996 plugins/support-lib/src/main/java/android/support/v4/app/FragmentManager.java
  15. +1 −0 samples/demos/AndroidManifest.xml
  16. +203 −0 samples/fragments/AndroidManifest.xml
  17. +13 −0 samples/fragments/README.md
  18. BIN samples/fragments/libs/android-support-v4.jar
  19. +125 −0 samples/fragments/pom.xml
  20. +13 −0 samples/fragments/project.properties
  21. +21 −0 samples/fragments/res/anim/decelerate_quint.xml
  22. +23 −0 samples/fragments/res/anim/fragment_slide_left_enter.xml
  23. +23 −0 samples/fragments/res/anim/fragment_slide_left_exit.xml
  24. +23 −0 samples/fragments/res/anim/fragment_slide_right_enter.xml
  25. +23 −0 samples/fragments/res/anim/fragment_slide_right_exit.xml
  26. BIN samples/fragments/res/drawable-hdpi/alert_dialog_icon.png
  27. BIN samples/fragments/res/drawable-hdpi/ic_compose.png
  28. BIN samples/fragments/res/drawable-hdpi/ic_compose_inverse.png
  29. BIN samples/fragments/res/drawable-hdpi/ic_refresh.png
  30. BIN samples/fragments/res/drawable-hdpi/ic_refresh_inverse.png
  31. BIN samples/fragments/res/drawable-hdpi/ic_search.png
  32. BIN samples/fragments/res/drawable-hdpi/ic_search_inverse.png
  33. BIN samples/fragments/res/drawable-hdpi/icon.png
  34. BIN samples/fragments/res/drawable-ldpi/icon.png
  35. BIN samples/fragments/res/drawable-mdpi/alert_dialog_icon.png
  36. BIN samples/fragments/res/drawable-mdpi/ic_compose.png
  37. BIN samples/fragments/res/drawable-mdpi/ic_compose_inverse.png
  38. BIN samples/fragments/res/drawable-mdpi/ic_refresh.png
  39. BIN samples/fragments/res/drawable-mdpi/ic_refresh_inverse.png
  40. BIN samples/fragments/res/drawable-mdpi/ic_search.png
  41. BIN samples/fragments/res/drawable-mdpi/ic_search_inverse.png
  42. BIN samples/fragments/res/drawable-mdpi/icon.png
  43. BIN samples/fragments/res/drawable-xhdpi/icon.png
  44. +57 −0 samples/fragments/res/layout-land/fragment_arguments_support.xml
  45. +33 −0 samples/fragments/res/layout-land/fragment_layout_support.xml
  46. +54 −0 samples/fragments/res/layout/fragment_arguments_support.xml
  47. +38 −0 samples/fragments/res/layout/fragment_context_menu.xml
  48. +40 −0 samples/fragments/res/layout/fragment_dialog.xml
  49. +64 −0 samples/fragments/res/layout/fragment_dialog_or_activity.xml
  50. +57 −0 samples/fragments/res/layout/fragment_hide_show_support.xml
  51. +27 −0 samples/fragments/res/layout/fragment_layout_support.xml
  52. +46 −0 samples/fragments/res/layout/fragment_menu.xml
  53. +46 −0 samples/fragments/res/layout/fragment_pager.xml
  54. +54 −0 samples/fragments/res/layout/fragment_pager_list.xml
  55. +46 −0 samples/fragments/res/layout/fragment_retain_instance.xml
  56. +38 −0 samples/fragments/res/layout/fragment_stack.xml
  57. +54 −0 samples/fragments/res/layout/fragment_tabs.xml
  58. +52 −0 samples/fragments/res/layout/fragment_tabs_pager.xml
  59. +26 −0 samples/fragments/res/layout/hello_world.xml
  60. +38 −0 samples/fragments/res/layout/labeled_text_edit.xml
  61. +32 −0 samples/fragments/res/layout/list_item_icon_text.xml
  62. +50 −0 samples/fragments/res/layout/receive_result.xml
  63. +45 −0 samples/fragments/res/layout/send_result.xml
  64. +29 −0 samples/fragments/res/layout/simple_list_item_checkable_1.xml
  65. +60 −0 samples/fragments/res/menu/shortcuts.xml
  66. +25 −0 samples/fragments/res/values-v11/styles.xml
  67. +25 −0 samples/fragments/res/values/attrs.xml
  68. +22 −0 samples/fragments/res/values/colors.xml
  69. +93 −0 samples/fragments/res/values/strings.xml
  70. +32 −0 samples/fragments/res/values/styles.xml
  71. +49 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/CheckableFrameLayout.java
  72. +154 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/Cheeses.java
  73. +109 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java
  74. +112 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentArgumentsSupport.java
  75. +77 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentContextMenuSupport.java
  76. +127 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentCustomAnimationSupport.java
  77. +81 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentDialogOrActivitySupport.java
  78. +167 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentDialogSupport.java
  79. +113 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentHideShowSupport.java
  80. +221 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentLayoutSupport.java
  81. +59 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentListArraySupport.java
  82. +132 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentMenuSupport.java
  83. +139 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentPagerSupport.java
  84. +133 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentReceiveResultSupport.java
  85. +231 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentRetainInstanceSupport.java
  86. +124 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentStackSupport.java
  87. +139 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentStatePagerSupport.java
  88. +170 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentTabs.java
  89. +179 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentTabsPager.java
  90. +171 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/LoaderCursorSupport.java
  91. +484 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/LoaderCustomSupport.java
  92. +510 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/LoaderThrottleSupport.java
  93. +175 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/SampleList.java
  94. +77 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/SendResult.java
  95. +223 −0 samples/fragments/src/com/actionbarsherlock/sample/fragments/Shakespeare.java
  96. +1 −0 samples/pom.xml
View
@@ -33,7 +33,7 @@
<module name="MemberName"/>
<!--module name="MethodName"/-->
<module name="PackageName"/>
- <module name="ParameterName"/>
+ <!--module name="ParameterName"/-->
<!--module name="StaticVariableName"/-->
<!--module name="TypeName"/-->
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.actionbarsherlock.plugin.support"
+ android:versionCode="45"
+ android:versionName="4.0.0-SNAPSHOT">
+
+ <uses-sdk
+ android:minSdkVersion="7"
+ android:targetSdkVersion="15" />
+
+</manifest>
Binary file not shown.
@@ -25,8 +25,6 @@
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
- <scope>provided</scope>
- <!-- We mark this as provided since we include its sources -->
</dependency>
<dependency>
@@ -39,23 +37,10 @@
<build>
<finalName>${apk.prefix}-${project.artifactId}-${project.version}</finalName>
+ <sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>android-maven-plugin</artifactId>
- <extensions>true</extensions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
-
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
@@ -70,31 +55,6 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>com.google.android</groupId>
- <artifactId>support-v4</artifactId>
- <version>${android-support.version}</version>
- <type>jar</type>
- </artifactItem>
- </artifactItems>
- <excludes>**/FragmentActivity*,**/FragmentManager*,**/Fragment.*,**/Fragment$*</excludes>
- <outputDirectory>${project.build.directory}/classes</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,13 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library=true
+# Project target.
+target=android-14
+android.library.reference.1=../../library
@@ -0,0 +1,233 @@
+package com.actionbarsherlock.app;
+
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.view.ActionProvider;
+import android.view.MenuItem;
+import android.view.SubMenu;
+import android.view.View;
+import android.view.ContextMenu.ContextMenuInfo;
+
+class MenuItemMule implements MenuItem {
+ private static final String ERROR = "Cannot interact with object designed for temporary "
+ + "instance passing. Make sure you using both SherlockFragmentActivity and "
+ + "SherlockFragment.";
+
+
+ private final com.actionbarsherlock.view.MenuItem mItem;
+
+ public MenuItemMule(com.actionbarsherlock.view.MenuItem item) {
+ mItem = item;
+ }
+
+ public com.actionbarsherlock.view.MenuItem unwrap() {
+ return mItem;
+ }
+
+
+ @Override
+ public boolean collapseActionView() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean expandActionView() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public ActionProvider getActionProvider() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public View getActionView() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public char getAlphabeticShortcut() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public int getGroupId() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public Drawable getIcon() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public Intent getIntent() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public int getItemId() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public ContextMenuInfo getMenuInfo() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public char getNumericShortcut() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public int getOrder() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public SubMenu getSubMenu() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public CharSequence getTitleCondensed() {
+ return mItem.getTitleCondensed();
+ //throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean hasSubMenu() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean isActionViewExpanded() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean isCheckable() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean isChecked() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public boolean isVisible() {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setActionProvider(ActionProvider arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setActionView(View arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setActionView(int arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setAlphabeticShortcut(char arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setCheckable(boolean arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setChecked(boolean arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setEnabled(boolean arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setIcon(Drawable arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setIcon(int arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setIntent(Intent arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setNumericShortcut(char arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setOnActionExpandListener(OnActionExpandListener arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setShortcut(char arg0, char arg1) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public void setShowAsAction(int arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setShowAsActionFlags(int arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setTitle(CharSequence arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setTitle(int arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setTitleCondensed(CharSequence arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+
+ @Override
+ public MenuItem setVisible(boolean arg0) {
+ throw new IllegalStateException(ERROR);
+ }
+}
Oops, something went wrong.

2 comments on commit e23de78

@iNoles
iNoles commented on e23de78 Feb 20, 2012

since I can't use getActivity().getSupportActionBar() under Sherlock*Fragment, would you add like

java public ActionBar getSupportActionBar() { return mActivity.getSupportActionBar(); }

@JakeWharton
Owner

I added getSherlockActivity() to all the fragment classes. It'll be pushed shortly.

Please sign in to comment.