mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-30 23:00:09 -05:00
Add setting to configure the splitview mode
This commit is contained in:
parent
573058bffc
commit
c5b1e1d0e5
@ -713,4 +713,15 @@
|
||||
<item name="3">ALWAYS</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="global_settings_splitview_mode_entries">
|
||||
<item>@string/global_settings_splitview_always</item>
|
||||
<item>@string/global_settings_splitview_never</item>
|
||||
<item>@string/global_settings_splitview_when_in_landscape</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="global_settings_splitview_mode_values">
|
||||
<item>ALWAYS</item>
|
||||
<item>NEVER</item>
|
||||
<item>WHEN_IN_LANDSCAPE</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<!--
|
||||
When removing strings from the main file, please cleanup the translations.
|
||||
|
||||
|
||||
This doesn't work on multiline strings, nor strings with the NEW tag.
|
||||
find . -name strings.xml | xargs perl -pi -e's!^\s+<string name="string_name_here".+?</string>\s*\z!!'
|
||||
-->
|
||||
@ -1129,4 +1129,9 @@ Please submit bug reports, contribute new features and ask questions at
|
||||
<string name="upgrade_database_format">Upgrading database of account \"<xliff:g id="account">%s</xliff:g>\"</string>
|
||||
|
||||
<string name="message_list_loading">Loading…</string>
|
||||
|
||||
<string name="global_settings_splitview_mode_label">Show split-screen</string>
|
||||
<string name="global_settings_splitview_always">Always</string>
|
||||
<string name="global_settings_splitview_never">Never</string>
|
||||
<string name="global_settings_splitview_when_in_landscape">When in Landscape orientation</string>
|
||||
</resources>
|
||||
|
@ -156,6 +156,14 @@
|
||||
android:title="@string/global_settings_threaded_view_label"
|
||||
android:summary="@string/global_settings_threaded_view_summary" />
|
||||
|
||||
<ListPreference
|
||||
android:persistent="false"
|
||||
android:key="splitview_mode"
|
||||
android:title="@string/global_settings_splitview_mode_label"
|
||||
android:entries="@array/global_settings_splitview_mode_entries"
|
||||
android:entryValues="@array/global_settings_splitview_mode_values"
|
||||
android:dialogTitle="@string/global_settings_splitview_mode_label" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
@ -210,6 +210,15 @@ public class K9 extends Application {
|
||||
NEVER
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls when to use the message list split view.
|
||||
*/
|
||||
public enum SplitViewMode {
|
||||
ALWAYS,
|
||||
NEVER,
|
||||
WHEN_IN_LANDSCAPE
|
||||
}
|
||||
|
||||
private static boolean mMessageListCheckboxes = false;
|
||||
private static int mMessageListPreviewLines = 2;
|
||||
|
||||
@ -251,6 +260,7 @@ public class K9 extends Application {
|
||||
|
||||
private static boolean sUseBackgroundAsUnreadIndicator = true;
|
||||
private static boolean sThreadedViewEnabled = true;
|
||||
private static SplitViewMode sSplitViewMode = SplitViewMode.WHEN_IN_LANDSCAPE;
|
||||
|
||||
/**
|
||||
* @see #areDatabasesUpToDate()
|
||||
@ -530,6 +540,7 @@ public class K9 extends Application {
|
||||
editor.putString("attachmentdefaultpath", mAttachmentDefaultPath);
|
||||
editor.putBoolean("useBackgroundAsUnreadIndicator", sUseBackgroundAsUnreadIndicator);
|
||||
editor.putBoolean("threadedView", sThreadedViewEnabled);
|
||||
editor.putString("splitViewMode", sSplitViewMode.name());
|
||||
fontSizes.save(editor);
|
||||
}
|
||||
|
||||
@ -737,6 +748,11 @@ public class K9 extends Application {
|
||||
sNotificationQuickDelete = NotificationQuickDelete.valueOf(notificationQuickDelete);
|
||||
}
|
||||
|
||||
String splitViewMode = sprefs.getString("splitViewMode", null);
|
||||
if (splitViewMode != null) {
|
||||
sSplitViewMode = SplitViewMode.valueOf(splitViewMode);
|
||||
}
|
||||
|
||||
mAttachmentDefaultPath = sprefs.getString("attachmentdefaultpath", Environment.getExternalStorageDirectory().toString());
|
||||
sUseBackgroundAsUnreadIndicator = sprefs.getBoolean("useBackgroundAsUnreadIndicator", true);
|
||||
sThreadedViewEnabled = sprefs.getBoolean("threadedView", true);
|
||||
@ -1218,10 +1234,10 @@ public class K9 extends Application {
|
||||
}
|
||||
|
||||
public static boolean wrapFolderNames() {
|
||||
return mWrapFolderNames;
|
||||
return mWrapFolderNames;
|
||||
}
|
||||
public static void setWrapFolderNames(final boolean state) {
|
||||
mWrapFolderNames = state;
|
||||
mWrapFolderNames = state;
|
||||
}
|
||||
|
||||
public static String getAttachmentDefaultPath() {
|
||||
@ -1267,6 +1283,14 @@ public class K9 extends Application {
|
||||
sThreadedViewEnabled = enable;
|
||||
}
|
||||
|
||||
public static synchronized SplitViewMode getSplitViewMode() {
|
||||
return sSplitViewMode;
|
||||
}
|
||||
|
||||
public static synchronized void setSplitViewMode(SplitViewMode mode) {
|
||||
sSplitViewMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we already know whether all databases are using the current database schema.
|
||||
*
|
||||
|
@ -3,6 +3,7 @@ package com.fsck.k9.activity;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
@ -66,6 +67,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
public static final String EXTRA_SEARCH_ACCOUNT = "com.fsck.k9.search_account";
|
||||
private static final String EXTRA_SEARCH_FOLDER = "com.fsck.k9.search_folder";
|
||||
|
||||
private static final String STATE_DISPLAY_MODE = "displayMode";
|
||||
|
||||
public static void actionDisplaySearch(Context context, SearchSpecification search,
|
||||
boolean noThreading, boolean newTask) {
|
||||
actionDisplaySearch(context, search, noThreading, newTask, true);
|
||||
@ -103,6 +106,12 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
return intent;
|
||||
}
|
||||
|
||||
private enum DisplayMode {
|
||||
MESSAGE_LIST,
|
||||
MESSAGE_VIEW,
|
||||
SPLIT_VIEW
|
||||
}
|
||||
|
||||
|
||||
private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation();
|
||||
|
||||
@ -112,6 +121,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
private TextView mActionBarUnread;
|
||||
private Menu mMenu;
|
||||
|
||||
private ViewGroup mMessageListContainer;
|
||||
private ViewGroup mMessageViewContainer;
|
||||
private View mMessageViewPlaceHolder;
|
||||
|
||||
@ -134,6 +144,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
*/
|
||||
private boolean mNoThreading;
|
||||
|
||||
private DisplayMode mDisplayMode;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -152,6 +165,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
|
||||
decodeExtras(getIntent());
|
||||
initializeFragments();
|
||||
initializeDisplayMode(savedInstanceState);
|
||||
initializeLayout();
|
||||
|
||||
ChangeLog cl = new ChangeLog(this);
|
||||
@ -176,12 +190,56 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeDisplayMode(Bundle savedInstanceState) {
|
||||
if (savedInstanceState != null) {
|
||||
mDisplayMode = (DisplayMode) savedInstanceState.getSerializable(STATE_DISPLAY_MODE);
|
||||
} else {
|
||||
mDisplayMode = DisplayMode.MESSAGE_LIST;
|
||||
}
|
||||
|
||||
switch (K9.getSplitViewMode()) {
|
||||
case ALWAYS: {
|
||||
mDisplayMode = DisplayMode.SPLIT_VIEW;
|
||||
break;
|
||||
}
|
||||
case NEVER: {
|
||||
// Either use the restored setting or DisplayMode.MESSAGE_LIST set above
|
||||
break;
|
||||
}
|
||||
case WHEN_IN_LANDSCAPE: {
|
||||
int orientation = getResources().getConfiguration().orientation;
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
mDisplayMode = DisplayMode.SPLIT_VIEW;
|
||||
} else if (mMessageViewFragment != null) {
|
||||
mDisplayMode = DisplayMode.MESSAGE_VIEW;
|
||||
} else {
|
||||
mDisplayMode = DisplayMode.MESSAGE_LIST;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeLayout() {
|
||||
mMessageListContainer = (ViewGroup) findViewById(R.id.message_list_container);
|
||||
mMessageViewContainer = (ViewGroup) findViewById(R.id.message_view_container);
|
||||
mMessageViewPlaceHolder = getLayoutInflater().inflate(R.layout.empty_message_view, null);
|
||||
|
||||
if (mMessageViewFragment == null) {
|
||||
showMessageViewPlaceHolder();
|
||||
switch (mDisplayMode) {
|
||||
case MESSAGE_LIST: {
|
||||
showMessageList();
|
||||
break;
|
||||
}
|
||||
case MESSAGE_VIEW: {
|
||||
showMessageView();
|
||||
break;
|
||||
}
|
||||
case SPLIT_VIEW: {
|
||||
if (mMessageViewFragment == null) {
|
||||
showMessageViewPlaceHolder();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,6 +330,13 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
StorageManager.getInstance(getApplication()).addListener(mStorageListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putSerializable(STATE_DISPLAY_MODE, mDisplayMode);
|
||||
}
|
||||
|
||||
private void initializeActionBar() {
|
||||
mActionBar = getSupportActionBar();
|
||||
|
||||
@ -628,7 +693,11 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mMessageViewFragment = fragment;
|
||||
ft.commit();
|
||||
|
||||
mMessageListFragment.setActiveMessage(messageReference);
|
||||
if (mDisplayMode == DisplayMode.SPLIT_VIEW) {
|
||||
mMessageListFragment.setActiveMessage(messageReference);
|
||||
} else {
|
||||
showMessageView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,8 +742,12 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(
|
||||
R.id.message_list_container);
|
||||
mMessageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById(
|
||||
R.id.message_view_container);
|
||||
|
||||
showMessageViewPlaceHolder();
|
||||
if (mDisplayMode == DisplayMode.SPLIT_VIEW) {
|
||||
showMessageViewPlaceHolder();
|
||||
}
|
||||
|
||||
configureMenu(mMenu);
|
||||
}
|
||||
@ -753,13 +826,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
}
|
||||
|
||||
private void showMessageViewPlaceHolder() {
|
||||
// Remove MessageViewFragment if necessary
|
||||
if (mMessageViewFragment != null) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.remove(mMessageViewFragment);
|
||||
mMessageViewFragment = null;
|
||||
ft.commit();
|
||||
}
|
||||
removeMessageViewFragment();
|
||||
|
||||
// Add placeholder view if necessary
|
||||
if (mMessageViewPlaceHolder.getParent() == null) {
|
||||
@ -769,6 +836,18 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mMessageListFragment.setActiveMessage(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove MessageViewFragment if necessary.
|
||||
*/
|
||||
private void removeMessageViewFragment() {
|
||||
if (mMessageViewFragment != null) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.remove(mMessageViewFragment);
|
||||
mMessageViewFragment = null;
|
||||
ft.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteSearchStarted() {
|
||||
// Remove action button for remote search
|
||||
@ -778,9 +857,10 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
@Override
|
||||
public void goBack() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (fragmentManager.getBackStackEntryCount() > 0) {
|
||||
if (mDisplayMode == DisplayMode.MESSAGE_VIEW) {
|
||||
showMessageList();
|
||||
} else if (fragmentManager.getBackStackEntryCount() > 0) {
|
||||
fragmentManager.popBackStack();
|
||||
showMessageViewPlaceHolder();
|
||||
} else if (mMessageListFragment.isManualSearch()) {
|
||||
onBackPressed();
|
||||
} else if (!mSingleFolderMode) {
|
||||
@ -871,4 +951,20 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
private void showNextMessage() {
|
||||
//TODO: implement
|
||||
}
|
||||
|
||||
private void showMessageList() {
|
||||
mDisplayMode = DisplayMode.MESSAGE_LIST;
|
||||
|
||||
mMessageViewContainer.setVisibility(View.GONE);
|
||||
mMessageListContainer.setVisibility(View.VISIBLE);
|
||||
removeMessageViewFragment();
|
||||
mMessageListFragment.setActiveMessage(null);
|
||||
}
|
||||
|
||||
private void showMessageView() {
|
||||
mDisplayMode = DisplayMode.MESSAGE_VIEW;
|
||||
|
||||
mMessageListContainer.setVisibility(View.GONE);
|
||||
mMessageViewContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.K9.NotificationHideSubject;
|
||||
import com.fsck.k9.K9.NotificationQuickDelete;
|
||||
import com.fsck.k9.K9.SplitViewMode;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.activity.ColorPickerDialog;
|
||||
@ -93,6 +94,7 @@ public class Prefs extends K9PreferenceActivity {
|
||||
private static final String PREFERENCE_BACKGROUND_AS_UNREAD_INDICATOR = "messagelist_background_as_unread_indicator";
|
||||
private static final String PREFERENCE_THREADED_VIEW = "threaded_view";
|
||||
private static final String PREFERENCE_FOLDERLIST_WRAP_NAME = "folderlist_wrap_folder_name";
|
||||
private static final String PREFERENCE_SPLITVIEW_MODE = "splitview_mode";
|
||||
|
||||
private static final int ACTIVITY_CHOOSE_FOLDER = 1;
|
||||
|
||||
@ -139,6 +141,7 @@ public class Prefs extends K9PreferenceActivity {
|
||||
private CheckBoxPreference mBatchButtonsUnselect;
|
||||
private CheckBoxPreference mBackgroundAsUnreadIndicator;
|
||||
private CheckBoxPreference mThreadedView;
|
||||
private ListPreference mSplitViewMode;
|
||||
|
||||
|
||||
public static void actionPrefs(Context context) {
|
||||
@ -396,7 +399,7 @@ public class Prefs extends K9PreferenceActivity {
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
mWrapFolderNames = (CheckBoxPreference)findPreference(PREFERENCE_FOLDERLIST_WRAP_NAME);
|
||||
mWrapFolderNames.setChecked(K9.wrapFolderNames());
|
||||
|
||||
@ -425,6 +428,10 @@ public class Prefs extends K9PreferenceActivity {
|
||||
mBatchButtonsArchive.setEnabled(false);
|
||||
mBatchButtonsArchive.setSummary(R.string.global_settings_archive_disabled_reason);
|
||||
}
|
||||
|
||||
mSplitViewMode = (ListPreference) findPreference(PREFERENCE_SPLITVIEW_MODE);
|
||||
initListPreference(mSplitViewMode, K9.getSplitViewMode().name(),
|
||||
mSplitViewMode.getEntries(), mSplitViewMode.getEntryValues());
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
@ -487,6 +494,7 @@ public class Prefs extends K9PreferenceActivity {
|
||||
K9.setBatchButtonsFlag(mBatchButtonsFlag.isChecked());
|
||||
K9.setBatchButtonsUnselect(mBatchButtonsUnselect.isChecked());
|
||||
|
||||
K9.setSplitViewMode(SplitViewMode.valueOf(mSplitViewMode.getValue()));
|
||||
K9.setAttachmentDefaultPath(mAttachmentPathPreference.getSummary().toString());
|
||||
boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue());
|
||||
K9.setUseGalleryBugWorkaround(mUseGalleryBugWorkaround.isChecked());
|
||||
|
@ -18,6 +18,7 @@ import com.fsck.k9.Account;
|
||||
import com.fsck.k9.FontSizes;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.K9.NotificationHideSubject;
|
||||
import com.fsck.k9.K9.SplitViewMode;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.Account.SortType;
|
||||
import com.fsck.k9.helper.DateFormatter;
|
||||
@ -228,6 +229,9 @@ public class GlobalSettings {
|
||||
s.put("threadedView", Settings.versions(
|
||||
new V(20, new BooleanSetting(true))
|
||||
));
|
||||
s.put("splitViewMode", Settings.versions(
|
||||
new V(23, new EnumSetting(SplitViewMode.class, SplitViewMode.WHEN_IN_LANDSCAPE))
|
||||
));
|
||||
|
||||
SETTINGS = Collections.unmodifiableMap(s);
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class Settings {
|
||||
*
|
||||
* @see SettingsExporter
|
||||
*/
|
||||
public static final int VERSION = 22;
|
||||
public static final int VERSION = 23;
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String,
|
||||
TreeMap<Integer, SettingsDescription>> settings,
|
||||
|
Loading…
Reference in New Issue
Block a user