diff --git a/.gitignore b/.gitignore index a002544..88afc98 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,9 @@ proguard/ # Android Studio captures folder captures/ -# Intellij +# IntelliJ *.iml -.idea/workspace.xml +.idea/* # Keystore files *.jks diff --git a/README.md b/README.md index 463db4c..4009382 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -# ProjectMobilegeddon -Team 9 CMPUT301W17T09's public Mobilegeddon repository. + + +# ProjectMO*od*9 +## Mood Organizer *overdose* #9 +Team 9 CMPUT301W17T09's public MOod9 repository. Teammembers: * vinnakot - Rohit Vinnakota * dannick - Dannick Pomerleau * cdkushni - Colin Kushniruk * ddao - Dai Dao -* shlakhte - Anton Shlakhter * fmachaal - Fady Machalani diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..b369805 --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +# Reading Week +* UML diagrams +* Stub model (method signatures) +* Stub controller (method signatures) +* Unit Test Model +* Unit Test Controller +* Create Activities +* Do XML for views +* Anything else you want to do on top (time permitted) diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..115f502 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + applicationId "ca.ualberta.cmput301w17t09.mood9.mood9" + minSdkVersion 23 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:design:25.1.0' + testCompile 'junit:junit:4.12' + compile 'com.android.support:recyclerview-v7:25.1.0' + compile 'io.searchbox:jest-droid:2.0.4' + compile 'com.google.guava:guava:21.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..35eb663 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/fady/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/ca/ualberta/cmput301w17t09/mood9/mood9/ExampleInstrumentedTest.java b/app/src/androidTest/java/ca/ualberta/cmput301w17t09/mood9/mood9/ExampleInstrumentedTest.java new file mode 100644 index 0000000..f6f9ad0 --- /dev/null +++ b/app/src/androidTest/java/ca/ualberta/cmput301w17t09/mood9/mood9/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("ca.ualberta.cmput301w17t09.mood9.mood9", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cc11daa --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/AddMoodActivity.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/AddMoodActivity.java new file mode 100644 index 0000000..6a6e86a --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/AddMoodActivity.java @@ -0,0 +1,59 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ExpandableListAdapter; +import android.widget.ExpandableListView; +import android.widget.SimpleExpandableListAdapter; +import android.widget.Spinner; +import android.widget.SpinnerAdapter; + +public class AddMoodActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_add_mood); + + Spinner emotionsSpinner = (Spinner) findViewById(R.id.emotions_spinner); + Spinner socialSpinner = (Spinner) findViewById(R.id.social_spinner); + EditText trigger = (EditText) findViewById(R.id.trigger_edittext); + Button addLocation = (Button) findViewById(R.id.button); + Button save = (Button) findViewById(R.id.button2); + + String[] emotions = {"Anger", "Confusion", "Happiness", "Sadness", "Shame", "Surprise"}; + int[] emoticons = {R.drawable.anger, R.drawable.confusion, R.drawable.happiness, R.drawable.sadness, R.drawable.shame, R.drawable.surpise}; + // map emotions = EmotionModel.getEmotions(); + String[] socials = {"TEMP", "DO NOT USE", "With my enemies", "All Alone"}; + + EmotionsSpinnerAdapter emotionsSpinnerAdapter = new EmotionsSpinnerAdapter(getApplicationContext(), emoticons, emotions); + emotionsSpinner.setAdapter(emotionsSpinnerAdapter); + + + ArrayAdapter socialSpinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, socials); + socialSpinner.setAdapter(socialSpinnerAdapter); + + + addLocation.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //TODO Add location functionality to the button + } + }); + + save.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //TODO Need to actually save the information that is entered + finish(); + } + }); + + } + +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/Emotion.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/Emotion.java new file mode 100644 index 0000000..4e20317 --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/Emotion.java @@ -0,0 +1,41 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +/** + * Created by dannick on 2/22/17. + */ + +public class Emotion { + private String id; + private String name; + private String color; + private String description; + private String image_name; + + public Emotion(String id, String name, String color, String description, String image_name) { + this.id = id; + this.name = name; + this.color = color; + this.description = description; + this.image_name = image_name; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getColor() { + return color; + } + + public String getDescription() { + return description; + } + + public String getImageName() { + return image_name; + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/EmotionModel.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/EmotionModel.java new file mode 100644 index 0000000..f6abf3a --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/EmotionModel.java @@ -0,0 +1,57 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; + +/** + * Created by dannick on 2/22/17. + */ + +public class EmotionModel { + protected static LoadingCache emotions; + + public static Emotion getEmotion(String id){ + Emotion emo = null; + try { + emo = emotions.get(id); + } catch (ExecutionException e) { + // TODO + } + return emo; + } + + public static void initEmotions() { + EmotionModel.emotions = CacheBuilder.newBuilder() + .maximumSize(100) // maximum 100 records can be cached + .build(new CacheLoader(){ // build the cacheloader + + @Override + public Emotion load(String id) throws Exception { + //make the expensive call + return getFromXMLRessource(id); + } + }); + } + + public static ConcurrentMap getEmotions(){ + return emotions.asMap(); + } + + public static Emotion getFromXMLRessource(String id){ + // TODO + return new Emotion("", "", "", "", ""); + } + + public static void setOnXMLResource(Emotion emotion){ + //Sets an emotion + } + + public static void initialLoad(){ + + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/EmotionsSpinnerAdapter.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/EmotionsSpinnerAdapter.java new file mode 100644 index 0000000..e42f6a9 --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/EmotionsSpinnerAdapter.java @@ -0,0 +1,55 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +/** + * Created by fmachaal on 2/22/17. + */ + +//Sourced from http://abhiandroid.com/ui/custom-spinner-examples.html + //On Feb 22, 2017 + +public class EmotionsSpinnerAdapter extends BaseAdapter { + Context context; + int emoticons[]; + String[] emotions; + LayoutInflater inflter; + + public EmotionsSpinnerAdapter(Context applicationContext, int[] emoticons, String[] emotions) { + this.context = applicationContext; + this.emoticons = emoticons; + this.emotions = emotions; + inflter = (LayoutInflater.from(applicationContext)); + } + + @Override + public int getCount() { + return emoticons.length; + } + + @Override + public Object getItem(int i) { + return null; + } + + @Override + public long getItemId(int i) { + return 0; + } + + @Override + public View getView(int i, View view, ViewGroup viewGroup) { + view = inflter.inflate(R.layout.emotion_spinner_layout, null); + ImageView icon = (ImageView) view.findViewById(R.id.imageView); + TextView names = (TextView) view.findViewById(R.id.textView); + icon.setImageResource(emoticons[i]); + names.setText(emotions[i]); + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/FeedActivity.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/FeedActivity.java new file mode 100644 index 0000000..8f7c5c0 --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/FeedActivity.java @@ -0,0 +1,111 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import android.content.Intent; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.view.View; +import android.support.design.widget.NavigationView; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; + +public class FeedActivity extends AppCompatActivity + implements NavigationView.OnNavigationItemSelectedListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_feed); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + addMood(); + } + }); + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + drawer.setDrawerListener(toggle); + toggle.syncState(); + + NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); + navigationView.setNavigationItemSelectedListener(this); + + + //This changes the title of the toolbar - need to change according to feed shown + toolbar.setTitle(R.string.universal_feed); + } + + @Override + public void onBackPressed() { + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_feed, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.search) { + //TODO Add functionality to the search button + return true; + } + + return super.onOptionsItemSelected(item); + } + + @SuppressWarnings("StatementWithEmptyBody") + @Override + public boolean onNavigationItemSelected(MenuItem item) { + // Handle navigation view item clicks here. + int id = item.getItemId(); + + if (id == R.id.personal) { + // Handle the camera action + } else if (id == R.id.followed) { + + } else if (id == R.id.universal) { + + } else if (id == R.id.near_me) { + + } else if (id == R.id.profile) { + + } else if (id == R.id.about) { + + } + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + return true; + } + + private void addMood() { + Intent addMoodIntent = new Intent(this, AddMoodActivity.class); + startActivity(addMoodIntent); + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MainActivity.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MainActivity.java new file mode 100644 index 0000000..6663e29 --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MainActivity.java @@ -0,0 +1,39 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + Button goButton = (Button) findViewById(R.id.go); + EditText usernameField = (EditText) findViewById(R.id.username_field); + + + goButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent feedIntent = new Intent(MainActivity.this, FeedActivity.class); + startActivity(feedIntent); + finish(); + } + }); + + } + + + + +} + diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/Mood.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/Mood.java new file mode 100644 index 0000000..cfaaa1c --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/Mood.java @@ -0,0 +1,131 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import java.util.Date; + +/** + * Created by dannick on 2/22/17. + */ + +public class Mood { + // The following fields are to be serialized + private String id; + private Double latitude; + private Double longitutde; + private String trigger; + private String emotionId; + private String socialSituationId; + private String imageTriggerId; + private Date date; + private String user_id; + + // The following fields should not be serialized + private User user; + private Emotion emotion; + private SocialSituation socialSituation; + + + public Mood(String id, Double latitude, Double longitutde, + String trigger, String emotionId, String socialSituationId, + String imageTriggerId, Date date,String user_id) { + this.id = id; + this.latitude = latitude; + this.longitutde = longitutde; + this.trigger = trigger; + this.emotionId = emotionId; + this.socialSituationId = socialSituationId; + this.imageTriggerId = imageTriggerId; + this.date = date; + this.user_id = user_id; + } + + + public Mood(){ + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitutde() { + return longitutde; + } + + public void setLongitutde(Double longitutde) { + this.longitutde = longitutde; + } + + public String getTrigger() { + return trigger; + } + + public void setTrigger(String trigger) { + this.trigger = trigger; + } + + public String getEmotionId() { + return emotionId; + } + + public void setEmotionId(String emotionId) { + this.emotionId = emotionId; + this.emotion = EmotionModel.getEmotion(emotionId); + } + + public String getSocialSituationId() { + return socialSituationId; + } + + public void setSocialSituationId(String socialSituationId) { + this.socialSituationId = socialSituationId; + this.socialSituation = SocialSituationModel.getSocialSituation(socialSituationId); + } + + public String getImageTriggerId() { + return imageTriggerId; + } + + public void setImageTriggerId(String imageTriggerId) { + this.imageTriggerId = imageTriggerId; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getUser_id() { + return user_id; + } + + public void setUser_id(String user_id) { + this.user_id = user_id; + } + + public User getUser() { + return user; + } + + public Emotion getEmotion() { + return emotion; + } + + public SocialSituation getSocialSituation() { + return socialSituation; + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MoodFeed.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MoodFeed.java new file mode 100644 index 0000000..0f6376b --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MoodFeed.java @@ -0,0 +1,9 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +/** + * Created by dannick on 2/22/17. + */ + +public class MoodFeed { + +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MoodModel.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MoodModel.java new file mode 100644 index 0000000..c365974 --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/MoodModel.java @@ -0,0 +1,106 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; + +import java.util.LinkedList; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +/** + * Created by dannick on 2/22/17. + */ + +public class MoodModel { + protected static LoadingCache moods; + protected static LinkedList tasks; + + private enum TaskType { + PUT, DELETE + } + + private class MoodTask{ + private Mood mood; + private TaskType type; + + public MoodTask(Mood mood, TaskType type) { + this.mood = mood; + this.type = type; + } + + public Mood getMood() { + return mood; + } + + public TaskType getType() { + return type; + } + } + + public static Mood getMood(String id){ + Mood m = null; + try { + m = moods.get(id); + } catch (ExecutionException e) { + // TODO + } + return m; + } + + public static void loadMood() { + MoodModel.moods = CacheBuilder.newBuilder() + .maximumSize(100) // maximum 100 records can be cached + .expireAfterAccess(30, TimeUnit.MINUTES) // cache will expire after 30 minutes of access + .build(new CacheLoader(){ // build the cacheloader + + @Override + public Mood load(String id) throws Exception { + //make the expensive call + return getFromElasticSearch(id); + } + }); + } + + public static ConcurrentMap getMoods(){ + return moods.asMap(); + } + + public static Mood getFromElasticSearch(String id){ + // TODO + return new Mood(); + } + + public static void setOnElasticSearch(Mood mood){ + //Send mood to elastic search + } + + public static ConcurrentMap getMyMoods(){ + // TODO + return moods.asMap(); + } + + public static ConcurrentMap getFollowedMoods(User user){ + // TODO + return moods.asMap(); + } + + public static ConcurrentMap getUniversalMoods(){ + // TODO + return moods.asMap(); + } + + public static ConcurrentMap getMoodsNear(Double latitude, Double longitude){ + // TODO + return moods.asMap(); + } + + public static void deleteMood(Mood mood){ + + } + + public static void updateMood(Mood mood){ + + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/SocialSituation.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/SocialSituation.java new file mode 100644 index 0000000..d4ab60d --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/SocialSituation.java @@ -0,0 +1,29 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +/** + * Created by dannick on 2/22/17. + */ + +public class SocialSituation { + private String id; + private String name; + private String description; + + public SocialSituation(String id, String name, String description) { + this.id = id; + this.name = name; + this.description = description; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/SocialSituationModel.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/SocialSituationModel.java new file mode 100644 index 0000000..26cf51d --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/SocialSituationModel.java @@ -0,0 +1,52 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; + +/** + * Created by dannick on 2/22/17. + */ + +public class SocialSituationModel { + protected static LoadingCache socialSituations; + + public static SocialSituation getSocialSituation(String id){ + SocialSituation ss = null; + try { + ss = socialSituations.get(id); + } catch (ExecutionException e) { + // TODO + } + return ss; + } + + public static void initSocialSituations() { + SocialSituationModel.socialSituations = CacheBuilder.newBuilder() + .maximumSize(100) // maximum 100 records can be cached + .build(new CacheLoader(){ // build the cacheloader + + @Override + public SocialSituation load(String id) throws Exception { + //make the expensive call + return getFromXMLRessource(id); + } + }); + } + + public static ConcurrentMap getSocialSituations(){ + return socialSituations.asMap(); + } + + public static SocialSituation getFromXMLRessource(String id){ + // TODO + return new SocialSituation("", "", ""); + } + + public static void initialLoad(){ + + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/User.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/User.java new file mode 100644 index 0000000..27dbe8b --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/User.java @@ -0,0 +1,31 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +/** + * Created by dannick on 2/22/17. + */ + +public class User { + private String id; + private String name; + + public User(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/UserModel.java b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/UserModel.java new file mode 100644 index 0000000..7179d0a --- /dev/null +++ b/app/src/main/java/ca/ualberta/cmput301w17t09/mood9/mood9/UserModel.java @@ -0,0 +1,59 @@ +package ca.ualberta.cmput301w17t09.mood9.mood9; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; + +import org.apache.commons.lang3.concurrent.ConcurrentException; + +import java.util.Date; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +/** + * Created by dannick on 2/22/17. + */ + +public class UserModel { + protected static LoadingCache users; + + + public void setOnElasticSearch(User user){ + //Add the user to elastic search + } + + + public static User getUser(String id){ + User u = null; + try { + u = users.get(id); + } catch (ExecutionException e) { + // TODO + } + return u; + } + + public static void loadUsers() { + UserModel.users = CacheBuilder.newBuilder() + .maximumSize(100) // maximum 100 records can be cached + .expireAfterAccess(30, TimeUnit.MINUTES) // cache will expire after 30 minutes of access + .build(new CacheLoader(){ // build the cacheloader + + @Override + public User load(String id) throws Exception { + //make the expensive call + return getFromElasticSearch(id); + } + }); + } + + public static ConcurrentMap getUsers(){ + return users.asMap(); + } + + public static User getFromElasticSearch(String id){ + // TODO + return new User("", ""); + } +} diff --git a/app/src/main/res/drawable/anger.png b/app/src/main/res/drawable/anger.png new file mode 100644 index 0000000..c89eb0d Binary files /dev/null and b/app/src/main/res/drawable/anger.png differ diff --git a/app/src/main/res/drawable/confusion.png b/app/src/main/res/drawable/confusion.png new file mode 100644 index 0000000..c04c33c Binary files /dev/null and b/app/src/main/res/drawable/confusion.png differ diff --git a/app/src/main/res/drawable/happiness.png b/app/src/main/res/drawable/happiness.png new file mode 100644 index 0000000..e4da7c6 Binary files /dev/null and b/app/src/main/res/drawable/happiness.png differ diff --git a/app/src/main/res/drawable/ic_add_mood.xml b/app/src/main/res/drawable/ic_add_mood.xml new file mode 100644 index 0000000..91b1ae9 --- /dev/null +++ b/app/src/main/res/drawable/ic_add_mood.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_face.xml b/app/src/main/res/drawable/ic_face.xml new file mode 100644 index 0000000..739bbfb --- /dev/null +++ b/app/src/main/res/drawable/ic_face.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_followed.xml b/app/src/main/res/drawable/ic_followed.xml new file mode 100644 index 0000000..4cfd869 --- /dev/null +++ b/app/src/main/res/drawable/ic_followed.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_globe.xml b/app/src/main/res/drawable/ic_globe.xml new file mode 100644 index 0000000..d976b42 --- /dev/null +++ b/app/src/main/res/drawable/ic_globe.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_lightbulb.xml b/app/src/main/res/drawable/ic_lightbulb.xml new file mode 100644 index 0000000..2a8e9d7 --- /dev/null +++ b/app/src/main/res/drawable/ic_lightbulb.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_location.xml b/app/src/main/res/drawable/ic_location.xml new file mode 100644 index 0000000..e3291a9 --- /dev/null +++ b/app/src/main/res/drawable/ic_location.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_camera.xml b/app/src/main/res/drawable/ic_menu_camera.xml new file mode 100644 index 0000000..0d9ea10 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_camera.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_menu_gallery.xml b/app/src/main/res/drawable/ic_menu_gallery.xml new file mode 100644 index 0000000..f6872c4 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_gallery.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_manage.xml b/app/src/main/res/drawable/ic_menu_manage.xml new file mode 100644 index 0000000..c1be60b --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_manage.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_send.xml b/app/src/main/res/drawable/ic_menu_send.xml new file mode 100644 index 0000000..00c668c --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_send.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_share.xml b/app/src/main/res/drawable/ic_menu_share.xml new file mode 100644 index 0000000..a28fb9e --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_share.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_menu_slideshow.xml b/app/src/main/res/drawable/ic_menu_slideshow.xml new file mode 100644 index 0000000..209aa64 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_personal.xml b/app/src/main/res/drawable/ic_personal.xml new file mode 100644 index 0000000..b2cb337 --- /dev/null +++ b/app/src/main/res/drawable/ic_personal.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..fa90906 --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/logo.png b/app/src/main/res/drawable/logo.png new file mode 100644 index 0000000..78ffafd Binary files /dev/null and b/app/src/main/res/drawable/logo.png differ diff --git a/app/src/main/res/drawable/logo_inv.png b/app/src/main/res/drawable/logo_inv.png new file mode 100644 index 0000000..0c24330 Binary files /dev/null and b/app/src/main/res/drawable/logo_inv.png differ diff --git a/app/src/main/res/drawable/sadness.png b/app/src/main/res/drawable/sadness.png new file mode 100644 index 0000000..130c8d2 Binary files /dev/null and b/app/src/main/res/drawable/sadness.png differ diff --git a/app/src/main/res/drawable/shame.png b/app/src/main/res/drawable/shame.png new file mode 100644 index 0000000..4363bb7 Binary files /dev/null and b/app/src/main/res/drawable/shame.png differ diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 0000000..458b4b0 --- /dev/null +++ b/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/surpise.png b/app/src/main/res/drawable/surpise.png new file mode 100644 index 0000000..ab9757a Binary files /dev/null and b/app/src/main/res/drawable/surpise.png differ diff --git a/app/src/main/res/layout/activity_add_mood.xml b/app/src/main/res/layout/activity_add_mood.xml new file mode 100644 index 0000000..bdd8dd7 --- /dev/null +++ b/app/src/main/res/layout/activity_add_mood.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_feed.xml b/app/src/main/res/layout/activity_feed.xml new file mode 100644 index 0000000..c7ad745 --- /dev/null +++ b/app/src/main/res/layout/activity_feed.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..e869142 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + +