Skip to content

Commit

Permalink
Merge pull request #39 from jogrimst/master
Browse files Browse the repository at this point in the history
#38 Add emojis
  • Loading branch information
literacyapp authored Dec 19, 2016
2 parents eb07049 + 91fefc9 commit 0b0ea45
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "org.literacyapp.chat"
minSdkVersion 21
targetSdkVersion 23
versionCode 1001005
versionName "1.1.5"
versionCode 1001006
versionName "1.1.6"
}

buildTypes {
Expand Down
93 changes: 93 additions & 0 deletions app/src/main/java/org/literacyapp/chat/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ public void onClick(View view) {

// Reset input field
messageText.setText("");

mButtonSend.postDelayed(new Runnable() {
@Override
public void run() {
// Simulate message from AI tutor

Message message = new Message();
message.setStudentId("00000000aaaaaaaa_1");
message.setTimeSent(Calendar.getInstance());
message.setText(getRandomEmoji());

// Add to UI
addToMessageListAndRefresh(message);
}
}, (int) (Math.random() * 5000));
}
});
}
Expand All @@ -184,4 +199,82 @@ public void run() {
}
}, 100);
}

private String getRandomEmoji() {
int[] unicodes = new int[] {
0x1F601,
0x1F602,
0x1F603,
0x1F604,
0x1F605,
0x1F606,
0x1F609,
0x1F60A,
0x1F60B,
0x1F60C,
0x1F60D,
0x1F60F,
0x1F612,
0x1F613,
0x1F614,
0x1F616,
0x1F618,
0x1F61A,
0x1F61C,
0x1F61D,
0x1F61E,
0x1F620,
0x1F621,
0x1F622,
0x1F623,
0x1F624,
0x1F625,
0x1F628,
0x1F629,
0x1F62A,
0x1F62B,
0x1F62D,
0x1F630,
0x1F631,
0x1F632,
0x1F633,
0x1F635,
0x1F637,
0x1F638,
0x1F639,
0x1F63A,
0x1F63B,
0x1F63C,
0x1F63D,
0x1F63E,
0x1F63F,
0x1F640,
0x1F645,
0x1F646,
0x1F647,
0x1F648,
0x1F649,
0x1F64A,
0x1F64B,
0x1F64C,
0x1F64D,
0x1F64E,
0x1F64F,
};
int randomIndex = (int) (Math.random() * unicodes.length);
int unicode = unicodes[randomIndex];
Log.d(getClass().getName(), "unicode: " + unicode);
String emoji = getEmijoByUnicode(unicode);
Log.i(getClass().getName(), "emoji: " + emoji);
return emoji;
}

/**
* See http://apps.timwhitlock.info/emoji/tables/unicode
* @param unicode Example: "U+1F601" --> "0x1F601"
* @return
*/
private String getEmijoByUnicode(int unicode) {
return new String(Character.toChars(unicode));
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/org/literacyapp/chat/dao/DaoMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 1001005): knows all DAOs.
* Master of DAO (schema version 1001006): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1001005;
public static final int SCHEMA_VERSION = 1001006;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
Expand Down
Binary file added app/src/main/res/drawable/akili.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_chat_list_item_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:id="@+id/imageViewAvatar"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/ic_account_circle_black_24dp"
android:src="@drawable/akili"
app:civ_border_width="1dp"
app:civ_border_color="#CCFFFFFF" />
</LinearLayout>

0 comments on commit 0b0ea45

Please sign in to comment.