Skip to content

Commit

Permalink
closes hhroc#139 (submit button) and hhroc#107 (notification dismiss)
Browse files Browse the repository at this point in the history
  • Loading branch information
thequbit committed Mar 6, 2015
1 parent dfb5eb3 commit 7ce802f
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 154 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<activity
android:name=".activities.PostActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_post"
android:label="@string/activity_post_title"
android:parentActivityName=".activities.HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
Expand All @@ -61,15 +61,15 @@
</activity>
<activity
android:name=".activities.ProfileActivity"
android:label="@string/title_activity_profile"
android:label="@string/activity_profile_title"
android:parentActivityName=".activities.HomeActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.HomeActivity" />
</activity>
<activity
android:name=".activities.LocationActivity"
android:label="@string/title_activity_location"
android:label="@string/activity_location_title"
android:parentActivityName=".activities.SplashActivity" >
android:noHistory="true">
</activity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ public void onReceive(Context context, Intent intent) {
Log.d("AssignmentsFragment.onReceive", "GSON puked");
}

if (response.success) {
if (response.success && response.assignments != null) {
assignmentsArrayAdapter.clear();
assignments = new Assignment[response.assignments.length];
for (int i = 0; i < response.assignments.length; i++) {
Assignment assignment = response.assignments[i];
assignmentsArrayAdapter.add(assignment);
assignments[i] = assignment;
}

swipeRefreshLayout.setRefreshing(false);
}

swipeRefreshLayout.setRefreshing(false);
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
textViewPostCount.setTypeface(font);

textViewQuestionText.setText(this.assignments.get(position).question_text);
textViewOrganization.setText("Organization: " + YellrUtils.ShortenString(this.assignments.get(position).organization));
textViewOrganization.setText(getString(R.string.organization_label) + YellrUtils.ShortenString(this.assignments.get(position).organization));
textViewPostCount.setText(getString(R.string.fa_comments) + " " + String.valueOf(this.assignments.get(position).post_count));

return row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class PostFragment extends Fragment {
TextView assignmentQuestion;
TextView assignmentDescription;

Button submitButton;

String mediaType = "text";
String imageFilename = "";
String proposedImageFilename = "";
Expand Down Expand Up @@ -115,7 +117,9 @@ public void onCreate(Bundle savedInstanceState) {
setHasOptionsMenu(true);

// get the cuid
this.cuid = YellrUtils.getCUID(getActivity().getApplicationContext());
//this.cuid = YellrUtils.getCUID(getActivity().getApplicationContext());



}

Expand All @@ -132,7 +136,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_post, container, false);

postText = (EditText)view.findViewById(R.id.frag_post_edittext);
submitButton = (Button)view.findViewById(R.id.frag_post_submit_button);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SubmitPostToYellr();
}
});

postText = (EditText)view.findViewById(R.id.frag_post_edit_text);

imageButton = (Button)view.findViewById(R.id.frag_post_photo_button);
videoButton = (Button)view.findViewById(R.id.frag_post_video_button);
Expand All @@ -157,8 +169,8 @@ public void onClick(View v) {
assignmentDescription = (TextView)view.findViewById(R.id.frag_post_assignment_description);

if(questionText == null){
assignmentQuestion.setText(R.string.fragment_post_assignment_title);
assignmentDescription.setText(R.string.fragment_post_assignment_description);
assignmentQuestion.setText(R.string.frag_post_assignment_title);
assignmentDescription.setText(R.string.frag_post_assignment_description);
} else {
assignmentQuestion.setText(questionText);
assignmentDescription.setText(questionDescription);
Expand Down Expand Up @@ -301,7 +313,6 @@ public static Bitmap getBitmapFromCameraData(Intent data, Context context){
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_post, menu);
if(this.isAdded()){
/*New Story*/
menu.findItem(R.id.action_post_upload).setIcon(
new IconDrawable(getActivity(), Iconify.IconValue.fa_upload)
.colorRes(R.color.black)
Expand Down Expand Up @@ -344,15 +355,15 @@ private void SubmitPostToYellr() {

Log.d("SubmitPostToYellr()", "Starting PublishPostIntentService intent ...");

Toast.makeText(getActivity(), "Sending post ...", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), R.string.frag_post_toast_sending_post, Toast.LENGTH_SHORT).show();

// launch intent service
getActivity().startService(postIntent);

// reset display
postText.setText("");
assignmentQuestion.setText(R.string.fragment_post_assignment_title);
assignmentDescription.setText(R.string.fragment_post_assignment_description);
assignmentQuestion.setText(R.string.frag_post_assignment_title);
assignmentDescription.setText(R.string.frag_post_assignment_description);

// go back to home screen
Intent homeIntent = new Intent(getActivity(), HomeActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public void onReceive(Context context, Intent intent) {
storiesArrayAdapter.add(story);
stories[i] = story;
}
swipeRefreshLayout.setRefreshing(false);
}

swipeRefreshLayout.setRefreshing(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,76 +50,67 @@ protected void onHandleIntent(Intent intent) {
*/
private void handleActionGetAssignments() {

//Log.d("AssignmentsIntentService.UpdateData()", "Starting UpdateData() ...");

// get location data

// via: http://stackoverflow.com/a/2227299
// TODO: check for last known good, and if null then
// poll to get a fresh location. This will be
// okay for now though, even if it takes a while
// to complete (since it's in the service)

String baseUrl = BuildConfig.BASE_URL + "/get_assignments.json";

String assignmentsJson = "[]";

// get the location, but if the user has turned off location services,
// it will come back null. If it's null, just dump out.
// TODO: pop-up a dialog maybe??
// it will come back null. If it's null, we won't ping the server
// and just return a blank json list

double latLng[] = YellrUtils.getLocation(getApplicationContext());
if (latLng == null )
return;
String lat = String.valueOf(latLng[0]);
String lng = String.valueOf(latLng[1]);
if (latLng != null ) {

String languageCode = Locale.getDefault().getLanguage();
String lat = String.valueOf(latLng[0]);
String lng = String.valueOf(latLng[1]);

String url = baseUrl
+ "?cuid=" + YellrUtils.getCUID(getApplicationContext())//cuid
+ "&language_code=" + languageCode
+ "&lat=" + lat
+ "&lng=" + lng;
String languageCode = Locale.getDefault().getLanguage();

//Log.d("AssignmentsIntentService.UpdateData()","URL: " + url);
String url = baseUrl
+ "?cuid=" + YellrUtils.getCUID(getApplicationContext())//cuid
+ "&language_code=" + languageCode
+ "&lat=" + lat
+ "&lng=" + lng;

//
// TODO: need to check for exceptions better, this bombs out sometimes
//
try {
//Log.d("AssignmentsIntentService.UpdateData()","URL: " + url);

//
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();

// TODO: need to check for exceptions better, this bombs out sometimes
//
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
try {

//
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
//
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();

String assignmentsJson = builder.toString();
//
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));

//Log.d("AssignmentsIntentService.UpdateData()","Broadcasting result ...");
//
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}

Log.d("AssignmentsIntentService.UpdateData()","JSON: " + assignmentsJson);
assignmentsJson = builder.toString();

Intent broadcastIntent = new Intent();
broadcastIntent.setAction(ACTION_NEW_ASSIGNMENTS);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.putExtra(PARAM_ASSIGNMENTS_JSON, assignmentsJson);
sendBroadcast(broadcastIntent);
Log.d("AssignmentsIntentService.UpdateData()", "Successfully got new assignments list from server.");

} catch( Exception e) {
} catch (Exception e) {
Log.d("AssignmentsIntentService.UpdateData()", "Error: " + e.toString());
}
}

Log.d("AssignmentsIntentService.UpdateData()","Error: " + e.toString());
Log.d("AssignmentsIntentService.UpdateData()", "JSON: " + assignmentsJson);

//e.printStackTrace();
}
Intent broadcastIntent = new Intent();
broadcastIntent.setAction(ACTION_NEW_ASSIGNMENTS);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.putExtra(PARAM_ASSIGNMENTS_JSON, assignmentsJson);
sendBroadcast(broadcastIntent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void onHandleIntent(Intent intent) {
//Log.d("MessagesIntentService.onHandleIntent()","Decoding intent action ...");

//String cuid = intent.getStringExtra(PARAM_CUID);
if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
//if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
handleActionGetMessages(); //cuid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void onHandleIntent(Intent intent) {
//Log.d("NotificationsIntentService.onHandleIntent()","Decoding intent action ...");

//String cuid = intent.getStringExtra(PARAM_CUID);
if (YellrUtils.isHomeLocationSet(getApplicationContext()))
//if (YellrUtils.isHomeLocationSet(getApplicationContext()))
handleActionGetNotifications(); //cuid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void onHandleIntent(Intent intent) {

// TODO: we really cant get here unless the home locsation is set, so we prob dont need to check tyhis

if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
//if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
handleActionGetPublishPost(assignmentId, mediaType, text, imageFilename, audioFilename, videoFilename);

}
Expand Down
Loading

0 comments on commit 7ce802f

Please sign in to comment.