Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to change the FloatingActionsMenu 's plus icon to other ones? #56

Open
OrNot opened this issue Dec 13, 2014 · 21 comments
Open

Comments

@OrNot
Copy link

OrNot commented Dec 13, 2014

Thanks a lot

@chalup
Copy link
Contributor

chalup commented Dec 13, 2014

Already answered in #41:

The problem with this request is that the icon is currently strictly connected with the animation: plus rotates 135 degrees and turns into "X", which closes the menu. So customizing icon would not be enough: you'd also have to customize the animation. I'll consider this for further releases, but it's not an area of focus right now.

Right now == forseeable future, unless someone comes up with a great, generic solution and implements it.

@str4d
Copy link
Contributor

str4d commented Dec 13, 2014

Here's an idea: If the FAM icon is set to anything (ie. not the default plus), then as the action menu expands out, that icon rotates about an axis in the plane of the screen (instead of perpendicular, like the current animation), revealing an "X". The reverse animation happens on collapse.

This is hard to convey in words, but imagine you are looking down at a roller which is moving a piece of paper. As the paper slides out, the roller turns, revealing a different side.

The direction that the icon rolls would depend on:

  • The orientation of the FAM (the icon would roll in opposite direction for down vs. up, and would roll horizontally for a horizontal FAM).
  • Whether the FABs in the FAM should be considered to be "under" or "over" the FAM's button. Returning to the roller analogy, this corresponds to whether the roller is beneath or above the paper; the different rollers turn in opposite directions to make the paper move in the same direction.

If this sounds like a great, generic solution then I can have a stab at implementing it :)

@chalup
Copy link
Contributor

chalup commented Dec 21, 2014

It is generic indeed, but I wouldn't call it great.

I'm leaning towards the Inbox approach, i.e. changing icon and replacing close action with custom action.

@DineshAnandan
Copy link

👍 for the option to replace + icon. Really most wanted feature too

@chap126
Copy link

chap126 commented Jan 1, 2015

The ability to achieve what Inbox does with the FAM would be excellent.

@ch3m1c
Copy link

ch3m1c commented Jan 4, 2015

Please add it, because + isn't just enough to describe what that FOA is going to do.. Inbox solution is great! ;)

Maybe you can start with just static icon (no animation at all, when user defined an icon)

@k0shk0sh
Copy link

well i have made some changes in code to be able to change icon inside of the floatingMenu. instead of adding AddFloatingButton i add FloatingButton plus i have made changes and added new attr to make the drawable works. i'll be requesting pull request.

@tamiof
Copy link

tamiof commented Jan 16, 2015

Joining the request
btw I noticed the animation doesn't work after using proguard with a signed apk. any solutions for this problem?

@chalup
Copy link
Contributor

chalup commented Jan 17, 2015

@tamiof The proguard issue was fixed in 1.2.0. I just checked the output of gradle proguardRelease task in sample project and everything looks fine. Maybe you have some other conflicting proguard rules? Can you share your config?

@tamiof
Copy link

tamiof commented Jan 19, 2015

This is my proguard config. It's an old project that was handed to me so things might be out of date or conflicted
Do you see any conflicts here I missed?

-optimizationpasses 5

#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames

#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses

#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose

#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/,!class/merging/

#To repackage classes on a single package
#-repackageclasses ''

#Uncomment if using annotations to keep them.
#-keepattributes Annotation

-printmapping proguard.map
-renamesourcefileattribute ProGuard
-keepattributes SourceFile,LineNumberTable

m libraries

#-libraryjars /libs/android-query-full.0.26.7.jar
-dontwarn com.androidquery.auth.**
-dontwarn com.jfeinstein.jazzyviewpager.**

-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
(android.app.Activity, int);
}

#Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService

#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}

#To avoid changing names of methods invoked on layout's onClick.
#Uncomment and add specific method names if using onClick on layouts
#-keepclassmembers class * {
#public void onClickButton(android.view.View);
#}

#Maintain java native methods
-keepclasseswithmembernames class * {
native ;
}

#To maintain custom components names that are used on layouts XML.
#Uncomment if having any problem with the approach below
#-keep public class custom.components.package.and.name.**

#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
public (android.content.Context);
public (android.content.Context, android.util.AttributeSet);
public (android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}

-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet, int);
}

#Maintain enums
-keepclassmembers enum * {
public static *[] values();
public static *
valueOf(java.lang.String);
}

#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

#Keep the R
-keepclassmembers class *.R$ {
public static ;
}

ADDITIONAL OPTIONS NOT USED NORMALLY

#To keep callback calls. Uncomment if using any
#http://proguard.sourceforge.net/index.html#/manual/examples.html#callback
#-keep class mypackage.MyCallbackClass {
#void myCallbackMethod(java.lang.String);
#}

#Uncomment if using Serializable
-keepclassmembers class * implements java.io.Serializable {
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
;
;
}

##---------------Begin: proguard configuration for Gson ----------
#Gson uses generic type information stored in a class file when working with fields. Proguard
#removes such information by default, so configure it to keep all of it.
-keepattributes Signature

#For using GSON @expose annotation
-keepattributes Annotation

#Gson specific classes
-keep class sun.misc.Unsafe { ; }
#-keep class com.google.gson.stream.
* { *; }

#Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

##---------------End: proguard configuration for Gson ----------

@chalup
Copy link
Contributor

chalup commented Jan 19, 2015

@tamiof Please create a gist with this config, it got completely mangled by github markdown. And one more obvious question, just to confirm - are you using gradle to build your projects?

@tamiof
Copy link

tamiof commented Jan 20, 2015

@chalup this particular project does not use gradle build. Any chance switching to gradle might fix this issue? I've been postponing it for a while so this might be a good time to switch to gradle
https://gist.github.com/tamiof/8aa534ece3b64cb8bbb8

@chalup
Copy link
Contributor

chalup commented Jan 20, 2015

@tamiof no need to switch to gradle, you just have to add this proguard rules: https://github.com/futuresimple/android-floating-action-button/blob/master/library/consumer-proguard-rules.pro

Were you using gradle, the build system would apply these rules to your build automatically.

@rubdottocom
Copy link

Is it possible to change AddFloatingActionButton background color for the FloatingActionsMenu programatically?
I can change color of child buttons but seems that the parent button color must be set only on XML

@chalup
Copy link
Contributor

chalup commented Feb 4, 2015

@rubdottocom this issue is tracked in #49

@rubdottocom
Copy link

Ooops! Sorry, thank you :-)

@tamiof
Copy link

tamiof commented Feb 4, 2015

@chalup guess I somehow missed on those particular rules. 10x!

@Poeschl
Copy link

Poeschl commented Feb 23, 2015

Any new progress for this issue? If approved, I would like to solve it like here: http://eichefam.net/2014/10/27/inbox-fab/

@nasko700
Copy link

Here is how I fixed the problem with adding icon on the menu button:
I created a FloatingActionButton on the menu button(this way it's hidden) and every color transparent in menu button. Then I'm listening if the added button is pressed:
myButton.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
if(floatMenu.isExpanded()){
floatMenu.collapse();
} else{
floatMenu.expand();
}
}
});

Hope it helps.

@jemshit
Copy link

jemshit commented May 19, 2015

@nasko700 lol, good trick 💃

@deshmukhrohit11
Copy link

@nasko700 : Thank you. You rock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests