mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-30 23:00:09 -05:00
Remove 100loc of custom date formatting code which worked around a deficiency in the android 1.0 API
This commit is contained in:
parent
5727cb3c3b
commit
7707270b31
@ -1,6 +1,5 @@
|
|||||||
package com.android.email.activity;
|
package com.android.email.activity;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -18,6 +17,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.text.format.DateFormat;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -83,51 +83,12 @@ public class FolderList extends K9ListActivity
|
|||||||
|
|
||||||
private FolderListHandler mHandler = new FolderListHandler();
|
private FolderListHandler mHandler = new FolderListHandler();
|
||||||
|
|
||||||
private DateFormat dateFormat = null;
|
|
||||||
|
|
||||||
private DateFormat timeFormat = null;
|
|
||||||
|
|
||||||
private boolean mStartup = false;
|
private boolean mStartup = false;
|
||||||
|
|
||||||
private DateFormat getDateFormat()
|
private java.text.DateFormat mDateFormat;
|
||||||
{
|
|
||||||
if (dateFormat == null)
|
|
||||||
{
|
|
||||||
String dateFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
|
||||||
android.provider.Settings.System.DATE_FORMAT);
|
|
||||||
|
|
||||||
if (dateFormatS != null)
|
private java.text.DateFormat mTimeFormat;
|
||||||
{
|
|
||||||
dateFormat = new java.text.SimpleDateFormat(dateFormatS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DateFormat getTimeFormat()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (timeFormat == null)
|
|
||||||
{
|
|
||||||
String timeFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
|
||||||
android.provider.Settings.System.TIME_12_24);
|
|
||||||
boolean b24 = !(timeFormatS == null || timeFormatS.equals("12"));
|
|
||||||
timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12);
|
|
||||||
}
|
|
||||||
|
|
||||||
return timeFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearFormats()
|
|
||||||
{
|
|
||||||
dateFormat = null;
|
|
||||||
timeFormat = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
class FolderListHandler extends Handler
|
class FolderListHandler extends Handler
|
||||||
{
|
{
|
||||||
@ -393,6 +354,10 @@ public class FolderList extends K9ListActivity
|
|||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||||
Log.v(Email.LOG_TAG, "savedInstanceState: " + (savedInstanceState==null));
|
Log.v(Email.LOG_TAG, "savedInstanceState: " + (savedInstanceState==null));
|
||||||
|
|
||||||
|
mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
|
||||||
|
mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format
|
||||||
|
|
||||||
if (savedInstanceState == null)
|
if (savedInstanceState == null)
|
||||||
{
|
{
|
||||||
initialFolder = intent.getStringExtra(EXTRA_INITIAL_FOLDER);
|
initialFolder = intent.getStringExtra(EXTRA_INITIAL_FOLDER);
|
||||||
@ -486,7 +451,6 @@ public class FolderList extends K9ListActivity
|
|||||||
@Override public void onResume()
|
@Override public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
clearFormats();
|
|
||||||
|
|
||||||
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
|
MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
|
||||||
mAccount.refresh(Preferences.getPreferences(this));
|
mAccount.refresh(Preferences.getPreferences(this));
|
||||||
@ -1233,8 +1197,8 @@ public class FolderList extends K9ListActivity
|
|||||||
{
|
{
|
||||||
Date lastCheckedDate = new Date(folder.lastChecked);
|
Date lastCheckedDate = new Date(folder.lastChecked);
|
||||||
|
|
||||||
statusText = (getDateFormat().format(lastCheckedDate) + " " + getTimeFormat()
|
statusText = mTimeFormat.format(lastCheckedDate) + " "+
|
||||||
.format(lastCheckedDate));
|
mDateFormat.format(lastCheckedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folder.pushActive)
|
if (folder.pushActive)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.android.email.activity;
|
package com.android.email.activity;
|
||||||
//import android.os.Debug;
|
//import android.os.Debug;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -17,6 +16,7 @@ import android.graphics.Typeface;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.text.format.DateFormat;
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
@ -135,6 +135,10 @@ public class MessageList
|
|||||||
|
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
|
|
||||||
|
private java.text.DateFormat mDateFormat;
|
||||||
|
|
||||||
|
private java.text.DateFormat mTimeFormat;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the name of the folder that we want to open as soon as possible
|
* Stores the name of the folder that we want to open as soon as possible
|
||||||
@ -144,10 +148,6 @@ public class MessageList
|
|||||||
|
|
||||||
private MessageListHandler mHandler = new MessageListHandler();
|
private MessageListHandler mHandler = new MessageListHandler();
|
||||||
|
|
||||||
private DateFormat dateFormat = null;
|
|
||||||
|
|
||||||
private DateFormat timeFormat = null;
|
|
||||||
|
|
||||||
private SORT_TYPE sortType = SORT_TYPE.SORT_DATE;
|
private SORT_TYPE sortType = SORT_TYPE.SORT_DATE;
|
||||||
|
|
||||||
private boolean sortAscending = true;
|
private boolean sortAscending = true;
|
||||||
@ -163,48 +163,6 @@ public class MessageList
|
|||||||
private Button mBatchDeleteButton;
|
private Button mBatchDeleteButton;
|
||||||
private Button mBatchFlagButton;
|
private Button mBatchFlagButton;
|
||||||
|
|
||||||
private DateFormat getDateFormat()
|
|
||||||
{
|
|
||||||
if (dateFormat == null)
|
|
||||||
{
|
|
||||||
String dateFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
|
||||||
android.provider.Settings.System.DATE_FORMAT);
|
|
||||||
|
|
||||||
if (dateFormatS != null)
|
|
||||||
{
|
|
||||||
dateFormat = new java.text.SimpleDateFormat(dateFormatS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DateFormat getTimeFormat()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (timeFormat == null)
|
|
||||||
{
|
|
||||||
String timeFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
|
||||||
android.provider.Settings.System.TIME_12_24);
|
|
||||||
boolean b24 = !(timeFormatS == null || timeFormatS.equals("12"));
|
|
||||||
timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12);
|
|
||||||
}
|
|
||||||
|
|
||||||
return timeFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearFormats()
|
|
||||||
{
|
|
||||||
dateFormat = null;
|
|
||||||
timeFormat = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MessageListHandler extends Handler
|
class MessageListHandler extends Handler
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -401,10 +359,12 @@ public class MessageList
|
|||||||
mAdapter.mListener);
|
mAdapter.mListener);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (mSelectedWidget == WIDGET_MULTISELECT) {
|
else if (mSelectedWidget == WIDGET_MULTISELECT)
|
||||||
|
{
|
||||||
CheckBox selected = (CheckBox) v.findViewById(R.id.selected_checkbox);
|
CheckBox selected = (CheckBox) v.findViewById(R.id.selected_checkbox);
|
||||||
selected.setChecked(!selected.isChecked());
|
selected.setChecked(!selected.isChecked());
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(position);
|
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(position);
|
||||||
onOpenMessage(message);
|
onOpenMessage(message);
|
||||||
@ -428,6 +388,11 @@ public class MessageList
|
|||||||
mListView.setScrollingCacheEnabled(true);
|
mListView.setScrollingCacheEnabled(true);
|
||||||
mListView.setOnItemClickListener(this);
|
mListView.setOnItemClickListener(this);
|
||||||
|
|
||||||
|
|
||||||
|
mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
|
||||||
|
mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format
|
||||||
|
|
||||||
|
|
||||||
registerForContextMenu(mListView);
|
registerForContextMenu(mListView);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -536,7 +501,6 @@ public class MessageList
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
clearFormats();
|
|
||||||
sortType = MessagingController.getInstance(getApplication()).getSortType();
|
sortType = MessagingController.getInstance(getApplication()).getSortType();
|
||||||
sortAscending = MessagingController.getInstance(getApplication()).isSortAscending(sortType);
|
sortAscending = MessagingController.getInstance(getApplication()).isSortAscending(sortType);
|
||||||
sortDateAscending = MessagingController.getInstance(getApplication()).isSortAscending(SORT_TYPE.SORT_DATE);
|
sortDateAscending = MessagingController.getInstance(getApplication()).isSortAscending(SORT_TYPE.SORT_DATE);
|
||||||
@ -626,7 +590,7 @@ public class MessageList
|
|||||||
{
|
{
|
||||||
if (position >= 0)
|
if (position >= 0)
|
||||||
{
|
{
|
||||||
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(position);
|
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(position);
|
||||||
|
|
||||||
|
|
||||||
if (message != null)
|
if (message != null)
|
||||||
@ -2013,13 +1977,14 @@ public class MessageList
|
|||||||
|
|
||||||
if (Utility.isDateToday(date))
|
if (Utility.isDateToday(date))
|
||||||
{
|
{
|
||||||
this.date = getTimeFormat().format(date);
|
this.date = mTimeFormat.format(date);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.date = getDateFormat().format(date);
|
this.date = mDateFormat.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.hasAttachments = message.getAttachmentCount() > 0;
|
this.hasAttachments = message.getAttachmentCount() > 0;
|
||||||
|
|
||||||
this.read = message.isSet(Flag.SEEN);
|
this.read = message.isSet(Flag.SEEN);
|
||||||
|
@ -96,6 +96,11 @@ public class MessageView extends K9Activity
|
|||||||
|
|
||||||
private static final int ACTIVITY_CHOOSE_FOLDER_COPY = 2;
|
private static final int ACTIVITY_CHOOSE_FOLDER_COPY = 2;
|
||||||
|
|
||||||
|
private java.text.DateFormat mDateFormat;
|
||||||
|
|
||||||
|
private java.text.DateFormat mTimeFormat;
|
||||||
|
|
||||||
|
|
||||||
private TextView mFromView;
|
private TextView mFromView;
|
||||||
private TextView mDateView;
|
private TextView mDateView;
|
||||||
private TextView mTimeView;
|
private TextView mTimeView;
|
||||||
@ -129,45 +134,8 @@ public class MessageView extends K9Activity
|
|||||||
|
|
||||||
private GestureDetector gestureDetector;
|
private GestureDetector gestureDetector;
|
||||||
|
|
||||||
private DateFormat dateFormat = null;
|
|
||||||
private DateFormat timeFormat = null;
|
|
||||||
|
|
||||||
private Menu optionsMenu = null;
|
private Menu optionsMenu = null;
|
||||||
|
|
||||||
private DateFormat getDateFormat()
|
|
||||||
{
|
|
||||||
if (dateFormat == null)
|
|
||||||
{
|
|
||||||
String dateFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
|
||||||
android.provider.Settings.System.DATE_FORMAT);
|
|
||||||
if (dateFormatS != null)
|
|
||||||
{
|
|
||||||
dateFormat = new java.text.SimpleDateFormat(dateFormatS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dateFormat;
|
|
||||||
}
|
|
||||||
private DateFormat getTimeFormat()
|
|
||||||
{
|
|
||||||
if (timeFormat == null)
|
|
||||||
{
|
|
||||||
String timeFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
|
||||||
android.provider.Settings.System.TIME_12_24);
|
|
||||||
boolean b24 = !(timeFormatS == null || timeFormatS.equals("12"));
|
|
||||||
timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12);
|
|
||||||
}
|
|
||||||
return timeFormat;
|
|
||||||
}
|
|
||||||
private void clearFormats()
|
|
||||||
{
|
|
||||||
dateFormat = null;
|
|
||||||
timeFormat = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Listener mListener = new Listener();
|
private Listener mListener = new Listener();
|
||||||
private MessageViewHandler mHandler = new MessageViewHandler();
|
private MessageViewHandler mHandler = new MessageViewHandler();
|
||||||
|
|
||||||
@ -520,6 +488,11 @@ public class MessageView extends K9Activity
|
|||||||
|
|
||||||
setContentView(R.layout.message_view);
|
setContentView(R.layout.message_view);
|
||||||
|
|
||||||
|
mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
|
||||||
|
mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mFromView = (TextView)findViewById(R.id.from);
|
mFromView = (TextView)findViewById(R.id.from);
|
||||||
mToView = (TextView)findViewById(R.id.to);
|
mToView = (TextView)findViewById(R.id.to);
|
||||||
mCcView = (TextView)findViewById(R.id.cc);
|
mCcView = (TextView)findViewById(R.id.cc);
|
||||||
@ -770,7 +743,6 @@ public class MessageView extends K9Activity
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
clearFormats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDelete()
|
private void onDelete()
|
||||||
@ -1410,8 +1382,8 @@ public class MessageView extends K9Activity
|
|||||||
String fromText = Address.toFriendly(message.getFrom());
|
String fromText = Address.toFriendly(message.getFrom());
|
||||||
String dateText = Utility.isDateToday(message.getSentDate()) ?
|
String dateText = Utility.isDateToday(message.getSentDate()) ?
|
||||||
null :
|
null :
|
||||||
getDateFormat().format(message.getSentDate());
|
mDateFormat.format(message.getSentDate());
|
||||||
String timeText = getTimeFormat().format(message.getSentDate());
|
String timeText = mTimeFormat.format(message.getSentDate());
|
||||||
String toText = Address.toFriendly(message.getRecipients(RecipientType.TO));
|
String toText = Address.toFriendly(message.getRecipients(RecipientType.TO));
|
||||||
String ccText = Address.toFriendly(message.getRecipients(RecipientType.CC));
|
String ccText = Address.toFriendly(message.getRecipients(RecipientType.CC));
|
||||||
Log.d(Email.LOG_TAG, ccText);
|
Log.d(Email.LOG_TAG, ccText);
|
||||||
|
Loading…
Reference in New Issue
Block a user