Skip to content

Commit

Permalink
Change support-lib plugin to allow using binary from Google. Closes J…
Browse files Browse the repository at this point in the history
…akeWharton#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
JakeWharton committed Feb 20, 2012
1 parent 5f395a3 commit e23de78
Show file tree
Hide file tree
Showing 96 changed files with 6,745 additions and 4,422 deletions.
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/-->

Expand Down
13 changes: 13 additions & 0 deletions plugins/support-lib/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -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 added plugins/support-lib/libs/android-support-v4.jar
Binary file not shown.
42 changes: 1 addition & 41 deletions plugins/support-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -39,22 +37,9 @@

<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>
Expand All @@ -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>
13 changes: 13 additions & 0 deletions plugins/support-lib/project.properties
Original file line number Diff line number Diff line change
@@ -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
233 changes: 233 additions & 0 deletions plugins/support-lib/src/com/actionbarsherlock/app/MenuItemMule.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading

0 comments on commit e23de78

Please sign in to comment.