flipkart-incubator / springy-heads

Chat heads library for android
Apache License 2.0
370 stars 108 forks source link

RTL support #11

Open hishambakr opened 7 years ago

hishambakr commented 7 years ago

Many thanks for great effort. I have an issue that there is a strange behavior happens when I force RTL the closed heads stick to the right and when I click them , the header is hidden

I use this code to force RTL: try { String languageToLoad = "ar"; // your language Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = activity.getResources().getConfiguration(); //config.locale = locale; config.setLocale(locale); activity.getResources().updateConfiguration(config, activity.getResources().getDisplayMetrics()); activity.getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); } catch (Exception ex){ LogUtil.e(ex); }

thekirankumar commented 7 years ago

Which branch are you on ? Master or "run_in_service" ?

thekirankumar commented 7 years ago

Can you try the new branch "run_in_service" ?

hishambakr commented 7 years ago

I just used compile 'com.flipkart.springyheads:library:0.9.6'

I will try "run_in_service" branch

thekirankumar commented 7 years ago

@hisham2007 any update ?

hishambakr commented 7 years ago

seems working but there is a crash when i close heads:

FATAL EXCEPTION: main Process: com.springyheads.service.demo, PID: 5463 java.lang.IllegalArgumentException: View=com.flipkart.chatheads.ui.container.WindowManagerContainer$MotionCaptureView{ad91479 V.ED..... ......I. 0,0-1440,2464} not attached to window manager at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:451) at android.view.WindowManagerGlobal.updateViewLayout(WindowManagerGlobal.java:363) at android.view.WindowManagerImpl.updateViewLayout(WindowManagerImpl.java:97) at com.flipkart.chatheads.ui.container.WindowManagerContainer.onArrangementChanged(WindowManagerContainer.java:209) at com.flipkart.chatheads.ui.container.DefaultChatHeadManager.setArrangementImpl(DefaultChatHeadManager.java:389) at com.flipkart.chatheads.ui.container.DefaultChatHeadManager.onMeasure(DefaultChatHeadManager.java:185) at com.flipkart.chatheads.ui.HostFrameLayout.onLayout(HostFrameLayout.java:23) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2666) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2367) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1437) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7397) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) at android.view.Choreographer.doCallbacks(Choreographer.java:695) at android.view.Choreographer.doFrame(Choreographer.java:631) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

also circles popup in left. i want them to be right finally, it was better to be displayed inside app only but this branch open outside app also

gssmanc commented 7 years ago

Many thanks for great effort. i am doing work on chat head using your library but i have an issue i want to use this code in service . kindly guide me how can i do this.some guide line about "run in service" branch. thanks

thekirankumar commented 7 years ago

@hisham2007 Can you open a new issue for the crash you reported ? By default chat heads work outside the activity, Optionally, you can use the new code within the app too. Create an issue for that.

thekirankumar commented 7 years ago

@gssmanc The run_in_service has been merged to master now.

HungTDO commented 7 years ago

@hisham2007 I solved the problem Just Check view is attached to window (in WindowManagerContainer.java#onArrangementChanged):

// TODO: ChatHeadLibs: Fix error here (not attached window)
        if (motionCaptureView != null && motionCaptureView.getWindowToken() != null)
        windowManager.updateViewLayout(motionCaptureView, layoutParams);

After resolved that, maybe raise error when minimized chathead. Plz edit code in MinimizedArrangement.java#getBundle()

if (hero != null && hero.getHorizontalSpring() != null) {
        relativeXPosition = hero.getHorizontalSpring().getCurrentValue() * 1.0 / maxWidth;
        relativeYPosition = hero.getVerticalSpring().getCurrentValue() * 1.0 / maxHeight;
    }

All worked.