Skip to content

Commit

Permalink
prod 1.01: fixed accented characters bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hissingpanda committed Aug 18, 2015
1 parent 2bf9325 commit 3f8d288
Show file tree
Hide file tree
Showing 10 changed files with 723 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

757 changes: 626 additions & 131 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ If you push code, please make sure it builds correctly. Feel free to use pull re
- [ ] Contact form without email client
- [ ] Update text directions while on tab
- [ ] Actionbar activity depreciated (HttpClient as well)
- [ ] Add different locales in strings.xml file

## Bugs
- [ ] Screen rotation re-updates map to initial closest location
Expand Down
8 changes: 5 additions & 3 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -24,7 +26,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
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 2
versionName "1"
versionCode 3
versionName "1.01"
}
buildTypes {
release {
Expand Down
58 changes: 52 additions & 6 deletions app/src/main/java/org/refugerestrooms/models/Bathroom.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

import android.text.TextUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
* Placeholder
* @author Refuge Restrooms
Expand Down Expand Up @@ -41,6 +45,29 @@ public class Bathroom {
private double mLongitude;

public String getName() {
/******************************************************************************************
* Following section encodes result into ISO-8859-1 and then decodes it into UTF-8.
* This is necessary for displaying accented characters; previously "é" was showing as "é", etc..
* Most likely because of an encoding redundancy from the restroom API, so this may break in the future
* if that is changed/fixed.
******************************************************************************************/
if (mName != null) {
String encodedString = null;
String decodedString = null;
try {
encodedString = URLEncoder.encode(mName, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
//e.printStackTrace();
}
try {
decodedString = URLDecoder.decode(encodedString, "UTF-8");
} catch (UnsupportedEncodingException e) {
//e.printStackTrace();
}
if (decodedString != null) {
mName = decodedString;
}
}
return mName;
}

Expand Down Expand Up @@ -70,6 +97,29 @@ public boolean isUnisex() {
}

public String getDirections() {
/******************************************************************************************
* Following section encodes result into ISO-8859-1 and then decodes it into UTF-8.
* This is necessary for displaying accented characters; previously "é" was showing as "é", etc..
* Most likely because of an encoding redundancy from the restroom API, so this may break in the future
* if that is changed/fixed.
******************************************************************************************/
if (mDirections != null) {
String encodedString = null;
String decodedString = null;
try {
encodedString = URLEncoder.encode(mDirections, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
//e.printStackTrace();
}
try {
decodedString = URLDecoder.decode(encodedString, "UTF-8");
} catch (UnsupportedEncodingException e) {
//e.printStackTrace();
}
if (decodedString != null) {
mDirections = decodedString;
}
}
return mDirections;
}

Expand All @@ -84,14 +134,10 @@ public String getComments() {
return mComments;
}

public void setName(String name) {
this.mName = name;
}
public void setName(String name) { this.mName = name; }

@Override
public String toString() {
return mName;
}
public String toString() { return mName; }

public String toJson() {
Gson gson = new Gson();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/refugerestrooms/servers/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private RemoteCallTask setSearchTerm(String searchTerm) {
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));
return new URI("http://www.refugerestrooms.org:80/api/v1/restrooms/search.json?per_page=20&query=" + Uri.encode(searchTerm, "UTF-8"));
else {
// Refuge Restrooms API bathrooms queried
// http://www.refugerestrooms.org/api/docs/#!/restrooms/GET_version_restrooms_search_format
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/org/refugerestrooms/views/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@
import org.refugerestrooms.servers.JsonRequest;
import org.refugerestrooms.servers.Server;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.text.Normalizer;
import java.util.List;

import static java.lang.Character.getNumericValue;

//TODO ActionBarActivity has been depreciated... use toolbar instead
public class MainActivity extends ActionBarActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks,
Expand Down Expand Up @@ -848,22 +855,23 @@ public void onSearchResults(List<Bathroom> results) {
Bathroom bathroom = results.get(i);
LatLng temp = bathroom.getLocation();
String name = bathroom.getName();

int score = bathroom.getScore();
//String comment = bathroom.getComments();
// Adds bathroom markers, blue for accessible, red for not
if (bathroom.isAccessible() == true)
{
mMap.addMarker(new MarkerOptions()
.position(new LatLng(temp.latitude, temp.longitude))
.title(bathroom.getName())
.title(name)
.snippet(bathroom.getDirections())
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
}
else
{
mMap.addMarker(new MarkerOptions()
.position(new LatLng(temp.latitude,temp.longitude))
.title(bathroom.getName())
.title(name)
.snippet(bathroom.getDirections())
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
}
Expand Down
2 changes: 1 addition & 1 deletion refugerestrooms-android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
Expand Down

0 comments on commit 3f8d288

Please sign in to comment.