{"_id":"568ce9707d3bf02300aa7734","project":"54aa7f773b56130b0056c86e","user":"54aa7f3f9bb00c0b00cb899b","category":{"_id":"55781fe35129590d003ff4fc","pages":["55781fe45129590d003ff50d","55781fe45129590d003ff50e","55781fe45129590d003ff50f","55781fe45129590d003ff510","55781fe45129590d003ff511","55781fe45129590d003ff512","55781fe45129590d003ff513","55781fe45129590d003ff514","55781fe45129590d003ff515","55781fe45129590d003ff516","55f692b4fe4cce21005c78b0","55f7e91e60cc850d008a7a45","56333cab9c607719001b85e4","564462ed9ce94c0d00068ce9","564f54fa48a1df1700836653","565ee9e7413e06170093dde0","5661a8fdb401c70d00dde6fa","5671348860c8e70d006c96a1","568ce9707d3bf02300aa7734"],"version":"55781fe25129590d003ff4f7","__v":10,"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:44:00.338Z","from_sync":false,"order":4,"slug":"android-sdk","title":"Android SDK"},"parentDoc":null,"version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"__v":8,"githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-06T10:16:16.085Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":20,"body":"With the release of version 2.5.2 the Pulsate SDK also supports showing the Inbox using fragments. This allows you to farther customize how the inbox works, and allows you to better support tablets.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Default Inbox\",\n  \"body\": \"The usage of fragments is optional. \\nThe default way to use the inbox can be found here - https://pulsate.readme.io/docs/showing--hiding-the-message-inbox\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Create PulsateInboxActivity\"\n}\n[/block]\nFor the SDK to know that you are using fragments instead of the default Inbox you must create an Activity and name it \"*PulsateInboxActivity*\". Also the activity must be in a package called \"*activities*\". The package \"*activities*\" must be in your projects main package. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/eGf2HkSOQRKTkVCIFfCu_Zrzut%20ekranu%20(8).png\",\n        \"Zrzut ekranu (8).png\",\n        \"500\",\n        \"500\",\n        \"#325eaf\",\n        \"\"\n      ],\n      \"sizing\": \"smart\"\n    }\n  ]\n}\n[/block]\nIn the \"*PulsateInboxActivity*\" we will only load our \"*pulsate_inbox.xml*\".\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public class PulsateInboxActivity extends Activity {\\n\\n    :::at:::Override\\n    protected void onCreate(Bundle savedInstanceState) {\\n        super.onCreate(savedInstanceState);\\n        setContentView(R.layout.pulsate_inbox);\\n    }\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nInstead of using \"*manager.showFeed()*\" you will need the code below to show the inbox:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Intent intent = new Intent();\\nintent.setClass(MyActivity.this, PulsateInboxActivity.class);\\nstartActivity(intent);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Create pulsate_inbox.xml\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" <fragment\\n        android:name=\\\"com.pulsatehq.internal.inbox.InboxFragment\\\"\\n        android:id=\\\"@+id/inbox_fragment_container\\\" />\\n <RelativeLayout\\n        android:id=\\\"@+id/card_fragment_container\\\">\",\n      \"language\": \"xml\",\n      \"name\": \"fragment\"\n    }\n  ]\n}\n[/block]\nYour \"*pulsate_inbox.xml*\" layout must always contain these two elements. You can set the width, height and position of these elements to anything that suits you. You can also add other elements.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"The ids must be \\\"*android:id=\\\"@+id/inbox_fragment_container\\\"*\\\" and \\\"*android:id=\\\"@+id/card_fragment_container\\\"*\\\". \\nThe fragment name also must be \\\"*android:name=\\\"com.pulsatehq.internal.inbox.InboxFragment\\\"*\\\".\"\n}\n[/block]\nExample of using fragments:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<LinearLayout xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\"\\n    android:orientation=\\\"horizontal\\\"\\n    android:layout_width=\\\"match_parent\\\"\\n    android:layout_height=\\\"match_parent\\\"\\n    android:fitsSystemWindows=\\\"true\\\">\\n    <fragment\\n        android:layout_weight=\\\"1\\\"\\n        android:name=\\\"com.pulsatehq.internal.inbox.InboxFragment\\\"\\n        android:id=\\\"@+id/inbox_fragment_container\\\"\\n        android:layout_width=\\\"0dp\\\"\\n        android:layout_height=\\\"match_parent\\\" />\\n    <RelativeLayout\\n        android:layout_weight=\\\"1\\\"\\n        android:layout_width=\\\"0dp\\\"\\n        android:layout_height=\\\"match_parent\\\"\\n        android:id=\\\"@+id/card_fragment_container\\\">\\n        <TextView\\n            android:layout_width=\\\"wrap_content\\\"\\n            android:layout_height=\\\"wrap_content\\\"\\n            android:text=\\\"HELLO HELLO\\\"\\n            android:layout_centerVertical=\\\"true\\\"\\n            android:layout_centerHorizontal=\\\"true\\\" />\\n    </RelativeLayout>\\n</LinearLayout>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nThis will create us a layout that looks like this:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ZKl3jalQoeMrv1c91HkY_inbox.png\",\n        \"inbox.png\",\n        \"1920\",\n        \"1080\",\n        \"#0c84fb\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe inbox is shown in the \"*inbox_fragment_container*\". When clicking a card it will show up in the \"*card_fragment_container*\".\n\nIn our example when we click a card the layout will look like this:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/KxqzfN85Q0uCAYUap9st_inbox2.png\",\n        \"inbox2.png\",\n        \"1920\",\n        \"1080\",\n        \"#0d83fb\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Recommended layouts\"\n}\n[/block]\nRecommended layout for phones\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<RelativeLayout xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\"\\n    android:orientation=\\\"horizontal\\\"\\n    android:layout_width=\\\"match_parent\\\"\\n    android:layout_height=\\\"match_parent\\\"\\n    android:fitsSystemWindows=\\\"true\\\">\\n    <fragment\\n        android:name=\\\"com.pulsatehq.internal.inbox.InboxFragment\\\"\\n        android:id=\\\"@+id/inbox_fragment_container\\\"\\n        android:layout_width=\\\"match_parent\\\"\\n        android:layout_height=\\\"match_parent\\\" />\\n    <RelativeLayout\\n        android:layout_width=\\\"match_parent\\\"\\n        android:layout_height=\\\"match_parent\\\"\\n        android:id=\\\"@+id/card_fragment_container\\\">\\n    </RelativeLayout>\\n</RelativeLayout>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nRecommended layout for tablets\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<LinearLayout xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\"\\n    android:orientation=\\\"horizontal\\\"\\n    android:layout_width=\\\"match_parent\\\"\\n    android:layout_height=\\\"match_parent\\\"\\n    android:fitsSystemWindows=\\\"true\\\">\\n    <fragment\\n        android:layout_weight=\\\"1\\\"\\n        android:name=\\\"com.pulsatehq.internal.inbox.InboxFragment\\\"\\n        android:id=\\\"@+id/inbox_fragment_container\\\"\\n        android:layout_width=\\\"0dp\\\"\\n        android:layout_height=\\\"match_parent\\\" />\\n    <RelativeLayout\\n        android:background=\\\"@color/pulsate_feed_background_color\\\"\\n        android:layout_weight=\\\"1\\\"\\n        android:layout_width=\\\"0dp\\\"\\n        android:layout_height=\\\"match_parent\\\"\\n        android:id=\\\"@+id/card_fragment_container\\\">\\n    </RelativeLayout>\\n</LinearLayout>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"showing-the-inbox-using-fragments","type":"basic","title":"Showing the Inbox using fragments"}

Showing the Inbox using fragments


With the release of version 2.5.2 the Pulsate SDK also supports showing the Inbox using fragments. This allows you to farther customize how the inbox works, and allows you to better support tablets. [block:callout] { "type": "info", "title": "Default Inbox", "body": "The usage of fragments is optional. \nThe default way to use the inbox can be found here - https://pulsate.readme.io/docs/showing--hiding-the-message-inbox" } [/block] [block:api-header] { "type": "basic", "title": "1. Create PulsateInboxActivity" } [/block] For the SDK to know that you are using fragments instead of the default Inbox you must create an Activity and name it "*PulsateInboxActivity*". Also the activity must be in a package called "*activities*". The package "*activities*" must be in your projects main package. [block:image] { "images": [ { "image": [ "https://files.readme.io/eGf2HkSOQRKTkVCIFfCu_Zrzut%20ekranu%20(8).png", "Zrzut ekranu (8).png", "500", "500", "#325eaf", "" ], "sizing": "smart" } ] } [/block] In the "*PulsateInboxActivity*" we will only load our "*pulsate_inbox.xml*". [block:code] { "codes": [ { "code": "public class PulsateInboxActivity extends Activity {\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.pulsate_inbox);\n }\n}", "language": "java" } ] } [/block] Instead of using "*manager.showFeed()*" you will need the code below to show the inbox: [block:code] { "codes": [ { "code": "Intent intent = new Intent();\nintent.setClass(MyActivity.this, PulsateInboxActivity.class);\nstartActivity(intent);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "2. Create pulsate_inbox.xml" } [/block] [block:code] { "codes": [ { "code": " <fragment\n android:name=\"com.pulsatehq.internal.inbox.InboxFragment\"\n android:id=\"@+id/inbox_fragment_container\" />\n <RelativeLayout\n android:id=\"@+id/card_fragment_container\">", "language": "xml", "name": "fragment" } ] } [/block] Your "*pulsate_inbox.xml*" layout must always contain these two elements. You can set the width, height and position of these elements to anything that suits you. You can also add other elements. [block:callout] { "type": "danger", "body": "The ids must be \"*android:id=\"@+id/inbox_fragment_container\"*\" and \"*android:id=\"@+id/card_fragment_container\"*\". \nThe fragment name also must be \"*android:name=\"com.pulsatehq.internal.inbox.InboxFragment\"*\"." } [/block] Example of using fragments: [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:orientation=\"horizontal\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:fitsSystemWindows=\"true\">\n <fragment\n android:layout_weight=\"1\"\n android:name=\"com.pulsatehq.internal.inbox.InboxFragment\"\n android:id=\"@+id/inbox_fragment_container\"\n android:layout_width=\"0dp\"\n android:layout_height=\"match_parent\" />\n <RelativeLayout\n android:layout_weight=\"1\"\n android:layout_width=\"0dp\"\n android:layout_height=\"match_parent\"\n android:id=\"@+id/card_fragment_container\">\n <TextView\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:text=\"HELLO HELLO\"\n android:layout_centerVertical=\"true\"\n android:layout_centerHorizontal=\"true\" />\n </RelativeLayout>\n</LinearLayout>", "language": "xml" } ] } [/block] This will create us a layout that looks like this: [block:image] { "images": [ { "image": [ "https://files.readme.io/ZKl3jalQoeMrv1c91HkY_inbox.png", "inbox.png", "1920", "1080", "#0c84fb", "" ] } ] } [/block] The inbox is shown in the "*inbox_fragment_container*". When clicking a card it will show up in the "*card_fragment_container*". In our example when we click a card the layout will look like this: [block:image] { "images": [ { "image": [ "https://files.readme.io/KxqzfN85Q0uCAYUap9st_inbox2.png", "inbox2.png", "1920", "1080", "#0d83fb", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Recommended layouts" } [/block] Recommended layout for phones [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:orientation=\"horizontal\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:fitsSystemWindows=\"true\">\n <fragment\n android:name=\"com.pulsatehq.internal.inbox.InboxFragment\"\n android:id=\"@+id/inbox_fragment_container\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\" />\n <RelativeLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:id=\"@+id/card_fragment_container\">\n </RelativeLayout>\n</RelativeLayout>", "language": "xml" } ] } [/block] Recommended layout for tablets [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:orientation=\"horizontal\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:fitsSystemWindows=\"true\">\n <fragment\n android:layout_weight=\"1\"\n android:name=\"com.pulsatehq.internal.inbox.InboxFragment\"\n android:id=\"@+id/inbox_fragment_container\"\n android:layout_width=\"0dp\"\n android:layout_height=\"match_parent\" />\n <RelativeLayout\n android:background=\"@color/pulsate_feed_background_color\"\n android:layout_weight=\"1\"\n android:layout_width=\"0dp\"\n android:layout_height=\"match_parent\"\n android:id=\"@+id/card_fragment_container\">\n </RelativeLayout>\n</LinearLayout>", "language": "xml" } ] } [/block]