diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-03 15:00:29 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-03 15:00:29 +0200 |
commit | 9ae52a235f39f86813220eae0bd084251242470e (patch) | |
tree | 9e05ae37e59b07d0de275dfc74a8dab69c0d2abb | |
parent | 335152b1915ddaf77e33aa1106553186f2ef7102 (diff) |
revised tablet ui. fixed #423
-rw-r--r-- | res/layout-w360dp/fragment_conversations_overview.xml (renamed from res/layout-sw600dp/fragment_conversations_overview.xml) | 8 | ||||
-rw-r--r-- | res/layout-w384dp/fragment_conversations_overview.xml (renamed from res/layout-sw384dp/fragment_conversations_overview.xml) | 2 | ||||
-rw-r--r-- | res/layout-w600dp/fragment_conversations_overview.xml (renamed from res/layout-sw360dp/fragment_conversations_overview.xml) | 4 | ||||
-rw-r--r-- | res/layout-w960dp/fragment_conversations_overview.xml (renamed from res/layout-sw720dp/fragment_conversations_overview.xml) | 13 | ||||
-rw-r--r-- | res/layout/fragment_conversations_overview.xml | 2 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationActivity.java | 245 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationFragment.java | 8 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/XmppActivity.java | 6 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 4 |
9 files changed, 175 insertions, 117 deletions
diff --git a/res/layout-sw600dp/fragment_conversations_overview.xml b/res/layout-w360dp/fragment_conversations_overview.xml index 5dfdceff..a639ed56 100644 --- a/res/layout-sw600dp/fragment_conversations_overview.xml +++ b/res/layout-w360dp/fragment_conversations_overview.xml @@ -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>
\ No newline at end of file +</eu.siacs.conversations.ui.SlidingPaneLayout>
\ No newline at end of file diff --git a/res/layout-sw384dp/fragment_conversations_overview.xml b/res/layout-w384dp/fragment_conversations_overview.xml index 2a422052..c3aa67ae 100644 --- a/res/layout-sw384dp/fragment_conversations_overview.xml +++ b/res/layout-w384dp/fragment_conversations_overview.xml @@ -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" > diff --git a/res/layout-sw360dp/fragment_conversations_overview.xml b/res/layout-w600dp/fragment_conversations_overview.xml index ef8a1b6e..331fb1f0 100644 --- a/res/layout-sw360dp/fragment_conversations_overview.xml +++ b/res/layout-w600dp/fragment_conversations_overview.xml @@ -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" > diff --git a/res/layout-sw720dp/fragment_conversations_overview.xml b/res/layout-w960dp/fragment_conversations_overview.xml index bc52ec46..5309674b 100644 --- a/res/layout-sw720dp/fragment_conversations_overview.xml +++ b/res/layout-w960dp/fragment_conversations_overview.xml @@ -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>
\ No newline at end of file +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/fragment_conversations_overview.xml b/res/layout/fragment_conversations_overview.xml index bc52ec46..d4145761 100644 --- a/res/layout/fragment_conversations_overview.xml +++ b/res/layout/fragment_conversations_overview.xml @@ -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" > diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 0c67beff..04af0e84 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -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; @@ -83,25 +88,59 @@ public class ConversationActivity extends XmppActivity implements } public void setSelectedConversation(Conversation conversation) { - this.selectedConversation = conversation; + this.selectedConversation = conversation; } public ListView getConversationListView() { 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,54 +161,61 @@ 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 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 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 + @Override + public void onPanelSlide(View arg0, float arg1) { + // TODO Auto-generated method stub - } - }); + } + }); + } } - + public void openConversation(Conversation conversation) { ActionBar ab = getActionBar(); if (ab != null) { @@ -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)); } } } diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 34c68e00..86e5257a 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -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); } } diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java index 518f7b0b..39ca623b 100644 --- a/src/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/eu/siacs/conversations/ui/XmppActivity.java @@ -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); } @@ -518,6 +520,10 @@ public abstract class XmppActivity extends Activity { public int getPrimaryColor() { return this.mPrimaryColor; } + + public int getSecondaryBackgroundColor() { + return this.mSecondaryBackgroundColor; + } class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> { private final WeakReference<ImageView> imageViewReference; diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 7b470faa..583772ba 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -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); } |