Skip to content

prashanthramakrishnan/RestaurantMenuMicroApplications

Repository files navigation

HotelMenuApp

Developed by:Prashanth Ramakrishnan

Features

  • Has 3 micro apps each doing the job as described in the task

restaurantmenudata

  • No launcher activity, has a hardcoded json file as given, I use this json to convert the response and provide it to other apps via a content provider

restauranthttpproxyserver

  • Uses the littleproxy open source library to create a local proxy server which is then used to intercept requests, thanks to github for prompting this when I googled httpproxy for java/android!
  • Since the littleproxy library is not maintained anymore, I decided to use a recent fork which you can find it here
  • The proxy runs on localhost port 8080 (127.0.0.1:8080)
  • This proxy intercepts the requests and if it finds the same URI already then the cached response is returned else the normal call goes through
  • Make sure you are connected to the network and set the proxy manually to host 127.0.0.1 and port 8080 in the WiFi settings, programmatically this is not possible to set proxy to a WebView, see the link here and the link Only apps that are signed with the same key as system apps can get this permission (i.e.: if you cook your own rom, you could add that functionality) - comment from StackOverflow
  • This link really helped me to see how littleproxy can be consumed for different scenarios

restaurantmenuapp

  • Contains a hardcode html which is loaded from assets folder
  • When the app is launched, this webview is inflated and loads the menu list.

Note

  • Tested on Motorola Moto G4, Android version 7.0

Closing comments

  • I decided to write in Kotlin first, but I faced a lot of issues with certain components with littleproxy, so I decided to switch back to java
  • To intercept https requests man in the middle approach is needed, which has of course the same trust authority as that of the original sender
  • littleproxy has an extension that could be used as shown here
  • I would also consider using Okhttp and running a custom client which intercepts all requests as shown [here] (https://square.github.io/okhttp/interceptors/)

Open source libraries used

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.