Giter VIP home page Giter VIP logo

actionbarextras's Introduction

Hi there 👋

I'm a curious computer scientist always trying to learn new stuff.

Feel free to browse around. Excuse the mess..I'm still learning! 🙂

Alco's GitHub stats

Most Used Languages

actionbarextras's People

Contributors

dbankier avatar drauggres avatar hansemannn avatar janisr avatar kbshl avatar m1ga avatar manumaticx avatar mpociot avatar ricardoalcocer avatar skypanther avatar williamrijksen avatar yomybaby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actionbarextras's Issues

Getting the current activity

Hey, this is really a nice module!
I really appreciate accessing the actionbar without having to get the window and then wait for the activity to be ready to finally activity.onCreateOptionsMenu ...

Here is the workaround I use:

$.currentWindow = require('windowController').getCurrentWin();
activity = $.currentWindow.getActivity();
// Window is not ready yet...
if (activity.actionBar and activity.invalidateOptionsMenu) {
return _.delay( function() {
$.currentWindow = require('windowController').getCurrentWin();
activity = $.currentWindow.getActivity();
}, 100 );

What would be even nicer for this module is to be able to get the activity so I could just simplify the previous code to abx.getActivity().onCreateOptionsMenu...

Thanks a bunch
Pierre

no method 'setHomeAsUpIcon'

Hi, I just discovered this module and trying to add it to my project. However I got the following error. Even in the example App. Any fix?

[ERROR] :  TiExceptionHandler: (main) [0,103866] - Message: Uncaught TypeError: Object #<Actionbarextras> has no method 'setHomeAsUpIcon'
[ERROR] :  TiExceptionHandler: (main) [0,103866] - Source:                 abx.setHomeAsUpIcon("/images/menu.png");
[ERROR] :  V8Exception: Exception occurred at app.js:58: Uncaught TypeError: Object #<Actionbarextras> has no method 'setHomeAsUpIcon'

By the way, I would like to use the same module to add a star icon for bookmarking, and hopefully could toggle the star icon color. Is it possible?

Thanks.

Can't setHomeAsUpIcon in 1.3.6 using Alloy MVC

Hello,

I'm using Alloy MVC, and inside of one of my controllers, I'm using the following:

$.win.addEventListener("open", function() {

    if (Ti.Platform.osname === "android") {
        if (!$.win.activity) {
            Ti.API.error("Can't access action bar on a lightweight window.");
        } else {
            var abx = require('com.alcoapps.actionbarextras');
            abx.window = $.win;

            actionBar = $.win.activity.actionBar;
            if (actionBar) {
                abx.setTitle("Example");
        abx.setHomeAsUpIcon('/images/icon_menu.png');
            }

        }
    }
});

I do have an image in /PROJECT_NAME/app/assets/images/icon_menu.png, and my controller is located in /PROJECT_NAME/app/controllers/example.js.

Just to note that all the others images for example in Titanium ImageViews load fine, using the same schema.

When starting my application, the title do change to "Example", however the homeAsUpIcon does not change and an error is shown in console:

[ERROR] ActionbarextrasModule: (main) [273,11626] Couldn't resolve appdata-private://PROJECT_NAME/android/images//icon_menu.png

I've already tried to play with slashes and some folder derivations in icon location, but I am not being able to get it work. Is it possible this is a bug in the module?

Thanks

Use actionbarextras to set regular menu items

i was just wandering if it is possible to use actionbarextras to set regular menu items.
I wanted to use FontAwesome to set icon actions by changing the font.
thanks for your incredible work, this module is very usefull :)

Split ActionBar background color?

It seems like background color is not setting the background of the Split ActionBar that will be available starting in SDK 3.5. Not sure if this can be changed by code. @manumaticx , ideas?

Hiding logo after added it

Hey,

not really an "issue" but maybe anyone around knows the solution.

After adding a logo to the actionbar (setLogo) i'm not able to remove this Logo.

My case:
On some screens there is a logo on other screens (same actionbar) there shouldn't.

Any idea? I've tried several things and properties but none of them are solving it.

thanks,
nico

show icon does not work

Once you have hidden the icon with abx.disableIcon = true; it is not possible to show it again.
I think we need to set the appicon as the actionBar.icon, but I'm not sure how to read that from tiapp.xml - but I'll have a look soon.

Appendix to Documentation

If you use the https://github.com/FokkeZB/IconFont to build yours js font file and want to use this module:

Follow the steps

At alloy.js

Alloy.Globals.icons = require('font-awesome');

At your *.js

$.tabs.addEventListener('open', function(e) {
    if (OS_ANDROID) {
        abx.title = 'My App';
        abx.titleColor = "white";
        var activity = $.tabs.getActivity();
        if (activity) {
            activity.onCreateOptionsMenu = function(e) {
                e.menu.clear();

                var createItem = e.menu.add({
                    itemId: 101, //unique random number
                    showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS,
                });

                abx.setMenuItemIcon({
                    menu:e.menu,
                    menuItem:createItem,
                    fontFamily:'FontAwesome',
                    icon:Alloy.Globals.icons.check, 
                    color:'white',
                    size:30
                })
            };
            activity.invalidateOptionsMenu();
        }
    }
}

Who's using it?

If anyone is using this library in production I'd like to add a section in the README with a link to the app in Google Play. @manumaticx, have you any app in the wild?

Resetting Title/Subtitle by setting it null.

I would like to be able to reset the title/subtitle and set it to null.

Now when I use abx.setSubtitle(null), nothing happens. I want to be able to 'hide' the subtitle for instance.

As shown in this thread, setting it to null, hides the view:
http://stackoverflow.com/questions/22709160/remove-actionbar-subtitle-reset-actionbar-text

Currently in setSubtitle for example, if the given obj is not an object or a string, it returns and does nothing. Could you add a check for a null value to reset it?

Thanks alot.

font ignored when set with object

When you set the title (or subtitle) like this, it doesn't apply the font, only the title.

abx.setTitle({
  text: "Test",
  font: "Aller.ttf"
});

NULL pointers with Allloy 1.5.1 and Ti SDK 3.5.1

It seems that module has some problems on latest Alloy and Ti SDK. According to documentation this should work:

_abx = require('com.alcoapps.actionbarextras');
_abx.setBackgroundColor("#ffffff");
_abx.title = "wewfwefwe";
_abx.hideLogo();

But in console, while window opens i can see those errors:

[WARN] :   W/System.err: java.lang.NullPointerException
[WARN] :   W/System.err:    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetBackgroundColor(ActionbarextrasModule.java:261)
[WARN] :   W/System.err:    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:126)
[WARN] :   W/System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
[WARN] :   W/System.err:    at android.os.Looper.loop(Looper.java:136)
[WARN] :   W/System.err:    at android.app.ActivityThread.main(ActivityThread.java:5196)
[WARN] :   W/System.err:    at java.lang.reflect.Method.invokeNative(Native Method)
[WARN] :   W/System.err:    at java.lang.reflect.Method.invoke(Method.java:515)
[WARN] :   W/System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[WARN] :   W/System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
[WARN] :   W/System.err:    at dalvik.system.NativeStart.main(Native Method)
[WARN] :   W/System.err: java.lang.NullPointerException
[WARN] :   W/System.err:    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetTitle(ActionbarextrasModule.java:190)
[WARN] :   W/System.err:    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:118)
[WARN] :   W/System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
[WARN] :   W/System.err:    at android.os.Looper.loop(Looper.java:136)
[WARN] :   W/System.err:    at android.app.ActivityThread.main(ActivityThread.java:5196)
[WARN] :   W/System.err:    at java.lang.reflect.Method.invokeNative(Native Method)
[WARN] :   W/System.err:    at java.lang.reflect.Method.invoke(Method.java:515)
[WARN] :   W/System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[WARN] :   W/System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
[WARN] :   W/System.err:    at dalvik.system.NativeStart.main(Native Method)
[WARN] :   W/System.err: java.lang.NullPointerException
[WARN] :   W/System.err:    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleHideLogo(ActionbarextrasModule.java:544)
[WARN] :   W/System.err:    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:162)
[WARN] :   W/System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
[WARN] :   W/System.err:    at android.os.Looper.loop(Looper.java:136)
[WARN] :   W/System.err:    at android.app.ActivityThread.main(ActivityThread.java:5196)
[WARN] :   W/System.err:    at java.lang.reflect.Method.invokeNative(Native Method)
[WARN] :   W/System.err:    at java.lang.reflect.Method.invoke(Method.java:515)
[WARN] :   W/System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[WARN] :   W/System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
[WARN] :   W/System.err:    at dalvik.system.NativeStart.main(Native Method)

Ti SDK 3.5.1
Alloy 1.5.1
Android device 4.4.4, emulator 5.1.0

"menu overflow" not working

Hi!

Is there any reason why this has been removed? from v1.3.0 it is not forcing menu overflow anymore.

// http://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button
        try {
            ViewConfiguration config = ViewConfiguration.get(app);
            java.lang.reflect.Field menuKeyField = ViewConfiguration.class
                    .getDeclaredField("sHasPermanentMenuKey");
            if (menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception ex) {
            // Ignore
        }

regerds,
janis

setHomeAsUpIndicator fails on API pre18

setHomeAsUpIndicator method is available starting from API level 18

E/AndroidRuntime( 4484): FATAL EXCEPTION: main
E/AndroidRuntime( 4484): java.lang.NoSuchMethodError: android.app.ActionBar.setHomeAsUpIndicator
E/AndroidRuntime( 4484):    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetHomeAsUpIcon(ActionbarextrasModule.java:384)
E/AndroidRuntime( 4484):    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:116)
E/AndroidRuntime( 4484):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 4484):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4484):    at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 4484):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4484):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4484):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 4484):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 4484):    at dalvik.system.NativeStart.main(Native Method)

library imports causing error

[ERROR] : �� �Failed to run dexer:
[ERROR] : �� �
[ERROR] : �� �trouble processing "javax/xml/datatype/DatatypeConstants$Field.class":
[ERROR] : �� �
[ERROR] : �� �Ill-advised or mistaken usage of a core class (java.* or javax.*)
[ERROR] : �� �when not building a core library.
[ERROR] : �� �
[ERROR] : �� �This is often due to inadvertently including a core library file
[ERROR] : �� �in your application's project, when using an IDE (such as
[ERROR] : �� �Eclipse). If you are sure you're not intentionally defining a
[ERROR] : �� �core class, then this is the most likely explanation of what's
[ERROR] : �� �going on.
[ERROR] : �� �
[ERROR] : �� �However, you might actually be trying to define a class in a core
[ERROR] : �� �namespace, the source of which you may have taken, for example,
[ERROR] : �� �from a non-Android virtual machine project. This will most
[ERROR] : �� �assuredly not work. At a minimum, it jeopardizes the
[ERROR] : �� �compatibility of your app with future versions of the platform.
[ERROR] : �� �It is also often of questionable legality.
[ERROR] : �� �
[ERROR] : �� �If you really intend to build a core library -- which is only
[ERROR] : �� �appropriate as part of creating a full virtual machine
[ERROR] : �� �distribution, as opposed to compiling an application -- then use
[ERROR] : �� �the "--core-library" option to suppress this error message.
[ERROR] : �� �
[ERROR] : �� �If you go ahead and use "--core-library" but are in fact
[ERROR] : �� �building an application, then be forewarned that your application
[ERROR] : �� �will still fail to build or run, at some point. Please be
[ERROR] : �� �prepared for angry customers who find, for example, that your
[ERROR] : �� �application ceases to function once they upgrade their operating
[ERROR] : �� �system. You will be to blame for this problem.
[ERROR] : �� �
[ERROR] : �� �If you are legitimately using some code that happens to be in a
[ERROR] : �� �core package, then the easiest safe alternative you have is to
[ERROR] : �� �repackage that code. That is, move the classes in question into
[ERROR] : �� �your own package namespace. This means that they will never be in
[ERROR] : �� �conflict with core system classes. JarJar is a tool that may help
[ERROR] : �� �you in this endeavor. If you find that you cannot do this, then
[ERROR] : �� �that is an indication that the path you are on will ultimately
[ERROR] : �� �lead to pain, suffering, grief, and lamentation.
[ERROR] : �� �
[ERROR] : �� �1 error; aborting

[ERROR] Application Installer abnormal process termination. Process exit value was 1

Search in actionbar – how can I disable?

Hi,

var searchView = Ti.UI.Android.createSearchView({
    hintText : "Suche in Mediathek"
});
searchView.addEventListener('submit', function(_e) {
    require('ui/search.window')(.open();
    _e.source.blur(); <== I want to close (decollapse?) the searchview
});
АктйонБар.setSearchView({
                searchView : searchView,
                cancelIcon : "/images/cancel.png",
                searchIcon : "/images/search.png"
  });

How can I hide the input field in actionbar after submitting?

Where should I place fonts in Alloy project

It is obvious from the example that fonts are placed in android folder within the resources folder. In case of alloy, putting it under /app/assets/android/fonts as described by Titanium documentation is not working.

Tab group does not work with dropdown

Adding a dropdown to a tab group causes the tabs to disappear.

Test case:

var abx = require('com.alcoapps.actionbarextras');
var opts = {dropdown: false};


var win1 = Ti.UI.createWindow();
var win2 = Ti.UI.createWindow();
var tabGroup = Ti.UI.createTabGroup({
    tabs: [Ti.UI.createTab({window: win1, title: 'Tab 1'}), Ti.UI.createTab({window: win2, title: 'Tab 2'})]
});

var dropdown
var btn_dropdown = Ti.UI.createButton({ title: 'Dropdown' });
btn_dropdown.addEventListener('click', function(){
    opts.dropdown = !opts.dropdown;

    if (opts.dropdown){
        dropdown = abx.createDropdown({
            titles: ["First", "Second", "Third"]
        });

        dropdown.addEventListener('change', function(e){
            Ti.API.info("dropdown changed to: " + e.index);
        });
    }else{
        dropdown.remove();
    }

});
win1.add(btn_dropdown);


tabGroup.open();

Note: I also tried creating the dropdown in the tab group's open event listener and in activity.onCreateOptionsMenu with the same result. It occurs on device with Android 4.4.2 and Genymotion emulator running 4.2.2, built with Ti SDK 3.4.0.GA.

Support short color code for backgroundColor

I was wondering why actionbarextras couldn't change the actionbar's background color of my classic project.
Apparently actionbarextras couldn't recognize short color code (3-4 hex digits like "#45" instead of "#004455") while regular Titanium components can.

V8Exception: NullPointerException

Very randomly I'm getting this error, which causes an application crash

[DEBUG] : �� �ActionbarextrasModule: (KrollRuntimeThread) [4783,4783] called the setextras method
[WARN] : �� � W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActionBar android.app.Activity.getActionBar()' on a null object reference
[WARN] : �� � W/System.err:     at com.alcoapps.actionbarextras.ActionbarextrasModule.setExtras(ActionbarextrasModule.java:72)
[WARN] : �� � W/System.err:     at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[WARN] : �� � W/System.err:     at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64)
[WARN] : �� � W/System.err:     at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884)
[WARN] : �� � W/System.err:     at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107)
[WARN] : �� � W/System.err:     at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:338)
[WARN] : �� � W/System.err:     at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:99)
[WARN] : �� � W/System.err:     at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:104)
[WARN] : �� � W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:98)
[WARN] : �� � W/System.err:     at android.os.Looper.loop(Looper.java:135)
[WARN] : �� � W/System.err:     at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
[WARN] : �� � TiExceptionHandler: (main) [63,4846] Activity is null or already finishing, skipping dialog.
[ERROR] : �� �V8Exception: Exception occurred at ui/android/ApplicationWindow.js:36: Uncaught Error: Attempt to invoke virtual method 'android.app.ActionBar android.app.Activity.getActionBar()' on a null object reference
[DEBUG] : �� �AndroidRuntime: Shutting down VM

It seems that in some cases the setExtras method gets called before the Activity is initialized (like when accessing it before the window is open). I'll have a closer look at this and do some tests.

Use text instead of "title" and "subtitle" properties

@manumaticx , perhaps for API consistency we should change

abextras.setTitle=({
title : 'This is the title',
font : 'Chunkfive.otf',
color : 'red'
});

abextras.setSubtitle=({
subtitle : 'This is the subtitle',
font : 'Chunkfive.otf',
color : 'blue'
});

so both use a text property like:

abextras.setTitle=({
text : 'This is the title',
font : 'Chunkfive.otf',
color : 'red'
});

abextras.setSubtitle=({
text : 'This is the subtitle',
font : 'Chunkfive.otf',
color : 'blue'
});

Dropdown preset?

Hi Manu + Ricardo,

it it possible to preset the list?

Codestrong!

Rainer

Using ABX with Drawer

Hey,

i am using your module( great work!) together with the Android Drawer ( https://github.com/manumaticx/Ti.DrawerLayout )

Strange:
I am using a special font for the title in the actionbar - working as expected. But after changing the centerView of the Drawer Instance it changed to the default font and i can't change it :/ New Windows are working fine - just the above case doesn't.

Do you have any idea why? (I thought the bar is attached to the current activity so it should be the same after changing just the centerView - or?

best, Nico

This WARN with NullPointer occurs when the app starts

[WARN]  W/System.err: java.lang.NullPointerException
[WARN]  W/System.err:   at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetMenuItemIcon(ActionbarextrasModule.java:527)
[WARN]  W/System.err:   at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:158)
[WARN]  W/System.err:   at android.os.Handler.dispatchMessage(Handler.java:95)
[WARN]  W/System.err:   at android.os.Looper.loop(Looper.java:137)
[WARN]  W/System.err:   at android.app.ActivityThread.main(ActivityThread.java:5103)
[WARN]  W/System.err:   at java.lang.reflect.Method.invokeNative(Native Method)
[WARN]  W/System.err:   at java.lang.reflect.Method.invoke(Method.java:525)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[WARN]  W/System.err:   at dalvik.system.NativeStart.main(Native Method)
[WARN]  W/System.err: java.lang.NullPointerException
[WARN]  W/System.err:   at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetMenuItemIcon(ActionbarextrasModule.java:527)
[WARN]  W/System.err:   at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:158)
[WARN]  W/System.err:   at android.os.Handler.dispatchMessage(Handler.java:95)
[WARN]  W/System.err:   at android.os.Looper.loop(Looper.java:137)
[WARN]  W/System.err:   at android.app.ActivityThread.main(ActivityThread.java:5103)
[WARN]  W/System.err:   at java.lang.reflect.Method.invokeNative(Native Method)
[WARN]  W/System.err:   at java.lang.reflect.Method.invoke(Method.java:525)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[WARN]  W/System.err:   at dalvik.system.NativeStart.main(Native Method)

Support to change font size

Would be nice if there's a support to change the font size as well.
I'm wondering if anyone knows how to do it from the theme (AppCompat) ?

handleSetMenuItemIcon doesn't parse hex values

If you pass icon: 0xf002 to setMenuItemIcon( ) you'll get this error:

05-27 11:28:51.261: W/System.err(12623): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
05-27 11:28:51.261: W/System.err(12623):    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetMenuItemIcon(ActionbarextrasModule.java:518)
05-27 11:28:51.261: W/System.err(12623):    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:158)
05-27 11:28:51.261: W/System.err(12623):    at android.os.Handler.dispatchMessage(Handler.java:98)
05-27 11:28:51.261: W/System.err(12623):    at android.os.Looper.loop(Looper.java:135)
05-27 11:28:51.261: W/System.err(12623):    at android.app.ActivityThread.main(ActivityThread.java:5254)
05-27 11:28:51.261: W/System.err(12623):    at java.lang.reflect.Method.invoke(Native Method)
05-27 11:28:51.261: W/System.err(12623):    at java.lang.reflect.Method.invoke(Method.java:372)
05-27 11:28:51.262: W/System.err(12623):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-27 11:28:51.262: W/System.err(12623):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-27 11:28:51.263: W/System.err(12623): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
05-27 11:28:51.265: W/System.err(12623):    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetMenuItemIcon(ActionbarextrasModule.java:518)
05-27 11:28:51.265: W/System.err(12623):    at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:158)
05-27 11:28:51.265: W/System.err(12623):    at android.os.Handler.dispatchMessage(Handler.java:98)
05-27 11:28:51.265: W/System.err(12623):    at android.os.Looper.loop(Looper.java:135)
05-27 11:28:51.265: W/System.err(12623):    at android.app.ActivityThread.main(ActivityThread.java:5254)
05-27 11:28:51.265: W/System.err(12623):    at java.lang.reflect.Method.invoke(Native Method)
05-27 11:28:51.265: W/System.err(12623):    at java.lang.reflect.Method.invoke(Method.java:372)
05-27 11:28:51.265: W/System.err(12623):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-27 11:28:51.265: W/System.err(12623):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

It should actually parse the hex value to a valid unicode char.

Android minsdk support?

What is the android minsdk support for this module? Now that Titanium uses the AppCompat theme, the ActionBar is available even in devices with API <11. But in the device with Android API <11, for example Android API level 10 (Android 2.3.7), I receive an error because the ActionBar is not found.

Code refactoring and API improvement

I think it's time for a little code refactoring. By now, the module has some features, all handled by dedicated functions, some properties can be set by setExtras. Beyond that there is no API documentation.

Here's some things I would like to change and I'm interested in what you think about it:

  • deprecate setExtras
  • turn the KrollModule into a KrollProxy
  • create a message handler
  • create properties (with setter functions) for:
    • title
    • subtitle
    • backgroundColor
    • titleFont
    • subtitleFont
    • titleColor
    • subtitleColor
    • disableIcon

It would also make sense to deprecate title and subtitle since these can be set with the Titanium ActionbarProxy. But at a second thought, we got clear about the issue #10 - so if one uses custom fonts for title or subtitle, these values have to be changed with this module unless we find a way to consistently change the font rather than just replacing the title with a modified string. Therefor it might be handy to have functions to set title, font and color at once.

var abx = require('com.alcoapps.actionbarextras');

abx.setTitle({
  title: "the Title",
  color: "red",
  font: "Roboto-Light.otf"
});

// or through properties as mentioned above

abx.title = "the Title";
abx.titleColor = "red";
abx.titleFont = "Roboto-Light.otf";

What do you think about it, @ricardoalcocer ?

setTitle({ font: { ... } }); Crashes app

abx.setTitle({
    text: "Font Object",
    font: {
      fontSize: 26,
      fontFamily: 'roboto'
    }
  });

This results in this error:

[ERROR] TiExceptionHandler: (main) [436,436] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [1,437] - In alloy/controllers/index.js:1,69
[ERROR] TiExceptionHandler: (main) [0,437] - Message: Uncaught Error: java.util.HashMap cannot be cast to java.lang.String
[ERROR] TiExceptionHandler: (main) [0,437] - Source: lobals.fontAgency.globesherpa,font:Alloy.Globals.fontAgencyName}),i.setTitle({
[DEBUG] Dialog: checkMirrorLinkEnabled returns : false
[DEBUG] Dialog: showing allowed
[ERROR] V8Exception: Exception occurred at alloy/controllers/index.js:1: Uncaught Error: java.util.HashMap cannot be cast to java.lang.String

This does work. It just doesn't allow for sizing:

abx.setTitle({
    text: "Font Object",
    font: 'roboto'
  });

Force Overflow

Titanium now supports force overflow but I've noticed that its implementation isn't consistent across all android API levels. It would be nice to get force overflow functionality back into this module.

Changing the title makes it switch back to the original font.

Hi, I'm using NappDrawer in Android to navigate between views and when i change views I also change the actionbar title and it returns to the original font. If I try to use setExtras() method to change the title it will return an error 'Only the original thread that created a view hierarchy can touch its views.'

If I try to setTitleFont() after I call actionBar.setTitle() in Titanium it will not keep the custom font.

I'm guessing a method to change only the current title (keeping the previously selected custom font) would solve this but it's a little out of my skill set.
Nice module btw.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.