Skip to content

Commit 7ce802f

Browse files
committed
closes hhroc#139 (submit button) and hhroc#107 (notification dismiss)
1 parent dfb5eb3 commit 7ce802f

17 files changed

+189
-154
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<activity
4545
android:name=".activities.PostActivity"
4646
android:configChanges="orientation|keyboardHidden|screenSize"
47-
android:label="@string/title_activity_post"
47+
android:label="@string/activity_post_title"
4848
android:parentActivityName=".activities.HomeActivity" >
4949
<meta-data
5050
android:name="android.support.PARENT_ACTIVITY"
@@ -61,15 +61,15 @@
6161
</activity>
6262
<activity
6363
android:name=".activities.ProfileActivity"
64-
android:label="@string/title_activity_profile"
64+
android:label="@string/activity_profile_title"
6565
android:parentActivityName=".activities.HomeActivity" >
6666
<meta-data
6767
android:name="android.support.PARENT_ACTIVITY"
6868
android:value=".activities.HomeActivity" />
6969
</activity>
7070
<activity
7171
android:name=".activities.LocationActivity"
72-
android:label="@string/title_activity_location"
72+
android:label="@string/activity_location_title"
7373
android:parentActivityName=".activities.SplashActivity" >
7474
android:noHistory="true">
7575
</activity>

app/src/main/java/yellr/net/yellr_android/fragments/AssignmentsFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ public void onReceive(Context context, Intent intent) {
141141
Log.d("AssignmentsFragment.onReceive", "GSON puked");
142142
}
143143

144-
if (response.success) {
144+
if (response.success && response.assignments != null) {
145145
assignmentsArrayAdapter.clear();
146146
assignments = new Assignment[response.assignments.length];
147147
for (int i = 0; i < response.assignments.length; i++) {
148148
Assignment assignment = response.assignments[i];
149149
assignmentsArrayAdapter.add(assignment);
150150
assignments[i] = assignment;
151151
}
152-
153-
swipeRefreshLayout.setRefreshing(false);
154152
}
153+
154+
swipeRefreshLayout.setRefreshing(false);
155155
}
156156
}
157157

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

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

200200
return row;

app/src/main/java/yellr/net/yellr_android/fragments/PostFragment.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class PostFragment extends Fragment {
7171
TextView assignmentQuestion;
7272
TextView assignmentDescription;
7373

74+
Button submitButton;
75+
7476
String mediaType = "text";
7577
String imageFilename = "";
7678
String proposedImageFilename = "";
@@ -115,7 +117,9 @@ public void onCreate(Bundle savedInstanceState) {
115117
setHasOptionsMenu(true);
116118

117119
// get the cuid
118-
this.cuid = YellrUtils.getCUID(getActivity().getApplicationContext());
120+
//this.cuid = YellrUtils.getCUID(getActivity().getApplicationContext());
121+
122+
119123

120124
}
121125

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

135-
postText = (EditText)view.findViewById(R.id.frag_post_edittext);
139+
submitButton = (Button)view.findViewById(R.id.frag_post_submit_button);
140+
submitButton.setOnClickListener(new View.OnClickListener() {
141+
@Override
142+
public void onClick(View v) {
143+
SubmitPostToYellr();
144+
}
145+
});
146+
147+
postText = (EditText)view.findViewById(R.id.frag_post_edit_text);
136148

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

159171
if(questionText == null){
160-
assignmentQuestion.setText(R.string.fragment_post_assignment_title);
161-
assignmentDescription.setText(R.string.fragment_post_assignment_description);
172+
assignmentQuestion.setText(R.string.frag_post_assignment_title);
173+
assignmentDescription.setText(R.string.frag_post_assignment_description);
162174
} else {
163175
assignmentQuestion.setText(questionText);
164176
assignmentDescription.setText(questionDescription);
@@ -301,7 +313,6 @@ public static Bitmap getBitmapFromCameraData(Intent data, Context context){
301313
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
302314
inflater.inflate(R.menu.menu_post, menu);
303315
if(this.isAdded()){
304-
/*New Story*/
305316
menu.findItem(R.id.action_post_upload).setIcon(
306317
new IconDrawable(getActivity(), Iconify.IconValue.fa_upload)
307318
.colorRes(R.color.black)
@@ -344,15 +355,15 @@ private void SubmitPostToYellr() {
344355

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

347-
Toast.makeText(getActivity(), "Sending post ...", Toast.LENGTH_SHORT).show();
358+
Toast.makeText(getActivity(), R.string.frag_post_toast_sending_post, Toast.LENGTH_SHORT).show();
348359

349360
// launch intent service
350361
getActivity().startService(postIntent);
351362

352363
// reset display
353364
postText.setText("");
354-
assignmentQuestion.setText(R.string.fragment_post_assignment_title);
355-
assignmentDescription.setText(R.string.fragment_post_assignment_description);
365+
assignmentQuestion.setText(R.string.frag_post_assignment_title);
366+
assignmentDescription.setText(R.string.frag_post_assignment_description);
356367

357368
// go back to home screen
358369
Intent homeIntent = new Intent(getActivity(), HomeActivity.class);

app/src/main/java/yellr/net/yellr_android/fragments/StoriesFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ public void onReceive(Context context, Intent intent) {
145145
storiesArrayAdapter.add(story);
146146
stories[i] = story;
147147
}
148-
swipeRefreshLayout.setRefreshing(false);
149148
}
150149

150+
swipeRefreshLayout.setRefreshing(false);
151151
}
152152
}
153153

app/src/main/java/yellr/net/yellr_android/intent_services/assignments/AssignmentsIntentService.java

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -50,76 +50,67 @@ protected void onHandleIntent(Intent intent) {
5050
*/
5151
private void handleActionGetAssignments() {
5252

53-
//Log.d("AssignmentsIntentService.UpdateData()", "Starting UpdateData() ...");
54-
55-
// get location data
56-
57-
// via: http://stackoverflow.com/a/2227299
58-
// TODO: check for last known good, and if null then
59-
// poll to get a fresh location. This will be
60-
// okay for now though, even if it takes a while
61-
// to complete (since it's in the service)
62-
6353
String baseUrl = BuildConfig.BASE_URL + "/get_assignments.json";
6454

55+
String assignmentsJson = "[]";
56+
6557
// get the location, but if the user has turned off location services,
66-
// it will come back null. If it's null, just dump out.
67-
// TODO: pop-up a dialog maybe??
58+
// it will come back null. If it's null, we won't ping the server
59+
// and just return a blank json list
60+
6861
double latLng[] = YellrUtils.getLocation(getApplicationContext());
69-
if (latLng == null )
70-
return;
71-
String lat = String.valueOf(latLng[0]);
72-
String lng = String.valueOf(latLng[1]);
62+
if (latLng != null ) {
7363

74-
String languageCode = Locale.getDefault().getLanguage();
64+
String lat = String.valueOf(latLng[0]);
65+
String lng = String.valueOf(latLng[1]);
7566

76-
String url = baseUrl
77-
+ "?cuid=" + YellrUtils.getCUID(getApplicationContext())//cuid
78-
+ "&language_code=" + languageCode
79-
+ "&lat=" + lat
80-
+ "&lng=" + lng;
67+
String languageCode = Locale.getDefault().getLanguage();
8168

82-
//Log.d("AssignmentsIntentService.UpdateData()","URL: " + url);
69+
String url = baseUrl
70+
+ "?cuid=" + YellrUtils.getCUID(getApplicationContext())//cuid
71+
+ "&language_code=" + languageCode
72+
+ "&lat=" + lat
73+
+ "&lng=" + lng;
8374

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

8977
//
90-
HttpClient client = new DefaultHttpClient();
91-
HttpGet httpGet = new HttpGet(url);
92-
HttpResponse response = client.execute(httpGet);
93-
HttpEntity entity = response.getEntity();
94-
78+
// TODO: need to check for exceptions better, this bombs out sometimes
9579
//
96-
InputStream content = entity.getContent();
97-
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
80+
try {
9881

99-
//
100-
StringBuilder builder = new StringBuilder();
101-
String line;
102-
while ((line = reader.readLine()) != null) {
103-
builder.append(line);
104-
}
82+
//
83+
HttpClient client = new DefaultHttpClient();
84+
HttpGet httpGet = new HttpGet(url);
85+
HttpResponse response = client.execute(httpGet);
86+
HttpEntity entity = response.getEntity();
10587

106-
String assignmentsJson = builder.toString();
88+
//
89+
InputStream content = entity.getContent();
90+
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
10791

108-
//Log.d("AssignmentsIntentService.UpdateData()","Broadcasting result ...");
92+
//
93+
StringBuilder builder = new StringBuilder();
94+
String line;
95+
while ((line = reader.readLine()) != null) {
96+
builder.append(line);
97+
}
10998

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

112-
Intent broadcastIntent = new Intent();
113-
broadcastIntent.setAction(ACTION_NEW_ASSIGNMENTS);
114-
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
115-
broadcastIntent.putExtra(PARAM_ASSIGNMENTS_JSON, assignmentsJson);
116-
sendBroadcast(broadcastIntent);
101+
Log.d("AssignmentsIntentService.UpdateData()", "Successfully got new assignments list from server.");
117102

118-
} catch( Exception e) {
103+
} catch (Exception e) {
104+
Log.d("AssignmentsIntentService.UpdateData()", "Error: " + e.toString());
105+
}
106+
}
119107

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

122-
//e.printStackTrace();
123-
}
110+
Intent broadcastIntent = new Intent();
111+
broadcastIntent.setAction(ACTION_NEW_ASSIGNMENTS);
112+
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
113+
broadcastIntent.putExtra(PARAM_ASSIGNMENTS_JSON, assignmentsJson);
114+
sendBroadcast(broadcastIntent);
124115
}
125116
}

app/src/main/java/yellr/net/yellr_android/intent_services/messages/MessagesIntentService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected void onHandleIntent(Intent intent) {
4040
//Log.d("MessagesIntentService.onHandleIntent()","Decoding intent action ...");
4141

4242
//String cuid = intent.getStringExtra(PARAM_CUID);
43-
if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
43+
//if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
4444
handleActionGetMessages(); //cuid);
4545
}
4646

app/src/main/java/yellr/net/yellr_android/intent_services/notifications/NotificationsIntentService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected void onHandleIntent(Intent intent) {
4141
//Log.d("NotificationsIntentService.onHandleIntent()","Decoding intent action ...");
4242

4343
//String cuid = intent.getStringExtra(PARAM_CUID);
44-
if (YellrUtils.isHomeLocationSet(getApplicationContext()))
44+
//if (YellrUtils.isHomeLocationSet(getApplicationContext()))
4545
handleActionGetNotifications(); //cuid);
4646
}
4747

app/src/main/java/yellr/net/yellr_android/intent_services/publish_post/PublishPostIntentService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected void onHandleIntent(Intent intent) {
9393

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

96-
if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
96+
//if ( YellrUtils.isHomeLocationSet(getApplicationContext()) )
9797
handleActionGetPublishPost(assignmentId, mediaType, text, imageFilename, audioFilename, videoFilename);
9898

9999
}

0 commit comments

Comments
 (0)