Code optimisation + fix OOM issue

This commit is contained in:
Sylvain Berfini 2012-07-23 16:30:55 +02:00
parent f493dacee2
commit 86cc525635
28 changed files with 55 additions and 78 deletions

View file

@ -23,7 +23,7 @@
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
<!-- Don't remove the space after android:debuggable: it prevents ndk-build to try including gdbserver and crash gcc -->
<application android:label="@string/app_name" android:debuggable ="true" android:icon="@drawable/logo_linphone_57x57">
<application android:label="@string/app_name" android:debuggable ="true" android:icon="@drawable/logo_linphone_57x57" android:largeHeap="true">
<activity android:name="org.linphone.LinphoneLauncherActivity"
android:label="@string/app_name"
@ -54,7 +54,7 @@
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait"
android:launchMode="singleTask">
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@ -63,7 +63,7 @@
<activity android:name="org.linphone.IncomingCallActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTop"
android:launchMode="singleInstance"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -81,7 +81,7 @@
<activity android:name="org.linphone.InCallActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:noHistory="true"
android:launchMode="singleTop">
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@ -108,7 +108,7 @@
</intent-filter>
</activity>
<service android:name="org.linphone.LinphoneService" />
<service android:name="org.linphone.LinphoneService" android:stopWithTask="false"/>
<receiver android:name="org.linphone.NetworkManager">
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

View file

@ -1,6 +1,7 @@
<?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:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

View file

@ -1,6 +1,7 @@
<?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:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

View file

@ -4,27 +4,27 @@
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
<TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" android:background="@drawable/numpad_one" />
<org.linphone.ui.Digit android:id="@+id/Digit2" android:text="2" style="@style/DialerDigit" android:background="@drawable/numpad_two" />
<org.linphone.ui.Digit android:id="@+id/Digit3" android:text="3" style="@style/DialerDigit" android:background="@drawable/numpad_three" />
<org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" android:background="@drawable/numpad_one" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit2" android:text="2" style="@style/DialerDigit" android:background="@drawable/numpad_two" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit3" android:text="3" style="@style/DialerDigit" android:background="@drawable/numpad_three" android:soundEffectsEnabled="true" />
</TableRow>
<TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/Digit4" android:text="4" style="@style/DialerDigit" android:background="@drawable/numpad_four" />
<org.linphone.ui.Digit android:id="@+id/Digit5" android:text="5" style="@style/DialerDigit" android:background="@drawable/numpad_five" />
<org.linphone.ui.Digit android:id="@+id/Digit6" android:text="6" style="@style/DialerDigit" android:background="@drawable/numpad_six" />
<org.linphone.ui.Digit android:id="@+id/Digit4" android:text="4" style="@style/DialerDigit" android:background="@drawable/numpad_four" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit5" android:text="5" style="@style/DialerDigit" android:background="@drawable/numpad_five" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit6" android:text="6" style="@style/DialerDigit" android:background="@drawable/numpad_six" android:soundEffectsEnabled="true" />
</TableRow>
<TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/Digit7" android:text="7" style="@style/DialerDigit" android:background="@drawable/numpad_seven" />
<org.linphone.ui.Digit android:id="@+id/Digit8" android:text="8" style="@style/DialerDigit" android:background="@drawable/numpad_eight" />
<org.linphone.ui.Digit android:id="@+id/Digit9" android:text="9" style="@style/DialerDigit" android:background="@drawable/numpad_nine" />
<org.linphone.ui.Digit android:id="@+id/Digit7" android:text="7" style="@style/DialerDigit" android:background="@drawable/numpad_seven" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit8" android:text="8" style="@style/DialerDigit" android:background="@drawable/numpad_eight" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit9" android:text="9" style="@style/DialerDigit" android:background="@drawable/numpad_nine" android:soundEffectsEnabled="true" />
</TableRow>
<TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" android:background="@drawable/numpad_star" />
<org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" android:background="@drawable/numpad_zero" />
<org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" android:background="@drawable/numpad_sharp" />
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" android:background="@drawable/numpad_star" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" android:background="@drawable/numpad_zero" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" android:background="@drawable/numpad_sharp" android:soundEffectsEnabled="true" />
</TableRow>
</TableLayout>

View file

@ -41,20 +41,20 @@ import android.widget.TextView;
* @author Sylvain Berfini
*/
public class AudioCallFragment extends Fragment {
private static AudioCallFragment instance;
private RelativeLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
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 rowThickRatio = 85; // Ratio dependent from the image
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
private static final int topMarginWithImage = topMargin + rowImageHeight;
private RelativeLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
private InCallActivity inCallActivity;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
instance = this;
this.inflater = inflater;
this.container = container;
@ -142,14 +142,20 @@ public class AudioCallFragment extends Fragment {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (InCallActivity.instance() == null) {
inCallActivity = (InCallActivity) activity;
inCallActivity.bindAudioFragment(this);
}
@Override
public void onStart() {
super.onStart();
if (inCallActivity == null) {
return;
}
InCallActivity.instance().bindAudioFragment(this);
// Just to be sure we have incall controls
InCallActivity.instance().setCallControlsVisibleAndRemoveCallbacks();
inCallActivity.setCallControlsVisibleAndRemoveCallbacks();
}
@Override
@ -160,13 +166,6 @@ public class AudioCallFragment extends Fragment {
refreshCallList(getResources());
}
/**
* @return null if not ready yet
*/
public static AudioCallFragment instance() {
return instance;
}
public void refreshCallList(Resources resources) {
if (callsList == null) {
return;

View file

@ -54,7 +54,6 @@ public class InCallActivity extends FragmentActivity implements
OnClickListener {
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
private static InCallActivity instance;
private Handler mHandler = new Handler();
private Handler controlsHandler = new Handler();
private Runnable mControls;
@ -65,18 +64,9 @@ public class InCallActivity extends FragmentActivity implements
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled;
private LinearLayout mControlsLayout;
static final boolean isInstanciated() {
return instance != null;
}
public static final InCallActivity instance() {
return instance;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
instance = this;
setContentView(R.layout.incall);
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
@ -107,7 +97,7 @@ public class InCallActivity extends FragmentActivity implements
switchCamera.setVisibility(View.GONE);
}
callFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commit();
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
}
LinphoneManager.addListener(this);
@ -567,15 +557,21 @@ public class InCallActivity extends FragmentActivity implements
setCallControlsVisibleAndRemoveCallbacks();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LinphoneUtils.onKeyVolumeAdjust(keyCode)) return true;
if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true;
// if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true;
return super.onKeyDown(keyCode, event);
}
public void bindAudioFragment(AudioCallFragment fragment) {
audioCallFragment = fragment;
}
@Override
protected void onDestroy() {
LinphoneManager.removeListener(this);
super.onDestroy();
}
}

View file

@ -73,7 +73,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
private static final int SETTINGS_ACTIVITY = 123;
private static final int FIRST_LOGIN_ACTIVITY = 101;
private static final int callActivity = 19;
private static LinphoneActivity instance;
private StatusFragment statusFragment;
private TextView missedCalls, missedChats;
private ImageView history, contacts, dialer, settings, chat;

View file

@ -430,8 +430,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
@ -450,19 +448,10 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
mWifiLock.release();
super.onDestroy();
}
private static final LinphoneGuiListener guiListener() {
return null;
}
private static final LinphoneOnCallStateChangedListener incallListener() {
return InCallActivity.instance();
}
}
public void onDisplayStatus(final String message) {
mHandler.post(new Runnable() {
@ -488,7 +477,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
}
}
public void onRegistrationStateChanged(final RegistrationState state,
final String message) {
if (instance == null) {
@ -545,8 +533,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
try {
LinphoneManager.getLc().deferCallUpdate(call);
if (incallListener() != null)
incallListener().onCallStateChanged(call, state, message);
// if (incallListener() != null)
// incallListener().onCallStateChanged(call, state, message);
} catch (LinphoneCoreException e) {
e.printStackTrace();
}

View file

@ -48,7 +48,6 @@ import android.widget.TextView;
* @author Sylvain Berfini
*/
public class StatusFragment extends Fragment {
private static StatusFragment instance;
private Handler mHandler = new Handler();
private Handler refreshHandler = new Handler();
private TextView statusText, exit;
@ -61,7 +60,6 @@ public class StatusFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
instance = this;
View view = inflater.inflate(R.layout.status, container, false);
statusText = (TextView) view.findViewById(R.id.statusText);
@ -81,13 +79,6 @@ public class StatusFragment extends Fragment {
return view;
}
/**
* @return null if not ready yet
*/
public static StatusFragment instance() {
return instance;
}
@Override
public void onAttach(Activity activity) {

View file

@ -23,6 +23,7 @@ import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
@ -42,16 +43,15 @@ import android.view.ViewGroup;
*/
@TargetApi(5)
public class VideoCallFragment extends Fragment {
private static VideoCallFragment instance;
private WakeLock mWakeLock;
private SurfaceView mVideoView;
private SurfaceView mCaptureView;
private AndroidVideoWindowImpl androidVideoWindowImpl;
private InCallActivity inCallActivity;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
instance = this;
View view = inflater.inflate(R.layout.video, container, false);
mVideoView = (SurfaceView) view.findViewById(R.id.videoSurface);
@ -93,7 +93,7 @@ public class VideoCallFragment extends Fragment {
mVideoView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
InCallActivity.instance().displayVideoCallControlsIfHidden();
inCallActivity.displayVideoCallControlsIfHidden();
return false;
}
});
@ -101,11 +101,10 @@ public class VideoCallFragment extends Fragment {
return view;
}
/**
* @return null if not ready yet
*/
public static VideoCallFragment instance() {
return instance;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
inCallActivity = (InCallActivity) activity;
}
private void fixZOrder(SurfaceView video, SurfaceView preview) {