{"id":20832481,"url":"https://github.com/codetanzania/open311-android-library","last_synced_at":"2025-12-26T06:14:32.663Z","repository":{"id":91615673,"uuid":"104496628","full_name":"CodeTanzania/open311-android-library","owner":"CodeTanzania","description":"This is a library that can be easily ported into any android project that wishes to use the CodeTanzania/open311-api","archived":false,"fork":false,"pushed_at":"2017-12-22T11:53:09.000Z","size":534,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-01-18T20:59:10.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeTanzania.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-22T16:38:41.000Z","updated_at":"2017-12-03T20:46:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"48bba32b-39b1-4937-b3d5-9acccf53696a","html_url":"https://github.com/CodeTanzania/open311-android-library","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fopen311-android-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fopen311-android-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fopen311-android-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeTanzania%2Fopen311-android-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeTanzania","download_url":"https://codeload.github.com/CodeTanzania/open311-android-library/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243183057,"owners_count":20249728,"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-11-18T00:12:00.233Z","updated_at":"2025-12-26T06:14:32.629Z","avatar_url":"https://github.com/CodeTanzania.png","language":"Java","readme":"*(Updated December 8, 2017)*\n\n# open311-android-library **_(WIP)_**\n\n[![Build Status](https://travis-ci.org/CodeTanzania/open311-android-library.svg?branch=develop)](https://travis-ci.org/CodeTanzania/open311-android-library)\n\nThis is a library that can be easily ported into any android project that wishes to use the CodeTanzania/open311-api\n\n**_At present, this library is in development._**\n\nCurrently there are three modules:\n- The `library-core` module contains the data models, network calls, and local db logic that is used to fetch and cache data for offline use from the majifix api. \n- The `library-ui` module depends on the `library-core` module, and contains useful ui components, that can be used out of the box. These ui elements will be able to be customized to match the app theme (still in development).\n- The `sample-app` module is a sample app that shows the `library-ui` functionality. It consists of a simple home screen with buttons that will take you to different `libarary-ui` activities.\n\nWe are using JavaRX and Retrofit to make network calls, and storing data locally using MYSQL (soon to switch to Room). Unit testing is done via Roboelectric. We hope that eventually the library will contain all of the logic and activities needed to submit an issue, update an issue, and view submitted issues, online and off.\n\n## Great! How do I use it?\n\nTwo .aar's are hosted on jitpack and can be incorporated into any project that wishes to access an open311-api fork.\n\nTo use this library in your project:\n\n### A) Add dependancy\n\n**1. Add jitpack to your highest level `build.gradle`.**\n\n    allprojects {\n        repositories {\n            jcenter()\n            maven { url \"https://jitpack.io\" }\n        }\n    }\n\n**2. Add the correct library to your app module `build.gradle`.** \n\nFor core functionality (Includes only `library-core` module):\n\n    dependencies {\n        compile 'com.github.CodeTanzania.open311-android-library:library-core:VERSION'\n    }\n    \nFor ui elements (Includes both `library-core` and `library-ui` modules):\n\n    dependencies {\n        compile 'com.github.CodeTanzania.open311-android-library:library-ui:VERSION'\n    }\n\n\nTo see all available versions: https://jitpack.io/#CodeTanzania/open311-android-library*\n\n**NOTE:** *Development is still in progress. To see the latest version of the library replace `VERSION` with `develop-SNAPSHOT`, and add the following to your `build.gradle` to ensure you always have the latest:*\n\n    configurations.all {\n       resolutionStrategy.cacheChangingMOdulesFor 0, 'seconds'\n    }\n\n\n\n\n### B) Configure Library\n\nAdd the base endpoint of the MajiFix API endpoint to `build.gradle`:\n\n```\nandroid {\n    defaultConfig {\n        buildConfigField(\"String\", \"END_POINT\", \"{YOUR_ENDPOINT_HERE}\")\n    }\n}\n```\n\nConfigure and Initialize the library in your application class, or sometime prior to use:\n```\nMajiFix.setup(getApplicationContext());\n```       \nCurrently, `setup` initializes the `Auth` module which ensures proper login and api token management, and makes an initial call to get issue `Categories` (\"services\" according to the MajiFix API and the 311 standard), which are  cached for later use. As development continues, this setup call will be used for a variety of other configuration tasks. \n\n### C) Make Magic! \n\nWhat sort of magic might you ask? Hopefully the sort that increases citizen feedback, institutional capacity, transparancy, blah, de blah, de blah... For example:\n\n# Submitting issues\n\n#####Library-Core\n\nThe `ReportService` can be used to post a new `Problem` to the api. \n\nTo use it directly, create a `Problem` using the `Problem.Builder`. The builder will ensure that all fields required by the api are set. When the Problem is created, call: \n```\nReportService.postNewProblem(activity, problem);\n``` \nWhen the network call has completed, result will be broadcast by the `EventHandler`. Listen for the network response like so:\n\n```\nLocalBroadcastManager.getInstance(this).registerReceiver(new BroadcastReceiver() {\n            @Override\n            public void onReceive(Context context, Intent intent) {\n                if (intent.getBooleanExtra(EventHandler.IS_SUCCESS, false)) {\n                    Problem posted = intent.getParcelableExtra(EventHandler.PROBLEM_INTENT);\n                    // handle success logic here\n                } else {\n                    // handle failure logic here\n                }\n            }\n        },\n        new IntentFilter(EventHandler.BROADCAST_REPORT_RECIEVED));\n```\n\nTo avoid memory leaks, do not forget to stop listening for Broadcasts in `onPause` or `onDestroy`.\n\n```\nLocalBroadcastManager.getInstance(activity).unregisterReceiver(myBroadcastReciever);\n```\n\n#####Library-Ui\n\nTo add a report form to your project, just start a `ReportProblemActivity`.  \n```\nIntent startReportIntent = new Intent(this, ReportProblemActivity.class);\nstartActivity(startReportIntent);\n```\nIf user is not logged in, this activity will show input fields for name and phone number, otherwise these fields will be automatically set and hidden.\n\n# Seeing Submitted Issues\n#####Library-Core\nThe `ReportService` can be used to fetch problems that were reported by a given phone number. To see it work, just call: \n```\nReportService.fetchProblems(context, phoneNumber);\n``` \nThe service will, in parallel, attempt to retrieve reported problems from the local MYSQL database, and make a api call. If problems are returned from the db, `isPreliminary` will be true. If problems are returned from the server, `isPreliminary` will be false.\n\nIf `Auth.getIstance().isLogin()`, the ApiToken of the logged in party will be used, otherwise, a default app token will be used to retrieve list.\n\nWhen the network call has completed, result will be broadcast by the `EventHandler`, similar to when posting. Listen for the network response like so:\n\n```\nLocalBroadcastManager.getInstance(getBaseContext()).registerReceiver(new BroadcastReceiver() {\n            @Override\n            public void onReceive(Context context, Intent intent) {\n                // preliminary flag is true if this data is coming from the local db and false if this data is coming from the server\n                boolean isPreliminary = intent.getBooleanExtra(EventHandler.IS_PRELIMINARY_DATA,false);\n                if (intent.getBooleanExtra(EventHandler.IS_SUCCESS, false)) {\n                    ArrayList\u003cProblem\u003e problems = intent.getParcelableArrayListExtra(EventHandler.REQUEST_LIST);\n                    // show problem list\n                } else {\n                    // show error\n                }\n            }\n        }, new IntentFilter(EventHandler.BROADCAST_MY_PROBLEMS_FETCHED));\n```\n\nTo avoid memory leaks, do not forget to stop listening for Broadcasts in `onPause` or `onDestroy`.\n\n```\nLocalBroadcastManager.getInstance(activity).unregisterReceiver(myBroadcastReciever);\n```\n\n\n#####Library-Core\n\n\nA `ProblemListActivity` can be used to see a list of Problems. Problems are displayed in a `ViewPager` with tabs to distinguish between `Open` and `Closed` issues. If no issues are found, an `EmptyFragment` is displayed, encouraging the user to report their first issue.\n\nRight now, `ProblemListActivity` is a child of `SecureCompatActivity` and is hardcoded to fetch the issues of a logged in user. The `SecureCompatActivity` will automatically direct users to the `SignInActivity` if not logged in or if API token has expired.\n\nClicking the `Fab` will redirect the user to the `ReportIssueActivity`. A a click on a problem list item will open a simple `ProblemDetailActivity`. In the future, this class is likely to be abstract, and the client app will be asked to provide a fetch data method and the relevant click listeners.\n\nWant to try it out? Just call:\n```\nIntent startReportIntent = new Intent(this, ProblemListActivity.class);\nstartActivity(startReportIntent);\n```\n\n\n# Sign In\n#####Library-Core\nDocumentation coming soon...\n#####Library-Ui\nDocumentation coming soon...\n\n# In Conclusion:\n\nIt is still the early days... I appreciate feedback and contributions. I will try to keep this README updated on a regular basis, but I'll admit, like many developers, sometimes I get behind on my documentation. \n\n## Want to contribute?\n\nWe are using gitflow to manage this project. Please see https://github.com/nvie/gitflow for more details.\nThere are tasks in development by the Tanzanian team. \n\nFor more information take a look at our Taiga board: https://tree.taiga.io/project/krtonga-majifix/us/64?kanban-status=1396627\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2017 CodeTanzania \u0026 Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodetanzania%2Fopen311-android-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodetanzania%2Fopen311-android-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodetanzania%2Fopen311-android-library/lists"}