Refactor, recreate incall, start Incall method.
This commit is contained in:
parent
427b252651
commit
3c8a684fcd
1 changed files with 95 additions and 38 deletions
|
@ -27,6 +27,7 @@ import static android.media.AudioManager.ROUTE_SPEAKER;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.EcCalibrationListener;
|
import org.linphone.LinphoneManager.EcCalibrationListener;
|
||||||
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.Version;
|
import org.linphone.core.Version;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
|
@ -54,10 +55,10 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.TabHost;
|
|
||||||
import android.widget.TabWidget;
|
import android.widget.TabWidget;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.widget.TabHost.TabSpec;
|
||||||
|
|
||||||
public class LinphoneActivity extends TabActivity {
|
public class LinphoneActivity extends TabActivity {
|
||||||
public static final String DIALER_TAB = "dialer";
|
public static final String DIALER_TAB = "dialer";
|
||||||
|
@ -77,7 +78,7 @@ public class LinphoneActivity extends TabActivity {
|
||||||
private static SensorEventListener mSensorEventListener;
|
private static SensorEventListener mSensorEventListener;
|
||||||
private static String TAG = LinphoneManager.TAG;
|
private static String TAG = LinphoneManager.TAG;
|
||||||
|
|
||||||
private static final String SCREEN_IS_HIDDEN ="screen_is_hidden";
|
private static final String SCREEN_IS_HIDDEN = "screen_is_hidden";
|
||||||
|
|
||||||
|
|
||||||
// Customization
|
// Customization
|
||||||
|
@ -178,54 +179,56 @@ public class LinphoneActivity extends TabActivity {
|
||||||
private synchronized void fillTabHost() {
|
private synchronized void fillTabHost() {
|
||||||
if (((TabWidget) findViewById(android.R.id.tabs)).getChildCount() != 0) return;
|
if (((TabWidget) findViewById(android.R.id.tabs)).getChildCount() != 0) return;
|
||||||
|
|
||||||
TabHost lTabHost = getTabHost(); // The activity TabHost
|
startActivityInTab("history",
|
||||||
TabHost.TabSpec spec; // Reusable TabSpec for each tab
|
new Intent().setClass(this, HistoryActivity.class),
|
||||||
Drawable tabDrawable; // Drawable for a tab
|
R.string.tab_history, R.drawable.history_orange);
|
||||||
Intent tabIntent; // Intent for the a table
|
|
||||||
CharSequence indicator;
|
|
||||||
|
|
||||||
//Call History
|
|
||||||
tabIntent = new Intent().setClass(this, HistoryActivity.class);
|
|
||||||
tabDrawable = getResources().getDrawable(R.drawable.history_orange);
|
|
||||||
indicator = getString(R.string.tab_history);
|
|
||||||
spec = lTabHost.newTabSpec("history")
|
|
||||||
.setIndicator(indicator, tabDrawable)
|
|
||||||
.setContent(tabIntent);
|
|
||||||
lTabHost.addTab(spec);
|
|
||||||
|
|
||||||
// Dialer
|
startActivityInTab(DIALER_TAB,
|
||||||
tabIntent = new Intent().setClass(this, DialerActivity.class).setData(getIntent().getData());
|
new Intent().setClass(this, DialerActivity.class).setData(getIntent().getData()),
|
||||||
tabDrawable = getResources().getDrawable(R.drawable.dialer_orange);
|
R.string.tab_dialer, R.drawable.dialer_orange);
|
||||||
indicator = getString(R.string.tab_dialer);
|
|
||||||
tabDrawable = getResources().getDrawable(R.drawable.dialer_orange);
|
|
||||||
spec = lTabHost.newTabSpec(DIALER_TAB)
|
|
||||||
.setIndicator(indicator, tabDrawable)
|
|
||||||
.setContent(tabIntent);
|
|
||||||
lTabHost.addTab(spec);
|
|
||||||
|
|
||||||
|
|
||||||
// Contact picker
|
startActivityInTab("contact",
|
||||||
tabIntent = new Intent().setClass(this, Version.sdkAboveOrEqual(5) ?
|
new Intent().setClass(this, Version.sdkAboveOrEqual(5) ?
|
||||||
ContactPickerActivityNew.class : ContactPickerActivityOld.class);
|
ContactPickerActivityNew.class : ContactPickerActivityOld.class),
|
||||||
indicator = getString(R.string.tab_contact);
|
R.string.tab_contact, R.drawable.contact_orange);
|
||||||
tabDrawable = getResources().getDrawable(R.drawable.contact_orange);
|
|
||||||
spec = lTabHost.newTabSpec("contact")
|
|
||||||
.setIndicator(indicator, tabDrawable)
|
|
||||||
.setContent(tabIntent);
|
|
||||||
lTabHost.addTab(spec);
|
|
||||||
|
|
||||||
|
|
||||||
lTabHost.setCurrentTabByTag("dialer");
|
/*if (LinphoneService.isReady()) {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
|
if (lc.isIncall()) {
|
||||||
|
String caller = LinphoneManager.getInstance().extractADisplayName();
|
||||||
|
startIncallActivity(caller);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
getTabHost().setCurrentTabByTag(DIALER_TAB);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
if (intent.getData() == null) {
|
if (intent.getData() == null) {
|
||||||
Log.e(TAG, "LinphoneActivity received an intent without data, discarding");
|
Log.e(TAG, "LinphoneActivity received an intent without data, recreating GUI if needed");
|
||||||
|
if (!LinphoneService.isReady() || !LinphoneManager.getLc().isIncall()) return;
|
||||||
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
|
if(lc.isInComingInvitePending()) {
|
||||||
|
// TODO
|
||||||
|
Log.e(TAG, "Not handled case: recreation while incoming invite pending");
|
||||||
|
} else {
|
||||||
|
if (getResources().getBoolean(R.bool.use_incall_activity)) {
|
||||||
|
startIncallActivity(LinphoneManager.getInstance().extractADisplayName());
|
||||||
|
} else {
|
||||||
|
// TODO
|
||||||
|
Log.e(TAG, "Not handled case: recreation while in call and not using incall activity");
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (DialerActivity.instance() != null) {
|
if (DialerActivity.instance() != null) {
|
||||||
DialerActivity.instance().newOutgoingCall(intent);
|
DialerActivity.instance().newOutgoingCall(intent);
|
||||||
|
@ -247,7 +250,6 @@ public class LinphoneActivity extends TabActivity {
|
||||||
stopProxymitySensor();//just in case
|
stopProxymitySensor();//just in case
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -432,9 +434,64 @@ public class LinphoneActivity extends TabActivity {
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAddressAndGoToDialer(String number, String name) {
|
static void setAddressAndGoToDialer(String number, String name) {
|
||||||
DialerActivity.instance().setContactAddress(number, name);
|
DialerActivity.instance().setContactAddress(number, name);
|
||||||
instance.getTabHost().setCurrentTabByTag(DIALER_TAB);
|
instance.getTabHost().setCurrentTabByTag(DIALER_TAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void startActivityInTab(String tag, Intent intent, int indicatorId, int drawableId) {
|
||||||
|
Drawable tabDrawable = getResources().getDrawable(drawableId);
|
||||||
|
TabSpec spec = getTabHost().newTabSpec(tag)
|
||||||
|
.setIndicator(getString(indicatorId), tabDrawable)
|
||||||
|
.setContent(intent);
|
||||||
|
getTabHost().addTab(spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startIncallActivity(CharSequence callerName) {
|
||||||
|
startActivityForResult(
|
||||||
|
new Intent().setClass(this, IncallActivity.class),
|
||||||
|
INCALL_ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeIncallActivity() {
|
||||||
|
finishActivity(INCALL_ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
private String INCALL_ACTIVITY_TAG = "incall";
|
||||||
|
|
||||||
|
void changeTabVisibility(String tag, int value) {
|
||||||
|
View tab = getTabHost().getTabWidget().findViewWithTag(tag);
|
||||||
|
if (tab != null) {
|
||||||
|
tab.setVisibility(value);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Tab not found: " + tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeIncallActivity() {
|
||||||
|
changeTabVisibility(DIALER_TAB, View.VISIBLE);
|
||||||
|
getTabHost().setCurrentTabByTag(DIALER_TAB);
|
||||||
|
getLocalActivityManager().getActivity(INCALL_ACTIVITY_TAG).finish();
|
||||||
|
getTabHost().clearAllTabs();
|
||||||
|
fillTabHost();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishFromChild(Activity child) {
|
||||||
|
if (child instanceof IncallActivity) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.finishFromChild(child);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
public void startVideoActivity() {
|
||||||
|
startActivityForResult(
|
||||||
|
new Intent().setClass(this, VideoCallActivity.class),
|
||||||
|
LinphoneActivity.VIDEO_VIEW_ACTIVITY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue