RiccardoMoro / RMSwitch

A simple and customizable two or three states Switch View
656 stars 81 forks source link

Question: why minSdk 16 ? #6

Closed AndroidDeveloperLB closed 6 years ago

AndroidDeveloperLB commented 7 years ago

There are still devices below, and this is only switches. Maybe set it to API 9 , or at least 14 ?

RiccardoMoro commented 7 years ago

If I remember correctly API >=16 means more than 90% (about 95%) of the active devices, it's not all, but it's more than enough I guess. With API >= 16 I've avoided some problems that might have occurred, especially because I do not have any device previous to jellybean to test on (I do not completely trust emulators, I've seen error on them that did not occurr on real devices and vice verse) If you have one and need this library for API < 16 feel free to downgrade the API version and test it, if it works open me a pull request and I will happily accept and merge it! Let me know

AndroidDeveloperLB commented 7 years ago

But have you tested it on emulators of API 15 or below? Maybe it is possible ?

RiccardoMoro commented 7 years ago

Nope, I also think this library needs some small changes to be used in API < 16

AndroidDeveloperLB commented 7 years ago

what changes? Currently, trying to run on pre-API 16, I get a crash with this error:

12-10 00:12:01.839 2151-2151/com.rm.switchsample E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rm.switchsample/com.rm.switchsample.ActivityMain}: android.view.InflateException: Binary XML file line #27: Error inflating class com.rm.rmswitch.RMTristateSwitch at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) at android.app.ActivityThread.access$1500(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class com.rm.rmswitch.RMTristateSwitch at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) at android.view.LayoutInflater.inflate(LayoutInflater.java:408) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at android.view.LayoutInflater.inflate(LayoutInflater.java:276) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.rm.switchsample.ActivityMain.onCreate(ActivityMain.java:63) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)  at android.app.ActivityThread.access$1500(ActivityThread.java:117)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:130)  at android.app.ActivityThread.main(ActivityThread.java:3683)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:507)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.ClassNotFoundException: com.rm.rmswitch.RMTristateSwitch in loader dalvik.system.PathClassLoader[/data/app/com.rm.switchsample-1.apk] at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) at java.lang.ClassLoader.loadClass(ClassLoader.java:551) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at android.view.LayoutInflater.createView(LayoutInflater.java:471) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)  at com.rm.switchsample.ActivityMain.onCreate(ActivityMain.java:63)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)  at android.app.ActivityThread.access$1500(ActivityThread.java:117)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:130)  at android.app.ActivityThread.main(ActivityThread.java:3683)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:507)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)  at dalvik.system.NativeStart.main(Native Method) 

RiccardoMoro commented 7 years ago

Ok, I found the problem. To animate the switch movements, i use LayoutTransition.CHANGING, which is available only in api 16+ I will push an update with min sdk version set as 11, but devices with api < 16 will not see animation for the switch toggle movements.. I'll write it down in the TODO section of the README, when I'll have time I will fix this too. Thanks again for the feedback @AndroidDeveloperLB

AndroidDeveloperLB commented 7 years ago

Nice. Can you please check my tiny library too?

On Wed, Dec 21, 2016 at 4:43 PM, Riccardo Moro notifications@github.com wrote:

Ok, I found the problem. To animate the switch movements, i use LayoutTransition.CHANGING, which is available only in api 16+ I will push an update with min sdk version set as 11, but devices with api < 16 will not see animation for the switch toggle movements.. I'll write it down in the TODO section of the README, when I'll have time I will fix this. Thanks again for the feedback @AndroidDeveloperLB https://github.com/AndroidDeveloperLB

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RiccardoMoro/RMSwitch/issues/6#issuecomment-268539260, or mute the thread https://github.com/notifications/unsubscribe-auth/AFG_1pfMtSuvTYG-yGt7-4PhNq8HACSGks5rKTsrgaJpZM4LDdGc .

RiccardoMoro commented 7 years ago

Mmm on my emulator is having a really strange behaviour on api < 16 :( I'll have to keep this change on a separated branch until I found a real device to test on. I'm looking into your library right now

RiccardoMoro commented 7 years ago

I'm sorry but I do not have real experience on old android API or Preferences.. Also, reading on other libraries/websites, everyone seems to have that problem with animations on Switch and CheckBox Preferences backward compatibility.. I do not think I'll be able to help you @AndroidDeveloperLB

AndroidDeveloperLB commented 7 years ago

It happens on new versions of Android too, even N . Just something in the library, but I use a simple Switch there, so I have no idea why it occurs.

On Wed, Dec 21, 2016 at 6:11 PM, Riccardo Moro notifications@github.com wrote:

I'm sorry but I do not have real experience on old android API or Preferences.. Also, reading on other libraries/websites, everyone seems to have that problem with animations on Switch and CheckBox Preferences backward compatibility.. I do not think I'll be able to help you @AndroidDeveloperLB https://github.com/AndroidDeveloperLB

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RiccardoMoro/RMSwitch/issues/6#issuecomment-268562346, or mute the thread https://github.com/notifications/unsubscribe-auth/AFG_1jOod16FC39cDOUCiX0ko5lhLBz6ks5rKU-8gaJpZM4LDdGc .