Skip to content

Commit

Permalink
Version 1.1 Update: bug fixes, 'add a bathroom' webview styling
Browse files Browse the repository at this point in the history
  • Loading branch information
hissingpanda committed Sep 21, 2015
1 parent 5db7f36 commit 7bdb9a7
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 295 deletions.
468 changes: 191 additions & 277 deletions .idea/workspace.xml

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,28 @@ If you push code, please make sure it builds correctly. Feel free to use pull re
- Currently location defaults to Minneapolis (Fix this!)
- Only really useful to use search
- If no bathroom within 30(ish?) miles, no results are given by refuge restrooms api, so a toast displays to the user that no bathrooms are nearby
- Max locations shown initially = 20
- Max locations shown initially: gps = 20, search = 75
- Searching with no GPS will move camera to first location found, and shows a toast saying locations were found

## TODO
- [x] Search bar
- [ ] Search by address option -- need to translate address to lat/lng
- [ ] Auto-complete search
- [ ] Get and set nearby location when gps is disabled (currently defaults to Minneapolis)
- [ ] Populate map with nearby pins like when gps is enabled
- [ ] Add list view to Drawer menu like in the original app w\ BathroomSpecsViewUpdater, DetailViewActivity (files in older commits)
- [ ] Feature to save bathrooms for offline use
- [ ] Detailed info button like in ios app, Add bathroom rating to info window
- [ ] Indicate red markers vs blue markers for accessibility
- [ ] Settings
- [ ] Settings Menu
- [ ] Add option to turn of navigation so that the blue line doesn't appear on map.
- [ ] Select number of bathrooms to show 1-50.
- [ ] Select number of bathrooms to show 1-99 (increase default)
- [ ] Style
- [x] Style Feedback Form better
- [ ] Navigation drawer icons
- [ ] Style text directions section -- directions.html
- [ ] Better add bathroom section, currently just a webview
- [x] Style webview in the meantime
- [ ] Contact form without email client
- [ ] Update text directions while on tab
- [ ] Actionbar activity depreciated (HttpClient as well)
Expand All @@ -54,6 +57,9 @@ If you push code, please make sure it builds correctly. Feel free to use pull re
## Bugs
- [ ] Screen rotation re-updates map to initial closest location
- [ ] Turning location off after it's been on doesn't grab last known location on app reopen
- [x] Going back from text directions removes polyline
- [x] GPS not enabled message shows after every search
- [x] Searching a second time doesn't remove first search pins

## Screenshots
![](/app/src/main/res/drawable-hdpi/Screenshots/screen1.png?raw=true)
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId "org.refugerestrooms"
minSdkVersion 14
targetSdkVersion 22
versionCode 3
versionName "1.01"
versionCode 4
versionName "1.1"
}
buildTypes {
release {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/org/refugerestrooms/servers/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ private RemoteCallTask setSearchTerm(String searchTerm) {
@Override
public URI buildUrl() throws URISyntaxException {
if(!location)
// limit per_page=20 so only the 20 nearest/most relevant results display
return new URI("http://www.refugerestrooms.org:80/api/v1/restrooms/search.json?per_page=20&query=" + Uri.encode(searchTerm, "UTF-8"));
// limit per_page=75 so only the 75 most relevant results display for search
return new URI("http://www.refugerestrooms.org:80/api/v1/restrooms/search.json?per_page=75&query=" + Uri.encode(searchTerm, "UTF-8"));
else {
// Refuge Restrooms API bathrooms queried
// http://www.refugerestrooms.org/api/docs/#!/restrooms/GET_version_restrooms_search_format
// limit per_page=20 so only the 20 nearest relevant results display for search
return new URI("http://www.refugerestrooms.org:80/api/v1/restrooms/by_location.json?per_page=20&" + searchTerm);
}
}
Expand Down
25 changes: 21 additions & 4 deletions app/src/main/java/org/refugerestrooms/views/AddBathroomClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Created by Refuge Restrooms on 7/14/2015.
*/

import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

Expand All @@ -22,19 +24,34 @@ saying that the bathroom was submitted successfully (only navigation away from p
Bathrooms are submitted correctly, but should probably do this without a text_directions. Note: the
restroom submitted successfully message is from the refuge restrooms site, not the app.
*/
view.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
if(url.equals(currentUrl)) {
view.loadUrl(url);
}
view.loadUrl("http://www.refugerestrooms.org/restrooms/new?");
return true;
}

// Removes header, footer -- areas where people can navigate away from the add a bathroom page
@Override
public void onPageFinished(WebView view, String url) {
public void onPageFinished(final WebView view, String url) {
// Removes header, footer -- areas where people can navigate away from the add a bathroom page
view.loadUrl("javascript:(function() { " +
"document.getElementsByTagName('header')[0].style.display='none'; " +
"document.getElementsByTagName('footer')[0].style.display='none';" +
"document.getElementsByTagName('header')[0].style.display='none'; " +
"document.getElementsByTagName('footer')[0].style.display='none';" +
"document.body.style.marginLeft=\"5%\";" +
"document.body.style.marginRight=\"5%\";" +
"document.body.style.backgroundColor=\"#e9e9e9\";" +
"document.body.style.color=\"#8377AF\";" +
"document.getElementsByTagName('h5')[0].style.display='none';" +
"document.getElementsByClassName('guess-btn')[0].style.display='none';" +
"})()");
// Time Delay to prevent display showing before javascript finishes
view.postDelayed(new Runnable() {
public void run() {
view.setVisibility(View.VISIBLE);
}
}, 50);

}
}
21 changes: 16 additions & 5 deletions app/src/main/java/org/refugerestrooms/views/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public class MainActivity extends ActionBarActivity
LatLng currentPosition;
boolean mUpdatesRequested;
private boolean mInProgress;

public boolean doNotDisplayDialog = false;
public boolean onSearchAction = false;
protected LatLng start;
protected LatLng end;
// temp lat/lng for setting up initial map
Expand Down Expand Up @@ -431,7 +432,6 @@ void showErrorDialog(int code) {
*/
private CharSequence mTitle;
private String mLocationTitle;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -467,8 +467,11 @@ public void onStatusChanged(String provider, int status, Bundle extras) {}
}

if (!gps_enabled) {
Dialog dialog = createDialog();
dialog.show();
// Added if statement to prevent dialog box from re-showing on search
if (!doNotDisplayDialog) {
Dialog dialog = createDialog();
dialog.show();
}

// Tries to get data from network otherwise
try {
Expand Down Expand Up @@ -567,8 +570,11 @@ private void handleIntent(Intent intent) {

if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
//use the query to search
// Use the query to search
Server mServer = new Server(this);
// Boolean to prevent "gps not enabled" dialog box from re-showing on search
doNotDisplayDialog = true;
onSearchAction = true;
mServer.performSearch(query, false);
}
}
Expand Down Expand Up @@ -849,6 +855,11 @@ public void onSearchResults(List<Bathroom> results) {
numLocations = results.size();
currentLoc = new int[numLocations];
lastLoc = new int[numLocations];
if (onSearchAction) {
// clear map markers before new displaying additional search results
mMap.clear();
onSearchAction = false;
}

for (int i = 0; i < numLocations; i++)
{
Expand Down
Binary file modified app/src/main/res/drawable-hdpi/Screenshots/screen5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions app/src/main/res/layout/add_bathroom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#e9e9e9"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView
android:id="@+id/addBathroom"
android:layout_width="match_parent"
android:layout_height="fill_parent"
/>
android:visibility="invisible"
/>
</LinearLayout>

0 comments on commit 7bdb9a7

Please sign in to comment.