mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
First very basic version of a split screen for message list + view
This commit is contained in:
parent
1d01bcb688
commit
933dd95047
14
res/layout/empty_message_view.xml
Normal file
14
res/layout/empty_message_view.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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="fill_parent" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="Please select a message on the left"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -4,7 +4,7 @@
|
|||||||
android:id="@+id/message_view"
|
android:id="@+id/message_view"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<!-- Header area -->
|
<!-- Header area -->
|
||||||
|
21
res/layout/split_message_list.xml
Normal file
21
res/layout/split_message_list.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/message_list_container"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/message_view_container"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,10 +1,9 @@
|
|||||||
package com.fsck.k9.activity;
|
package com.fsck.k9.activity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||||
@ -13,6 +12,7 @@ import android.util.Log;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -29,8 +29,11 @@ import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener;
|
|||||||
import com.fsck.k9.activity.setup.AccountSettings;
|
import com.fsck.k9.activity.setup.AccountSettings;
|
||||||
import com.fsck.k9.activity.setup.FolderSettings;
|
import com.fsck.k9.activity.setup.FolderSettings;
|
||||||
import com.fsck.k9.activity.setup.Prefs;
|
import com.fsck.k9.activity.setup.Prefs;
|
||||||
|
import com.fsck.k9.crypto.PgpData;
|
||||||
import com.fsck.k9.fragment.MessageListFragment;
|
import com.fsck.k9.fragment.MessageListFragment;
|
||||||
|
import com.fsck.k9.fragment.MessageViewFragment;
|
||||||
import com.fsck.k9.fragment.MessageListFragment.MessageListFragmentListener;
|
import com.fsck.k9.fragment.MessageListFragment.MessageListFragmentListener;
|
||||||
|
import com.fsck.k9.fragment.MessageViewFragment.MessageViewFragmentListener;
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.store.StorageManager;
|
import com.fsck.k9.mail.store.StorageManager;
|
||||||
import com.fsck.k9.search.LocalSearch;
|
import com.fsck.k9.search.LocalSearch;
|
||||||
@ -39,6 +42,7 @@ import com.fsck.k9.search.SearchSpecification;
|
|||||||
import com.fsck.k9.search.SearchSpecification.Attribute;
|
import com.fsck.k9.search.SearchSpecification.Attribute;
|
||||||
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||||
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
||||||
|
import com.fsck.k9.view.MessageHeader;
|
||||||
|
|
||||||
import de.cketti.library.changelog.ChangeLog;
|
import de.cketti.library.changelog.ChangeLog;
|
||||||
|
|
||||||
@ -49,7 +53,7 @@ import de.cketti.library.changelog.ChangeLog;
|
|||||||
* From this Activity the user can perform all standard message operations.
|
* From this Activity the user can perform all standard message operations.
|
||||||
*/
|
*/
|
||||||
public class MessageList extends K9FragmentActivity implements MessageListFragmentListener,
|
public class MessageList extends K9FragmentActivity implements MessageListFragmentListener,
|
||||||
OnBackStackChangedListener, OnSwipeGestureListener {
|
MessageViewFragmentListener, OnBackStackChangedListener, OnSwipeGestureListener {
|
||||||
|
|
||||||
// for this activity
|
// for this activity
|
||||||
private static final String EXTRA_SEARCH = "search";
|
private static final String EXTRA_SEARCH = "search";
|
||||||
@ -108,7 +112,11 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
private TextView mActionBarUnread;
|
private TextView mActionBarUnread;
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
|
|
||||||
|
private ViewGroup mMessageViewContainer;
|
||||||
|
private View mMessageViewPlaceHolder;
|
||||||
|
|
||||||
private MessageListFragment mMessageListFragment;
|
private MessageListFragment mMessageListFragment;
|
||||||
|
private MessageViewFragment mMessageViewFragment;
|
||||||
|
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
private String mFolderName;
|
private String mFolderName;
|
||||||
@ -135,7 +143,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setContentView(R.layout.message_list);
|
setContentView(R.layout.split_message_list);
|
||||||
|
|
||||||
initializeActionBar();
|
initializeActionBar();
|
||||||
|
|
||||||
@ -143,8 +151,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
setupGestureDetector(this);
|
setupGestureDetector(this);
|
||||||
|
|
||||||
decodeExtras(getIntent());
|
decodeExtras(getIntent());
|
||||||
|
|
||||||
initializeFragments();
|
initializeFragments();
|
||||||
|
initializeLayout();
|
||||||
|
|
||||||
ChangeLog cl = new ChangeLog(this);
|
ChangeLog cl = new ChangeLog(this);
|
||||||
if (cl.isFirstRun()) {
|
if (cl.isFirstRun()) {
|
||||||
@ -157,6 +165,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
fragmentManager.addOnBackStackChangedListener(this);
|
fragmentManager.addOnBackStackChangedListener(this);
|
||||||
|
|
||||||
mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(R.id.message_list_container);
|
mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(R.id.message_list_container);
|
||||||
|
mMessageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById(R.id.message_view_container);
|
||||||
|
|
||||||
if (mMessageListFragment == null) {
|
if (mMessageListFragment == null) {
|
||||||
FragmentTransaction ft = fragmentManager.beginTransaction();
|
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||||
@ -167,6 +176,15 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeLayout() {
|
||||||
|
mMessageViewContainer = (ViewGroup) findViewById(R.id.message_view_container);
|
||||||
|
mMessageViewPlaceHolder = getLayoutInflater().inflate(R.layout.empty_message_view, null);
|
||||||
|
|
||||||
|
if (mMessageViewFragment == null) {
|
||||||
|
showMessageViewPlaceHolder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void decodeExtras(Intent intent) {
|
private void decodeExtras(Intent intent) {
|
||||||
if (ACTION_SHORTCUT.equals(intent.getAction())) {
|
if (ACTION_SHORTCUT.equals(intent.getAction())) {
|
||||||
// Handle shortcut intents
|
// Handle shortcut intents
|
||||||
@ -602,24 +620,14 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
if (folderName.equals(account.getDraftsFolderName())) {
|
if (folderName.equals(account.getDraftsFolderName())) {
|
||||||
MessageCompose.actionEditDraft(this, messageReference);
|
MessageCompose.actionEditDraft(this, messageReference);
|
||||||
} else {
|
} else {
|
||||||
ArrayList<MessageReference> messageRefs = mMessageListFragment.getMessageReferences();
|
mMessageViewContainer.removeView(mMessageViewPlaceHolder);
|
||||||
|
|
||||||
Log.i(K9.LOG_TAG, "MessageList sending message " + messageReference);
|
MessageViewFragment fragment = MessageViewFragment.newInstance(messageReference);
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
Intent i = MessageView.actionViewIntent(this, messageReference, messageRefs);
|
ft.replace(R.id.message_view_container, fragment);
|
||||||
startActivity(i);
|
mMessageViewFragment = fragment;
|
||||||
|
ft.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* We set read=true here for UI performance reasons. The actual value
|
|
||||||
* will get picked up on the refresh when the Activity is resumed but
|
|
||||||
* that may take a second or so and we don't want this to show and
|
|
||||||
* then go away. I've gone back and forth on this, and this gives a
|
|
||||||
* better UI experience, so I am putting it back in.
|
|
||||||
*/
|
|
||||||
// if (!message.read) {
|
|
||||||
// message.read = true;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -664,6 +672,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(
|
mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(
|
||||||
R.id.message_list_container);
|
R.id.message_list_container);
|
||||||
|
|
||||||
|
showMessageViewPlaceHolder();
|
||||||
|
|
||||||
configureMenu(mMenu);
|
configureMenu(mMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,6 +740,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showThread(Account account, String folderName, long threadRootId) {
|
public void showThread(Account account, String folderName, long threadRootId) {
|
||||||
|
showMessageViewPlaceHolder();
|
||||||
|
|
||||||
LocalSearch tmpSearch = new LocalSearch();
|
LocalSearch tmpSearch = new LocalSearch();
|
||||||
tmpSearch.addAccountUuid(account.getUuid());
|
tmpSearch.addAccountUuid(account.getUuid());
|
||||||
tmpSearch.and(Searchfield.THREAD_ID, String.valueOf(threadRootId), Attribute.EQUALS);
|
tmpSearch.and(Searchfield.THREAD_ID, String.valueOf(threadRootId), Attribute.EQUALS);
|
||||||
@ -738,6 +750,21 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
addMessageListFragment(fragment, true);
|
addMessageListFragment(fragment, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showMessageViewPlaceHolder() {
|
||||||
|
// Remove MessageViewFragment if necessary
|
||||||
|
if (mMessageViewFragment != null) {
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.remove(mMessageViewFragment);
|
||||||
|
mMessageViewFragment = null;
|
||||||
|
ft.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add placeholder view if necessary
|
||||||
|
if (mMessageViewPlaceHolder.getParent() == null) {
|
||||||
|
mMessageViewContainer.addView(mMessageViewPlaceHolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remoteSearchStarted() {
|
public void remoteSearchStarted() {
|
||||||
// Remove action button for remote search
|
// Remove action button for remote search
|
||||||
@ -749,6 +776,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
if (fragmentManager.getBackStackEntryCount() > 0) {
|
if (fragmentManager.getBackStackEntryCount() > 0) {
|
||||||
fragmentManager.popBackStack();
|
fragmentManager.popBackStack();
|
||||||
|
showMessageViewPlaceHolder();
|
||||||
} else if (mMessageListFragment.isManualSearch()) {
|
} else if (mMessageListFragment.isManualSearch()) {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
} else if (!mSingleFolderMode) {
|
} else if (!mSingleFolderMode) {
|
||||||
@ -778,4 +806,65 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restartActivity() {
|
||||||
|
// restart the current activity, so that the theme change can be applied
|
||||||
|
if (Build.VERSION.SDK_INT < 11) {
|
||||||
|
Intent intent = getIntent();
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
finish();
|
||||||
|
overridePendingTransition(0, 0); // disable animations to speed up the switch
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
} else {
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayMessageSubject(String subject) {
|
||||||
|
setTitle(subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReply(Message message, PgpData pgpData) {
|
||||||
|
MessageCompose.actionReply(this, mAccount, message, false, pgpData.getDecryptedData());
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReplyAll(Message message, PgpData pgpData) {
|
||||||
|
MessageCompose.actionReply(this, mAccount, message, true, pgpData.getDecryptedData());
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onForward(Message mMessage, PgpData mPgpData) {
|
||||||
|
MessageCompose.actionForward(this, mAccount, mMessage, mPgpData.getDecryptedData());
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showNextMessageOrReturn() {
|
||||||
|
if (K9.messageViewReturnToList()) {
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
showNextMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProgress(boolean enable) {
|
||||||
|
setSupportProgressBarIndeterminateVisibility(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageHeaderViewAvailable(MessageHeader header) {
|
||||||
|
//TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNextMessage() {
|
||||||
|
//TODO: implement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user