1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Update to new room naming system

This commit is contained in:
Christophe Beyls 2014-01-22 00:52:53 +01:00
parent a9f82d90c1
commit 08a0cb66ea
10 changed files with 23 additions and 3 deletions

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/room_ud2120" />

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/room_h2215" />

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/room_ua2220" />

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/room_ub2252" />

View file

@ -146,7 +146,7 @@ public class EventDetailsFragment extends Fragment {
((TextView) view.findViewById(R.id.time)).setText(text);
final String roomName = event.getRoomName();
TextView roomTextView = (TextView) view.findViewById(R.id.room);
Spannable roomText = new SpannableString(String.format("%1$s (Building %2$s)", roomName, Building.fromRoomName(roomName)));
Spannable roomText = new SpannableString(String.format("%1$s [Building %2$s]", roomName, Building.fromRoomName(roomName)));
final int roomImageResId = getResources().getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", getActivity().getPackageName());
// If the room image exists, make the room text clickable to display it
if (roomImageResId != 0) {

View file

@ -102,7 +102,8 @@ public class StringUtils {
}
/**
* Converts a room name to a local drawable resource name, by stripping non-alpha chars and converting to lower case.
* Converts a room name to a local drawable resource name, by stripping non-alpha chars and converting to lower case. Any letter following a digit will be
* ignored, along with the rest of the string.
*
* @return
*/
@ -110,10 +111,17 @@ public class StringUtils {
StringBuilder builder = new StringBuilder(ROOM_DRAWABLE_PREFIX.length() + roomName.length());
builder.append(ROOM_DRAWABLE_PREFIX);
int size = roomName.length();
boolean lastDigit = false;
for (int i = 0; i < size; ++i) {
char c = roomName.charAt(i);
if (Character.isLetterOrDigit(c)) {
if (Character.isLetter(c)) {
if (lastDigit) {
break;
}
builder.append(Character.toLowerCase(c));
} else if (Character.isDigit(c)) {
builder.append(c);
lastDigit = true;
}
}
return builder.toString();