Tablet changes started

This commit is contained in:
Sylvain Berfini 2012-07-31 17:39:54 +02:00
parent 7f02ef7284
commit 8e4a40e6e9
13 changed files with 309 additions and 64 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.linphone"
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET"/>
@ -50,10 +50,10 @@
</intent-filter>
</activity>
<!-- Behind : Hack to force the portrait on phones and landscape on tablets thanks to a hack in LinphoneLauncherActivity -->
<activity android:name="org.linphone.LinphoneActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait"
android:screenOrientation="behind"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -62,7 +62,7 @@
</activity>
<activity android:name="org.linphone.IncomingCallActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
@ -70,14 +70,6 @@
</intent-filter>
</activity>
<activity android:name="org.linphone.FirstLoginActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name="org.linphone.InCallActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:noHistory="true"

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res/org.linphone">
<RelativeLayout
android:id="@+id/addressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center">
<org.linphone.ui.AddressText
android:id="@+id/Adress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="30dp"
android:background="@drawable/dialer_address_background"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:gravity="center"
android:inputType="textEmailAddress" />
<org.linphone.ui.EraseButton
android:id="@+id/Erase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@drawable/backspace" />
</RelativeLayout>
<org.linphone.ui.Numpad
android:id="@+id/Dialer"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_below="@id/addressbar"
android:background="@drawable/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
<ImageView
android:contentDescription="@string/content_description_add_contact"
android:id="@+id/addContact"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/add_contact" />
<org.linphone.ui.CallButton
android:id="@+id/Call"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/call" />
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="70dp"
android:paddingTop="20dp">
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.67" />
<LinearLayout
android:id="@+id/fragmentContainer2"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.33" />
</LinearLayout>
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/status" />
</FrameLayout>
<LinearLayout
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2" >
<ImageView
android:id="@+id/history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/content_description_history"
android:scaleType="fitXY"
android:src="@drawable/history" />
<TextView
android:id="@+id/missedCalls"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/missed_calls_bg"
android:gravity="center"
android:textSize="20dp"
android:visibility="gone" />
</RelativeLayout>
<ImageView
android:id="@+id/contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:contentDescription="@string/content_description_contacts"
android:scaleType="fitXY"
android:src="@drawable/contacts" />
<ImageView
android:id="@+id/dialer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:adjustViewBounds="true"
android:contentDescription="@string/content_description_dialer"
android:scaleType="fitEnd"
android:src="@drawable/dialer" />
<ImageView
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:contentDescription="@string/content_description_settings"
android:scaleType="fitXY"
android:src="@drawable/settings" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2" >
<ImageView
android:id="@+id/chat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:contentDescription="@string/content_description_chat"
android:scaleType="fitXY"
android:src="@drawable/chat" />
<TextView
android:id="@+id/missedChats"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/missed_calls_bg"
android:gravity="center"
android:textSize="20dp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -2,12 +2,12 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
android:layout_alignParentTop="true">
<LinearLayout
android:id="@+id/fragmentContainer"
@ -30,12 +30,12 @@
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2" >
android:layout_weight="0.2">
<ImageView
android:id="@+id/history"
@ -87,7 +87,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2" >
android:layout_weight="0.2">
<ImageView
android:id="@+id/chat"
@ -109,6 +109,7 @@
android:textSize="20dp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_disable_account">Disable</string>
<string name="pref_tunnel">Tunnel</string>

View file

@ -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;

View file

@ -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;

View file

@ -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;
}
}
}

View file

@ -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<String> getChatList() {
if (chatStorage != null) {
return chatStorage.getChatList();
}
return null;
return getChatStorage().getChatList();
}
public List<ChatMessage> 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;
}

View file

@ -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()) {

View file

@ -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);

View file

@ -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);