diff --git a/.komment/00000.json b/.komment/00000.json index e4ec29b..5240bf4 100644 --- a/.komment/00000.json +++ b/.komment/00000.json @@ -715,5 +715,661 @@ ] } } + }, + { + "name": "TabsPagerAdapter.java", + "path": "client/src/main/java/io/sensable/client/adapter/TabsPagerAdapter.java", + "content": { + "structured": { + "description": "A custom FragmentPagerAdapter that provides fragments for a tabbed interface with three tabs: FavouriteSensablesFragment, LocalSensablesFragment, and RemoteSensablesFragment. The adapter uses Android's support package v4 and extends FragmentPagerAdapter to manage the fragments. It determines which fragment to display based on its index and returns an instance of one of these three fragments accordingly.", + "diagram": { + "gviz": "digraph G {\n bgcolor=\"#151719\"\n fontcolor=\"#ECEDED\"\n splines=ortho\n fontname=\"Courier New\"\n edge [color=\"#26de81\"]\n node [style=filled,color=\"#717D86\", shape=rectangle, fontname=\"Courier New\"]\n \n FragmentPagerAdapter [label=\"android.support.v4.app.FragmentPagerAdapter\", style=\"rounded,filled\"]\n RemoteSensablesFragment []\n FavouriteSensablesFragment []\n Fragment [label=\"android.support.v4.app.Fragment\", style=\"rounded,filled\"]\n MainActivity []\n FragmentManager [label=\"android.support.v4.app.FragmentManager\", style=\"rounded,filled\"]\n LocalSensablesFragment []\n subgraph cluster_main {\n // style=filled\n color=\"#00000000\"\n TabsPagerAdapter [] [fontsize=\"20pt\",style=filled,color=\"#26de81\",shape=square, fontname=\"Courier New\"]\n label = \"\"\n }\n TabsPagerAdapter -> Fragment [penwidth=1]\n TabsPagerAdapter -> FragmentManager [style=\"dashed\"]\n TabsPagerAdapter -> FragmentPagerAdapter [style=\"dashed\"]\n MainActivity -> TabsPagerAdapter [style=\"dashed\"]\n TabsPagerAdapter -> FavouriteSensablesFragment [style=\"dashed\"]\n FragmentManager -> TabsPagerAdapter [penwidth=1]\n TabsPagerAdapter -> Fragment [style=\"dashed\"]\n TabsPagerAdapter -> LocalSensablesFragment [style=\"dashed\"]\n TabsPagerAdapter -> RemoteSensablesFragment [style=\"dashed\"]\n}\n", + "d2": "ioandroidsensablesupportclientv4MainActivityadapterappviewsTabsPagerAdapterFragmentFragmentManagerFragmentPagerAdapterFavouriteSensablesFragmentLocalSensablesFragmentRemoteSensablesFragment importsimportsimportsimportsimportsimportsimports\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", + "d2_src": "direction: down\n\nvars: {\n d2-config: {\n pad: 0\n theme-overrides: {\n B1: \"#717D86\"\n B2: \"#717D86\"\n B3: \"#ffff00\"\n B4: \"#151719\"\n B5: \"#151719\"\n B6: \"#151719\"\n N1: \"#ECEDED\"\n N7: \"#151719\"\n AA2: \"#ECEDED\"\n }\n }\n}\n\nstyle: {\n fill: \"#151719\"\n}\nio.sensable.client.MainActivity -> io.sensable.client.adapter.TabsPagerAdapter: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> android.support.v4.app.Fragment: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> android.support.v4.app.FragmentManager: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> android.support.v4.app.FragmentPagerAdapter: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> io.sensable.client.views.FavouriteSensablesFragment: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> io.sensable.client.views.LocalSensablesFragment: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> io.sensable.client.views.RemoteSensablesFragment: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nandroid.support.v4.app.FragmentManager -> io.sensable.client.adapter.TabsPagerAdapter: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter -> android.support.v4.app.Fragment: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nandroid.support.v4.app.Fragment: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.support.v4.app.FragmentManager: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.support.v4.app.FragmentPagerAdapter: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nio.sensable.client.views.LocalSensablesFragment: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.views.FavouriteSensablesFragment: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.views.RemoteSensablesFragment: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nandroid.support.v4.app.FragmentManager: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nandroid.support.v4.app.Fragment: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.MainActivity: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.adapter.TabsPagerAdapter: {\n style: {\n fill: \"#26de81\"\n font-color: \"#151719\"\n stroke-width: 0\n }\n}\n" + }, + "items": [ + { + "id": "5521e0f6-72bb-d9a2-7243-da03618ff2e4", + "ancestors": [], + "description": "Is an extension of FragmentPagerAdapter that provides fragments for a tabbed interface with three tabs. It determines the type of fragment to display based on its index and returns a reference to a Fragment object representing one of four different activity types. The class retrieves the count of items by calculating the number of tabs and returns it as an integer value.", + "name": "TabsPagerAdapter", + "location": { + "start": 18, + "insert": 13, + "offset": " ", + "indent": 0, + "comment": { + "start": 12, + "end": 17 + } + }, + "item_type": "class", + "length": 68, + "docLength": 5 + }, + { + "id": "a5f7974a-1354-4388-8b48-2e3fb24b3b71", + "ancestors": [ + "5521e0f6-72bb-d9a2-7243-da03618ff2e4" + ], + "description": "Returns a specific fragment based on the provided index. It uses a switch statement to determine which fragment to return, with options for Top Rated, Games, and Movies.", + "params": [ + { + "name": "index", + "type_name": "int", + "description": "0-based index of the fragment to be returned, determining which type of fragment is created and returned based on the value.", + "complex_type": false + } + ], + "returns": { + "type_name": "Fragment", + "description": "a fragment instance based on the input index.\n\nThe returned output is a fragment object which can be one out of three possible fragments - FavouriteSensablesFragment, LocalSensablesFragment or RemoteSensablesFragment - based on the input index.", + "complex_type": true + }, + "usage": { + "language": "java", + "code": "TabsPagerAdapter pagerAdapter = new TabsPagerAdapter(getSupportFragmentManager());\nFragment fragment = pagerAdapter.getItem(0);\n", + "description": "" + }, + "name": "getItem", + "location": { + "start": 49, + "insert": 24, + "offset": " ", + "indent": 4, + "comment": { + "start": 23, + "end": 48 + } + }, + "item_type": "method", + "length": 17, + "docLength": 25 + }, + { + "id": "af8aa251-d90c-1ba0-8248-105204cdb389", + "ancestors": [ + "5521e0f6-72bb-d9a2-7243-da03618ff2e4" + ], + "description": "Returns an integer value indicating the total number of items. In this case, it consistently returns a fixed value of 3, implying that there are always three tabs being counted. This function provides a count of the number of items available for display or processing.", + "params": [], + "returns": { + "type_name": "integer", + "description": "an integer value, specifically 3.", + "complex_type": false + }, + "usage": { + "language": "java", + "code": "TabsPagerAdapter adapter = new TabsPagerAdapter(getSupportFragmentManager());\nViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);\nviewPager.setAdapter(adapter);", + "description": "" + }, + "name": "getCount", + "location": { + "start": 79, + "insert": 67, + "offset": " ", + "indent": 4, + "comment": { + "start": 66, + "end": 78 + } + }, + "item_type": "method", + "length": 5, + "docLength": 12 + } + ] + } + } + }, + { + "name": "SensorHelper.java", + "path": "client/src/main/java/io/sensable/client/SensorHelper.java", + "content": { + "structured": { + "description": "A class named SensorHelper which provides utility methods for determining the unit of measurement and image resource based on different types of sensors. It uses Android's hardware sensor API to map sensor types to corresponding units of measurement or image resources. The determineUnit method returns the appropriate unit of measurement for a given sensor type, while the determineImage method returns an image resource ID based on the sensor type.", + "diagram": { + "gviz": "digraph G {\n bgcolor=\"#151719\"\n fontcolor=\"#ECEDED\"\n splines=ortho\n fontname=\"Courier New\"\n edge [color=\"#26de81\"]\n node [style=filled,color=\"#717D86\", shape=rectangle, fontname=\"Courier New\"]\n \n subgraph cluster_1 {\n label=\"android\"\n color=\"#33363A\"\n Sensor [label=\"android.hardware.Sensor\", style=\"rounded,filled\"]\n }\n subgraph cluster_3 {\n label=\"io/sensable\"\n color=\"#33363A\"\n subgraph cluster_main {\n // style=filled\n color=\"#00000000\"\n SensorHelper [] [fontsize=\"20pt\",style=filled,color=\"#26de81\",shape=square, fontname=\"Courier New\"]\n label = \"\"\n }\n subgraph cluster_4 {\n label=\"client\"\n color=\"#33363A\"\n ScheduledSensableService []\n SensableListAdapter []\n }\n }\n SensableListAdapter -> SensorHelper [style=\"dashed\"]\n ScheduledSensableService -> SensorHelper [style=\"dashed\"]\n SensorHelper -> Sensor [style=\"dashed\"]\n}\n", + "d2": "ioandroidsensablehardwareclientSensorSensorHelperschedulerviewsScheduledSensableServiceSensableListAdapter importsimportsimports\n\n\n\n\n\n\n\n\n\n\n\n\n\n", + "d2_src": "direction: down\n\nvars: {\n d2-config: {\n pad: 0\n theme-overrides: {\n B1: \"#717D86\"\n B2: \"#717D86\"\n B3: \"#ffff00\"\n B4: \"#151719\"\n B5: \"#151719\"\n B6: \"#151719\"\n N1: \"#ECEDED\"\n N7: \"#151719\"\n AA2: \"#ECEDED\"\n }\n }\n}\n\nstyle: {\n fill: \"#151719\"\n}\nio.sensable.client.SensorHelper -> android.hardware.Sensor: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.scheduler.ScheduledSensableService -> io.sensable.client.SensorHelper: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.views.SensableListAdapter -> io.sensable.client.SensorHelper: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nandroid.hardware.Sensor: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nio.sensable.client.SensorHelper: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.views.SensableListAdapter: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.scheduler.ScheduledSensableService: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.SensorHelper: {\n style: {\n fill: \"#26de81\"\n font-color: \"#151719\"\n stroke-width: 0\n }\n}\n" + }, + "items": [ + { + "id": "eb5e7d50-c664-f29e-954e-adf4d2cf16e6", + "ancestors": [], + "description": "Provides a way to determine the unit of measurement and appropriate drawable resource for various types of sensors based on their names. It contains three methods: `determineUnit`, which returns the unit of measurement for a given sensor type; `determineImage(int)`, which determines an image resource based on a sensor type using a switch statement; and `determineImage(String)`, which determines the appropriate drawable resource for a given sensor type based on its name.", + "name": "SensorHelper", + "location": { + "start": 15, + "insert": 8, + "offset": " ", + "indent": 0, + "comment": { + "start": 7, + "end": 14 + } + }, + "item_type": "class", + "length": 192, + "docLength": 7 + }, + { + "id": "37c66821-7a50-8885-8a47-ca3c754a4454", + "ancestors": [ + "eb5e7d50-c664-f29e-954e-adf4d2cf16e6" + ], + "description": "Maps a given sensor type to its corresponding measurement unit, returning the unit as a string. The mapping is performed through a switch statement that covers various sensor types, each associated with a specific unit.", + "params": [ + { + "name": "sensorType", + "type_name": "int", + "description": "type of sensor, determining which measurement unit is returned based on its value.", + "complex_type": false + } + ], + "returns": { + "type_name": "String", + "description": "a string representing the unit of measurement for a given sensor type.", + "complex_type": false + }, + "name": "determineUnit", + "location": { + "start": 29, + "insert": 17, + "offset": " ", + "indent": 4, + "comment": { + "start": 16, + "end": 28 + } + }, + "item_type": "method", + "length": 53, + "docLength": 12 + }, + { + "id": "8445ee28-5e2b-7d9c-4f4b-2a9ab0a88bf6", + "ancestors": [ + "eb5e7d50-c664-f29e-954e-adf4d2cf16e6" + ], + "description": "Maps a given sensor type to a corresponding image resource ID. It uses a switch statement to match the input sensor type with a predefined set of cases, assigning an image ID accordingly and returning it.", + "params": [ + { + "name": "sensorType", + "type_name": "int", + "description": "type of sensor being used, and it determines which image to return based on its value.", + "complex_type": false + } + ], + "returns": { + "type_name": "int", + "description": "a drawable integer resource ID.", + "complex_type": false + }, + "name": "determineImage", + "location": { + "start": 94, + "insert": 83, + "offset": " ", + "indent": 4, + "comment": { + "start": 82, + "end": 93 + } + }, + "item_type": "method", + "length": 53, + "docLength": 11 + }, + { + "id": "9a4c9bd7-7c26-02ad-124f-a1f19749486a", + "ancestors": [ + "eb5e7d50-c664-f29e-954e-adf4d2cf16e6" + ], + "description": "Maps a sensor type to an associated image based on the input string, taking into account both exact matches and containing substrings. It returns the corresponding image resource ID as an integer.", + "params": [ + { + "name": "sensorType", + "type_name": "String", + "description": "type of sensor to be displayed, which determines the corresponding image to be returned by the function.", + "complex_type": false + } + ], + "returns": { + "type_name": "integer", + "description": "an integer resource ID corresponding to a specific sensor type.\n\nThe output is an integer representing the resource ID of an image drawable in the R.drawable class. It can take various values such as type_lux, type_accelerometer, type_magnetic and so on.", + "complex_type": true + }, + "name": "determineImage", + "location": { + "start": 158, + "insert": 148, + "offset": " ", + "indent": 4, + "comment": { + "start": 147, + "end": 157 + } + }, + "item_type": "method", + "length": 47, + "docLength": 10 + } + ] + } + } + }, + { + "name": "SensableUser.java", + "path": "client/src/main/java/io/sensable/client/SensableUser.java", + "content": { + "structured": { + "description": "A class called SensableUser that handles user authentication and settings retrieval in an Android application using Retrofit, a popular REST client for Java. It provides methods for login, logout, retrieving user settings, saving user information to preferences, and deleting saved user information. The class uses SharedPreferences to store user data locally on the device.", + "diagram": { + "gviz": "digraph G {\n bgcolor=\"#151719\"\n fontcolor=\"#ECEDED\"\n splines=ortho\n fontname=\"Courier New\"\n edge [color=\"#26de81\"]\n node [style=filled,color=\"#717D86\", shape=rectangle, fontname=\"Courier New\"]\n \n subgraph cluster_1 {\n label=\"sensable\"\n color=\"#33363A\"\n UserLogin []\n User []\n subgraph cluster_main {\n // style=filled\n color=\"#00000000\"\n SensableUser [] [fontsize=\"20pt\",style=filled,color=\"#26de81\",shape=square, fontname=\"Courier New\"]\n label = \"\"\n }\n subgraph cluster_2 {\n label=\"client\"\n color=\"#33363A\"\n ScheduledSensableService []\n }\n }\n Context [label=\"android.content.Context\", style=\"rounded,filled\"]\n RestAdapter [label=\"retrofit.RestAdapter\", style=\"rounded,filled\"]\n Response [label=\"retrofit.client.Response\", style=\"rounded,filled\"]\n RetrofitError [label=\"retrofit.RetrofitError\", style=\"rounded,filled\"]\n CookieHandler [label=\"java.net.CookieHandler\", style=\"rounded,filled\"]\n SharedPreferences [label=\"android.content.SharedPreferences\", style=\"rounded,filled\"]\n CookieManager [label=\"java.net.CookieManager\", style=\"rounded,filled\"]\n Log [label=\"android.util.Log\", style=\"rounded,filled\"]\n SensableService []\n CookiePolicy [label=\"java.net.CookiePolicy\", style=\"rounded,filled\"]\n Callback [label=\"retrofit.Callback\", style=\"rounded,filled\"]\n SensableUser -> UserLogin [style=\"dashed\"]\n SensableUser -> CookieManager [style=\"dashed\"]\n SensableUser -> Callback [style=\"dashed\"]\n SensableUser -> CookieHandler [style=\"dashed\"]\n Context -> SensableUser [penwidth=1]\n SensableUser -> User [style=\"dashed\"]\n User -> SensableUser [penwidth=2]\n SensableUser -> RetrofitError [style=\"dashed\"]\n SensableUser -> CookiePolicy [style=\"dashed\"]\n Response -> SensableUser [penwidth=2]\n UserLogin -> SensableUser [penwidth=1]\n SensableUser -> Response [style=\"dashed\"]\n ScheduledSensableService -> SensableUser [style=\"dashed\"]\n SensableUser -> Log [style=\"dashed\"]\n SensableUser -> Context [style=\"dashed\"]\n SensableUser -> RestAdapter [style=\"dashed\"]\n SensableUser -> SharedPreferences [style=\"dashed\"]\n SharedPreferences -> SensableUser [penwidth=1]\n RetrofitError -> SensableUser [penwidth=2]\n SensableUser -> SensableService [style=\"dashed\"]\n}\n", + "d2": "ioandroidretrofitjavasensablecontentutilCallbackRestAdapterRetrofitErrorclientnetclientContextSharedPreferencesLogSensableServicemodelResponseCookieHandlerCookieManagerCookiePolicySensableUserUserUserLoginschedulerScheduledSensableService importsimportsimportsimportsimportsimportsimportsimportsimportsimportsimportsimportsimportsimports\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", + "d2_src": "direction: down\n\nvars: {\n d2-config: {\n pad: 0\n theme-overrides: {\n B1: \"#717D86\"\n B2: \"#717D86\"\n B3: \"#ffff00\"\n B4: \"#151719\"\n B5: \"#151719\"\n B6: \"#151719\"\n N1: \"#ECEDED\"\n N7: \"#151719\"\n AA2: \"#ECEDED\"\n }\n }\n}\n\nstyle: {\n fill: \"#151719\"\n}\nio.sensable.client.SensableUser -> android.content.Context: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> android.content.SharedPreferences: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> android.util.Log: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> io.sensable.SensableService: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> io.sensable.model.User: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> io.sensable.model.UserLogin: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> retrofit.Callback: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> retrofit.RestAdapter: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> retrofit.RetrofitError: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> retrofit.client.Response: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> java.net.CookieHandler: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> java.net.CookieManager: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensableUser -> java.net.CookiePolicy: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.scheduler.ScheduledSensableService -> io.sensable.client.SensableUser: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nandroid.content.Context -> io.sensable.client.SensableUser: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nandroid.content.SharedPreferences -> io.sensable.client.SensableUser: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nio.sensable.model.User -> io.sensable.client.SensableUser: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nio.sensable.model.UserLogin -> io.sensable.client.SensableUser: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nretrofit.RetrofitError -> io.sensable.client.SensableUser: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nretrofit.client.Response -> io.sensable.client.SensableUser: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nretrofit.RestAdapter: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.util.Log: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\njava.net.CookiePolicy: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nretrofit.client.Response: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.content.Context: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nretrofit.Callback: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\njava.net.CookieHandler: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.content.SharedPreferences: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\njava.net.CookieManager: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nretrofit.RetrofitError: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.content.SharedPreferences: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.model.UserLogin: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.SensableService: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.scheduler.ScheduledSensableService: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nretrofit.client.Response: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nandroid.content.Context: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.SensableUser: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nretrofit.RetrofitError: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.model.User: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.SensableUser: {\n style: {\n fill: \"#26de81\"\n font-color: \"#151719\"\n stroke-width: 0\n }\n}\n" + }, + "items": [ + { + "id": "6574ac94-cc72-8498-d040-6ca417fc74e3", + "ancestors": [], + "description": "Is responsible for handling user authentication and settings retrieval in an Android application. It provides functions to login, logout, retrieve user settings, and save user information to preferences. The class interacts with a backend API using Retrofit to authenticate users and update their status.", + "name": "SensableUser", + "location": { + "start": 27, + "insert": 21, + "offset": " ", + "indent": 0, + "comment": { + "start": 20, + "end": 26 + } + }, + "item_type": "class", + "length": 279, + "docLength": 6 + }, + { + "id": "458d1d28-ce3b-4ba9-1649-b38ade138d55", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3" + ], + "description": "Retrieves user preferences from shared preferences, such as username, email, and access token. If any of these values are present, it updates a user object with these values and sets a flag indicating whether an access token is available.", + "params": [], + "returns": { + "type_name": "boolean", + "description": "a boolean value indicating user login status.", + "complex_type": false + }, + "usage": { + "language": "java", + "code": "if(sensableUser.readUserFromPreferences()){\n // User is logged in\n Log.d(TAG, \"User is logged in\");\n} else {\n // User is not logged in\n Log.d(TAG, \"User is not logged in\");\n}\n", + "description": "" + }, + "name": "readUserFromPreferences", + "location": { + "start": 65, + "insert": 59, + "offset": " ", + "indent": 4, + "comment": { + "start": 58, + "end": 64 + } + }, + "item_type": "method", + "length": 21, + "docLength": 6 + }, + { + "id": "958b3d4b-05ff-9c9a-6b4d-24b85d73b907", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3" + ], + "description": "Performs a login request using the authentication service, and upon success, it sets user details, updates preferences, and notifies the callback interface about the login status update. Upon failure, it logs an error message to the console.", + "params": [ + { + "name": "userLogin", + "type_name": "UserLogin", + "description": "credentials to be used for login authentication and is passed to the `service.login()` method.\n\n", + "complex_type": true + }, + { + "name": "cb", + "type_name": "MainActivity.CallbackInterface", + "description": "CallbackInterface object that notifies the login status update to the caller of the login method.\n\nCallbackInterface cb: It has a loginStatusUpdate method, which is called with a boolean parameter.", + "complex_type": true + } + ], + "usage": { + "language": "java", + "code": "UserLogin userLogin = new UserLogin();\nuserLogin.setUsername(\"username\");\nuserLogin.setEmail(\"email\");\n\nSensibleUser sensibleUser = new SensibleUser(sharedPreferences, context);\nsensibleUser.login(userLogin, new CallbackInterface() {\n @Override\n public void loginStatusUpdate(boolean loggedIn) {\n // Update UI based on the login status\n }\n});\n", + "description": "" + }, + "name": "login", + "location": { + "start": 122, + "insert": 87, + "offset": " ", + "indent": 4, + "comment": { + "start": 86, + "end": 121 + } + }, + "item_type": "method", + "length": 78, + "docLength": 35 + }, + { + "id": "387c1ee3-f249-ef9b-b440-1227d03cf59b", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3", + "958b3d4b-05ff-9c9a-6b4d-24b85d73b907" + ], + "description": "Updates a local user object with received data, sets login status to true if an access token is available, and calls a callback method to update login status. If no access token is present, it triggers another method for user settings.", + "params": [ + { + "name": "user", + "type_name": "User", + "description": "user's data, whose details such as username and email are retrieved to update the local user model.\n\nExtracted: \n- `getUsername()`: Returns a string representing the username.\n- `getEmail()`: Returns a string representing the email.\n- `getAccessToken()`: Returns a possibly null token.", + "complex_type": true + }, + { + "name": "response", + "type_name": "Response", + "description": "response from the server to the login request, but it is not used within the function as its value is ignored.\n\nThe `response` object contains no relevant data or methods within its scope, serving only as a generic callback parameter.", + "complex_type": true + } + ], + "usage": { + "language": "java", + "code": "service.login(new UserLogin(\"username\", \"email\"), new CallbackInterface() {\n @Override\n public void loginStatusUpdate(boolean loggedIn) {\n\n }\n\n @Override\n public void failure(RetrofitError retrofitError) {\n\n }\n});\n", + "description": "\nIn this example, a `UserLogin` object with username and email is passed to the `login` method. The callback interface is implemented with two methods: `loginStatusUpdate` and `failure`." + }, + "name": "success", + "location": { + "start": 161, + "insert": 125, + "offset": " ", + "indent": 12, + "comment": { + "start": 124, + "end": 160 + } + }, + "item_type": "method", + "length": 22, + "docLength": 36 + }, + { + "id": "37524a6e-4f5c-2795-5d4a-85ec87aa78f2", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3", + "958b3d4b-05ff-9c9a-6b4d-24b85d73b907" + ], + "description": "Handles failures when attempting to perform a login operation using Retrofit. It logs an error message with the error details to the Android log using the specified tag, indicating that the login callback has failed.", + "params": [ + { + "name": "retrofitError", + "type_name": "RetrofitError", + "description": "error that occurred during the API call.", + "complex_type": false + } + ], + "usage": { + "language": "java", + "code": "@Override\npublic void onFailure(RetrofitError retrofitError) {\n Log.e(TAG, \"Login callback failure\" + retrofitError.toString());\n}\n", + "description": "\nExample input: \nretrofitError: RetrofitError" + }, + "name": "failure", + "location": { + "start": 194, + "insert": 184, + "offset": " ", + "indent": 12, + "comment": { + "start": 183, + "end": 193 + } + }, + "item_type": "method", + "length": 4, + "docLength": 10 + }, + { + "id": "1b71c94b-e0c8-55a5-7b40-e4f728d2cd8f", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3" + ], + "description": "Retrieves user settings from a login API, updates the local user object with received information, and saves it to preferences if an access token is provided. It handles successful responses by updating the user details and saving them, and failed responses by logging errors.", + "params": [], + "usage": { + "language": "java", + "code": "SensableUser sensableUser = new SensableUser(sharedPreferences, context);\nsensableUser.userSettings();\n", + "description": "" + }, + "name": "userSettings", + "location": { + "start": 205, + "insert": 201, + "offset": " ", + "indent": 4, + "comment": { + "start": 200, + "end": 204 + } + }, + "item_type": "method", + "length": 63, + "docLength": 4 + }, + { + "id": "d74742bd-2364-b298-4847-f7ab2e0dbe32", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3", + "1b71c94b-e0c8-55a5-7b40-e4f728d2cd8f" + ], + "description": "Handles a successful login operation by updating local user data, setting login status to true, and saving the access token if provided. It logs relevant information, such as user credentials and access token, for debugging purposes.", + "params": [ + { + "name": "user", + "type_name": "User", + "description": "authenticated user, whose properties such as username, email, and access token are updated and logged accordingly.\n\n* Username\n* Email\n* AccessToken", + "complex_type": true + }, + { + "name": "response", + "type_name": "Response", + "description": "response from the authentication service, which is not used within the method.\n\nThe response has no explicit properties mentioned, implying that it may be an object or a class with default constructors. However, based on its presence in the method signature, it likely contains information about the success status and possibly other details related to user authentication.", + "complex_type": true + } + ], + "usage": { + "language": "java", + "code": "User user = new User();\nuser.setUsername(\"username\");\nuser.setEmail(\"email@example.com\");\n\nservice.login(new UserLogin(user.getUsername(), user.getEmail()), new Callback() {\n @Override\n public void success(User result, Response response) {\n // The code provided will execute here.\n }\n\n @Override\n public void failure(RetrofitError retrofitError) {\n Log.e(TAG, \"Failure\" + retrofitError.toString());\n }\n});\n", + "description": "" + }, + "name": "success", + "location": { + "start": 230, + "insert": 208, + "offset": " ", + "indent": 12, + "comment": { + "start": 207, + "end": 229 + } + }, + "item_type": "method", + "length": 18, + "docLength": 22 + }, + { + "id": "d9482bae-c539-c1b0-0149-a1378449a5ac", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3", + "1b71c94b-e0c8-55a5-7b40-e4f728d2cd8f" + ], + "description": "Logs an error message with a given tag and Retrofit error when a login operation fails. The error message includes the `toString()` representation of the Retrofit error object.", + "params": [ + { + "name": "retrofitError", + "type_name": "RetrofitError", + "description": "exception thrown when a Retrofit request fails, providing details about the error.", + "complex_type": false + } + ], + "usage": { + "language": "java", + "code": "failure(new RetrofitError(\"Retrofit error message\", 400, null, null));\n", + "description": "" + }, + "name": "failure", + "location": { + "start": 262, + "insert": 249, + "offset": " ", + "indent": 12, + "comment": { + "start": 248, + "end": 261 + } + }, + "item_type": "method", + "length": 4, + "docLength": 13 + }, + { + "id": "0623fd0d-46c2-578f-4044-9500c8c9f7b6", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3" + ], + "description": "Logs the user's information and stores it in the device's preferences using SharedPreferences.Editor. It saves the username, email, and access token to designated keys in the preferences file. The changes are committed immediately after saving.", + "params": [], + "usage": { + "language": "java", + "code": "saveUserToPreferences();\n", + "description": "" + }, + "name": "saveUserToPreferences", + "location": { + "start": 273, + "insert": 269, + "offset": " ", + "indent": 4, + "comment": { + "start": 268, + "end": 272 + } + }, + "item_type": "method", + "length": 8, + "docLength": 4 + }, + { + "id": "a39d7079-444c-37be-3644-959b8b143c09", + "ancestors": [ + "6574ac94-cc72-8498-d040-6ca417fc74e3" + ], + "description": "Removes previously saved user credentials from SharedPreferences, resets the `mUser`, `loggedIn`, and `hasAccessToken` variables, and updates the login status through a callback interface.", + "params": [ + { + "name": "cb", + "type_name": "MainActivity.CallbackInterface", + "description": "CallbackInterface, which is used to notify the caller of the login status update after deleting saved user data.\n\nInterface: CallbackInterface\nType: final MainActivity.CallbackInterface", + "complex_type": true + } + ], + "usage": { + "language": "java", + "code": "deleteSavedUser(new CallbackInterface() {\n @Override\n public void loginStatusUpdate(boolean logged_in) {\n // update the UI based on the login status\n }\n});\n", + "description": "" + }, + "name": "deleteSavedUser", + "location": { + "start": 293, + "insert": 282, + "offset": " ", + "indent": 4, + "comment": { + "start": 281, + "end": 292 + } + }, + "item_type": "method", + "length": 11, + "docLength": 11 + } + ] + } + } + }, + { + "name": "SensorListActivity.java", + "path": "client/src/main/java/io/sensable/client/SensorListActivity.java", + "content": { + "structured": { + "description": "An Android ListActivity that displays a list of sensor types available on the device. It uses the SensorManager class from the android.hardware package to retrieve a list of all sensors and then creates a ArrayAdapter to display their names in a ListView. The activity also enables text filtering on the ListView.", + "diagram": { + "gviz": "digraph G {\n bgcolor=\"#151719\"\n fontcolor=\"#ECEDED\"\n splines=ortho\n fontname=\"Courier New\"\n edge [color=\"#26de81\"]\n node [style=filled,color=\"#717D86\", shape=rectangle, fontname=\"Courier New\"]\n \n subgraph cluster_1 {\n label=\"sensable\"\n color=\"#33363A\"\n subgraph cluster_main {\n // style=filled\n color=\"#00000000\"\n SensorListActivity [] [fontsize=\"20pt\",style=filled,color=\"#26de81\",shape=square, fontname=\"Courier New\"]\n label = \"\"\n }\n }\n List [label=\"java.util.List\", style=\"rounded,filled\"]\n ArrayList [label=\"java.util.ArrayList\", style=\"rounded,filled\"]\n Sensor [label=\"android.hardware.Sensor\", style=\"rounded,filled\"]\n ListActivity [label=\"android.app.ListActivity\", style=\"rounded,filled\"]\n SensorManager [label=\"android.hardware.SensorManager\", style=\"rounded,filled\"]\n Bundle [label=\"android.os.Bundle\", style=\"rounded,filled\"]\n Context [label=\"android.content.Context\", style=\"rounded,filled\"]\n ArrayAdapter [label=\"android.widget.ArrayAdapter\", style=\"rounded,filled\"]\n SensorListActivity -> List [style=\"dashed\"]\n SensorListActivity -> ArrayList [style=\"dashed\"]\n SensorListActivity -> ArrayAdapter [style=\"dashed\"]\n SensorListActivity -> ListActivity [style=\"dashed\"]\n SensorListActivity -> Sensor [style=\"dashed\"]\n Bundle -> SensorListActivity [penwidth=1]\n SensorListActivity -> Bundle [style=\"dashed\"]\n SensorListActivity -> SensorManager [style=\"dashed\"]\n SensorListActivity -> Context [style=\"dashed\"]\n}\n", + "d2": "ioandroidjavasensableappcontenthardwareoswidgetutilclientListActivityContextSensorSensorManagerBundleArrayAdapterArrayListListSensorListActivity importsimportsimportsimportsimportsimportsimportsimports\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", + "d2_src": "direction: down\n\nvars: {\n d2-config: {\n pad: 0\n theme-overrides: {\n B1: \"#717D86\"\n B2: \"#717D86\"\n B3: \"#ffff00\"\n B4: \"#151719\"\n B5: \"#151719\"\n B6: \"#151719\"\n N1: \"#ECEDED\"\n N7: \"#151719\"\n AA2: \"#ECEDED\"\n }\n }\n}\n\nstyle: {\n fill: \"#151719\"\n}\nio.sensable.client.SensorListActivity -> android.app.ListActivity: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> android.content.Context: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> android.hardware.Sensor: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> android.hardware.SensorManager: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> android.os.Bundle: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> android.widget.ArrayAdapter: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> java.util.ArrayList: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nio.sensable.client.SensorListActivity -> java.util.List: {\n target-arrowhead: \"imports\"\n style: {\n stroke: \"#26de81\"\n stroke-dash: 3\n }\n}\n\nandroid.os.Bundle -> io.sensable.client.SensorListActivity: {\n style: {\n stroke: \"#26de81\"\n }\n}\n\nandroid.hardware.Sensor: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.widget.ArrayAdapter: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\njava.util.List: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.hardware.SensorManager: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.content.Context: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.os.Bundle: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\njava.util.ArrayList: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nandroid.app.ListActivity: {\n style: {\n font: mono\n fill: \"#717D86\"\n border-radius: 100\n }\n}\n\nio.sensable.client.SensorListActivity: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nandroid.os.Bundle: {\n style: {\n font: mono\n fill: \"#717D86\"\n stroke-width: 0\n }\n}\n\nio.sensable.client.SensorListActivity: {\n style: {\n fill: \"#26de81\"\n font-color: \"#151719\"\n stroke-width: 0\n }\n}\n" + }, + "items": [ + { + "id": "3a994ce0-ec82-4a95-0e4f-64965f13c73e", + "ancestors": [], + "description": "Extends ListActivity to display a list of available sensors on an Android device. It retrieves a list of sensors using the SensorManager and populates a list view with their names. The activity enables text filtering on the list view for easy navigation.", + "name": "SensorListActivity", + "location": { + "start": 13, + "insert": 13, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "class", + "length": 44, + "docLength": null + }, + { + "id": "6a968fef-a466-4385-4348-e47fb88d7429", + "ancestors": [ + "3a994ce0-ec82-4a95-0e4f-64965f13c73e" + ], + "description": "Initializes a sensor manager and retrieves a list of all available sensors. It then creates an array adapter to display the names of these sensors as a list, allowing the user to filter the list by text input.", + "params": [ + { + "name": "savedInstanceState", + "type_name": "Bundle", + "description": "Bundle object that contains the data previously saved by the activity, which is used to restore its state after being recreated.\n\nBundle - contains key-value pairs representing the application's saved state; null by default if no data is provided.", + "complex_type": true + } + ], + "usage": { + "language": "java", + "code": "public class SensorListActivity extends ListActivity {\n public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n // ... rest of the code...\n }\n\n public static void main(String[] args) {\n Bundle savedInstanceState = new Bundle();\n SensorListActivity activity = new SensorListActivity();\n activity.onCreate(savedInstanceState);\n }\n}\n", + "description": "" + }, + "name": "onCreate", + "location": { + "start": 40, + "insert": 17, + "offset": " ", + "indent": 4, + "comment": { + "start": 16, + "end": 39 + } + }, + "item_type": "method", + "length": 16, + "docLength": 23 + } + ] + } + } } ] \ No newline at end of file diff --git a/.komment/komment.json b/.komment/komment.json index b58dcbd..a4bb9ba 100644 --- a/.komment/komment.json +++ b/.komment/komment.json @@ -1,17 +1,22 @@ { "meta": { "version": "1", - "updated_at": "2024-08-12T19:47:47.827Z", + "updated_at": "2024-08-12T20:40:47.143Z", "created_at": "2024-08-12T18:03:18.789Z", "pipelines": [ "5290e9fb-b07e-4f3a-b1dc-ade204499fa5", - "6ce8c123-10dc-4848-87ac-c2fd538e4116" + "6ce8c123-10dc-4848-87ac-c2fd538e4116", + "e3c5077a-79f2-4dd1-9c80-093fc7876e9c" ] }, "lookup": [ [ "client/src/main/java/io/sensable/client/adapter/ExpandableListAdapter.java", - "client/src/main/java/io/sensable/client/component/FontFitTextView.java" + "client/src/main/java/io/sensable/client/component/FontFitTextView.java", + "client/src/main/java/io/sensable/client/adapter/TabsPagerAdapter.java", + "client/src/main/java/io/sensable/client/SensorHelper.java", + "client/src/main/java/io/sensable/client/SensableUser.java", + "client/src/main/java/io/sensable/client/SensorListActivity.java" ] ] } \ No newline at end of file diff --git a/client/src/main/java/io/sensable/client/SensableUser.java b/client/src/main/java/io/sensable/client/SensableUser.java index 4b8bbf9..81a97b4 100644 --- a/client/src/main/java/io/sensable/client/SensableUser.java +++ b/client/src/main/java/io/sensable/client/SensableUser.java @@ -19,10 +19,10 @@ * Created by simonmadine on 12/07/2014. */ /** - * is responsible for handling user authentication and settings retrieval in an Android + * Is responsible for handling user authentication and settings retrieval in an Android * application. It provides functions to login, logout, retrieve user settings, and - * save the user's information to preferences. Additionally, it offers methods to - * delete the saved user information and update the login status. + * save user information to preferences. The class interacts with a backend API using + * Retrofit to authenticate users and update their status. */ public class SensableUser { @@ -57,10 +57,11 @@ public SensableUser(SharedPreferences sharedPreferences, Context context) { } /** - * retrieves user information from shared preferences and sets it to a `User` object, - * returning `true` if successful or `false` otherwise. - * - * @returns a boolean value indicating whether the user is logged in or not. + * Retrieves user preferences from shared preferences, such as username, email, and + * access token. If any of these values are present, it updates a user object with + * these values and sets a flag indicating whether an access token is available. + * + * @returns a boolean value indicating user login status. */ private boolean readUserFromPreferences() { String username = sharedPreferences.getString(context.getString(R.string.saved_username), ""); @@ -85,78 +86,40 @@ private boolean readUserFromPreferences() { } /** - * takes a `UserLogin` object and a `CallbackInterface` object as inputs, calls the - * service's login method to authenticate the user, and updates the user's data and - * saves it to preferences upon success. - * - * @param userLogin UserLogin object containing the login credentials of the user to - * be authenticated. - * - * - `userLogin`: This is an instance of the `UserLogin` class, which contains - * information about the user attempting to log in. - * + `username`: The username of the user attempting to log in. - * + `email`: The email address of the user attempting to log in. - * - * The function call is made to the `service` object's `login` method, passing in - * `userLogin` and a callback interface `cb`. The callback interface has two methods: - * `success` and `failure`. - * - * In the `success` method, if the login attempt is successful, the `User` object's - * properties are set to the deserialized response data, including the `username` and - * `email`. Additionally, the `loggedIn` flag is set to `true`, and the `accessToken` - * property is set to the `accessToken` property of the `User` object. Finally, the - * `saveUserToPreferences()` method is called to save the user's data to preferences. - * - * In the `failure` method, an error message is logged to the console if the login - * attempt fails. - * - * @param cb `CallbackInterface` that will receive updates on the login status. - * - * The `CallbackInterface cb` is an interface with two methods: `loginStatusUpdate(loggedIn)` - * and `failure(RetrofitError retrofitError)`. The `loginStatusUpdate` method is - * invoked when the login callback is successful, and it takes a boolean parameter - * `loggedIn` indicating whether the user is logged in or not. The `failure` method - * is invoked when there is an error during the login process, and it takes a - * `RetrofitError` object as its parameter. + * Performs a login request using the authentication service, and upon success, it + * sets user details, updates preferences, and notifies the callback interface about + * the login status update. Upon failure, it logs an error message to the console. + * + * @param userLogin credentials to be used for login authentication and is passed to + * the `service.login()` method. + * + * @param cb CallbackInterface object that notifies the login status update to the + * caller of the login method. + * + * CallbackInterface cb: It has a loginStatusUpdate method, which is called with a + * boolean parameter. */ public void login(UserLogin userLogin, final MainActivity.CallbackInterface cb) { service.login(userLogin, new Callback() { /** - * handles a successful login callback from the authentication service. It sets the - * user's username, email, and access token (if available), updates the user's - * preferences, and notifies the login status update to the callback interface. - * - * @param user login result, containing the user's username and email address. - * - * - `username`: The username of the user. - * - `email`: The email address of the user. - * - `accessToken`: An access token for the user. - * - * The `mUser` object is set to the deserialized `user` object, and various attributes - * of `mUser` are updated. Additionally, a call to `saveUserToPreferences()` is made - * to persist the user's data to preferences. Finally, the login status is updated - * using `cb.loginStatusUpdate(loggedIn)`. - * - * @param response response from the login API, which provides the user's authentication - * information. - * - * - `user`: A `User` object representing the authenticated user. - * - `accessToken`: The access token obtained from the authentication process, which - * can be used for further requests. - * - * The function performs the following actions: - * - * 1/ Logs a message to the debug log with the username of the successfully authenticated - * user. - * 2/ Sets the `username` and `email` properties of the `mUser` object to those of - * the `user` object. - * 3/ Sets the `loggedIn` property of the `mUser` object to `true`. - * 4/ Checks if an access token was obtained and, if so, sets the `accessToken` - * property of the `mUser` object to the obtained value. - * 5/ Calls the `saveUserToPreferences()` function to save the `mUser` object to user - * preferences. - * 6/ Updates the login status in the caller with the newly set `loggedIn` property. + * Updates a local user object with received data, sets login status to true if an + * access token is available, and calls a callback method to update login status. If + * no access token is present, it triggers another method for user settings. + * + * @param user user's data, whose details such as username and email are retrieved + * to update the local user model. + * + * Extracted: + * - `getUsername()`: Returns a string representing the username. + * - `getEmail()`: Returns a string representing the email. + * - `getAccessToken()`: Returns a possibly null token. + * + * @param response response from the server to the login request, but it is not used + * within the function as its value is ignored. + * + * The `response` object contains no relevant data or methods within its scope, serving + * only as a generic callback parameter. */ @Override public void success(User user, Response response) { @@ -182,14 +145,11 @@ public void success(User user, Response response) { } /** - * is called when a login request fails, and it logs an error message to the console - * using the `Log.e()` method. - * - * @param retrofitError error that occurred during the login callback, which is then - * logged with a message indicating the nature of the error. - * - * - `toString()`: Returns a string representation of the error object, which can - * be used for logging or display to the user. + * Handles failures when attempting to perform a login operation using Retrofit. It + * logs an error message with the error details to the Android log using the specified + * tag, indicating that the login callback has failed. + * + * @param retrofitError error that occurred during the API call. */ @Override public void failure(RetrofitError retrofitError) { @@ -199,33 +159,33 @@ public void failure(RetrofitError retrofitError) { } /** - * sets user's settings by calling API with given username and returns access token - * if successful. + * Retrieves user settings from a login API, updates the local user object with + * received information, and saves it to preferences if an access token is provided. + * It handles successful responses by updating the user details and saving them, and + * failed responses by logging errors. */ public void userSettings() { service.settings(mUser.getUsername(), new Callback() { /** - * handles the callback response from the login API, updates the user object with the - * received information, and saves it to preferences if an access token is provided. - * - * @param user authenticated user returned by the authentication service, providing - * the user's username and email address, as well as an access token if available. - * - * - `username`: The username of the user. - * - `email`: The email address of the user. - * - `accessToken`: The access token of the user. - * - * @param response result of the login API call, providing the user's authentication - * status and other relevant information. - * - * - `user`: A `User` object representing the user who has successfully logged in. - * - `accessToken`: The access token obtained through the login process, which can - * be used for further authenticated API requests. - * - * The function then updates the `mUser` field with the values of `user`, sets - * `loggedIn` to `true`, and saves the user details to the preferences file if - * `hasAccessToken` is set to `true`. + * Handles a successful login operation by updating local user data, setting login + * status to true, and saving the access token if provided. It logs relevant information, + * such as user credentials and access token, for debugging purposes. + * + * @param user authenticated user, whose properties such as username, email, and + * access token are updated and logged accordingly. + * + * * Username + * * Email + * * AccessToken + * + * @param response response from the authentication service, which is not used within + * the method. + * + * The response has no explicit properties mentioned, implying that it may be an + * object or a class with default constructors. However, based on its presence in the + * method signature, it likely contains information about the success status and + * possibly other details related to user authentication. */ @Override public void success(User user, Response response) { @@ -247,17 +207,12 @@ public void success(User user, Response response) { } /** - * is called when a Retrofit error occurs during the login callback. It logs an error - * message to the console using the `Log.e()` method, including the error details in - * the message. - * - * @param retrofitError error object generated by the Retrofit API call, which contains - * information about the failure of the login callback. - * - * - `retrofitError.message`: String value representing the error message in - * human-readable form. - * - `retrofitError.statusCode`: Integer value representing the HTTP status code - * associated with the error, if applicable. + * Logs an error message with a given tag and Retrofit error when a login operation + * fails. The error message includes the `toString()` representation of the Retrofit + * error object. + * + * @param retrofitError exception thrown when a Retrofit request fails, providing + * details about the error. */ @Override public void failure(RetrofitError retrofitError) { @@ -267,8 +222,10 @@ public void failure(RetrofitError retrofitError) { } /** - * saves user information to shared preferences, including username, email, and access - * token. + * Logs the user's information and stores it in the device's preferences using + * SharedPreferences.Editor. It saves the username, email, and access token to + * designated keys in the preferences file. The changes are committed immediately + * after saving. */ private void saveUserToPreferences() { Log.d(TAG, "Saving: " + mUser.getUsername() + ", " + mUser.getEmail() + ", " + mUser.getAccessToken()); @@ -280,15 +237,15 @@ private void saveUserToPreferences() { } /** - * removes saved user information from SharedPreferences and updates login status, - * access token, and user data to empty values. - * - * @param cb CallbackInterface, which is an interface that provides a method for - * updating the login status of the user after the save operation is completed. - * - * - `CallbackInterface cb`: This is an interface that provides methods for updating - * the login status of the user. It has one method, `loginStatusUpdate`, which takes - * a boolean parameter indicating whether the user is logged in or not. + * Removes previously saved user credentials from SharedPreferences, resets the + * `mUser`, `loggedIn`, and `hasAccessToken` variables, and updates the login status + * through a callback interface. + * + * @param cb CallbackInterface, which is used to notify the caller of the login status + * update after deleting saved user data. + * + * Interface: CallbackInterface + * Type: final MainActivity.CallbackInterface */ public void deleteSavedUser(final MainActivity.CallbackInterface cb) { SharedPreferences.Editor editor = sharedPreferences.edit(); diff --git a/client/src/main/java/io/sensable/client/SensorHelper.java b/client/src/main/java/io/sensable/client/SensorHelper.java index eaba950..8bdbb6f 100644 --- a/client/src/main/java/io/sensable/client/SensorHelper.java +++ b/client/src/main/java/io/sensable/client/SensorHelper.java @@ -6,24 +6,23 @@ * Created by madine on 16/07/14. */ /** - * provides a way to determine the type of sensor based on its name, and return an - * appropriate image resource for that sensor. The class includes methods to determine - * the image for different types of sensors, such as accelerometer, magnetic field, - * orientation, light, pressure, proximity, gravity, linear acceleration, rotation, - * humidity, temperature, and CO2. + * Provides a way to determine the unit of measurement and appropriate drawable + * resource for various types of sensors based on their names. It contains three + * methods: `determineUnit`, which returns the unit of measurement for a given sensor + * type; `determineImage(int)`, which determines an image resource based on a sensor + * type using a switch statement; and `determineImage(String)`, which determines the + * appropriate drawable resource for a given sensor type based on its name. */ public class SensorHelper { /** - * takes an integer input parameter representing a sensor type, and returns a string - * indicating the appropriate unit for that sensor type. - * - * @param sensorType 16-bit value of the sensor type, which determines the unit of - * measurement for the accelerometer, magnetic field, gyroscope, light, pressure, - * proximity, gravity, linear acceleration, rotation vector, orientation, relative - * humidity, ambient temperature, or uncalibrated magnetic field, gyroscope, or game - * rotation vector output. - * + * Maps a given sensor type to its corresponding measurement unit, returning the unit + * as a string. The mapping is performed through a switch statement that covers various + * sensor types, each associated with a specific unit. + * + * @param sensorType type of sensor, determining which measurement unit is returned + * based on its value. + * * @returns a string representing the unit of measurement for a given sensor type. */ public static String determineUnit(int sensorType) { @@ -81,15 +80,14 @@ public static String determineUnit(int sensorType) { } /** - * determines an image resource based on a sensor type, using a switch statement to - * map the sensor type to a corresponding image resource ID. - * - * @param sensorType 16-bit integer value returned by the Android sensor API, which - * determines the type of sensor data to be fetched and displayed in the `determineImage()` - * function. - * - * @returns an integer representing the drawable resource ID for the corresponding - * sensor type. + * Maps a given sensor type to a corresponding image resource ID. It uses a switch + * statement to match the input sensor type with a predefined set of cases, assigning + * an image ID accordingly and returning it. + * + * @param sensorType type of sensor being used, and it determines which image to + * return based on its value. + * + * @returns a drawable integer resource ID. */ public static int determineImage(int sensorType) { @@ -146,14 +144,18 @@ public static int determineImage(int sensorType) { } /** - * determines the appropriate drawable resource for a given sensor type based on a - * case-insensitive match of the sensor name. - * - * @param sensorType type of sensor, and based on its value, the function returns a - * different drawable resource ID for the image to be displayed. - * - * @returns an integer representing the drawable resource ID for the corresponding - * sensor type. + * Maps a sensor type to an associated image based on the input string, taking into + * account both exact matches and containing substrings. It returns the corresponding + * image resource ID as an integer. + * + * @param sensorType type of sensor to be displayed, which determines the corresponding + * image to be returned by the function. + * + * @returns an integer resource ID corresponding to a specific sensor type. + * + * The output is an integer representing the resource ID of an image drawable in the + * R.drawable class. It can take various values such as type_lux, type_accelerometer, + * type_magnetic and so on. */ public static int determineImage(String sensorType) { diff --git a/client/src/main/java/io/sensable/client/SensorListActivity.java b/client/src/main/java/io/sensable/client/SensorListActivity.java index d972c69..6447541 100644 --- a/client/src/main/java/io/sensable/client/SensorListActivity.java +++ b/client/src/main/java/io/sensable/client/SensorListActivity.java @@ -10,32 +10,25 @@ import java.util.ArrayList; import java.util.List; +/** + * Extends ListActivity to display a list of available sensors on an Android device. + * It retrieves a list of sensors using the SensorManager and populates a list view + * with their names. The activity enables text filtering on the list view for easy navigation. + */ public class SensorListActivity extends ListActivity { /** * Called when the activity is first created. */ /** - * sets up a list adapter for displaying sensor types and enables text filtering on - * the ListView. - * - * @param savedInstanceState state of the activity that was previously saved, which - * can be used to restore the state of the activity if it is restarted or recreated. - * - * The `super.onCreate(savedInstanceState)` line is executed first to call the parent - * class's `onCreate` method and perform any necessary initialization. The - * `getSystemService()` method calls the `SensorManager` class to get an instance of - * the sensor manager, which is then stored in the variable `sensorManager`. - * - * The `getSensorList()` method of the `SensorManager` class returns a list of all - * available sensors on the device. The list is stored in the variable `listSensor`. - * - * The `List` variable `listSensorType` is created to store the names of the - * sensors in the list returned by `getSensorList()`. - * - * Finally, a new `ArrayAdapter` object is created to display the sensor names in a - * list view. The adapter takes three arguments: the context of the activity (`this`), - * a resource ID for the layout to use for each item in the list - * (`android.R.layout.simple_list_item_1`), and the list of sensor names stored in `listSensorType`. + * Initializes a sensor manager and retrieves a list of all available sensors. It + * then creates an array adapter to display the names of these sensors as a list, + * allowing the user to filter the list by text input. + * + * @param savedInstanceState Bundle object that contains the data previously saved + * by the activity, which is used to restore its state after being recreated. + * + * Bundle - contains key-value pairs representing the application's saved state; null + * by default if no data is provided. */ @Override public void onCreate(Bundle savedInstanceState) { diff --git a/client/src/main/java/io/sensable/client/adapter/TabsPagerAdapter.java b/client/src/main/java/io/sensable/client/adapter/TabsPagerAdapter.java index 9885628..df0847f 100644 --- a/client/src/main/java/io/sensable/client/adapter/TabsPagerAdapter.java +++ b/client/src/main/java/io/sensable/client/adapter/TabsPagerAdapter.java @@ -11,9 +11,11 @@ * Created by simonmadine on 20/07/2014. */ /** - * is an extension of FragmentPagerAdapter that provides fragments for a tabbed - * interface with three tabs: Top Rated, Games, and Movies. The adapter receives the - * index of the current tab and returns the corresponding fragment activity. + * Is an extension of FragmentPagerAdapter that provides fragments for a tabbed + * interface with three tabs. It determines the type of fragment to display based on + * its index and returns a reference to a Fragment object representing one of four + * different activity types. The class retrieves the count of items by calculating + * the number of tabs and returns it as an integer value. */ public class TabsPagerAdapter extends FragmentPagerAdapter { @@ -22,29 +24,17 @@ public TabsPagerAdapter(FragmentManager fm) { } /** - * determines the type of fragment to display based on its index and returns a - * `Fragment` instance accordingly. - * - * @param index 0-based index of the fragment to be returned, with values 0, 1, and - * 2 corresponding to different fragments: `FavouriteSensablesFragment`, - * `LocalSensablesFragment`, and `RemoteSensablesFragment`, respectively. - * - * @returns a reference to a `Fragment` object that represents one of four different - * activity types based on the input index. - * - * The return type of the function is `Fragment`, which means that the function returns - * an instance of a fragment class. - * - * The variable `index` passed as an argument to the function takes on the values 0, - * 1, or 2, indicating the type of fragment to be returned. - * - * The code inside the `switch` statement defines three different fragments: - * `FavouriteSensablesFragment`, `LocalSensablesFragment`, and `RemoteSensablesFragment`. - * Each of these fragments represents a specific type of content, such as top-rated - * sensibles, local sensibles, or remote sensibles. - * - * The `return` statement at the end of the `switch` statement returns an instance - * of one of these fragments based on the value of `index`. + * Returns a specific fragment based on the provided index. It uses a switch statement + * to determine which fragment to return, with options for Top Rated, Games, and Movies. + * + * @param index 0-based index of the fragment to be returned, determining which type + * of fragment is created and returned based on the value. + * + * @returns a fragment instance based on the input index. + * + * The returned output is a fragment object which can be one out of three possible + * fragments - FavouriteSensablesFragment, LocalSensablesFragment or RemoteSensablesFragment + * - based on the input index. */ @Override public Fragment getItem(int index) { @@ -65,16 +55,12 @@ public Fragment getItem(int index) { } /** - * retrieves the count of items by calculating the number of tabs. The count is - * returned as an integer value, equal to the number of tabs. - * - * @returns the number of tabs. - * - * - The output is an integer value representing the number of tabs. - * - The value is equal to 3 in this case, indicating that there are three tabs - * present in the system. - * - The output does not provide any information about the contents or organization - * of the tabs, only their total count. + * Returns an integer value indicating the total number of items. In this case, it + * consistently returns a fixed value of 3, implying that there are always three tabs + * being counted. This function provides a count of the number of items available for + * display or processing. + * + * @returns an integer value, specifically 3. */ @Override public int getCount() {