From 8e4a40e6e9296384a3c85f3c33cd37c47ffc0457 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 31 Jul 2012 17:39:54 +0200 Subject: [PATCH] Tablet changes started --- AndroidManifest.xml | 16 +-- res/drawable-xlarge-land/background.png | Bin 0 -> 5336 bytes res/layout-xlarge-land/dialer.xml | 71 ++++++++++ res/layout-xlarge-land/main.xml | 129 ++++++++++++++++++ res/layout/main.xml | 11 +- res/values/strings.xml | 1 - .../linphone/AccountPreferencesActivity.java | 1 - src/org/linphone/AudioCallFragment.java | 4 +- src/org/linphone/FragmentsAvailable.java | 16 +++ src/org/linphone/LinphoneActivity.java | 107 +++++++++------ .../linphone/LinphoneLauncherActivity.java | 12 ++ .../linphone/LinphonePreferencesActivity.java | 1 + src/org/linphone/PreferencesActivity.java | 4 +- 13 files changed, 309 insertions(+), 64 deletions(-) create mode 100644 res/drawable-xlarge-land/background.png create mode 100644 res/layout-xlarge-land/dialer.xml create mode 100644 res/layout-xlarge-land/main.xml diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9c3630c93..2222af699 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="2000" android:versionName="2.0" android:installLocation="auto"> @@ -50,10 +50,10 @@ + @@ -62,7 +62,7 @@ @@ -70,14 +70,6 @@ - - - - - - ePWa!dnA_po{)`Mx@1+%-~vn*M`{tq23Evf_bYXWX+YIePRyje)SP?oWd8&51c zj3+BH6YQUDp|k{JFgDs|A4>*r)9Cqmtv02D?`Eo2bYWecR`hK3nTdZQP zq`nAtQB%LGiTQQtSCjjT;Z(Cy#qm)sf0b zvjk$W0R~St)6OoVjE%5H!Xma|7$)%mB%-IM++0I9uPme))dc8U_6P@PhL&E{+06#g zza%7TviK9X`oFvAVlwAgkG+#-FHyB>5AYJxd5rl#p(T!~(ZlXupa< zO9<9KG_-7TVmhDV%Al{+3`Zg>jxJYbzsXKI!eB7$47ed`wJ4vS+Ns|F81Ks44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kIiv&KvZG_SI7c$oJ6lhO{w$?m_1hMUI*(ogUPT)6Ov^Pysstv`wP|@ z^T3N)tKRX|ZH}EZC z4$pj6j_&3?f~GUf5}E$r!7EeZP2m8{^wc-b^7*$a%@0ZZBViZypKIU^Tol2Q5E(Hm+C@_|c;H4GS`*MA~8lCrI2;<~>;zNosn3MS~Mn zc$PEc^fjW1pG(?VqDXMYu;wp@Fj!=}m&je<*WAo;{ZKdN%+9&Yhlw|bg0sYYauJll6nI5E zOXZ!jvm|zYp-R+&7O5Yn5#XUDM0bM2{2bj0uSDYR2+l8qS}QbJ&r8z6fL{ispY4B zW6AyP@eKUT=$h}-+cry?-9eD zFybfrh9t2?#f1N#fp#$eIfIrrjwifxj-7ozI D!QF&i literal 0 HcmV?d00001 diff --git a/res/layout-xlarge-land/dialer.xml b/res/layout-xlarge-land/dialer.xml new file mode 100644 index 000000000..ffbccb97a --- /dev/null +++ b/res/layout-xlarge-land/dialer.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-xlarge-land/main.xml b/res/layout-xlarge-land/main.xml new file mode 100644 index 000000000..f382317d9 --- /dev/null +++ b/res/layout-xlarge-land/main.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/main.xml b/res/layout/main.xml index fbdb2c272..0e97f0c85 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -2,12 +2,12 @@ + android:layout_height="match_parent"> + android:layout_alignParentTop="true"> + android:orientation="horizontal"> + android:layout_weight="0.2"> + android:layout_weight="0.2"> + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index d3ef2cac2..35059ec29 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,6 +1,5 @@ - Disable Tunnel diff --git a/src/org/linphone/AccountPreferencesActivity.java b/src/org/linphone/AccountPreferencesActivity.java index 813cf7846..19be0a4ce 100644 --- a/src/org/linphone/AccountPreferencesActivity.java +++ b/src/org/linphone/AccountPreferencesActivity.java @@ -25,7 +25,6 @@ import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; -import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.text.InputType; diff --git a/src/org/linphone/AudioCallFragment.java b/src/org/linphone/AudioCallFragment.java index 630f9f783..a33d2b10d 100644 --- a/src/org/linphone/AudioCallFragment.java +++ b/src/org/linphone/AudioCallFragment.java @@ -43,10 +43,10 @@ import android.widget.TextView; */ public class AudioCallFragment extends Fragment { private static final int rowHeight = 75; // Value set in active_call.xml - private static final int rowImageHeight = 100; // Value set in active_call.xml +// private static final int rowImageHeight = 100; // Value set in active_call.xml private static final int rowThickRatio = 85; // Ratio dependent from the image private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100); - private static final int topMarginWithImage = topMargin + rowImageHeight; +// private static final int topMarginWithImage = topMargin + rowImageHeight; private RelativeLayout callsList; private LayoutInflater inflater; diff --git a/src/org/linphone/FragmentsAvailable.java b/src/org/linphone/FragmentsAvailable.java index c4d8c7035..b77ba49b4 100644 --- a/src/org/linphone/FragmentsAvailable.java +++ b/src/org/linphone/FragmentsAvailable.java @@ -69,4 +69,20 @@ public enum FragmentsAvailable { return false; } } + + public boolean shouldAddItselfToTheRightOf(FragmentsAvailable fragment) { + switch (this) { + case HISTORY_DETAIL: + return fragment == HISTORY; + + case CONTACT: + return fragment == CONTACTS; + + case CHAT: + return fragment == CHATLIST; + + default: + return false; + } + } } diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index eb8a58ba6..3ff1cb3e8 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -38,12 +38,14 @@ import org.linphone.core.LinphoneCallLog.CallStatus; import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.Log; +import org.linphone.mediastream.Version; import org.linphone.setup.SetupActivity; import org.linphone.ui.AddressText; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; @@ -60,6 +62,7 @@ import android.view.View.OnClickListener; import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; /** @@ -123,11 +126,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene } if (findViewById(R.id.fragmentContainer) != null) { - if (savedInstanceState != null) { - return; - } - - dialerFragment = new DialerFragment(); + dialerFragment = new DialerFragment(); dialerFragment.setArguments(getIntent().getExtras()); getSupportFragmentManager().beginTransaction() .add(R.id.fragmentContainer, dialerFragment).commit(); @@ -204,7 +203,11 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene if (newFragment != null) { newFragment.setArguments(extras); - changeFragment(newFragment, newFragmentType, withoutAnimation); + if (Version.isXLargeScreen(this)) { + changeFragmentForTablets(newFragment, newFragmentType, withoutAnimation); + } else { + changeFragment(newFragment, newFragmentType, withoutAnimation); + } } } @@ -235,7 +238,50 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene currentFragment = newFragmentType; } + private void changeFragmentForTablets(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) { + if (statusFragment != null) { + statusFragment.closeStatusBar(); + } + + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + + if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) { + LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2); + ll.setVisibility(View.VISIBLE); + + transaction.addToBackStack(newFragmentType.toString()); + transaction.replace(R.id.fragmentContainer2, newFragment); + + transaction.commitAllowingStateLoss(); + + } else { + if (!withoutAnimation && !getResources().getBoolean(R.bool.disable_animations) && currentFragment.shouldAnimate()) { + if (newFragmentType.isRightOf(currentFragment)) { + transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right); + } else { + transaction.setCustomAnimations(R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left); + } + } + + LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2); + ll.setVisibility(View.GONE); + + try { + getSupportFragmentManager().popBackStack(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE); + } catch (java.lang.IllegalStateException e) { + + } + + transaction.addToBackStack(newFragmentType.toString()); + transaction.replace(R.id.fragmentContainer, newFragment); + + transaction.commitAllowingStateLoss(); + } + currentFragment = newFragmentType; + } + public void displayHistoryDetail(String sipUri, LinphoneCallLog log) { + //TODO Update current fragment if already visible (tablets) LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri); Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver()); @@ -271,6 +317,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene } public void displayContact(Contact contact) { + //TODO Update current fragment if already visible (tablets) Bundle extras = new Bundle(); extras.putSerializable("Contact", contact); changeCurrentFragment(FragmentsAvailable.CONTACT, extras); @@ -281,6 +328,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene } public void displayChat(String sipUri) { + //TODO Update current fragment if already visible (tablets) LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri); Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver()); @@ -294,7 +342,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene LinphoneService.instance().resetMessageNotifCount(); LinphoneService.instance().removeMessageNotification(); changeCurrentFragment(FragmentsAvailable.CHAT, extras); - displayMissedChats(chatStorage.getUnreadMessageCount()); + displayMissedChats(getChatStorage().getUnreadMessageCount()); } @Override @@ -332,9 +380,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene // } } else if (id == R.id.chat) { - if (chatStorage == null) { - chatStorage = new ChatStorage(this); - } changeCurrentFragment(FragmentsAvailable.CHATLIST, null); chat.setSelected(true); } @@ -399,61 +444,38 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene } public ArrayList getChatList() { - if (chatStorage != null) { - return chatStorage.getChatList(); - } - return null; + return getChatStorage().getChatList(); } public List getChatMessages(String correspondent) { - if (chatStorage == null) { - chatStorage = new ChatStorage(this); - } - - return chatStorage.getMessages(correspondent); + return getChatStorage().getMessages(correspondent); } public void removeFromChatList(String sipUri) { - if (chatStorage == null) { - chatStorage = new ChatStorage(this); - } - - chatStorage.removeDiscussion(sipUri); + getChatStorage().removeDiscussion(sipUri); } @Override public void onMessageReceived(LinphoneAddress from, String message) { - if (chatStorage == null) { - chatStorage = new ChatStorage(this); - } - - int id = chatStorage.saveMessage(from.asStringUriOnly(), "", message); + int id = getChatStorage().saveMessage(from.asStringUriOnly(), "", message); ChatFragment chatFragment = ((ChatFragment) messageListenerFragment); if (messageListenerFragment != null && messageListenerFragment.isVisible() && chatFragment.getSipUri().equals(from.asStringUriOnly())) { chatFragment.onMessageReceived(from, message); - chatStorage.markMessageAsRead(id); + getChatStorage().markMessageAsRead(id); } else if (LinphoneService.isReady()) { - displayMissedChats(chatStorage.getUnreadMessageCount()); + displayMissedChats(getChatStorage().getUnreadMessageCount()); } LinphoneUtils.findUriPictureOfContactAndSetDisplayName(from, getContentResolver()); LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getDisplayName(), message); } public void updateMissedChatCount() { - if (chatStorage == null) { - chatStorage = new ChatStorage(this); - } - - displayMissedChats(chatStorage.getUnreadMessageCount()); + displayMissedChats(getChatStorage().getUnreadMessageCount()); } public void onMessageSent(String to, String message) { - if (chatStorage == null) { - chatStorage = new ChatStorage(this); - } - - chatStorage.saveMessage("", to, message); + getChatStorage().saveMessage("", to, message); } @Override @@ -655,6 +677,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene } public ChatStorage getChatStorage() { + if (chatStorage == null) { + chatStorage = new ChatStorage(this); + } return chatStorage; } diff --git a/src/org/linphone/LinphoneLauncherActivity.java b/src/org/linphone/LinphoneLauncherActivity.java index 17055dbd1..32bde832a 100644 --- a/src/org/linphone/LinphoneLauncherActivity.java +++ b/src/org/linphone/LinphoneLauncherActivity.java @@ -19,8 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone; import static android.content.Intent.ACTION_MAIN; + +import org.linphone.mediastream.Version; + import android.app.Activity; import android.content.Intent; +import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; @@ -40,6 +44,14 @@ public class LinphoneLauncherActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.launcher); + + // Hack to avoid to draw twice LinphoneActivity on tablets + if (Version.isXLargeScreen(this)) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + mHandler = new Handler(); if (LinphoneService.isReady()) { diff --git a/src/org/linphone/LinphonePreferencesActivity.java b/src/org/linphone/LinphonePreferencesActivity.java index 2fa1dd601..14b5a1dc3 100644 --- a/src/org/linphone/LinphonePreferencesActivity.java +++ b/src/org/linphone/LinphonePreferencesActivity.java @@ -38,6 +38,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements O @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // Hack to allow custom view in preferences, in this case the bottom menu setContentView(R.layout.settings); diff --git a/src/org/linphone/PreferencesActivity.java b/src/org/linphone/PreferencesActivity.java index c883248e1..7ca709d67 100644 --- a/src/org/linphone/PreferencesActivity.java +++ b/src/org/linphone/PreferencesActivity.java @@ -163,8 +163,8 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) { if (lpc.getIdentity().contains(prefs.getString(keyUsername, "")) && lpc.getIdentity().contains(prefs.getString(keyDomain, ""))) { - while (lpc.getState() == RegistrationState.RegistrationProgress || lpc.getState() == RegistrationState.RegistrationNone) - {}; + while (lpc.getState() == RegistrationState.RegistrationProgress || lpc.getState() == RegistrationState.RegistrationNone) + { }; if (lpc.getState() == LinphoneCore.RegistrationState.RegistrationOk) { me.setWidgetLayoutResource(R.layout.preference_led_connected);