1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-10 11:35:11 -05:00

Switch our font sizes to have a "default", which is the size described in the XML.

Unify the text field size setting code. We should put it in a better place
This commit is contained in:
Jesse Vincent 2013-02-08 21:19:22 -05:00
parent cf988cad7e
commit c4b941b9b9
10 changed files with 79 additions and 58 deletions

View File

@ -537,6 +537,7 @@
</string-array>
<string-array name="font_entries">
<item>@string/font_size_default</item>
<item>@string/font_size_tiniest</item>
<item>@string/font_size_tiny</item>
<item>@string/font_size_smaller</item>
@ -547,6 +548,7 @@
</string-array>
<string-array name="font_values">
<item>-1</item>
<item>10</item>
<item>12</item>
<item>14</item>

View File

@ -941,6 +941,7 @@ Please submit bug reports, contribute new features and ask questions at
<string name="font_size_message_compose">Message composition</string>
<string name="font_size_message_compose_input">Text input fields</string>
<string name="font_size_default">Default</string>
<string name="font_size_tiniest">Tiniest</string>
<string name="font_size_tiny">Tiny</string>
<string name="font_size_smaller">Smaller</string>

View File

@ -1,7 +1,9 @@
package com.fsck.k9;
import android.content.SharedPreferences;
import android.util.TypedValue;
import android.webkit.WebSettings.TextSize;
import android.widget.TextView;
/**
* Manage font size of the information displayed in the account list, folder
@ -32,6 +34,7 @@ public class FontSizes {
/*
* Values for the font sizes in SP (Scale-independent Pixels)
*/
public static final int FONT_DEFAULT = -1; // Don't force-reset the size of this setting
public static final int FONT_10SP = 10;
public static final int FONT_12SP = 12;
public static final int SMALL = 14; // ?android:attr/textAppearanceSmall
@ -133,24 +136,24 @@ public class FontSizes {
* Create a <code>FontSizes</code> object with default values.
*/
public FontSizes() {
accountName = MEDIUM;
accountDescription = SMALL;
accountName = FONT_DEFAULT;
accountDescription = FONT_DEFAULT;
folderName = MEDIUM;
folderStatus = SMALL;
folderName = FONT_DEFAULT;
folderStatus = FONT_DEFAULT;
messageListSubject = FONT_16SP;
messageListSender = SMALL;
messageListDate = SMALL;
messageListPreview = SMALL;
messageListSubject = FONT_DEFAULT;
messageListSender = FONT_DEFAULT;
messageListDate = FONT_DEFAULT;
messageListPreview = FONT_DEFAULT;
messageViewSender = SMALL;
messageViewTo = FONT_12SP;
messageViewCC = FONT_12SP;
messageViewAdditionalHeaders = FONT_12SP;
messageViewSubject = FONT_12SP;
messageViewTime = FONT_10SP;
messageViewDate = FONT_10SP;
messageViewSender = FONT_DEFAULT;
messageViewTo = FONT_DEFAULT;
messageViewCC = FONT_DEFAULT;
messageViewAdditionalHeaders = FONT_DEFAULT;
messageViewSubject = FONT_DEFAULT;
messageViewTime = FONT_DEFAULT;
messageViewDate = FONT_DEFAULT;
messageComposeInput = MEDIUM;
}
@ -380,4 +383,12 @@ public class FontSizes {
public void setMessageComposeInput(int messageComposeInput) {
this.messageComposeInput = messageComposeInput;
}
}
// This, arguably, should live somewhere in a view class, but since we call it from activities, fragments
// and views, where isn't exactly clear.
public void setViewTextSize(TextView v, int fontSize) {
if (fontSize != FONT_DEFAULT) {
v.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
}
}
}

View File

@ -154,10 +154,9 @@ public abstract class AccountList extends K9ListActivity implements OnItemClickL
holder.chip.getBackground().setAlpha(255);
holder.description.setTextSize(TypedValue.COMPLEX_UNIT_SP,
mFontSizes.getAccountName());
holder.email.setTextSize(TypedValue.COMPLEX_UNIT_SP,
mFontSizes.getAccountDescription());
mFontSizes.setViewTextSize(holder.description, mFontSizes.getAccountName());
mFontSizes.setViewTextSize(holder.email, mFontSizes.getAccountDescription());
return view;
}

View File

@ -1748,8 +1748,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
}
holder.description.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getAccountName());
holder.email.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getAccountDescription());
mFontSizes.setViewTextSize(holder.description, mFontSizes.getAccountName());
mFontSizes.setViewTextSize(holder.email, mFontSizes.getAccountDescription());
if (account instanceof SearchAccount) {
holder.folders.setVisibility(View.GONE);

View File

@ -1103,7 +1103,9 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
holder.chip.setBackgroundDrawable(mAccount.generateColorChip((folder.unreadMessageCount == 0 ? true : false ), false, false, false,false).drawable());
holder.folderName.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getFolderName());
mFontSizes.setViewTextSize(holder.folderName, mFontSizes.getFolderName());
if (K9.wrapFolderNames()) {
holder.folderName.setEllipsize(null);
holder.folderName.setSingleLine(false);
@ -1112,7 +1114,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
holder.folderName.setEllipsize(TruncateAt.START);
holder.folderName.setSingleLine(true);
}
holder.folderStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getFolderStatus());
mFontSizes.setViewTextSize(holder.folderStatus, mFontSizes.getFolderStatus());
return view;

View File

@ -850,13 +850,14 @@ public class MessageCompose extends K9Activity implements OnClickListener {
// Set font size of input controls
int fontSize = mFontSizes.getMessageComposeInput();
mToView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mCcView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mBccView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mSubjectView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mMessageContentView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mQuotedText.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mSignatureView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
mFontSizes.setViewTextSize(mToView, fontSize);
mFontSizes.setViewTextSize(mCcView, fontSize);
mFontSizes.setViewTextSize(mBccView, fontSize);
mFontSizes.setViewTextSize(mSubjectView, fontSize);
mFontSizes.setViewTextSize(mMessageContentView, fontSize);
mFontSizes.setViewTextSize(mQuotedText, fontSize);
mFontSizes.setViewTextSize(mSignatureView, fontSize);
updateMessageFormat();

View File

@ -1746,17 +1746,20 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
if (mSenderAboveSubject) {
holder.from = (TextView) view.findViewById(R.id.subject);
holder.from.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListSender());
mFontSizes.setViewTextSize(holder.from, mFontSizes.getMessageListSender());
} else {
holder.subject = (TextView) view.findViewById(R.id.subject);
holder.subject.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListSubject());
mFontSizes.setViewTextSize(holder.subject, mFontSizes.getMessageListSubject());
}
holder.date.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListDate());
mFontSizes.setViewTextSize(holder.date, mFontSizes.getMessageListDate());
// 1 preview line is needed even if it is set to 0, because subject is part of the same text view
holder.preview.setLines(Math.max(mPreviewLines,1));
holder.preview.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListPreview());
mFontSizes.setViewTextSize(holder.preview, mFontSizes.getMessageListPreview());
holder.threadCount = (TextView) view.findViewById(R.id.thread_count);
holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);

View File

@ -73,55 +73,55 @@ public class GlobalSettings {
new V(1, new BooleanSetting(false))
));
s.put("fontSizeAccountDescription", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.SMALL))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeAccountName", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.MEDIUM))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeFolderName", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.LARGE))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeFolderStatus", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.SMALL))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageComposeInput", Settings.versions(
new V(5, new FontSizeSetting(FontSizes.MEDIUM))
new V(5, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageListDate", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.SMALL))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageListPreview", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.SMALL))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageListSender", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.SMALL))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageListSubject", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_16SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewAdditionalHeaders", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_12SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewCC", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_12SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewContent", Settings.versions(
new V(1, new WebFontSizeSetting(3))
));
s.put("fontSizeMessageViewDate", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_10SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewSender", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.SMALL))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewSubject", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_12SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewTime", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_10SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("fontSizeMessageViewTo", Settings.versions(
new V(1, new FontSizeSetting(FontSizes.FONT_12SP))
new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
));
s.put("gesturesEnabled", Settings.versions(
new V(1, new BooleanSetting(true)),

View File

@ -100,14 +100,14 @@ public class MessageHeader extends ScrollView implements OnClickListener {
mFlagged = (CheckBox) findViewById(R.id.flagged);
defaultSubjectColor = mSubjectView.getCurrentTextColor();
mSubjectView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewSubject());
mTimeView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewTime());
mDateView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewDate());
mAdditionalHeadersView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewAdditionalHeaders());
mFontSizes.setViewTextSize(mSubjectView, mFontSizes.getMessageViewSubject());
mFontSizes.setViewTextSize(mTimeView, mFontSizes.getMessageViewTime());
mFontSizes.setViewTextSize(mDateView, mFontSizes.getMessageViewDate());
mFontSizes.setViewTextSize(mAdditionalHeadersView, mFontSizes.getMessageViewAdditionalHeaders());
mFromView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewSender());
mToView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewTo());
mCcView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewCC());
mFontSizes.setViewTextSize(mFromView, mFontSizes.getMessageViewSender());
mFontSizes.setViewTextSize(mToView, mFontSizes.getMessageViewTo());
mFontSizes.setViewTextSize(mCcView, mFontSizes.getMessageViewCC());
mFromView.setOnClickListener(this);
mToView.setOnClickListener(this);