1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -05:00

Fixed issue 858: Added option to choose which side the widgets in message list will be on

This commit is contained in:
Bao-Long Nguyen-Trong 2009-12-08 01:32:59 +00:00
parent 5d2df0b12d
commit 4117175b0f
12 changed files with 222 additions and 9 deletions

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="1dip"
android:paddingTop="2dip"
android:background="@drawable/message_list_item_background">
<View
android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1"
android:layout_width="4dip"
android:layout_height="20dip"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" />
<include
layout="@layout/message_list_widgets_left"
android:id="@+id/widgets"
android:layout_toRightOf="@+id/chip" />
<TextView
android:id="@+id/subject"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:paddingRight="3dip"
android:layout_centerVertical="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/widgets"
android:layout_toLeftOf="@+id/from"/>
<TextView
android:id="@+id/from"
android:ellipsize="end"
android:singleLine="true"
android:layout_width="110dip"
android:layout_height="wrap_content"
android:paddingRight="3dip"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:layout_toLeftOf="@+id/date" />
<TextView
android:id="@+id/date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>

View File

@ -13,7 +13,7 @@
android:layout_height="20dip"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" />
<include layout="@layout/message_list_widgets" android:id="@+id/widgets" />
<include layout="@layout/message_list_widgets_right" android:id="@+id/widgets" />
<TextView
android:id="@+id/date"
android:textAppearance="?android:attr/textAppearanceSmall"
@ -22,7 +22,8 @@
android:layout_width="70dip"
android:paddingRight="3dip"
android:layout_height="wrap_content"
android:gravity="right|bottom"
android:gravity="right"
android:layout_centerVertical="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/widgets" />
<TextView
@ -31,6 +32,7 @@
android:singleLine="true"
android:layout_width="110dip"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:paddingLeft="3dip"
@ -44,6 +46,7 @@
android:textColor="?android:attr/textColorPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="10dip"
android:layout_marginRight="1dip"
android:layout_alignWithParentIfMissing="true"

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="38dip"
android:paddingRight="1dip"
android:paddingTop="2dip"
android:background="#999999"
>
<View
android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1"
android:layout_width="4dip"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"/>
<include
layout="@layout/message_list_widgets_left"
android:id="@+id/widgets"
android:layout_toRightOf="@+id/chip" />
<TextView
android:id="@+id/subject"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:layout_toRightOf="@+id/widgets" />
<TextView
android:id="@+id/from"
android:ellipsize="end"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/widgets" />
<TextView
android:id="@+id/date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:gravity="right|bottom"
android:textColor="?android:attr/textColorSecondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/from"
android:background="@android:color/transparent" />
</RelativeLayout>

View File

@ -13,7 +13,7 @@
android:layout_width="4dip"
android:layout_height="fill_parent"
android:layout_centerVertical="true" />
<include layout="@layout/message_list_widgets" android:id="@+id/widgets" />
<include layout="@layout/message_list_widgets_right" android:id="@+id/widgets" />
<TextView
android:id="@+id/subject"
android:ellipsize="end"

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="30dip"
android:layout_centerVertical="true"
android:paddingLeft="5dip"
>
<CheckBox
android:id="@+id/flagged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
style="?android:attr/starStyle"
android:layout_gravity="center_vertical"
/>
<!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items
we want something a bit bigger than it is right now -->
<CheckBox
android:id="@+id/selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:focusable="false"
android:button="@drawable/checkbox"
android:background="@drawable/checkbox_background"
/>
</LinearLayout>

View File

@ -212,5 +212,15 @@
<item>@string/date_format_common</item>
<item>@string/date_format_iso8601</item>
</string-array>
<string-array name="message_list_widget_side_entries">
<item>@string/message_list_widget_left_side</item>
<item>@string/message_list_widget_right_side</item>
</string-array>
<string-array name="message_list_widget_side_values">
<item>LEFT</item>
<item>RIGHT</item>
</string-array>
</resources>

View File

@ -571,6 +571,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="date_format_medium">MEDIUM</string>
<string name="date_format_common">dd-MMM-yyyy</string>
<string name="date_format_iso8601">yyyy-MM-dd</string>
<string name="message_list_widget_side_label">Message list's widget side</string>
<string name="message_list_widget_left_side">Left</string>
<string name="message_list_widget_right_side">Right</string>
</resources>

View File

@ -25,12 +25,20 @@
android:entryValues="@array/settings_theme_values"
android:dialogTitle="@string/settings_theme_label" />
<ListPreference
<ListPreference
android:key="dateFormat"
android:title="@string/date_format_label"
android:entries="@array/date_formats"
android:entryValues="@array/date_formats"
android:dialogTitle="@string/date_format_label" />
<ListPreference
android:key="messageListWidgetSide"
android:title="@string/message_list_widget_side_label"
android:entries="@array/message_list_widget_side_entries"
android:entryValues="@array/message_list_widget_side_values"
android:dialogTitle="@string/message_list_widget_side_label" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/operational_preferences" android:key="operational_preferences">

View File

@ -33,6 +33,13 @@ public class Email extends Application
private static int theme = android.R.style.Theme_Light;
public enum MessageListWidgetSide
{
LEFT, RIGHT
}
private static MessageListWidgetSide messageListWidgetSide = MessageListWidgetSide.RIGHT;
private static BACKGROUND_OPS backgroundOps = BACKGROUND_OPS.WHEN_CHECKED;
/**
* Some log messages can be sent to a file, so that the logs
@ -469,6 +476,7 @@ public class Email extends Application
editor.putBoolean("enableSensitiveLogging", Email.DEBUG_SENSITIVE);
editor.putString("backgroundOperations", Email.backgroundOps.toString());
editor.putInt("theme", theme);
editor.putString("messageListWidgetSide", messageListWidgetSide.toString());
}
@Override
@ -491,6 +499,7 @@ public class Email extends Application
}
Email.setK9Theme(sprefs.getInt("theme", android.R.style.Theme_Light));
Email.setMessageListWidgetSide(MessageListWidgetSide.valueOf(sprefs.getString("messageListWidgetSide", MessageListWidgetSide.RIGHT.toString())));
MessagingController.getInstance(this).resetVisibleLimits(prefs.getAccounts());
/*
@ -559,6 +568,16 @@ public class Email extends Application
{
Email.backgroundOps = BACKGROUND_OPS.valueOf(nbackgroundOps);
}
public static MessageListWidgetSide getMessageListWidgetSide()
{
return Email.messageListWidgetSide;
}
public static void setMessageListWidgetSide(MessageListWidgetSide messageListWidgetSide)
{
Email.messageListWidgetSide = messageListWidgetSide;
}
}

View File

@ -1745,14 +1745,28 @@ public class MessageList
MessageInfoHolder message = (MessageInfoHolder) getItem(position);
View view;
if ((convertView != null) && (convertView.getId() == R.layout.message_list_item))
if ((convertView != null)
&& (
(convertView.getId() == R.layout.message_list_item_left)
|| (convertView.getId() == R.layout.message_list_item_right)
)
)
{
view = convertView;
}
else
{
view = mInflater.inflate(R.layout.message_list_item, parent, false);
view.setId(R.layout.message_list_item);
int layoutId;
if (Email.getMessageListWidgetSide()==Email.MessageListWidgetSide.LEFT)
{
layoutId = R.layout.message_list_item_left;
}
else
{
layoutId = R.layout.message_list_item_right;
}
view = mInflater.inflate(layoutId, parent, false);
view.setId(layoutId);
}

View File

@ -11,6 +11,7 @@ import android.preference.Preference;
import android.view.KeyEvent;
import com.android.email.Email;
import com.android.email.Email.MessageListWidgetSide;
import com.android.email.K9PreferenceActivity;
import com.android.email.Preferences;
import com.android.email.R;
@ -22,12 +23,14 @@ public class Prefs extends K9PreferenceActivity
private static final String PREFERENCE_THEME = "theme";
private static final String PREFERENCE_DATE_FORMAT = "dateFormat";
private static final String PREFERENCE_MESSAGE_LIST_WIDGET_SIDE = "messageListWidgetSide";
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
private static final String PREFERENCE_DEBUG_LOGGING = "debug_logging";
private static final String PREFERENCE_SENSITIVE_LOGGING = "sensitive_logging";
private ListPreference mTheme;
private ListPreference mDateFormat;
private ListPreference mMessageListWidgetSide;
private ListPreference mBackgroundOps;
private CheckBoxPreference mDebugLogging;
private CheckBoxPreference mSensitiveLogging;
@ -91,6 +94,21 @@ public class Prefs extends K9PreferenceActivity
}
});
mMessageListWidgetSide = (ListPreference) findPreference(PREFERENCE_MESSAGE_LIST_WIDGET_SIDE);
mMessageListWidgetSide.setValue(Email.getMessageListWidgetSide().toString());
mMessageListWidgetSide.setSummary(mMessageListWidgetSide.getEntry());
mMessageListWidgetSide.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
public boolean onPreferenceChange(Preference preference, Object newValue)
{
final String summary = newValue.toString();
int index = mMessageListWidgetSide.findIndexOfValue(summary);
mMessageListWidgetSide.setSummary(mMessageListWidgetSide.getEntries()[index]);
mMessageListWidgetSide.setValue(summary);
return false;
}
});
mBackgroundOps = (ListPreference) findPreference(PREFERENCE_BACKGROUND_OPS);
initBackgroundOps = Email.getBackgroundOps().toString();
mBackgroundOps.setValue(initBackgroundOps);
@ -125,6 +143,7 @@ public class Prefs extends K9PreferenceActivity
{
SharedPreferences preferences = Preferences.getPreferences(this).getPreferences();
Email.setK9Theme(mTheme.getValue().equals("dark") ? android.R.style.Theme : android.R.style.Theme_Light);
Email.setMessageListWidgetSide(MessageListWidgetSide.valueOf(mMessageListWidgetSide.getValue()));
Email.DEBUG = mDebugLogging.isChecked();
Email.DEBUG_SENSITIVE = mSensitiveLogging.isChecked();
String newBackgroundOps = mBackgroundOps.getValue();