@@ -13,6 +13,7 @@
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.WorkingTextArea;
import tools.AudioTools.AudioPlayer;

/**
* This is essentially a card layout.
@@ -35,6 +36,7 @@ public static StateManager getInstance() {
return ourInstance;
}

private static AudioPlayer ap = AudioPlayer.getInstance();

public State getCurrentState() {
return currentState;
@@ -100,6 +102,12 @@ public void update(float dt) {
currentState.update(dt);

TalkerFactory.getServerTalker().update(dt);



if(!ap.isPlaying() && ap.isPlayingSnapshot()) {
ap.stop();
}
}

@Override
@@ -140,11 +148,11 @@ public void translateStage() {
if (WorkingTextArea.getKeyboardIsVisible()){
System.out.println(currentState.getStage().getCamera());
if (!stateUp)
currentState.getStage().getCamera().translate(0, -400, 0);
currentState.getStage().getCamera().translate(0, -KEY_BOARD_HEIGHT, 0);
stateUp = true;
} else{
if (stateUp)
currentState.getStage().getCamera().translate(0, 400, 0);
currentState.getStage().getCamera().translate(0, KEY_BOARD_HEIGHT, 0);
stateUp = false;
}
}
@@ -8,7 +8,7 @@
* Created by Hongyu Wang on 4/2/2016.
*/
public interface Constants {
float M = 0.5F;
float M = 1F;

int LEFT = -1;
int RIGHT = 1;
@@ -17,6 +17,8 @@ public interface Constants {

int HEIGHT = 1334;

int KEY_BOARD_HEIGHT = 400;

int RECIEVED_READ = 1;
int RECIEVED_UNREAD = 2;
int SENT_READ = 3;
@@ -26,7 +28,7 @@ public interface Constants {

boolean MAC = true;

boolean os = WINDOWS;
boolean os = MAC;

static String getCurrentTimestamp(long time){
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy HH:mm");
@@ -51,28 +51,33 @@ public boolean handle(Event e) {
if (newLineAtEnd()){

resetText();
WorkingTextArea.keyboardIsVisible = false;
StateManager.getInstance().translateStage();
if (WorkingTextArea.keyboardIsVisible) {
WorkingTextArea.keyboardIsVisible = false;
StateManager.getInstance().translateStage();
}
return true;
}
return false;
}
});
setOnscreenKeyboard(new MyDefaultOnscreenKeyboard());
setOnscreenKeyboard(new OnscreenKeyboard() {
@Override
public void show(boolean visible) {
System.out.println(getY());
System.out.println(getHeight());
if (getY() - getHeight() < KEY_BOARD_HEIGHT) {
WorkingTextArea.keyboardIsVisible = true;
}
StateManager.getInstance().translateStage();
Gdx.input.setOnscreenKeyboardVisible(visible);

}
});

}

static public class MyDefaultOnscreenKeyboard extends DefaultOnscreenKeyboard {
}

@Override
public void show(boolean visible) {
WorkingTextArea.keyboardIsVisible = true;
StateManager.getInstance().translateStage();
Gdx.input.setOnscreenKeyboardVisible(visible);

}
}


protected WorkingTextArea(String text, Skin skin, boolean test) {
@@ -35,7 +35,7 @@ public List<Long> getMusicKeys() {
return musicKeys;
}

public void setHashtag(String hashtag) {
public void setHashtagName(String hashtag) {
this.hashtagName = hashtag;
}

@@ -13,60 +13,40 @@ public class MMusic extends MMusicPost {
String name;

String artist;

public long getMusicKey() {
return musicKey;
}

public void setMusicKey(long musicKey) {
this.musicKey = musicKey;
}

/**
* The key to the audio.
*/
long audioKey;
long musicKey;

long albumArt;

String album;

/**
* Returns the title of the music.
*
* @return The title string.
*/

public String getName() {
return name;
}

/**
* Returns the audio which represents the music file.
*
* @return The audio file.
*/
public long getMusicKey() {
return audioKey;
}

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

public void setMusicKey(long audioKey) {
this.audioKey = audioKey;
}

public String getArtist(){
public String getArtist() {
return artist;
}

public void setArtist(String artist){
public void setArtist(String artist) {
this.artist = artist;
}


public String getAlbum() {
return album;
}

public void setAlbum(String album) {
this.album = album;
}


public long getAlbumArt() {
return albumArt;
}
@@ -75,5 +55,12 @@ public void setAlbumArt(long albumArt) {
this.albumArt = albumArt;
}

public String getAlbum() {
return album;
}

public void setAlbum(String album) {
this.album = album;
}
}

@@ -18,7 +18,6 @@ public class MSnapShot extends ServerModel {

private long creator;


public long getMessage() {
return message;
}
@@ -51,7 +50,6 @@ public void setEndTime(int endTime) {
this.endTime = endTime;
}


public long getCreator() {
return creator;
}
@@ -16,25 +16,18 @@ public class MText extends ServerModel {
*/
private String text;

/**Returns the style type of the MText.
*
* @return The style type of the text.
*/
public int getType() {
return type;
}
/**Returns the text content of the MText.
*
* @return The text contents of the MText.
*/
public String getText() {
return text;
}

public void setType(int type) {
this.type = type;
}


public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}
@@ -35,7 +35,6 @@ public class MBand extends ServerModel {
*/
private List<Long> songs;


public String getName() {
return name;
}
@@ -52,6 +51,14 @@ public void setDescription(String description) {
this.description = description;
}

public long getBandImage() {
return bandImage;
}

public void setBandImage(long bandImage) {
this.bandImage = bandImage;
}

public List<Long> getAlbums() {
return albums;
}
@@ -67,12 +74,4 @@ public List<Long> getSongs() {
public void setSongs(List<Long> songs) {
this.songs = songs;
}

public long getBandImage() {
return bandImage;
}

public void setBandImage(long bandImage) {
this.bandImage = bandImage;
}
}
@@ -18,118 +18,71 @@
* Created by Kevin Zheng on 2016-02-18.
*/
public class User extends ServerModel {
public long getProfileKey() {
return profileKey;
}

public void setProfileKey(long profileKey) {
this.profileKey = profileKey;
}

/**
* The key to the userProfile.
*/
private long profileKey;
/**
* The key to the userConversations.
*/
private long conversationsKey;
private long conversations;
/**
* The key to the userDiary.
*/
private long diaryKey;
private long diary;
/**
* The key to the userLog.
*/
private long logKey;
private long log;
/**
* The key to the userContent.
*/
private long contentKey;
private long content;
/**
* The current generated key count.
*/
private long keyState;
/**
* The current snapchat.
*/
private long snapChat;
/**
* The keys to the friends.
*/
private List<Long> friendKeys;

/**
* The keys to the bands.
*/
private List<Long> bandKeys;

/**Gets all basic user information.
*
* @return The userProfile containing info.
*/
public long getProfile() {
return profileKey;
public long getConversations() {
return conversations;
}

/**Returns a model of all conversations a user has.
*
* @return The userConversation containing convos.
*/
public long getConversations() {
return conversationsKey;
public void setConversations(long conversations) {
this.conversations = conversations;
}

/**Returns a model of all diary posts a user has.
*
* @return The userDiaryContent.
*/
public long getDiary() {
return diaryKey;
return diary;
}

/**Returns a model of all uploaded content a user has.
*
* @return The userUploadedContent.
*/
public long getContent() {
return contentKey;
public void setDiary(long diary) {
this.diary = diary;
}

/**Gets all logged activity of the user.
*
* @return The userActivitylog.
*/
public long getLog() {
return logKey;
return log;
}

/**Gets the list of all friend keys.
*
* @return The List of friend keys.
*/
public List<Long> getFriendKeys() {
return friendKeys;
public void setLog(long log) {
this.log = log;
}

/**Gets the list of all band keys.
*
* @return The list of all band keys.
*/
public List<Long> getBandKeys() { return bandKeys; }

// SETTERS
public void setProfile(long profileKey) {
this.profileKey = profileKey;
}
public void setConversations(long conversationsKey) {
this.conversationsKey = conversationsKey;
}
public void setDiary(long diaryKey) {
this.diaryKey = diaryKey;
}
public void setLog(long logKey) {
this.logKey = logKey;
}
public void setContent(long contentKey) {
this.contentKey = contentKey;
public long getContent() {
return content;
}
public void setFriendKeys(List<Long> friendKeys) {
this.friendKeys = friendKeys;

public void setContent(long content) {
this.content = content;
}
public void setBandKeys(List<Long> bandKeys) { this.bandKeys = bandKeys; }

public long getKeyState() {
return keyState;
@@ -146,4 +99,35 @@ public long getSnapChat() {
public void setSnapChat(long snapChat) {
this.snapChat = snapChat;
}

public List<Long> getFriendKeys() {
return friendKeys;
}

public void setFriendKeys(List<Long> friendKeys) {
this.friendKeys = friendKeys;
}

public List<Long> getBandKeys() {
return bandKeys;
}

public void setBandKeys(List<Long> bandKeys) {
this.bandKeys = bandKeys;
}

/**
* The current snapchat.
*/
private long snapChat;
/**
* The keys to the friends.
*/
private List<Long> friendKeys;

/**
* The keys to the bands.
*/
private List<Long> bandKeys;
}
@@ -38,7 +38,7 @@ public MHashtag createNewHashTag(String hashtagName) {
// long hashtagKey = 0;
// hashtag.setKey(hashtagKey);
//
// hashtag.setHashtag(hashtagName);
// hashtag.setHashtagName(hashtagName);

return hashtag;
}
@@ -1,6 +1,6 @@
package server.webclient.services;

import com.sun.corba.se.spi.activation.Server;

import server.model.media.MText;
import server.model.structureModels.ServerModel;
import server.services.interfaces.models.UserProfileManager;

This file was deleted.

@@ -75,7 +75,7 @@ public static void initializeAlbums(){

public static void initializeAll(){
fm = new NSFileManager();

int count=0;
initializeAlbums();
//Top Singles, Tagged
songNameToMMusic = new TreeMap<String,MMusic>();
@@ -84,6 +84,8 @@ public static void initializeAll(){
List<String> urls = NSBundle.getMainBundle().findResourcesPaths("mp3",null);

for(String f : urls) {


if(!f.toString().equals(".DS_Store")) {
File mp3 = new File(f);
NSURL url = new NSURL(mp3.toURI().toString());
@@ -96,6 +98,7 @@ public static void initializeAll(){
List<MMusic> temp = artistToMMusic.get(m.getArtist());
temp.add(m);
artistToMMusic.put(m.getArtist(), temp);
count++;



@@ -106,8 +109,8 @@ public static void initializeAll(){
AudioCreator.pushList();

//Artists: The Weeknd, Justin Bieber, Justin Timberlake, Ed Sheeran, Maroon 5, Kanye West
System.out.println(songNameToMMusic.get("On Sight").getMusicKey());
System.out.println("done");
//System.out.println(songNameToMMusic.get("On Sight").getMusicKey());
//System.out.println("done");
/*
System.out.println(songNameToMMusic.keySet().size());
@@ -16,9 +16,10 @@ public class AudioPlayer {

private boolean running = false;

private AVAudioPlayer player1;
private AVAudioPlayer player2;
boolean snapShot = false;
private AVAudioPlayer musicPlayer;
private AVAudioPlayer voicePlayer;
private AVAudioPlayer snapShotPlayer;
private boolean snapShot = false;
private static AVAudioSession session = AVAudioSession.getSharedInstance();

private NSTimer timer;
@@ -27,8 +28,9 @@ public class AudioPlayer {
private static AudioPlayer singleInstance = new AudioPlayer();

private AudioPlayer(){
player1 = new AVAudioPlayer();
player2 = new AVAudioPlayer();
musicPlayer = new AVAudioPlayer();
voicePlayer = new AVAudioPlayer();
snapShotPlayer = new AVAudioPlayer();
}

public static AudioPlayer getInstance(){
@@ -37,31 +39,36 @@ public static AudioPlayer getInstance(){


public void setSongSnapShot(MAudio voice, MAudio song, double startTime){
currentSong = voice;
player1.dispose();
player2.dispose();
currentSong = song;
//musicPlayer.dispose();
musicPlayer.stop();
voicePlayer.dispose();
snapShotPlayer.dispose();
snapShot = true;

try {
player2 = new AVAudioPlayer(new NSData(voice.getmData()));
player1 = new AVAudioPlayer(new NSData(song.getmData()));
player1.setCurrentTime(startTime);
voicePlayer = new AVAudioPlayer(new NSData(voice.getmData()));
snapShotPlayer = new AVAudioPlayer(new NSData(song.getmData()));
snapShotPlayer.setCurrentTime(startTime);
} catch (NSErrorException e) {
e.printStackTrace();
}

player1.setCurrentTime(startTime);

}

public void setSong(MAudio audio){
currentSong = audio;
player1.dispose();
if(snapShot)
player2.dispose();
musicPlayer.dispose();
if(snapShot) {
voicePlayer.stop();
snapShotPlayer.stop();

}
snapShot = false;

try {
player1 = new AVAudioPlayer(new NSData(audio.getmData()));
musicPlayer = new AVAudioPlayer(new NSData(audio.getmData()));
} catch (NSErrorException e) {
e.printStackTrace();
}
@@ -75,35 +82,46 @@ public void prepareToPlay() {
e.printStackTrace();
}

player1.prepareToPlay();
player1.setDelegate(player1.getDelegate());
musicPlayer.prepareToPlay();
musicPlayer.setDelegate(musicPlayer.getDelegate());
if(snapShot) {
player2.prepareToPlay();
player2.setDelegate(player2.getDelegate());
voicePlayer.prepareToPlay();
voicePlayer.setDelegate(voicePlayer.getDelegate());
snapShotPlayer.prepareToPlay();
snapShotPlayer.setDelegate(snapShotPlayer.getDelegate());
}
}

public void play(){
running = true;
player1.play();
if(snapShot)
player2.play();

}
if(snapShot) {
voicePlayer.play();
snapShotPlayer.play();
return;
}


musicPlayer.play();

public void playAtTime(int time){
player1.setCurrentTime((double)time);
if(snapShot)
player2.setCurrentTime(player2.getCurrentTime() + (double)time);

play();
}

//public void playAtTime(int time){
//musicPlayer.setCurrentTime((double)time);
//if(snapShot)
//player2.setCurrentTime(player2.getCurrentTime() + (double)time);

//play();
//}

public void pause(){
running = false;
player1.stop();
if(snapShot)
player2.stop();
musicPlayer.stop();
if(snapShot) {
voicePlayer.stop();
snapShotPlayer.stop();
}

}

@@ -114,17 +132,22 @@ public void stop(){
} catch (NSErrorException e) {
e.printStackTrace();
}
player1.stop();
if(snapShot)
player2.stop();
if(snapShot) {
voicePlayer.stop();
snapShotPlayer.stop();
}
musicPlayer.stop();



}

public boolean isPlaying(){
if(!running)
return false;
running = player1.isPlaying();
if(snapShot)
return voicePlayer.isPlaying();
running = musicPlayer.isPlaying();

return running;
}
@@ -136,12 +159,17 @@ public void startSnapChatTime(){
}

public double[] stopSnapChatTime(){


time[1] = this.getCurrentTime();

double[] timeArray = time;

time = new double[]{0, 0};

for(double s : timeArray)
System.out.println(s);

return timeArray;
}

@@ -152,10 +180,14 @@ public MAudio getCurrentAudio(){
}

public double getCurrentTime(){
return player1.getCurrentTime();
return musicPlayer.getCurrentTime();
}

public void setTime(double time){
player1.setCurrentTime(time);
musicPlayer.setCurrentTime(time);
}

public boolean isPlayingSnapshot(){ return snapShot;}


}
@@ -139,8 +139,6 @@ public MAudio stopRecording(){

NSData mData = new NSData(fm.getContentsAtPath(filePath.getPath()));

assert(mData!=null);

MAudio audio = AudioCreator.createMAudio(mData);
audio.setKey(LocalDatabaseFactory.createLocalDatabase().generateKey());
return audio;
@@ -86,6 +86,12 @@ public MServerKey getKeyState(){
pulledKeys = new ConcurrentSkipListSet<>();
// unassignedKeys = new ArrayList<Long>();
initStringMaps();
// try {
// models = new VirtualDatabase().data;
// }
// catch(Exception e){
// System.out.println("Fuck");
// }
}

private void initStringMaps(){
@@ -21,7 +21,7 @@
* Created by Kevin Zheng on 2016-03-09.
*/
public class VirtualDatabase {
private Map<Long, ServerModel> data;
public Map<Long, ServerModel> data;
private Map<String, Long> hashtag_key;
private Map<String, Long> username_key;
private List<Long> updatedKeys;
@@ -118,9 +118,9 @@ private void initMediaData(){
User user2 = (User)data.get(2L);
User user3 = (User)data.get(3L);

UserProfile profile1 = (UserProfile)data.get(user1.getProfile());
UserProfile profile2 = (UserProfile)data.get(user2.getProfile());
UserProfile profile3 = (UserProfile)data.get(user3.getProfile());
UserProfile profile1 = (UserProfile)data.get(user1.getProfileKey());
UserProfile profile2 = (UserProfile)data.get(user2.getProfileKey());
UserProfile profile3 = (UserProfile)data.get(user3.getProfileKey());

profile1.setImageKey(-11L);
profile2.setImageKey(-12L);
@@ -271,7 +271,7 @@ private void generateTestUser(String username, long key) {
serverKey.setCurrentKey(0L);

//Assign to user.
user.setProfile(profile.getKey());
user.setProfileKey(profile.getKey());
user.setConversations(conversations.getKey());
user.setLog(log.getKey());
user.setContent(content.getKey());
@@ -295,7 +295,7 @@ private MHashtag generateTestHashtags(String hashtag){

tag.setKey(generator.generateSerial());

tag.setHashtag(hashtag);
tag.setHashtagName(hashtag);

tag.setMusicKeys(
new ArrayList<Long>()
@@ -419,7 +419,7 @@ private void generateStaticDiaryPost(String title, User creator, long descriptio
}

private void generateComment(MDiaryPost post, User creator){
UserProfile profile = (UserProfile)data.get(creator.getProfile());
UserProfile profile = (UserProfile)data.get(creator.getProfileKey());

MComment comment = new MComment();
comment.setKey(generator.generateSerial());
@@ -8,7 +8,7 @@
<resources>

<resource>
<directory>../android/assets/MusicAssets</directory>
<directory>../android/assets/massets</directory>
<includes>
<include>**</include>
</includes>