1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 09:08:49 -05:00

find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs --unpad=paren

This commit is contained in:
Jesse Vincent 2010-04-29 04:59:14 +00:00
parent 2775795abe
commit 8af7f4a7b6
48 changed files with 579 additions and 513 deletions

View File

@ -219,9 +219,9 @@ public class Account implements BaseAccount
Random random = new Random((long)mAccountNumber+4); Random random = new Random((long)mAccountNumber+4);
mChipColor = preferences.getPreferences().getInt(mUuid+".chipColor", mChipColor = preferences.getPreferences().getInt(mUuid+".chipColor",
(random.nextInt(0x70) ) + (random.nextInt(0x70)) +
(random.nextInt(0x70) * 0xff ) + (random.nextInt(0x70) * 0xff) +
(random.nextInt(0x70) * 0xffff ) + (random.nextInt(0x70) * 0xffff) +
0xff000000); 0xff000000);
mVibrate = preferences.getPreferences().getBoolean(mUuid + ".vibrate", false); mVibrate = preferences.getPreferences().getBoolean(mUuid + ".vibrate", false);
@ -505,11 +505,13 @@ public class Account implements BaseAccount
} }
public void setChipColor(int color) { public void setChipColor(int color)
{
mChipColor = color; mChipColor = color;
} }
public int getChipColor() { public int getChipColor()
{
return mChipColor; return mChipColor;
} }

View File

@ -25,25 +25,30 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
public class ColorPickerDialog extends Dialog { public class ColorPickerDialog extends Dialog
{
public interface OnColorChangedListener { public interface OnColorChangedListener
{
void colorChanged(int color); void colorChanged(int color);
} }
private OnColorChangedListener mListener; private OnColorChangedListener mListener;
private int mInitialColor; private int mInitialColor;
private static class ColorPickerView extends View { private static class ColorPickerView extends View
{
private Paint mPaint; private Paint mPaint;
private Paint mCenterPaint; private Paint mCenterPaint;
private final int[] mColors; private final int[] mColors;
private OnColorChangedListener mListener; private OnColorChangedListener mListener;
ColorPickerView(Context c, OnColorChangedListener l, int color) { ColorPickerView(Context c, OnColorChangedListener l, int color)
{
super(c); super(c);
mListener = l; mListener = l;
mColors = new int[] { mColors = new int[]
{
0xFF800000, 0xFF800080, 0xFF000080, 0xFF008080, 0xFF008000, 0xFF800000, 0xFF800080, 0xFF000080, 0xFF008080, 0xFF008000,
0xFF808000, 0xFF800000 0xFF808000, 0xFF800000
}; };
@ -63,7 +68,8 @@ public class ColorPickerDialog extends Dialog {
private boolean mHighlightCenter; private boolean mHighlightCenter;
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas)
{
float r = CENTER_X - mPaint.getStrokeWidth()*0.5f; float r = CENTER_X - mPaint.getStrokeWidth()*0.5f;
canvas.translate(CENTER_X, CENTER_X); canvas.translate(CENTER_X, CENTER_X);
@ -71,13 +77,17 @@ public class ColorPickerDialog extends Dialog {
canvas.drawOval(new RectF(-r, -r, r, r), mPaint); canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint); canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);
if (mTrackingCenter) { if (mTrackingCenter)
{
int c = mCenterPaint.getColor(); int c = mCenterPaint.getColor();
mCenterPaint.setStyle(Paint.Style.STROKE); mCenterPaint.setStyle(Paint.Style.STROKE);
if (mHighlightCenter) { if (mHighlightCenter)
{
mCenterPaint.setAlpha(0xFF); mCenterPaint.setAlpha(0xFF);
} else { }
else
{
mCenterPaint.setAlpha(0x80); mCenterPaint.setAlpha(0x80);
} }
canvas.drawCircle(0, 0, canvas.drawCircle(0, 0,
@ -90,7 +100,8 @@ public class ColorPickerDialog extends Dialog {
} }
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
setMeasuredDimension(CENTER_X*2, CENTER_Y*2); setMeasuredDimension(CENTER_X*2, CENTER_Y*2);
} }
@ -98,28 +109,37 @@ public class ColorPickerDialog extends Dialog {
private static final int CENTER_Y = 100; private static final int CENTER_Y = 100;
private static final int CENTER_RADIUS = 32; private static final int CENTER_RADIUS = 32;
private int floatToByte(float x) { private int floatToByte(float x)
{
int n = java.lang.Math.round(x); int n = java.lang.Math.round(x);
return n; return n;
} }
private int pinToByte(int n) { private int pinToByte(int n)
if (n < 0) { {
if (n < 0)
{
n = 0; n = 0;
} else if (n > 255) { }
else if (n > 255)
{
n = 255; n = 255;
} }
return n; return n;
} }
private int ave(int s, int d, float p) { private int ave(int s, int d, float p)
return s + java.lang.Math.round(p * (d - s)); {
return s + java.lang.Math.round(p *(d - s));
} }
private int interpColor(int colors[], float unit) { private int interpColor(int colors[], float unit)
if (unit <= 0) { {
if (unit <= 0)
{
return colors[0]; return colors[0];
} }
if (unit >= 1) { if (unit >= 1)
{
return colors[colors.length - 1]; return colors[colors.length - 1];
} }
@ -138,7 +158,8 @@ public class ColorPickerDialog extends Dialog {
return Color.argb(a, r, g, b); return Color.argb(a, r, g, b);
} }
private int rotateColor(int color, float rad) { private int rotateColor(int color, float rad)
{
float deg = rad * 180 / 3.1415927f; float deg = rad * 180 / 3.1415927f;
int r = Color.red(color); int r = Color.red(color);
int g = Color.green(color); int g = Color.green(color);
@ -166,30 +187,38 @@ public class ColorPickerDialog extends Dialog {
private static final float PI = 3.1415926f; private static final float PI = 3.1415926f;
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event)
{
float x = event.getX() - CENTER_X; float x = event.getX() - CENTER_X;
float y = event.getY() - CENTER_Y; float y = event.getY() - CENTER_Y;
boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS; boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS;
switch (event.getAction()) { switch (event.getAction())
{
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
mTrackingCenter = inCenter; mTrackingCenter = inCenter;
if (inCenter) { if (inCenter)
{
mHighlightCenter = true; mHighlightCenter = true;
invalidate(); invalidate();
break; break;
} }
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
if (mTrackingCenter) { if (mTrackingCenter)
if (mHighlightCenter != inCenter) { {
if (mHighlightCenter != inCenter)
{
mHighlightCenter = inCenter; mHighlightCenter = inCenter;
invalidate(); invalidate();
} }
} else { }
else
{
float angle = (float)java.lang.Math.atan2(y, x); float angle = (float)java.lang.Math.atan2(y, x);
// need to turn angle [-PI ... PI] into unit [0....1] // need to turn angle [-PI ... PI] into unit [0....1]
float unit = angle/(2*PI); float unit = angle/(2*PI);
if (unit < 0) { if (unit < 0)
{
unit += 1; unit += 1;
} }
mCenterPaint.setColor(interpColor(mColors, unit)); mCenterPaint.setColor(interpColor(mColors, unit));
@ -197,8 +226,10 @@ public class ColorPickerDialog extends Dialog {
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
if (mTrackingCenter) { if (mTrackingCenter)
if (inCenter) { {
if (inCenter)
{
mListener.colorChanged(mCenterPaint.getColor()); mListener.colorChanged(mCenterPaint.getColor());
} }
mTrackingCenter = false; // so we draw w/o halo mTrackingCenter = false; // so we draw w/o halo
@ -214,7 +245,8 @@ public class ColorPickerDialog extends Dialog {
public ColorPickerDialog(Context context, public ColorPickerDialog(Context context,
OnColorChangedListener listener, OnColorChangedListener listener,
int initialColor) { int initialColor)
{
super(context); super(context);
mListener = listener; mListener = listener;
@ -222,10 +254,13 @@ public class ColorPickerDialog extends Dialog {
} }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OnColorChangedListener l = new OnColorChangedListener() { OnColorChangedListener l = new OnColorChangedListener()
public void colorChanged(int color) { {
public void colorChanged(int color)
{
mListener.colorChanged(color); mListener.colorChanged(color);
dismiss(); dismiss();
} }

View File

@ -34,7 +34,8 @@ public class EmailAddressAdapterSdk5 extends EmailAddressAdapter
private static final String SORT_ORDER = Contacts.TIMES_CONTACTED private static final String SORT_ORDER = Contacts.TIMES_CONTACTED
+ " DESC, " + Contacts.DISPLAY_NAME; + " DESC, " + Contacts.DISPLAY_NAME;
private static final String[] PROJECTION = { private static final String[] PROJECTION =
{
Data._ID, // 0 Data._ID, // 0
Contacts.DISPLAY_NAME, // 1 Contacts.DISPLAY_NAME, // 1
Email.DATA // 2 Email.DATA // 2

View File

@ -325,12 +325,17 @@ public class FontSizes
{ {
switch (messageViewContent) switch (messageViewContent)
{ {
case SMALLEST: return 1; case SMALLEST:
case SMALLER: return 2; return 1;
case SMALLER:
return 2;
default: default:
case NORMAL: return 3; case NORMAL:
case LARGER: return 4; return 3;
case LARGEST: return 5; case LARGER:
return 4;
case LARGEST:
return 5;
} }
} }
@ -338,11 +343,21 @@ public class FontSizes
{ {
switch (size) switch (size)
{ {
case 1: messageViewContent = TextSize.SMALLEST; break; case 1:
case 2: messageViewContent = TextSize.SMALLER; break; messageViewContent = TextSize.SMALLEST;
case 3: messageViewContent = TextSize.NORMAL; break; break;
case 4: messageViewContent = TextSize.LARGER; break; case 2:
case 5: messageViewContent = TextSize.LARGEST; break; messageViewContent = TextSize.SMALLER;
break;
case 3:
messageViewContent = TextSize.NORMAL;
break;
case 4:
messageViewContent = TextSize.LARGER;
break;
case 5:
messageViewContent = TextSize.LARGEST;
break;
} }
} }
} }

View File

@ -308,7 +308,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
@Override @Override
public void onCreate(Bundle icicle) public void onCreate(Bundle icicle)
{ {
unreadAccount = new SearchAccount(this, false, null, null ); unreadAccount = new SearchAccount(this, false, null, null);
unreadAccount.setDescription(getString(R.string.search_all_messages_title)); unreadAccount.setDescription(getString(R.string.search_all_messages_title));
unreadAccount.setEmail(getString(R.string.search_all_messages_detail)); unreadAccount.setEmail(getString(R.string.search_all_messages_detail));
@ -918,7 +918,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
final BaseAccount account; final BaseAccount account;
final SearchModifier searchModifier; final SearchModifier searchModifier;
AccountClickListener(BaseAccount nAccount, SearchModifier nSearchModifier ) AccountClickListener(BaseAccount nAccount, SearchModifier nSearchModifier)
{ {
account = nAccount; account = nAccount;
searchModifier = nSearchModifier; searchModifier = nSearchModifier;

View File

@ -74,7 +74,8 @@ public class EditIdentity extends K9Activity
mSignatureUse = (CheckBox)findViewById(R.id.signature_use); mSignatureUse = (CheckBox)findViewById(R.id.signature_use);
mSignatureView = (EditText)findViewById(R.id.signature); mSignatureView = (EditText)findViewById(R.id.signature);
mSignatureUse.setChecked(mIdentity.getSignatureUse()); mSignatureUse.setChecked(mIdentity.getSignatureUse());
mSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { mSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{ {
if (isChecked) if (isChecked)

View File

@ -1446,7 +1446,7 @@ public class FolderList extends K9ListActivity
final String folderName; final String folderName;
final String displayName; final String displayName;
final SearchModifier searchModifier; final SearchModifier searchModifier;
FolderClickListener(BaseAccount nAccount, String folderName, String displayName, SearchModifier nSearchModifier ) FolderClickListener(BaseAccount nAccount, String folderName, String displayName, SearchModifier nSearchModifier)
{ {
account = nAccount; account = nAccount;
this.folderName = folderName; this.folderName = folderName;

View File

@ -980,11 +980,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
File f = new File(uriString.substring("file://".length())); File f = new File(uriString.substring("file://".length()));
attachment.size = f.length(); attachment.size = f.length();
} }
else { else
{
Log.v(K9.LOG_TAG, "Not a file: " + uriString); Log.v(K9.LOG_TAG, "Not a file: " + uriString);
} }
} }
else { else
{
Log.v(K9.LOG_TAG, "old attachment.size: " + attachment.size); Log.v(K9.LOG_TAG, "old attachment.size: " + attachment.size);
} }
Log.v(K9.LOG_TAG, "new attachment.size: " + attachment.size); Log.v(K9.LOG_TAG, "new attachment.size: " + attachment.size);
@ -1602,7 +1604,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* *
* @mailToString the href (which must start with "mailto:"). * @mailToString the href (which must start with "mailto:").
*/ */
private void initializeFromMailTo(String mailToString) { private void initializeFromMailTo(String mailToString)
{
// Chop up everything between mailto: and ? to find recipients // Chop up everything between mailto: and ? to find recipients
int index = mailToString.indexOf("?"); int index = mailToString.indexOf("?");

View File

@ -498,7 +498,7 @@ public class MessageList
} }
private void initializeLayout () private void initializeLayout()
{ {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS);

View File

@ -279,7 +279,7 @@ public class MessageView extends K9Activity implements OnClickListener
mTimeView.setText(time); mTimeView.setText(time);
mToView.setText(to); mToView.setText(to);
mCcContainerView.setVisibility((cc != null && cc.length() > 0 )? View.VISIBLE : View.GONE); mCcContainerView.setVisibility((cc != null && cc.length() > 0)? View.VISIBLE : View.GONE);
mCcView.setText(cc); mCcView.setText(cc);
mAttachmentIcon.setVisibility(hasAttachments ? View.VISIBLE : View.GONE); mAttachmentIcon.setVisibility(hasAttachments ? View.VISIBLE : View.GONE);

View File

@ -8,7 +8,7 @@ import com.fsck.k9.mail.Flag;
enum SearchModifier enum SearchModifier
{ {
FLAGGED(R.string.flagged_modifier, new Flag[] { Flag.FLAGGED}, null), UNREAD(R.string.unread_modifier, null, new Flag[] { Flag.SEEN} ); FLAGGED(R.string.flagged_modifier, new Flag[] { Flag.FLAGGED}, null), UNREAD(R.string.unread_modifier, null, new Flag[] { Flag.SEEN});
final int resId; final int resId;
final Flag[] requiredFlags; final Flag[] requiredFlags;

View File

@ -325,7 +325,8 @@ public class AccountSettings extends K9PreferenceActivity
mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName())); mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName()));
mAutoExpandFolder.setOnPreferenceClickListener( mAutoExpandFolder.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() { new Preference.OnPreferenceClickListener()
{
public boolean onPreferenceClick(Preference preference) public boolean onPreferenceClick(Preference preference)
{ {
onChooseAutoExpandFolder(); onChooseAutoExpandFolder();
@ -338,7 +339,8 @@ public class AccountSettings extends K9PreferenceActivity
mChipColor = (Preference)findPreference(PREFERENCE_CHIP_COLOR); mChipColor = (Preference)findPreference(PREFERENCE_CHIP_COLOR);
mChipColor.setOnPreferenceClickListener( mChipColor.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() { new Preference.OnPreferenceClickListener()
{
public boolean onPreferenceClick(Preference preference) public boolean onPreferenceClick(Preference preference)
{ {
onChooseChipColor(); onChooseChipColor();
@ -509,8 +511,13 @@ public class AccountSettings extends K9PreferenceActivity
public void onChooseChipColor() public void onChooseChipColor()
{ {
new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener () { new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener()
public void colorChanged (int color) { mAccount.setChipColor(color); } }, {
public void colorChanged(int color)
{
mAccount.setChipColor(color);
}
},
mAccount.getChipColor()).show(); mAccount.getChipColor()).show();
} }

View File

@ -74,7 +74,8 @@ public class AccountSetupComposition extends K9Activity
mAccountSignatureUse = (CheckBox)findViewById(R.id.account_signature_use); mAccountSignatureUse = (CheckBox)findViewById(R.id.account_signature_use);
boolean useSignature = mAccount.getSignatureUse(); boolean useSignature = mAccount.getSignatureUse();
mAccountSignatureUse.setChecked(useSignature); mAccountSignatureUse.setChecked(useSignature);
mAccountSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { mAccountSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{ {
if (isChecked) if (isChecked)

View File

@ -166,7 +166,8 @@ public class AttachmentProvider extends ContentProvider
if (!file.exists()) if (!file.exists())
{ {
file = new File("/sdcard" + attachmentsDir.getCanonicalPath().substring("/data".length()), id); file = new File("/sdcard" + attachmentsDir.getCanonicalPath().substring("/data".length()), id);
if (!file.exists()) { if (!file.exists())
{
throw new FileNotFoundException(); throw new FileNotFoundException();
} }
} }

View File

@ -137,7 +137,7 @@ public abstract class CoreService extends Service
if (threadPool == null) if (threadPool == null)
{ {
Log.e(K9.LOG_TAG, "CoreService.execute (" + className + ") called with no threadPool available; running Runnable " + runner.hashCode() + " in calling thread", new Throwable()); Log.e(K9.LOG_TAG, "CoreService.execute (" + className + ") called with no threadPool available; running Runnable " + runner.hashCode() + " in calling thread", new Throwable());
synchronized(this) synchronized (this)
{ {
myRunner.run(); myRunner.run();
} }

View File

@ -192,7 +192,7 @@ public class MailService extends CoreService
startIdObj = null; startIdObj = null;
} }
} }
else if (CONNECTIVITY_CHANGE.equals(intent.getAction()) ) else if (CONNECTIVITY_CHANGE.equals(intent.getAction()))
{ {
notifyConnectionStatus(hasConnectivity); notifyConnectionStatus(hasConnectivity);
rescheduleAll(hasConnectivity, doBackground, startIdObj); rescheduleAll(hasConnectivity, doBackground, startIdObj);