1
0
mirror of https://github.com/etesync/android synced 2024-11-15 20:38:58 +00:00

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

This commit is contained in:
Tom Hacohen 2017-05-12 11:26:57 +01:00
parent 9f069692c9
commit 0503efa8ac
2 changed files with 36 additions and 19 deletions

View File

@ -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<Telephone> labeledPhone : contact.phoneNumbers) {
List<TelephoneType> 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<Email> labeledEmail : contact.emails) {
List<EmailType> 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<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
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<Address> labeledAddress : contact.addresses) {
List<AddressType> 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<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
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<RelatedType> 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

View File

@ -130,6 +130,22 @@
<!-- JournalItemActivity -->
<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 -->
<string name="permissions_title">EteSync permissions</string>