Skip to content

Commit

Permalink
Merge branch 'development' into 2022-01-26-Madelein-Move-Surface-Holder
Browse files Browse the repository at this point in the history
  • Loading branch information
rohankulkz authored Jan 31, 2022
2 parents 20b0547 + 88e9adb commit 17e35cb
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 11 deletions.
24 changes: 24 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# PR Info

## Issue Details

<!-- Please choose the relevant option -->

- **Fixes** #---- <!-- to automatically close the linked issue -->
- **Addresses** #---- <!-- to link the issue but not close - work pending etc. -->

## Branch
- **Addresses** `development` <!-- Please change this if your PR is targetting other branches -->

## Type of change

<!-- Please delete options that are not relevant -->

- **Bug Fix** <!-- non-breaking change which fixes an issue -->
- **New Feature** <!-- non-breaking change which adds functionality -->
- **Breaking Change** <!-- fix or feature that would cause existing functionality to not work as expected -->
- **Other** <!-- please specify -->

## Additional Info

<!-- Any additional info we should know about the PR! -->
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

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

2 changes: 2 additions & 0 deletions .idea/jarRepositories.xml

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

14 changes: 13 additions & 1 deletion .idea/misc.xml

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

2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ android:
components:
- tools
- android-26

- build-tools-29.0.2
- platform-tools
before_cache:
Expand All @@ -27,3 +28,4 @@ branches:
only:
- master
- development

3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
apply plugin: 'com.android.application'

android {

compileSdkVersion 30
buildToolsVersion '30.0.2'


defaultConfig {
applicationId "com.example.iris.login1"
minSdkVersion 15
Expand Down
42 changes: 36 additions & 6 deletions app/src/main/java/com/example/iris/login1/Common.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package com.example.iris.login1;

import android.util.Pair;
import com.example.iris.login1.DataHelper;

import java.util.HashMap;
import java.util.Map;

/**
* Created by Zero on 2016/9/16.
*
*
*/
public class Common {

// different app states






public enum STATE {
IF_YOU_SEE_YOUR_PICTURE, PLEASE_TAP_ON_YOUR_PICTURE, TO_SEE_MORE_PICTURES,
IF_YOU_DONT_FIND_YOUR_PICTURE, SLIDE_THEM_LIKE_THIS, TAP_HERE_RECORD, PLEASE_SAY_YOUR_NAME,
Expand All @@ -27,7 +36,7 @@ public enum STATE {
TO_SEE_MORE_ICONS, SLIDE_ICONS_LIKE_THIS
}

public static final String[] ANIMAL_NAMES_ENG = {"bat", "bear", "bee", "buffalo", "butterfly",
public static String[] ANIMAL_NAMES_ENG = {"bat", "bear", "bee", "buffalo", "butterfly",
"camel", "cat", "cheetah", "chicken", "chimpanzee", "cow", "crocodile", "dog", "donkey", "dove",
"duck", "eagle", "elephant", "fish", "flamingo", "fox", "frog", "giraffe", "goat", "gorilla", "hippo", "horse",
"hyena", "kangaroo", "leopard", "lion", "monkey", "mouse", "ostrich", "parrot","rabbit",
Expand All @@ -36,13 +45,13 @@ public enum STATE {
// chimp and gorilla => sokwe
// zebra and donkey => punda

public static final String[] ANIMAL_NAMES_SWA = {"popo", "dubu", "nyuki", "nyati", "kipepeo",
public static String[] ANIMAL_NAMES_SWA = {"popo", "dubu", "nyuki", "nyati", "kipepeo",
"ngamia", "paka", "duma", "kuku", "sokwe (chimpanzee)", "ng'ombe", "mamba", "mbwa", "punda (donkey)", "njiwa",
"bata", "tai", "tembo", "samaki", "korongo", "mbweha", "chura", "twiga", "mbuzi", "sokwe (gorilla)", "kiboko", "farasi",
"fisi", "kangaruu", "chui", "simba", "tumbili", "panya", "mbuni", "kasuku","sungura",
"kondoo", "nyoka", "buibui", "kuchakuro", "kobe", "mbwa mwitu", "punda (zebra)"};

public static final int[] ANIMAL_PATHS = {R.drawable.bat, R.drawable.bear, R.drawable.bee, R.drawable.buffalo,
public static int[] ANIMAL_PATHS = {R.drawable.bat, R.drawable.bear, R.drawable.bee, R.drawable.buffalo,
R.drawable.butterfly, R.drawable.camel, R.drawable.cat, R.drawable.cheetah,
R.drawable.chicken, R.drawable.chimpanzee, R.drawable.cow, R.drawable.crocodile, R.drawable.dog,
R.drawable.donkey, R.drawable.dove, R.drawable.duck, R.drawable.eagle, R.drawable.elephant,
Expand All @@ -53,25 +62,46 @@ public enum STATE {
R.drawable.spider, R.drawable.squirrel, R.drawable.turtle,
R.drawable.wolf, R.drawable.zebra};

public static final int[] ANIMAL_SOUNDS = {R.raw.popo, R.raw.dubu, R.raw.nyuki, R.raw.nyati, R.raw.kipepeo,
public static int[] ANIMAL_SOUNDS = {R.raw.popo, R.raw.dubu, R.raw.nyuki, R.raw.nyati, R.raw.kipepeo,
R.raw.ngamia, R.raw.paka, R.raw.duma, R.raw.kuku, R.raw.sokwe, R.raw.ng_ombe, R.raw.mamba, R.raw.mbwa,
R.raw.punda, R.raw.njiwa, R.raw.bata, R.raw.tai, R.raw.tembo, R.raw.samaki, R.raw.korongo, R.raw.mbweha,
R.raw.chura, R.raw.twiga, R.raw.mbuzi, R.raw.sokwe, R.raw.kiboko, R.raw.farasi, R.raw.fisi, R.raw.kangaruu,
R.raw.chui, R.raw.simba, R.raw.tumbili, R.raw.panya, R.raw.mbuni, R.raw.kasuku, R.raw.sungura, R.raw.kondoo,
R.raw.nyoka, R.raw.buibui, R.raw.kuchakuro, R.raw.kobe, R.raw.mbwa_mwitu, R.raw.punda};

public static final Map<String, Pair<Integer, Integer>> ANIMALS_ENG = new HashMap<String, Pair<Integer, Integer>>() {{
public static Map<String, String> ANIMALS_Link = new HashMap<String, String>() {{
for(int i = 0; i < ANIMAL_NAMES_ENG.length; i++){
put(ANIMAL_NAMES_ENG[i],ANIMAL_NAMES_SWA[i]);
}
}};



public static Map<String, Pair<Integer, Integer>> ANIMALS_ENG = new HashMap<String, Pair<Integer, Integer>>() {{
for(int i = 0; i < ANIMAL_NAMES_ENG.length; i++){
put(ANIMAL_NAMES_ENG[i], Pair.create(ANIMAL_PATHS[i], ANIMAL_SOUNDS[i]));
}
}};

public static final Map<String, Pair<Integer, Integer>> ANIMALS_SWA = new HashMap<String, Pair<Integer,Integer>>() {{
public static Map<String, Pair<Integer, Integer>> ANIMALS_SWA = new HashMap<String, Pair<Integer,Integer>>() {{
for(int i = 0; i < ANIMAL_NAMES_SWA.length; i++){
put(ANIMAL_NAMES_SWA[i], Pair.create(ANIMAL_PATHS[i], ANIMAL_SOUNDS[i]));
}
}};


//method remaps the hashmaps to the new order.
public static void reMap(){
ANIMALS_ENG.clear();
ANIMALS_SWA.clear();
for(int i = 0; i < ANIMAL_NAMES_ENG.length; i++){
ANIMALS_ENG.put(ANIMAL_NAMES_ENG[i], Pair.create(ANIMAL_PATHS[i], ANIMAL_SOUNDS[i]));
}
for(int i = 0; i < ANIMAL_NAMES_SWA.length; i++){
ANIMALS_SWA.put(ANIMAL_NAMES_SWA[i], Pair.create(ANIMAL_PATHS[i], ANIMAL_SOUNDS[i]));
}
}

//indicate the delay time
public static final int DELAY_TO_SHOW_VIDEO_FULL_SCREEN = 7000;
public static final int DELAY_TO_SHOW_VIDEO = 5000;
Expand Down
77 changes: 77 additions & 0 deletions app/src/main/java/com/example/iris/login1/DataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.util.Log;
import android.util.Pair;

import java.io.File;
import java.text.SimpleDateFormat;
Expand All @@ -14,9 +15,14 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import static com.example.iris.login1.Common.ANIMALS_ENG;
import static com.example.iris.login1.Common.ANIMALS_Link;
import static com.example.iris.login1.Common.ANIMAL_NAMES_ENG;
import static com.example.iris.login1.Common.ANIMAL_NAMES_SWA;
import static com.example.iris.login1.Common.ANIMAL_PATHS;
import static com.example.iris.login1.Common.ANIMAL_SOUNDS;
import static com.example.iris.login1.Common.FACE_LOGIN_PATH;

/**
Expand Down Expand Up @@ -215,4 +221,75 @@ public String getTableAsString(String tableName) {
return tableString;
}

public String[] getImageOrder() {
Log.d("DataHelper","getImageOrder called");
Cursor values = db.rawQuery("SELECT Count(_id), profileIcon from users Group by profileicon order By Count(_id) ASC", null);

ArrayList<String> animal_names = new ArrayList<String>();
ArrayList<String> animal_names_swa = new ArrayList<String>();
values.moveToFirst();

while(!values.isAfterLast()){
String val = values.getString(values.getColumnIndex("profileIcon"));
animal_names.add(val.toLowerCase(Locale.ROOT));
values.moveToNext();
}

int startingListLength = animal_names.size();

for (int i = 0; i < ANIMAL_NAMES_ENG.length; i++) {

boolean is_in_list = true;

for (int k = 0; k < animal_names.size(); k++) {

if (animal_names.get(k).equals(ANIMAL_NAMES_ENG[i])) {
is_in_list = false;
break;
}
}
if(is_in_list){
animal_names.add(0,ANIMAL_NAMES_ENG[i]);
}


}

for (int i = 0; i < (int)(ANIMAL_NAMES_ENG.length-startingListLength)/2; i++) {
String placeholder = animal_names.get(i);

animal_names.set(i,animal_names.get(ANIMAL_NAMES_ENG.length-startingListLength-i));

animal_names.set(ANIMAL_NAMES_ENG.length-startingListLength-i,placeholder);

}


for (int i = 0; i < ANIMAL_NAMES_ENG.length; i++) {
String tempName = animal_names.get(i);
ANIMAL_NAMES_ENG[i] = animal_names.get(i);



;

Pair<Integer, Integer> animalData = ANIMALS_ENG.get(tempName);

ANIMAL_PATHS[i] = animalData.first;
ANIMAL_SOUNDS[i] = animalData.second;


ANIMAL_NAMES_SWA[i] = ANIMALS_Link.get(tempName);

}

//
String[] response = new String[animal_names.size()];
response = animal_names.toArray(response);
return response;



}

}
17 changes: 16 additions & 1 deletion app/src/main/java/com/example/iris/login1/GalleryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public class GalleryActivity extends AppCompatActivity implements SurfaceHolder.
private List<Integer> mIcons = new ArrayList<Integer>();

private DataHelper dbHelper;



private List<UserInfo> userInfo = new ArrayList<UserInfo>();
private ImageView capture;
private ImageView like;
Expand Down Expand Up @@ -331,6 +334,7 @@ protected void onCreate(Bundle savedInstanceState) {
// MARCH START WITH THIS_IS_ROBOTUTOR
_audioPlaying = THIS_IS_ROBOTUTOR;


setLogoOnTouchListener();

setLikeOnClickListener();
Expand Down Expand Up @@ -745,6 +749,7 @@ public void onCompletion(MediaPlayer mp) {
firstAttempt = true;
String newSessId = generateSessionID();
currentUser.setLastLoginTime(newSessId.split("_", 2)[1]);

dbHelper.updateUserTime(currentUser);

// when the Confirm button is tapped, launch RoboTutor
Expand Down Expand Up @@ -1134,8 +1139,10 @@ public void run() {
genderlay.setVisibility(View.GONE);

//TODO pick less used
dbHelper.getImageOrder();
String[] ANIMAL_NAMES = (language.equals(LANG_EN) ? ANIMAL_NAMES_ENG : ANIMAL_NAMES_SWA);


Integer icnpic = mIcons.get(0);
String icntext = ANIMAL_NAMES[0];

Expand Down Expand Up @@ -1426,6 +1433,7 @@ public void onClick(View view, int position) {
// create a new EnrollmentVideo thread
videoThread = new PlayEnrollmentVideo(surfaceHolder, mHandler, GalleryActivity.this, v, p, startTimeWithSilence);
videoThread.start();

view.setBackgroundColor(Color.YELLOW);
}
});
Expand All @@ -1440,6 +1448,8 @@ private void initUserInfo(){
String tempUrl = userInfo.get(i).getUserIcon();
String profIconName = userInfo.get(i).getProfileIcon().toLowerCase();

dbHelper.getImageOrder();

Integer profIcon = (language.equals(LANG_EN) ? ANIMALS_ENG.get(profIconName).first : ANIMALS_SWA.get(profIconName).first);

Bitmap bmp = BitmapFactory.decodeFile(tempUrl);
Expand Down Expand Up @@ -1798,8 +1808,10 @@ public boolean onTouch(View v, MotionEvent event) {
genderlay.setVisibility(View.GONE);

//TODO pick less used
dbHelper.getImageOrder();
String[] ANIMAL_NAMES = (language.equals(LANG_EN) ? ANIMAL_NAMES_ENG : ANIMAL_NAMES_SWA);


Integer icnpic = mIcons.get(0);
String icntext = ANIMAL_NAMES[0];

Expand Down Expand Up @@ -1843,8 +1855,10 @@ public boolean onTouch(View v, MotionEvent event) {
genderlay.setVisibility(View.GONE);

//TODO pick less used
dbHelper.getImageOrder();
String[] ANIMAL_NAMES = (language.equals(LANG_EN) ? ANIMAL_NAMES_ENG : ANIMAL_NAMES_SWA);


Integer icnpic = mIcons.get(0);
String icntext = ANIMAL_NAMES[0];

Expand Down Expand Up @@ -1944,9 +1958,10 @@ public boolean onTouch(View v, MotionEvent event) {
stopFlash(FLASH_DISLIKE);
stopFlash(FLASH_LIKE);
//TODO pick less used

dbHelper.getImageOrder();
String[] ANIMAL_NAMES = (language.equals(LANG_EN) ? ANIMAL_NAMES_ENG : ANIMAL_NAMES_SWA);


String icntext = ANIMAL_NAMES[new Random().nextInt(ANIMAL_NAMES.length)];
icontext.setText(icntext.toUpperCase());
iconpic.setImageDrawable(getResources().getDrawable((language.equals(LANG_EN) ?
Expand Down
Loading

0 comments on commit 17e35cb

Please sign in to comment.