Skip to content

Commit

Permalink
finished commenting votes and comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Rosier committed Apr 19, 2015
1 parent 032b491 commit 3ecc214
Show file tree
Hide file tree
Showing 18 changed files with 459 additions and 146 deletions.
7 changes: 7 additions & 0 deletions .idea/dictionaries/xetk.xml

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

Binary file modified app/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "uk.co.tomrosier.xetk.losesono.prototype.prototype"
minSdkVersion 14
targetSdkVersion 21
versionCode 2
versionName "1.1"
versionCode 3
versionName "1.2"
}
buildTypes {
release {
Expand Down
104 changes: 53 additions & 51 deletions app/manifest-merger-release-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,110 +42,112 @@ ADDED from AndroidManifest.xml:12:5
android:name
ADDED from AndroidManifest.xml:12:22
application
ADDED from AndroidManifest.xml:14:5
ADDED from AndroidManifest.xml:15:5
MERGED from com.android.support:appcompat-v7:21.0.3:16:5
MERGED from com.android.support:support-v4:21.0.3:16:5
MERGED from com.google.android.gms:play-services:6.5.87:20:5
MERGED from com.android.support:support-v4:21.0.3:16:5
android:label
ADDED from AndroidManifest.xml:17:9
ADDED from AndroidManifest.xml:18:9
android:allowBackup
ADDED from AndroidManifest.xml:15:9
android:icon
ADDED from AndroidManifest.xml:16:9
android:icon
ADDED from AndroidManifest.xml:17:9
android:theme
ADDED from AndroidManifest.xml:18:9
ADDED from AndroidManifest.xml:19:9
meta-data#com.google.android.gms.version
ADDED from AndroidManifest.xml:19:9
ADDED from AndroidManifest.xml:20:9
MERGED from com.google.android.gms:play-services:6.5.87:21:9
android:value
ADDED from AndroidManifest.xml:21:13
ADDED from AndroidManifest.xml:22:13
android:name
ADDED from AndroidManifest.xml:20:13
ADDED from AndroidManifest.xml:21:13
meta-data#com.google.android.maps.v2.API_KEY
ADDED from AndroidManifest.xml:22:9
ADDED from AndroidManifest.xml:23:9
android:value
ADDED from AndroidManifest.xml:24:13
ADDED from AndroidManifest.xml:25:13
android:name
ADDED from AndroidManifest.xml:23:13
ADDED from AndroidManifest.xml:24:13
receiver#uk.co.tomrosier.xetk.losesono.prototype.prototype.services.BootReceiver
ADDED from AndroidManifest.xml:26:9
ADDED from AndroidManifest.xml:27:9
android:name
ADDED from AndroidManifest.xml:26:19
ADDED from AndroidManifest.xml:27:19
intent-filter#android.intent.action.BOOT_COMPLETED+android.intent.action.MY_PACKAGE_REPLACED
ADDED from AndroidManifest.xml:27:13
ADDED from AndroidManifest.xml:28:13
action#android.intent.action.BOOT_COMPLETED
ADDED from AndroidManifest.xml:28:17
android:name
ADDED from AndroidManifest.xml:28:25
action#android.intent.action.MY_PACKAGE_REPLACED
ADDED from AndroidManifest.xml:29:17
android:name
ADDED from AndroidManifest.xml:29:25
action#android.intent.action.MY_PACKAGE_REPLACED
ADDED from AndroidManifest.xml:30:17
android:name
ADDED from AndroidManifest.xml:30:25
service#uk.co.tomrosier.xetk.losesono.prototype.prototype.services.DiscoverService
ADDED from AndroidManifest.xml:33:9
ADDED from AndroidManifest.xml:34:9
android:exported
ADDED from AndroidManifest.xml:36:13
android:name
ADDED from AndroidManifest.xml:35:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.NotificationActivity
ADDED from AndroidManifest.xml:38:9
android:excludeFromRecents
ADDED from AndroidManifest.xml:41:13
android:taskAffinity
ADDED from AndroidManifest.xml:40:13
android:name
ADDED from AndroidManifest.xml:34:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.MainActivity
ADDED from AndroidManifest.xml:37:9
android:label
ADDED from AndroidManifest.xml:39:13
android:name
ADDED from AndroidManifest.xml:38:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.RegisterActivity
ADDED from AndroidManifest.xml:47:9
ADDED from AndroidManifest.xml:48:9
android:label
ADDED from AndroidManifest.xml:49:13
ADDED from AndroidManifest.xml:50:13
android:name
ADDED from AndroidManifest.xml:48:13
ADDED from AndroidManifest.xml:49:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.LoginActivity
ADDED from AndroidManifest.xml:51:9
ADDED from AndroidManifest.xml:52:9
android:label
ADDED from AndroidManifest.xml:53:13
ADDED from AndroidManifest.xml:54:13
android:name
ADDED from AndroidManifest.xml:52:13
ADDED from AndroidManifest.xml:53:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.NavigationActivity
ADDED from AndroidManifest.xml:55:9
ADDED from AndroidManifest.xml:56:9
android:label
ADDED from AndroidManifest.xml:57:13
ADDED from AndroidManifest.xml:58:13
android:name
ADDED from AndroidManifest.xml:56:13
ADDED from AndroidManifest.xml:57:13
intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:58:13
ADDED from AndroidManifest.xml:59:13
action#android.intent.action.MAIN
ADDED from AndroidManifest.xml:59:17
ADDED from AndroidManifest.xml:60:17
android:name
ADDED from AndroidManifest.xml:59:25
ADDED from AndroidManifest.xml:60:25
category#android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:61:17
ADDED from AndroidManifest.xml:62:17
android:name
ADDED from AndroidManifest.xml:61:27
ADDED from AndroidManifest.xml:62:27
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.PostMessageAcvitiy
ADDED from AndroidManifest.xml:64:9
ADDED from AndroidManifest.xml:65:9
android:label
ADDED from AndroidManifest.xml:66:13
ADDED from AndroidManifest.xml:67:13
android:name
ADDED from AndroidManifest.xml:65:13
ADDED from AndroidManifest.xml:66:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.AddFriendActivity
ADDED from AndroidManifest.xml:68:9
ADDED from AndroidManifest.xml:69:9
android:label
ADDED from AndroidManifest.xml:70:13
ADDED from AndroidManifest.xml:71:13
android:name
ADDED from AndroidManifest.xml:69:13
ADDED from AndroidManifest.xml:70:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.MessageFriendsActivity
ADDED from AndroidManifest.xml:72:9
ADDED from AndroidManifest.xml:73:9
android:label
ADDED from AndroidManifest.xml:74:13
ADDED from AndroidManifest.xml:75:13
android:name
ADDED from AndroidManifest.xml:73:13
ADDED from AndroidManifest.xml:74:13
activity#uk.co.tomrosier.xetk.losesono.prototype.prototype.activities.ViewMessage
ADDED from AndroidManifest.xml:76:9
ADDED from AndroidManifest.xml:77:9
android:label
ADDED from AndroidManifest.xml:78:13
ADDED from AndroidManifest.xml:79:13
android:name
ADDED from AndroidManifest.xml:77:13
ADDED from AndroidManifest.xml:78:13
uses-sdk
INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
MERGED from com.android.support:appcompat-v7:21.0.3:15:5
Expand Down
8 changes: 1 addition & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
android:name=".services.DiscoverService"
android:exported="false" />

<activity
android:name=".activities.MainActivity"
android:label="@string/app_name" >

</activity>

<activity
android:name=".activities.NotificationActivity"
android:taskAffinity=""
Expand Down Expand Up @@ -69,7 +63,7 @@
</intent-filter>
</activity>
<activity
android:name=".activities.PostMessageAcvitiy"
android:name=".activities.PostMessageActivity"
android:label="@string/title_activity_post_message_acvitiy" >
</activity>
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.co.tomrosier.xetk.losesono.prototype.prototype;

/**
* Created by xetk on 18/04/15.
* This is the two effects than can be add when voting on a post or message, made them enums to make them easy to track.
*/
public enum ActionEffect {
positive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,163 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import uk.co.tomrosier.xetk.losesono.prototype.prototype.ActionEffect;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.R;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.RestClient.VoteRestClient;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.VoteType;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.entities.Comment;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.entities.User;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.entities.Vote;
import uk.co.tomrosier.xetk.losesono.prototype.prototype.utils.AjaxCompleteHandler;

/**
* This is for the listview on the adding friends to a message page.
* This is the container and handler for the listview for comments on each message.
*/
public class CommentArrayAdapter extends ArrayAdapter<Comment> {


// Keep a list of the comment objects that are currently on the activity.
private ArrayList<Comment> commentList = new ArrayList<Comment>();

// When we instantiate the listview we want to get everything ready, for action.
public CommentArrayAdapter(Context context, ArrayList<Comment> comments) {
super(context, 0, comments);
// Create a new list of comments, when we instantiate the class.
this.commentList = new ArrayList<Comment>();
// And copy all of the comments into the new comment list we are working with.
this.commentList.addAll(commentList);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

// Get the comment we are working with from the list.
final Comment comment = getItem(position);
// Check if an existing view is being reused, otherwise inflate the view

// Set the type of view we have for each element.
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.comment_list_item, parent, false);
}

// Get all of the elements on the page that we want to edit.
TextView cName = (TextView) convertView.findViewById(R.id.lblCommenterName);
TextView cComment = (TextView) convertView.findViewById(R.id.lblCommentorComment);
TextView cTime = (TextView) convertView.findViewById(R.id.LBLCommentTime);
TextView cUpVotes = (TextView) convertView.findViewById(R.id.lblUpVotes);
TextView cDownVotes = (TextView) convertView.findViewById(R.id.lblDownVotes);


// Grab the user from the comment so we can strip the important information out.
User user = comment.getUser();

// Generate the string to describe the user that posted the comment.
String name = user.getFirstName() + " " + user.getLastName() + " (" + user.getUserNmae() + ")";

// Get the date that the comment was originally posted.
Date createdDate = comment.getCreatedDate();

// Make the format that we want to display the time the comment was created.
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm dd/MM/yy");

// Get the string with the date in to add to the comment.
String dateStr = dateFormat.format(createdDate);

// Set all labels on the list view item to the values we want.
cName.setText(name);
cComment.setText(comment.getContent());
cTime.setText(dateStr);

// Grab the vote information for the comment so we can process it.
Vote vote = comment.getVote();

// Get the strings that we want to put next to the icons.
String lblPos = String.valueOf(vote.getPositive());
String lblNeg = String.valueOf(vote.getNegative());

// Set the labels to the values we want.
cUpVotes.setText(lblPos);
cDownVotes.setText(lblNeg);


// Get the buttons so we can set there action handlers.
ImageButton upVote = (ImageButton) convertView.findViewById(R.id.btnUpVote);
ImageButton downVote = (ImageButton) convertView.findViewById(R.id.btnDownVote);

// Bind the buttons to change the vote characteristics.
upVote.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
vote(ActionEffect.positive, comment);
}
}
);

downVote.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
vote(ActionEffect.negative, comment);
}
}
);

// Return the completed view to render on screen
return convertView;
}


// This is the action that is carried out when the buttons are pressed to give votes.
private void vote(ActionEffect ae, Comment comment) {

// Get the vote rest client ready for us to pass the information we need to the server.
VoteRestClient vrc = new VoteRestClient(getContext());

// TODO: fix this dirty big hack, this just shows the values in the UI but dosn't actually reflect whats going on in the server.

// Get the current stats for the comment.
Vote vote = comment.getVote();

// Get the values out of the vote object.
int pos = vote.getPositive();
int neg = vote.getNegative();

// Increment them depending on the effect.
if (ae == ActionEffect.positive) {
pos++;
} else {
neg++;
}

// Gen a new vote object with are apended values.
Vote newVote = new Vote(pos,neg);

// Bodge that onto the comment object like nothing ever happened seriously no one will ever know...
comment.setVote(newVote);

// Pass the effect of the vote back to the server.
vrc.addVote(
comment.getCommentID(),
VoteType.comment,
ae,
new AjaxCompleteHandler() {
@Override
public void handleAction(Object someData) {
// Tell the user they have updated the the vote for the given object they are working on.
Toast.makeText(getContext(), "Vote Added", Toast.LENGTH_LONG).show();
// Invalidate the dataset so it draws again.
notifyDataSetInvalidated();
}
}
);
}

// This gets the id for a given item.
@Override
public long getItemId(int position) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* Theses are constants that are changed between different types of build eg production or development.
*/
public class Constants {
//public static final String BASE_URL = "https://xetk.co.uk:3000";
public static final String BASE_URL = "https://csclp0132.csc.aber.ac.uk:8080";
public static final String BASE_URL = "https://46.101.9.11";
//public static final String BASE_URL = "https://csclp0132.csc.aber.ac.uk:8080";
}
Loading

0 comments on commit 3ecc214

Please sign in to comment.