Skip to content

Commit f809f96

Browse files
committed
added stub for spanish strings. closes hhroc#140 (includes app version)
1 parent 7ce802f commit f809f96

File tree

14 files changed

+189
-45
lines changed

14 files changed

+189
-45
lines changed

app/src/main/java/yellr/net/yellr_android/activities/HomeActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ public CharSequence getPageTitle(int position) {
248248
Locale l = Locale.getDefault();
249249
switch (position) {
250250
case 0:
251-
return getString(R.string.title_fragment_assignments).toUpperCase(l);
251+
return getString(R.string.fragment_assignments_title).toUpperCase(l);
252252
case 1:
253-
return getString(R.string.title_fragment_stories).toUpperCase(l);
253+
return getString(R.string.fragment_stories_title).toUpperCase(l);
254254
}
255255
return null;
256256
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
191191
TextView textViewPostCount = (TextView) row.findViewById(R.id.frag_home_assignment_post_count);
192192

193193
Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fontawesome-webfont.ttf");
194+
textViewOrganization.setTypeface(font);
194195
textViewPostCount.setTypeface(font);
195196

196197
textViewQuestionText.setText(this.assignments.get(position).question_text);
197-
textViewOrganization.setText(getString(R.string.organization_label) + YellrUtils.ShortenString(this.assignments.get(position).organization));
198+
textViewOrganization.setText(getString(R.string.fa_user) + " " + YellrUtils.shortenString(this.assignments.get(position).organization));
198199
textViewPostCount.setText(getString(R.string.fa_comments) + " " + String.valueOf(this.assignments.get(position).post_count));
199200

200201
return row;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ private void SubmitPostToYellr() {
362362

363363
// reset display
364364
postText.setText("");
365-
assignmentQuestion.setText(R.string.frag_post_assignment_title);
366-
assignmentDescription.setText(R.string.frag_post_assignment_description);
365+
assignmentQuestion.setText(getString(R.string.frag_post_assignment_title));
366+
assignmentDescription.setText(getString(R.string.frag_post_assignment_description));
367367

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ public View getView(int position, View convertView, ViewGroup parent) {
194194
textViewPublishAuthor.setTypeface(font);
195195
textViewPublishDateTime.setTypeface(font);
196196

197-
textViewPublishAuthor.setText(getString(R.string.fa_user) + " " + stories.get(position).author_first_name + " " + stories.get(position).author_last_name);
197+
textViewPublishAuthor.setText(getString(R.string.fa_user) + " " + stories.get(position).author_first_name + " " + stories.get(position).author_last_name);
198198
textViewTitle.setText(this.stories.get(position).title);
199199

200-
Date pubDateStr = YellrUtils.PrettifyDateTime(this.stories.get(position).publish_datetime);
200+
Date pubDateStr = YellrUtils.prettifyDateTime(this.stories.get(position).publish_datetime);
201201
String pubAgo = YellrUtils.calcTimeBetween(pubDateStr, new Date());
202202

203203
textViewPublishDateTime.setText(getString(R.string.fa_pencil) + " " + pubAgo + " ago.");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
6262
String contentsRendered = intent.getStringExtra(ViewStoryFragment.ARG_STORY_CONTENTS_RENDERED);
6363

6464
//TODO Use new datetime prettifier
65-
Date pubDT = YellrUtils.PrettifyDateTime(publishedDateTime);
65+
Date pubDT = YellrUtils.prettifyDateTime(publishedDateTime);
6666
String pubAgo = YellrUtils.calcTimeBetween(pubDT, new Date());
6767

6868
Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fontawesome-webfont.ttf");

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,13 @@ protected void onHandleIntent(Intent intent) {
5050
*/
5151
private void handleActionGetAssignments() {
5252

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

55-
String assignmentsJson = "[]";
5654

5755
// get the location, but if the user has turned off location services,
5856
// it will come back null. If it's null, we won't ping the server
5957
// and just return a blank json list
6058

59+
/*
6160
double latLng[] = YellrUtils.getLocation(getApplicationContext());
6261
if (latLng != null ) {
6362
@@ -71,8 +70,13 @@ private void handleActionGetAssignments() {
7170
+ "&language_code=" + languageCode
7271
+ "&lat=" + lat
7372
+ "&lng=" + lng;
73+
*/
7474

75-
//Log.d("AssignmentsIntentService.UpdateData()","URL: " + url);
75+
String assignmentsJson = "[]";
76+
77+
String baseUrl = BuildConfig.BASE_URL + "/get_assignments.json";
78+
String url = YellrUtils.buildUrl(getApplicationContext(),baseUrl);
79+
if (url != null) {
7680

7781
//
7882
// TODO: need to check for exceptions better, this bombs out sometimes

app/src/main/java/yellr/net/yellr_android/intent_services/stories/StoriesIntentService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ protected void onHandleIntent(Intent intent) {
5151
*/
5252
private void handleActionGetStories() {
5353

54-
String baseUrl = BuildConfig.BASE_URL + "/get_stories.json";
54+
//String baseUrl = BuildConfig.BASE_URL + "/get_stories.json";
5555

56-
String storiesJson = "[]";
56+
//String storiesJson = "[]";
5757

5858
// get the location, but if the user has turned off location services,
5959
// it will come back null. If it's null, we won't ping the server
6060
// and just return a blank json list
6161

62+
/*
6263
double latLng[] = YellrUtils.getLocation(getApplicationContext());
6364
if (latLng != null ) {
6465
@@ -72,7 +73,12 @@ private void handleActionGetStories() {
7273
+ "&language_code=" + languageCode
7374
+ "&lat=" + lat
7475
+ "&lng=" + lng;
76+
*/
77+
String storiesJson = "[]";
7578

79+
String baseUrl = BuildConfig.BASE_URL + "/get_stories.json";
80+
String url = YellrUtils.buildUrl(getApplicationContext(),baseUrl);
81+
if (url != null) {
7682
try {
7783

7884
//

app/src/main/java/yellr/net/yellr_android/utils/YellrUtils.java

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.content.SharedPreferences;
5+
import android.content.pm.PackageInfo;
56
import android.location.Criteria;
67
import android.location.Location;
78
import android.location.LocationManager;
@@ -10,6 +11,7 @@
1011
import java.text.SimpleDateFormat;
1112
import java.util.Date;
1213
import java.util.List;
14+
import java.util.Locale;
1315
import java.util.StringTokenizer;
1416
import java.util.UUID;
1517

@@ -18,7 +20,7 @@
1820
*/
1921
public class YellrUtils {
2022

21-
public static Date PrettifyDateTime(String rawDateTime) {
23+
public static Date prettifyDateTime(String rawDateTime) {
2224

2325
Date date = new Date();
2426
try {
@@ -45,44 +47,72 @@ public static String calcTimeBetween(Date start, Date end) {
4547
if (milliSeconds > DAY) {
4648
t = Math.round(milliSeconds / DAY);
4749
retString = String.format("%d day", t);
48-
if( t > 1) {
50+
if (t > 1) {
4951
retString += "s";
5052
}
5153
//return retString;
52-
}
53-
else if (milliSeconds < DAY && milliSeconds > HOUR) {
54+
} else if (milliSeconds < DAY && milliSeconds > HOUR) {
5455
t = Math.round(milliSeconds / HOUR);
5556
retString = String.format("%d hour", t);
56-
if (t > 1 ) {
57+
if (t > 1) {
5758
retString += "s";
5859
}
5960
//return retString;
60-
}
61-
else if (milliSeconds < HOUR && milliSeconds > 15 * MINUTE) {
61+
} else if (milliSeconds < HOUR && milliSeconds > 15 * MINUTE) {
6262
t = Math.round(milliSeconds / MINUTE);
6363
retString = String.format("%d minute", t);
64-
if ( t > 1 ) {
64+
if (t > 1) {
6565
retString += "s";
6666
}
6767
//return retString;
68-
}
69-
else if (milliSeconds < 15 * MINUTE) {
68+
} else if (milliSeconds < 15 * MINUTE) {
7069
retString = "Moments";
71-
}
72-
else {
70+
} else {
7371
//Throw an exception instead?
7472
}
7573
return retString;
7674
}
7775

78-
public static String ShortenString(String str) {
76+
public static String shortenString(String str) {
7977
String retString = str;
80-
if ( str.length() > 20) {
81-
retString = str.substring(0,20) + " ...";
78+
if (str.length() > 20) {
79+
retString = str.substring(0, 20) + " ...";
8280
}
8381
return retString;
8482
}
8583

84+
public static String getAppVersion(Context context) {
85+
String version = "Unknown";
86+
try {
87+
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
88+
version = pInfo.versionName;
89+
} catch (Exception ex) {
90+
Log.d("YellrUtils.GetAppVersion()", "Error: " + ex.toString());
91+
}
92+
return version;
93+
}
94+
95+
public static String buildUrl(Context context, String baseUrl ) {
96+
97+
String url = null;
98+
99+
double latLng[] = YellrUtils.getLocation(context);
100+
if (latLng != null) {
101+
102+
String languageCode = Locale.getDefault().getLanguage();
103+
104+
url = baseUrl
105+
+ "?cuid=" + YellrUtils.getCUID(context)
106+
+ "&language_code=" + languageCode
107+
+ "&lat=" + latLng[0]
108+
+ "&lng=" + latLng[1]
109+
+ "&platform=" + "Android"
110+
+ "&app_version=" + YellrUtils.getAppVersion(context);
111+
}
112+
113+
return url;
114+
}
115+
86116
public static double[] getLocation(Context context) {
87117

88118
/*
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container"
3-
android:layout_width="match_parent" android:layout_height="match_parent"
4-
tools:context="yellr.net.yellr_android.activities.PostActivity" tools:ignore="MergeRootFrame" />
1+
<FrameLayout
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/container"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context="yellr.net.yellr_android.activities.PostActivity"
8+
tools:ignore="MergeRootFrame" />

app/src/main/res/layout/activity_splash.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<TextView
1414
android:id="@+id/splash_title"
15-
android:text="@string/splash_title"
15+
android:text="@string/activity_splash_title"
1616
android:layout_width="wrap_content"
1717
android:layout_height="wrap_content"
1818
android:layout_centerInParent="true"
@@ -22,7 +22,7 @@
2222

2323
<TextView
2424
android:id="@+id/splash_tagline"
25-
android:text="@string/splash_tagline"
25+
android:text="@string/activity_splash_tag_line"
2626
android:layout_width="wrap_content"
2727
android:layout_height="wrap_content"
2828
android:layout_centerHorizontal="true"

0 commit comments

Comments
 (0)