ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
148 stars 60 forks source link

Android minsdk support? #54

Closed Astrovic closed 9 years ago

Astrovic commented 9 years ago

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.

manumaticx commented 9 years ago

@Astrovic This module uses the support action bar (appcompat compatible) since version 1.4.0 It should work on APIs < 11 - I've actually tested this on Android 2.3.7. I'll have a look again asap.

Astrovic commented 9 years ago

Thanks @manumaticx This is the simple code I use:

if(OS_ANDROID){
   var abx = require('com.alcoapps.actionbarextras');
   abx.title = "Win title...";
};

It works well on Android API >= 11, but when I test the app on Android 2.3.7 device I receive this error:

[ERROR] : TiApplication: (main) [192,860] Sending event: exception on thread: main msg:java.lang.NoSuchMethodError: android.app.Activity.getActionBar; Titanium 3.4.1,2014/11/13 13:33,5982e8f [ERROR] : TiApplication: java.lang.NoSuchMethodError: android.app.Activity.getActionBar [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetTitle(ActionbarextrasModule.java:134) [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:84) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:130) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:3683) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:507) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) [ERROR] : AndroidRuntime: FATAL EXCEPTION: main [ERROR] : AndroidRuntime: java.lang.NoSuchMethodError: android.app.Activity.getActionBar [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetTitle(ActionbarextrasModule.java:134) [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:84) [ERROR] : AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : AndroidRuntime: at android.os.Looper.loop(Looper.java:130) [ERROR] : AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:3683) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:507) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) [ERROR] : AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)

manumaticx commented 9 years ago

@Astrovic Ah okay, I see. You have to wait until the window is open, before you access the actionbar.

Have a look into the example.

win.addEventListener('open',function(e){
  abx.title = "Win title...";
};
Astrovic commented 9 years ago

Sorry, now I noticed that I still had the version 1.3.8... Now I upgraded to 1.4.2, and it works properly. Thank you very much, this module is awesome! :)

manumaticx commented 9 years ago

thank you! :smiley:

Astrovic commented 9 years ago

But the problem continues to persist if I use titleFont:

win.addEventListener('open',function(e){
  abx.title = "Win title...";
  abx.titleFont = "Arial.ttf";
};

I receive this error (only on Android 2.3.7):

[ERROR] : TiApplication: (main) [300,1084] Sending event: exception on thread: main msg:java.lang.ExceptionInInitializerError; Titanium 3.4.1,2014/11/13 13:33,5982e8f [ERROR] : TiApplication: java.lang.ExceptionInInitializerError [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetTitleFont(ActionbarextrasModule.java:256) [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:116) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:130) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:3683) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:507) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) [ERROR] : TiApplication: Caused by: java.lang.NoClassDefFoundError: android.util.LruCache [ERROR] : TiApplication: at com.alcoapps.actionbarextras.TypefaceSpan.(TypefaceSpan.java:35) [ERROR] : TiApplication: ... 10 more [ERROR] : AndroidRuntime: FATAL EXCEPTION: main [ERROR] : AndroidRuntime: java.lang.ExceptionInInitializerError [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetTitleFont(ActionbarextrasModule.java:256) [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:116) [ERROR] : AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : AndroidRuntime: at android.os.Looper.loop(Looper.java:130) [ERROR] : AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:3683) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:507) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) [ERROR] : AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) [ERROR] : AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: android.util.LruCache [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.TypefaceSpan.(TypefaceSpan.java:35) [ERROR] : AndroidRuntime: ... 10 more

manumaticx commented 9 years ago

Thanks for the pointer, I've pushed a fix. :)

Astrovic commented 9 years ago

Great job! Thanks to you! :))