revised tablet ui. fixed #423
This commit is contained in:
parent
335152b191
commit
9ae52a235f
|
@ -1,11 +1,11 @@
|
|||
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slidingpanelayout"
|
||||
<eu.siacs.conversations.ui.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/content_view_spl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="240dp"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primarybackground"
|
||||
android:orientation="vertical" >
|
||||
|
@ -27,4 +27,4 @@
|
|||
android:orientation="vertical" >
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.SlidingPaneLayout>
|
||||
</eu.siacs.conversations.ui.SlidingPaneLayout>
|
|
@ -1,5 +1,5 @@
|
|||
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slidingpanelayout"
|
||||
android:id="@+id/content_view_spl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slidingpanelayout"
|
||||
android:id="@+id/content_view_spl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="324dp"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primarybackground"
|
||||
android:orientation="vertical" >
|
|
@ -1,11 +1,11 @@
|
|||
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slidingpanelayout"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/content_view_ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="288dp"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primarybackground"
|
||||
android:orientation="vertical" >
|
||||
|
@ -23,8 +23,7 @@
|
|||
android:id="@+id/selected_conversation"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" >
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.SlidingPaneLayout>
|
||||
</LinearLayout>
|
|
@ -1,5 +1,5 @@
|
|||
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slidingpanelayout"
|
||||
android:id="@+id/content_view_spl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
|
|
|
@ -59,8 +59,13 @@ public class ConversationActivity extends XmppActivity implements
|
|||
private static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301;
|
||||
private static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302;
|
||||
private static final int ATTACHMENT_CHOICE_RECORD_VOICE = 0x0303;
|
||||
private static final String STATE_OPEN_CONVERSATION = "state_open_conversation";
|
||||
private static final String STATE_PANEL_OPEN = "state_panel_open";
|
||||
|
||||
protected SlidingPaneLayout spl;
|
||||
private String mOpenConverstaion = null;
|
||||
private boolean mPanelOpen = true;
|
||||
|
||||
private View mContentView;
|
||||
|
||||
private List<Conversation> conversationList = new ArrayList<Conversation>();
|
||||
private Conversation selectedConversation = null;
|
||||
|
@ -90,18 +95,52 @@ public class ConversationActivity extends XmppActivity implements
|
|||
return this.listView;
|
||||
}
|
||||
|
||||
public SlidingPaneLayout getSlidingPaneLayout() {
|
||||
return this.spl;
|
||||
}
|
||||
|
||||
public boolean shouldPaneBeOpen() {
|
||||
return paneShouldBeOpen;
|
||||
}
|
||||
|
||||
public void showConversationsOverview() {
|
||||
if (mContentView instanceof SlidingPaneLayout) {
|
||||
SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
|
||||
mSlidingPaneLayout.openPane();
|
||||
}
|
||||
}
|
||||
|
||||
public void hideConversationsOverview() {
|
||||
if (mContentView instanceof SlidingPaneLayout) {
|
||||
SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
|
||||
mSlidingPaneLayout.closePane();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isConversationsOverviewHideable() {
|
||||
if (mContentView instanceof SlidingPaneLayout) {
|
||||
SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
|
||||
return mSlidingPaneLayout.isSlideable();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isConversationsOverviewVisable() {
|
||||
if (mContentView instanceof SlidingPaneLayout) {
|
||||
SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
|
||||
return mSlidingPaneLayout.isOpen();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mOpenConverstaion = savedInstanceState.getString(
|
||||
STATE_OPEN_CONVERSATION, null);
|
||||
mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true);
|
||||
}
|
||||
|
||||
setContentView(R.layout.fragment_conversations_overview);
|
||||
|
||||
listView = (ListView) findViewById(R.id.list);
|
||||
|
@ -122,52 +161,59 @@ public class ConversationActivity extends XmppActivity implements
|
|||
setSelectedConversation(conversationList.get(position));
|
||||
swapConversationFragment();
|
||||
} else {
|
||||
spl.closePane();
|
||||
hideConversationsOverview();
|
||||
}
|
||||
}
|
||||
});
|
||||
spl = (SlidingPaneLayout) findViewById(R.id.slidingpanelayout);
|
||||
spl.setParallaxDistance(150);
|
||||
spl.setShadowResource(R.drawable.es_slidingpane_shadow);
|
||||
spl.setSliderFadeColor(0);
|
||||
spl.setPanelSlideListener(new PanelSlideListener() {
|
||||
mContentView = findViewById(R.id.content_view_spl);
|
||||
if (mContentView==null) {
|
||||
mContentView = findViewById(R.id.content_view_ll);
|
||||
}
|
||||
if (mContentView instanceof SlidingPaneLayout) {
|
||||
SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
|
||||
mSlidingPaneLayout.setParallaxDistance(150);
|
||||
mSlidingPaneLayout.setShadowResource(R.drawable.es_slidingpane_shadow);
|
||||
mSlidingPaneLayout.setSliderFadeColor(0);
|
||||
mSlidingPaneLayout.setPanelSlideListener(new PanelSlideListener() {
|
||||
|
||||
@Override
|
||||
public void onPanelOpened(View arg0) {
|
||||
paneShouldBeOpen = true;
|
||||
ActionBar ab = getActionBar();
|
||||
if (ab != null) {
|
||||
ab.setDisplayHomeAsUpEnabled(false);
|
||||
ab.setHomeButtonEnabled(false);
|
||||
ab.setTitle(R.string.app_name);
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
hideKeyboard();
|
||||
if (xmppConnectionServiceBound) {
|
||||
xmppConnectionService.getNotificationService().setOpenConversation(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelClosed(View arg0) {
|
||||
paneShouldBeOpen = false;
|
||||
if ((conversationList.size() > 0)
|
||||
&& (getSelectedConversation() != null)) {
|
||||
openConversation(getSelectedConversation());
|
||||
if (!getSelectedConversation().isRead()) {
|
||||
xmppConnectionService
|
||||
.markRead(getSelectedConversation(),true);
|
||||
listView.invalidateViews();
|
||||
@Override
|
||||
public void onPanelOpened(View arg0) {
|
||||
paneShouldBeOpen = true;
|
||||
ActionBar ab = getActionBar();
|
||||
if (ab != null) {
|
||||
ab.setDisplayHomeAsUpEnabled(false);
|
||||
ab.setHomeButtonEnabled(false);
|
||||
ab.setTitle(R.string.app_name);
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
hideKeyboard();
|
||||
if (xmppConnectionServiceBound) {
|
||||
xmppConnectionService.getNotificationService()
|
||||
.setOpenConversation(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelSlide(View arg0, float arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
@Override
|
||||
public void onPanelClosed(View arg0) {
|
||||
paneShouldBeOpen = false;
|
||||
if ((conversationList.size() > 0)
|
||||
&& (getSelectedConversation() != null)) {
|
||||
openConversation(getSelectedConversation());
|
||||
if (!getSelectedConversation().isRead()) {
|
||||
xmppConnectionService.markRead(
|
||||
getSelectedConversation(), true);
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onPanelSlide(View arg0, float arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void openConversation(Conversation conversation) {
|
||||
|
@ -179,13 +225,14 @@ public class ConversationActivity extends XmppActivity implements
|
|||
|| activity.useSubjectToIdentifyConference()) {
|
||||
ab.setTitle(getSelectedConversation().getName());
|
||||
} else {
|
||||
ab.setTitle(getSelectedConversation()
|
||||
.getContactJid().split("/")[0]);
|
||||
ab.setTitle(getSelectedConversation().getContactJid()
|
||||
.split("/")[0]);
|
||||
}
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
if (xmppConnectionServiceBound) {
|
||||
xmppConnectionService.getNotificationService().setOpenConversation(conversation);
|
||||
xmppConnectionService.getNotificationService().setOpenConversation(
|
||||
conversation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +253,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||
.findItem(R.id.action_invite);
|
||||
MenuItem menuMute = (MenuItem) menu.findItem(R.id.action_mute);
|
||||
|
||||
if ((spl.isOpen() && (spl.isSlideable()))) {
|
||||
if (isConversationsOverviewVisable() && isConversationsOverviewHideable()) {
|
||||
menuArchive.setVisible(false);
|
||||
menuMucDetails.setVisible(false);
|
||||
menuContactDetails.setVisible(false);
|
||||
|
@ -216,7 +263,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||
menuClearHistory.setVisible(false);
|
||||
menuMute.setVisible(false);
|
||||
} else {
|
||||
menuAdd.setVisible(!spl.isSlideable());
|
||||
menuAdd.setVisible(!isConversationsOverviewHideable());
|
||||
if (this.getSelectedConversation() != null) {
|
||||
if (this.getSelectedConversation().getLatestMessage()
|
||||
.getEncryption() != Message.ENCRYPTION_NONE) {
|
||||
|
@ -325,7 +372,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
spl.openPane();
|
||||
showConversationsOverview();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_add) {
|
||||
startActivity(new Intent(this, StartConversationActivity.class));
|
||||
|
@ -377,7 +424,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||
public void endConversation(Conversation conversation) {
|
||||
conversation.setStatus(Conversation.STATUS_ARCHIVED);
|
||||
paneShouldBeOpen = true;
|
||||
spl.openPane();
|
||||
showConversationsOverview();
|
||||
xmppConnectionService.archiveConversation(conversation);
|
||||
if (conversationList.size() > 0) {
|
||||
setSelectedConversation(conversationList.get(0));
|
||||
|
@ -563,8 +610,8 @@ public class ConversationActivity extends XmppActivity implements
|
|||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (!spl.isOpen()) {
|
||||
spl.openPane();
|
||||
if (!isConversationsOverviewVisable()) {
|
||||
showConversationsOverview();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -612,63 +659,71 @@ public class ConversationActivity extends XmppActivity implements
|
|||
xmppConnectionService.removeOnConversationListChangedListener();
|
||||
xmppConnectionService.removeOnAccountListChangedListener();
|
||||
xmppConnectionService.removeOnRosterUpdateListener();
|
||||
xmppConnectionService.getNotificationService().setOpenConversation(null);
|
||||
xmppConnectionService.getNotificationService().setOpenConversation(
|
||||
null);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
savedInstanceState.putString(STATE_OPEN_CONVERSATION,
|
||||
getSelectedConversation().getUuid());
|
||||
savedInstanceState.putBoolean(STATE_PANEL_OPEN, isConversationsOverviewVisable());
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
void onBackendConnected() {
|
||||
this.registerListener();
|
||||
if (conversationList.size() == 0) {
|
||||
updateConversationList();
|
||||
updateConversationList();
|
||||
|
||||
if (xmppConnectionService.getAccounts().size() == 0) {
|
||||
startActivity(new Intent(this, EditAccountActivity.class));
|
||||
} else if (conversationList.size() <= 0) {
|
||||
startActivity(new Intent(this, StartConversationActivity.class));
|
||||
finish();
|
||||
} else if (mOpenConverstaion != null) {
|
||||
selectConversationByUuid(mOpenConverstaion);
|
||||
paneShouldBeOpen = mPanelOpen;
|
||||
if (paneShouldBeOpen) {
|
||||
showConversationsOverview();
|
||||
}
|
||||
swapConversationFragment();
|
||||
mOpenConverstaion = null;
|
||||
} else if (getIntent() != null
|
||||
&& VIEW_CONVERSATION.equals(getIntent().getType())) {
|
||||
String uuid = (String) getIntent().getExtras().get(CONVERSATION);
|
||||
String text = getIntent().getExtras().getString(TEXT, null);
|
||||
selectConversationByUuid(uuid);
|
||||
paneShouldBeOpen = false;
|
||||
swapConversationFragment().setText(text);
|
||||
setIntent(null);
|
||||
} else {
|
||||
showConversationsOverview();
|
||||
ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
|
||||
.findFragmentByTag("conversation");
|
||||
if (selectedFragment != null) {
|
||||
selectedFragment.onBackendConnected();
|
||||
} else {
|
||||
pendingImageUri = null;
|
||||
setSelectedConversation(conversationList.get(0));
|
||||
swapConversationFragment();
|
||||
}
|
||||
}
|
||||
|
||||
if (getSelectedConversation() != null && pendingImageUri != null) {
|
||||
if (pendingImageUri != null) {
|
||||
attachImageToConversation(getSelectedConversation(),
|
||||
pendingImageUri);
|
||||
pendingImageUri = null;
|
||||
} else {
|
||||
pendingImageUri = null;
|
||||
}
|
||||
ExceptionHelper.checkForCrash(this, this.xmppConnectionService);
|
||||
}
|
||||
|
||||
if ((getIntent().getAction() != null)
|
||||
&& (getIntent().getAction().equals(Intent.ACTION_VIEW) && (!handledViewIntent))) {
|
||||
if (getIntent().getType().equals(
|
||||
ConversationActivity.VIEW_CONVERSATION)) {
|
||||
handledViewIntent = true;
|
||||
|
||||
String convToView = (String) getIntent().getExtras().get(
|
||||
CONVERSATION);
|
||||
|
||||
for (int i = 0; i < conversationList.size(); ++i) {
|
||||
if (conversationList.get(i).getUuid().equals(convToView)) {
|
||||
setSelectedConversation(conversationList.get(i));
|
||||
}
|
||||
}
|
||||
paneShouldBeOpen = false;
|
||||
String text = getIntent().getExtras().getString(TEXT, null);
|
||||
swapConversationFragment().setText(text);
|
||||
}
|
||||
} else {
|
||||
if (xmppConnectionService.getAccounts().size() == 0) {
|
||||
startActivity(new Intent(this, EditAccountActivity.class));
|
||||
} else if (conversationList.size() <= 0) {
|
||||
// add no history
|
||||
startActivity(new Intent(this, StartConversationActivity.class));
|
||||
finish();
|
||||
} else {
|
||||
spl.openPane();
|
||||
// find currently loaded fragment
|
||||
ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
|
||||
.findFragmentByTag("conversation");
|
||||
if (selectedFragment != null) {
|
||||
selectedFragment.onBackendConnected();
|
||||
} else {
|
||||
setSelectedConversation(conversationList.get(0));
|
||||
swapConversationFragment();
|
||||
}
|
||||
ExceptionHelper.checkForCrash(this, this.xmppConnectionService);
|
||||
private void selectConversationByUuid(String uuid) {
|
||||
for (int i = 0; i < conversationList.size(); ++i) {
|
||||
if (conversationList.get(i).getUuid().equals(uuid)) {
|
||||
setSelectedConversation(conversationList.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,9 +245,7 @@ public class ConversationFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (activity.getSlidingPaneLayout().isSlideable()) {
|
||||
activity.getSlidingPaneLayout().closePane();
|
||||
}
|
||||
activity.hideConversationsOverview();
|
||||
}
|
||||
});
|
||||
mEditMessage.setOnEditorActionListener(mEditorActionListener);
|
||||
|
@ -376,9 +374,9 @@ public class ConversationFragment extends Fragment {
|
|||
int position = mEditMessage.length();
|
||||
Editable etext = mEditMessage.getText();
|
||||
Selection.setSelection(etext, position);
|
||||
if (activity.getSlidingPaneLayout().isSlideable()) {
|
||||
if (activity.isConversationsOverviewHideable()) {
|
||||
if (!activity.shouldPaneBeOpen()) {
|
||||
activity.getSlidingPaneLayout().closePane();
|
||||
activity.hideConversationsOverview();
|
||||
activity.openConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public abstract class XmppActivity extends Activity {
|
|||
|
||||
protected int mPrimaryTextColor;
|
||||
protected int mSecondaryTextColor;
|
||||
protected int mSecondaryBackgroundColor;
|
||||
protected int mColorRed;
|
||||
protected int mColorOrange;
|
||||
protected int mColorGreen;
|
||||
|
@ -207,6 +208,7 @@ public abstract class XmppActivity extends Activity {
|
|||
mColorOrange = getResources().getColor(R.color.orange);
|
||||
mColorGreen = getResources().getColor(R.color.green);
|
||||
mPrimaryColor = getResources().getColor(R.color.primary);
|
||||
mSecondaryBackgroundColor = getResources().getColor(R.color.secondarybackground);
|
||||
if (getPreferences().getBoolean("use_larger_font", false)) {
|
||||
setTheme(R.style.ConversationsTheme_LargerText);
|
||||
}
|
||||
|
@ -519,6 +521,10 @@ public abstract class XmppActivity extends Activity {
|
|||
return this.mPrimaryColor;
|
||||
}
|
||||
|
||||
public int getSecondaryBackgroundColor() {
|
||||
return this.mSecondaryBackgroundColor;
|
||||
}
|
||||
|
||||
class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> {
|
||||
private final WeakReference<ImageView> imageViewReference;
|
||||
private Message message = null;
|
||||
|
|
|
@ -40,9 +40,9 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||
Conversation conv = getItem(position);
|
||||
if (this.activity instanceof ConversationActivity) {
|
||||
ConversationActivity activity = (ConversationActivity) this.activity;
|
||||
if (!activity.getSlidingPaneLayout().isSlideable()) {
|
||||
if (!activity.isConversationsOverviewHideable()) {
|
||||
if (conv == activity.getSelectedConversation()) {
|
||||
view.setBackgroundColor(0xffdddddd);
|
||||
view.setBackgroundColor(activity.getSecondaryBackgroundColor());
|
||||
} else {
|
||||
view.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue