Journal item activity: Use string resources instead of hardcoded strings.

pull/14/head
Tom Hacohen 7 years ago
parent 9f069692c9
commit 0503efa8ac

@ -99,17 +99,19 @@ public class JournalItemActivity extends BaseActivity implements Refreshable {
refresh(); refresh();
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); 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 tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
} }
private static class TabsAdapter extends FragmentPagerAdapter { private static class TabsAdapter extends FragmentPagerAdapter {
private Context context;
private CollectionInfo info; private CollectionInfo info;
private SyncEntry syncEntry; private SyncEntry syncEntry;
public TabsAdapter(FragmentManager fm, CollectionInfo info, SyncEntry syncEntry) { public TabsAdapter(FragmentManager fm, Context context, CollectionInfo info, SyncEntry syncEntry) {
super(fm); super(fm);
this.context = context;
this.info = info; this.info = info;
this.syncEntry = syncEntry; this.syncEntry = syncEntry;
} }
@ -122,11 +124,10 @@ public class JournalItemActivity extends BaseActivity implements Refreshable {
@Override @Override
public CharSequence getPageTitle(int position) { public CharSequence getPageTitle(int position) {
// FIXME: use string resources
if (position == 0) { if (position == 0) {
return "Main"; return context.getString(R.string.journal_item_tab_main);
} else { } 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) { for (Attendee attendee : event.attendees) {
if (first) { if (first) {
first = false; first = false;
sb.append("Attendees: "); sb.append(getString(R.string.journal_item_attendees)).append(": ");
} else { } else {
sb.append(", "); sb.append(", ");
} }
@ -258,7 +259,7 @@ public class JournalItemActivity extends BaseActivity implements Refreshable {
for (VAlarm alarm : event.alarms) { for (VAlarm alarm : event.alarms) {
if (first) { if (first) {
first = false; first = false;
sb.append("Reminders: "); sb.append(getString(R.string.journal_item_reminders)).append(": ");
} else { } else {
sb.append(", "); sb.append(", ");
} }
@ -307,67 +308,67 @@ public class JournalItemActivity extends BaseActivity implements Refreshable {
for (LabeledProperty<Telephone> labeledPhone : contact.phoneNumbers) { for (LabeledProperty<Telephone> labeledPhone : contact.phoneNumbers) {
List<TelephoneType> types = labeledPhone.property.getTypes(); List<TelephoneType> types = labeledPhone.property.getTypes();
String type = (types.size() > 0) ? types.get(0).getValue() : null; 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 // EMAIL
for (LabeledProperty<Email> labeledEmail : contact.emails) { for (LabeledProperty<Email> labeledEmail : contact.emails) {
List<EmailType> types = labeledEmail.property.getTypes(); List<EmailType> types = labeledEmail.property.getTypes();
String type = (types.size() > 0) ? types.get(0).getValue() : null; 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 // ORG, TITLE, ROLE
if (contact.organization != null) { 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) { 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 // IMPP
for (LabeledProperty<Impp> labeledImpp : contact.impps) { for (LabeledProperty<Impp> 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 // NICKNAME
if (contact.nickName != null) { 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 // ADR
for (LabeledProperty<Address> labeledAddress : contact.addresses) { for (LabeledProperty<Address> labeledAddress : contact.addresses) {
List<AddressType> types = labeledAddress.property.getTypes(); List<AddressType> types = labeledAddress.property.getTypes();
String type = (types.size() > 0) ? types.get(0).getValue() : null; 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 // NOTE
if (contact.note != null) { 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 // URL
for (LabeledProperty<Url> labeledUrl : contact.urls) { for (LabeledProperty<Url> 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 // ANNIVERSARY
if (contact.anniversary != null) { if (contact.anniversary != null) {
String date = getDisplayedDatetime(contact.anniversary.getDate().getTime(), contact.anniversary.getDate().getTime(), true, getContext()); 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 // BDAY
if (contact.birthDay != null) { if (contact.birthDay != null) {
String date = getDisplayedDatetime(contact.birthDay.getDate().getTime(), contact.birthDay.getDate().getTime(), true, getContext()); 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 // RELATED
for (Related related : contact.relations) { for (Related related : contact.relations) {
List<RelatedType> types = related.getTypes(); List<RelatedType> types = related.getTypes();
String type = (types.size() > 0) ? types.get(0).getValue() : null; 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 // PHOTO

@ -130,6 +130,22 @@
<!-- JournalItemActivity --> <!-- JournalItemActivity -->
<string name="about">About</string> <string name="about">About</string>
<string name="journal_item_tab_main">Main</string>
<string name="journal_item_tab_raw">Raw</string>
<string name="journal_item_attendees">Attendees</string>
<string name="journal_item_reminders">Reminders</string>
<string name="journal_item_phone">Phone</string>
<string name="journal_item_email">Email</string>
<string name="journal_item_organization">Organization</string>
<string name="journal_item_job_description">Job Description</string>
<string name="journal_item_impp">Instant Messaging</string>
<string name="journal_item_nickname">Nickname</string>
<string name="journal_item_address">Address</string>
<string name="journal_item_note">Note</string>
<string name="journal_item_website">Website</string>
<string name="journal_item_anniversary">Anniversary</string>
<string name="journal_item_birthday">Birthday</string>
<string name="journal_item_relation">Relation</string>
<!-- PermissionsActivity --> <!-- PermissionsActivity -->
<string name="permissions_title">EteSync permissions</string> <string name="permissions_title">EteSync permissions</string>

Loading…
Cancel
Save