{"id":13396060,"url":"https://github.com/recruit-lifestyle/FloatingView","last_synced_at":"2025-03-13T22:31:37.020Z","repository":{"id":35407441,"uuid":"39671961","full_name":"recruit-lifestyle/FloatingView","owner":"recruit-lifestyle","description":null,"archived":true,"fork":false,"pushed_at":"2020-02-03T05:53:41.000Z","size":1889,"stargazers_count":1145,"open_issues_count":12,"forks_count":209,"subscribers_count":54,"default_branch":"master","last_synced_at":"2024-09-27T03:01:30.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://engineer.recruit-lifestyle.co.jp/techblog/2015-07-29-floatingview/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/recruit-lifestyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-25T04:04:15.000Z","updated_at":"2024-06-27T13:03:12.000Z","dependencies_parsed_at":"2022-09-13T02:52:00.987Z","dependency_job_id":null,"html_url":"https://github.com/recruit-lifestyle/FloatingView","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recruit-lifestyle%2FFloatingView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recruit-lifestyle%2FFloatingView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recruit-lifestyle%2FFloatingView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recruit-lifestyle%2FFloatingView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recruit-lifestyle","download_url":"https://codeload.github.com/recruit-lifestyle/FloatingView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243493772,"owners_count":20299715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:38.687Z","updated_at":"2025-03-13T22:31:36.444Z","avatar_url":"https://github.com/recruit-lifestyle.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`","其他","Java","Index"],"sub_categories":[],"readme":"# FloatingView\n[Archived] Use instead: https://developer.android.com/guide/topics/ui/bubbles\n\nThe Android project is View to display information such as chat in front.\nTo API Level 14 or higher are supported\n\n## Screenshots\n![](./screenshot/animation.gif)  \n\u003cimg src=\"./screenshot/ss01.png\" width=\"200\"\u003e\n\u003cimg src=\"./screenshot/ss02.png\" width=\"200\"\u003e\n\u003cimg src=\"./screenshot/ss03.png\" width=\"200\"\u003e\n  \n*Watch YouTube video*  \n[SimpleFloating](http://youtu.be/nb8M2p0agF4)\n\n## Requirements\nTarget Sdk Version : 28  \nMin Sdk Version : 14  \n\n## How to use\n1) Add this to your **build.gradle**.\n  ```java\n  repositories {\n      maven {\n          url \"https://jitpack.io\"\n      }\n  }\n\n  dependencies {\n    implementation 'com.github.recruit-lifestyle:FloatingView:2.4.4'\n  }\n  ```\n  \n2) Implement Service for displaying FloatingView\n```java\npublic class ChatHeadService extends Service {\n  ... ...\n}\n```\n  \n3) You will do the setting of the View to be displayed in the FloatingView(Sample have a set in onStartCommand)\n```java\n  final LayoutInflater inflater = LayoutInflater.from(this);\n  final ImageView iconView = (ImageView) inflater.inflate(R.layout.widget_chathead, null, false);\n  iconView.setOnClickListener(......);\n```  \n\n4) Use the FloatingViewManager, make the setting of FloatingView\n```java\n  mFloatingViewManager = new FloatingViewManager(this, this);\n  mFloatingViewManager.setFixedTrashIconImage(R.drawable.ic_trash_fixed);\n  mFloatingViewManager.setActionTrashIconImage(R.drawable.ic_trash_action);\n  final FloatingViewManager.Options options = new FloatingViewManager.Options();\n  options.overMargin = (int) (16 * metrics.density);\n  mFloatingViewManager.addViewToWindow(iconView, options);\n```  \n\nThe second argument of `FloatingViewManager` is `FloatingViewListener`\n  \nDescribe the process (`onFinishFloatingView`) that is called when you exit the FloatingView\n```java\n    @Override\n    public void onFinishFloatingView() {\n        stopSelf();\n    }\n```\n  \n5) Add the permission to AndroidManifest\n```xml\n \u003cuses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\"/\u003e\n \u003cuses-permission android:name=\"android.permission.FOREGROUND_SERVICE\" /\u003e\n```  \n  \n6) Define the Service to AndroidManifest\n\nexample)\n```java\n    \u003capplication ...\u003e\n        ...\n        \u003c!-- Demo --\u003e\n        \u003cservice\n            android:name=\"jp.co.recruit_lifestyle.sample.service.ChatHeadService\"\n            android:exported=\"false\"/\u003e\n        ...\n    \u003c/application\u003e\n```\n  \n7) Describe the process to start the Service (run on foreground)\n\n\nexample)  \n\n- FloatingViewControlFragment.java  \n\n```java\n    final Intent intent = new Intent(activity, ChatHeadService.class);\n    ContextCompat.startForegroundService(activity, intent);\n```\n\n- ChatHeadService.java  \n\n```java\npublic int onStartCommand(Intent intent, int flags, int startId) {\n    ...\n    startForeground(NOTIFICATION_ID, createNotification(this));\n    ...\n}\n```\n\n8) Create notification channel (targetSdkVersion \u003e= 26)\n\nexample)\n```java\nif (Build.VERSION.SDK_INT \u003e= Build.VERSION_CODES.O) {\n    final String channelId = getString(R.string.default_floatingview_channel_id);\n    final String channelName = getString(R.string.default_floatingview_channel_name);\n    final NotificationChannel defaultChannel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_MIN);\n    final NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);\n    if (manager != null) {\n        manager.createNotificationChannel(defaultChannel);\n    }\n}\n\n```\n\n9) Add DisplayCutout process(API Level \u003e= 28)\n\nCall `FloatingViewManager.findCutoutSafeArea(activity)`.  \nNote: Activity must be portrait oriented.  \nNote: You must not set `windowLayoutInDisplayCutoutMode` to `never`.  \n\nexample)\n\n- FloatingViewControlFragment.java\n\n```java\nfinal Intent intent = new Intent(activity, ChatHeadService.class);\nintent.putExtra(ChatHeadService.EXTRA_CUTOUT_SAFE_AREA, FloatingViewManager.findCutoutSafeArea(activity));\nContextCompat.startForegroundService(activity, intent);\n```\n\n- ChatHeadService.java\n\n```java\nmFloatingViewManager.setSafeInsetRect((Rect) intent.getParcelableExtra(EXTRA_CUTOUT_SAFE_AREA));\n```\n\n\n## Static Options\nIt can be set only when displaying for the first time\n  \nexample)\n```java\nfinal FloatingViewManager.Options options = new FloatingViewManager.Options();\noptions.overMargin = (int) (16 * metrics.density);\nmFloatingViewManager.addViewToWindow(iconView, options);\n```\n\n|Option|Description|  \n|:-:|---|  \n|shape|`FloatingViewManager.SHAPE_CIRCLE`:Circle(default)\u003cbr\u003e `FloatingViewManager.SHAPE_RECTANGLE`:Rectangle|  \n|overMargin|Margin over the edge of the screen (px)\u003cbr\u003e(default) 0|  \n|floatingViewX|X coordinate of initial display\u003cbr\u003e(default) left side of display|  \n|floatingViewY|Y coordinate of initial display\u003cbr\u003e(default) top of display|  \n|floatingViewWidth|FloatingView width\u003cbr\u003e(default) The width of the layout added to FloatingView |  \n|floatingViewHeight|FloatingView height\u003cbr\u003e(default) The height of the layout added to FloatingView|  \n|moveDirection|`FloatingViewManager.MOVE_DIRECTION_DEFAULT`:Left end or right end(default)\u003cbr\u003e `FloatingViewManager.MOVE_DIRECTION_LEFT`:Left end\u003cbr\u003e`FloatingViewManager.MOVE_DIRECTION_RIGHT`:Right end\u003cbr\u003e`FloatingViewManager.MOVE_DIRECTION_NONE`:Not move\u003cbr\u003e`FloatingViewManager.MOVE_DIRECTION_NEAREST`:Move nearest edge\u003cbr\u003e`FloatingViewManager.MOVE_DIRECTION_THROWN`:Move in the throwing direction (left end or right end)|\n|usePhysics|Use physics-based animation(depends on `moveDirection`)\u003cbr\u003e(default) true\u003cbr\u003eInfo:If `MOVE_DIRECTION_NEAREST` is set, nothing happens\u003cbr\u003eInfo:Can not be used before API 16|\n|animateInitialMove|If true, animation when first displayed\u003cbr\u003e(FloatingViewX, floatingViewY) to screen edge\u003cbr\u003eInfo: If `MOVE_DIRECTION_NONE` is set, nothing happens|  \n\n## Dynamic Options\nIt can be set any time  \n  \nexample)\n```java\nmFloatingViewManager.setFixedTrashIconImage(R.drawable.ic_trash_fixed);\nmFloatingViewManager.setActionTrashIconImage(R.drawable.ic_trash_action);\n```\n\n|Option|Description|\n|:-:|---|\n|setFixedTrashIconImage|It is an icon that does *not* enlarge when FloatingView overlaps.|\n|setActionTrashIconImage|It is an icon that enlarge when FloatingView overlaps.|\n|setDisplayMode|`FloatingViewManager.DISPLAY_MODE_SHOW_ALWAYS`:Always show\u003cbr\u003e`FloatingViewManager.DISPLAY_MODE_HIDE_ALWAYS`:Always hidden\u003cbr\u003e`FloatingViewManager.DISPLAY_MODE_HIDE_FULLSCREEN`:It is hidden when in full screen|\n|setTrashViewEnabled|If false, the trash icon does not show during dragging.\u003cbr\u003e(default) true|\n\n# Credits\n\nFloatingView is owned and maintained by [RECRUIT LIFESTYLE CO., LTD.](http://www.recruit-lifestyle.co.jp/)\n\nFloatingView was originally created by [Yoshihide Sogawa](https://twitter.com/egg_sogawa)  \n\n\n# License\n\n    Copyright 2015 RECRUIT LIFESTYLE CO., LTD.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecruit-lifestyle%2FFloatingView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecruit-lifestyle%2FFloatingView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecruit-lifestyle%2FFloatingView/lists"}