From 0503efa8ace5de99b0985f870ac5e4f2188fefa3 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 12 May 2017 11:26:57 +0100 Subject: [PATCH] Journal item activity: Use string resources instead of hardcoded strings. --- .../syncadapter/ui/JournalItemActivity.java | 39 ++++++++++--------- app/src/main/res/values/strings.xml | 16 ++++++++ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.java index a66e0ad5..633e127a 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.java @@ -99,17 +99,19 @@ public class JournalItemActivity extends BaseActivity implements Refreshable { refresh(); ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); - viewPager.setAdapter(new TabsAdapter(getSupportFragmentManager(), info, syncEntry)); + viewPager.setAdapter(new TabsAdapter(getSupportFragmentManager(), this, info, syncEntry)); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); } private static class TabsAdapter extends FragmentPagerAdapter { + private Context context; private CollectionInfo info; private SyncEntry syncEntry; - public TabsAdapter(FragmentManager fm, CollectionInfo info, SyncEntry syncEntry) { + public TabsAdapter(FragmentManager fm, Context context, CollectionInfo info, SyncEntry syncEntry) { super(fm); + this.context = context; this.info = info; this.syncEntry = syncEntry; } @@ -122,11 +124,10 @@ public class JournalItemActivity extends BaseActivity implements Refreshable { @Override public CharSequence getPageTitle(int position) { - // FIXME: use string resources if (position == 0) { - return "Main"; + return context.getString(R.string.journal_item_tab_main); } else { - return "Raw"; + return context.getString(R.string.journal_item_tab_raw); } } @@ -245,7 +246,7 @@ public class JournalItemActivity extends BaseActivity implements Refreshable { for (Attendee attendee : event.attendees) { if (first) { first = false; - sb.append("Attendees: "); + sb.append(getString(R.string.journal_item_attendees)).append(": "); } else { sb.append(", "); } @@ -258,7 +259,7 @@ public class JournalItemActivity extends BaseActivity implements Refreshable { for (VAlarm alarm : event.alarms) { if (first) { first = false; - sb.append("Reminders: "); + sb.append(getString(R.string.journal_item_reminders)).append(": "); } else { sb.append(", "); } @@ -307,67 +308,67 @@ public class JournalItemActivity extends BaseActivity implements Refreshable { for (LabeledProperty labeledPhone : contact.phoneNumbers) { List types = labeledPhone.property.getTypes(); String type = (types.size() > 0) ? types.get(0).getValue() : null; - addInfoItem(view.getContext(), mainCard, "Phone", type, labeledPhone.property.getText()); + addInfoItem(view.getContext(), mainCard, getString(R.string.journal_item_phone), type, labeledPhone.property.getText()); } // EMAIL for (LabeledProperty labeledEmail : contact.emails) { List types = labeledEmail.property.getTypes(); String type = (types.size() > 0) ? types.get(0).getValue() : null; - addInfoItem(view.getContext(), mainCard, "Email", type, labeledEmail.property.getValue()); + addInfoItem(view.getContext(), mainCard, getString(R.string.journal_item_email), type, labeledEmail.property.getValue()); } // ORG, TITLE, ROLE if (contact.organization != null) { - addInfoItem(view.getContext(), aboutCard, "Organization", contact.jobTitle, contact.organization.getValues().get(0)); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_organization), contact.jobTitle, contact.organization.getValues().get(0)); } if (contact.jobDescription != null) { - addInfoItem(view.getContext(), aboutCard, "Job Description", null, contact.jobTitle); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_job_description), null, contact.jobTitle); } // IMPP for (LabeledProperty labeledImpp : contact.impps) { - addInfoItem(view.getContext(), mainCard, "Instant Messaging", labeledImpp.property.getProtocol(), labeledImpp.property.getHandle()); + addInfoItem(view.getContext(), mainCard, getString(R.string.journal_item_impp), labeledImpp.property.getProtocol(), labeledImpp.property.getHandle()); } // NICKNAME if (contact.nickName != null) { - addInfoItem(view.getContext(), aboutCard, "Nickname", null, contact.nickName.getValues().get(0)); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_nickname), null, contact.nickName.getValues().get(0)); } // ADR for (LabeledProperty
labeledAddress : contact.addresses) { List types = labeledAddress.property.getTypes(); String type = (types.size() > 0) ? types.get(0).getValue() : null; - addInfoItem(view.getContext(), mainCard, "Address", type, labeledAddress.property.getLabel()); + addInfoItem(view.getContext(), mainCard, getString(R.string.journal_item_address), type, labeledAddress.property.getLabel()); } // NOTE if (contact.note != null) { - addInfoItem(view.getContext(), aboutCard, "Note", null, contact.note); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_note), null, contact.note); } // URL for (LabeledProperty labeledUrl : contact.urls) { - addInfoItem(view.getContext(), aboutCard, "Website", null, labeledUrl.property.getValue()); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_website), null, labeledUrl.property.getValue()); } // ANNIVERSARY if (contact.anniversary != null) { String date = getDisplayedDatetime(contact.anniversary.getDate().getTime(), contact.anniversary.getDate().getTime(), true, getContext()); - addInfoItem(view.getContext(), aboutCard, "Anniversary", null, date); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_anniversary), null, date); } // BDAY if (contact.birthDay != null) { String date = getDisplayedDatetime(contact.birthDay.getDate().getTime(), contact.birthDay.getDate().getTime(), true, getContext()); - addInfoItem(view.getContext(), aboutCard, "Birthday", null, date); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_birthday), null, date); } // RELATED for (Related related : contact.relations) { List types = related.getTypes(); String type = (types.size() > 0) ? types.get(0).getValue() : null; - addInfoItem(view.getContext(), aboutCard, "Relation", type, related.getText()); + addInfoItem(view.getContext(), aboutCard, getString(R.string.journal_item_relation), type, related.getText()); } // PHOTO diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b563adc1..bea6501b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -130,6 +130,22 @@ About + Main + Raw + Attendees + Reminders + Phone + Email + Organization + Job Description + Instant Messaging + Nickname + Address + Note + Website + Anniversary + Birthday + Relation EteSync permissions