Improved dialer loading & numpad in call loading + no more white screen while activity is loading

This commit is contained in:
Sylvain Berfini 2019-06-17 16:36:25 +02:00
parent 45254d3261
commit b1c8219c7b
26 changed files with 133 additions and 91 deletions

View file

@ -67,8 +67,7 @@
<activity <activity
android:name=".activities.LinphoneLauncherActivity" android:name=".activities.LinphoneLauncherActivity"
android:noHistory="true" android:noHistory="true">
android:theme="@style/LinphoneLauncherStyle">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View file

@ -23,12 +23,14 @@ import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.TextureView; import android.view.TextureView;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.asynclayoutinflater.view.AsyncLayoutInflater;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
@ -55,6 +57,7 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
private boolean mIsTransfer; private boolean mIsTransfer;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private boolean mInterfaceLoaded;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -63,62 +66,32 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
return; return;
} }
mInterfaceLoaded = false;
// Uses the fragment container layout to inflate the dialer view instead of using a fragment // Uses the fragment container layout to inflate the dialer view instead of using a fragment
View dialerView = LayoutInflater.from(this).inflate(R.layout.dialer, null, false); new AsyncLayoutInflater(this)
LinearLayout fragmentContainer = findViewById(R.id.fragmentContainer); .inflate(
R.layout.dialer,
null,
new AsyncLayoutInflater.OnInflateFinishedListener() {
@Override
public void onInflateFinished(
@NonNull View view, int resid, @Nullable ViewGroup parent) {
LinearLayout fragmentContainer =
findViewById(R.id.fragmentContainer);
LinearLayout.LayoutParams params = LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams( new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); ViewGroup.LayoutParams.MATCH_PARENT,
fragmentContainer.addView(dialerView, params); ViewGroup.LayoutParams.MATCH_PARENT);
fragmentContainer.addView(view, params);
initUI(view);
mInterfaceLoaded = true;
}
});
if (isTablet()) { if (isTablet()) {
findViewById(R.id.fragmentContainer2).setVisibility(View.GONE); findViewById(R.id.fragmentContainer2).setVisibility(View.GONE);
} }
mAddress = findViewById(R.id.address);
mAddress.setAddressListener(this);
EraseButton erase = findViewById(R.id.erase);
erase.setAddressWidget(mAddress);
mStartCall = findViewById(R.id.start_call);
mStartCall.setAddressWidget(mAddress);
mAddCall = findViewById(R.id.add_call);
mAddCall.setAddressWidget(mAddress);
mTransferCall = findViewById(R.id.transfer_call);
mTransferCall.setAddressWidget(mAddress);
mTransferCall.setIsTransfer(true);
mAddContact = findViewById(R.id.add_contact);
mAddContact.setEnabled(false);
mAddContact.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DialerActivity.this, ContactsActivity.class);
intent.putExtra("EditOnClick", true);
intent.putExtra("SipAddress", mAddress.getText().toString());
startActivity(intent);
}
});
mBackToCall = findViewById(R.id.back_to_call);
mBackToCall.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(DialerActivity.this, CallActivity.class));
}
});
mIsTransfer = false;
if (getIntent() != null) {
mIsTransfer = getIntent().getBooleanExtra("Transfer", false);
mAddress.setText(getIntent().getStringExtra("SipUri"));
}
mListener = mListener =
new CoreListenerStub() { new CoreListenerStub() {
@Override @Override
@ -139,7 +112,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
Manifest.permission.READ_CONTACTS Manifest.permission.READ_CONTACTS
}; };
setUpNumpad(dialerView);
handleIntentParams(getIntent()); handleIntentParams(getIntent());
} }
@ -160,9 +132,11 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
core.addListener(mListener); core.addListener(mListener);
} }
if (mInterfaceLoaded) {
updateLayout(); updateLayout();
enableVideoPreviewIfTablet(true); enableVideoPreviewIfTablet(true);
} }
}
@Override @Override
protected void onPause() { protected void onPause() {
@ -175,6 +149,56 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
super.onPause(); super.onPause();
} }
private void initUI(View view) {
mAddress = view.findViewById(R.id.address);
mAddress.setAddressListener(this);
EraseButton erase = view.findViewById(R.id.erase);
erase.setAddressWidget(mAddress);
mStartCall = view.findViewById(R.id.start_call);
mStartCall.setAddressWidget(mAddress);
mAddCall = view.findViewById(R.id.add_call);
mAddCall.setAddressWidget(mAddress);
mTransferCall = view.findViewById(R.id.transfer_call);
mTransferCall.setAddressWidget(mAddress);
mTransferCall.setIsTransfer(true);
mAddContact = view.findViewById(R.id.add_contact);
mAddContact.setEnabled(false);
mAddContact.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DialerActivity.this, ContactsActivity.class);
intent.putExtra("EditOnClick", true);
intent.putExtra("SipAddress", mAddress.getText().toString());
startActivity(intent);
}
});
mBackToCall = view.findViewById(R.id.back_to_call);
mBackToCall.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(DialerActivity.this, CallActivity.class));
}
});
mIsTransfer = false;
if (getIntent() != null) {
mIsTransfer = getIntent().getBooleanExtra("Transfer", false);
mAddress.setText(getIntent().getStringExtra("SipUri"));
}
setUpNumpad(view);
updateLayout();
enableVideoPreviewIfTablet(true);
}
private void enableVideoPreviewIfTablet(boolean enable) { private void enableVideoPreviewIfTablet(boolean enable) {
Core core = LinphoneManager.getCore(); Core core = LinphoneManager.getCore();
TextureView preview = findViewById(R.id.video_preview); TextureView preview = findViewById(R.id.video_preview);

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout" android:id="@+id/topLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<androidx.drawerlayout.widget.DrawerLayout <androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/side_menu" android:id="@+id/side_menu"
@ -130,9 +131,10 @@
</RelativeLayout> </RelativeLayout>
<include layout="@layout/numpad" <ViewStub
android:id="@+id/numpad" android:id="@+id/numpad"
android:visibility="gone" android:inflatedId="@+id/numpad"
android:layout="@layout/numpad"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"

View file

@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status_fragment" android:id="@+id/status_fragment"

View file

@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status_fragment" android:id="@+id/status_fragment"

View file

@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status_fragment" android:id="@+id/status_fragment"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout" android:id="@+id/topLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<androidx.drawerlayout.widget.DrawerLayout <androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/side_menu" android:id="@+id/side_menu"
@ -122,9 +123,10 @@
</RelativeLayout> </RelativeLayout>
<include layout="@layout/numpad" <ViewStub
android:id="@+id/numpad" android:id="@+id/numpad"
android:visibility="gone" android:inflatedId="@+id/numpad"
android:layout="@layout/numpad"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout" android:id="@+id/topLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -3,7 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout" android:id="@+id/topLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status" android:id="@+id/status"

View file

@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<fragment <fragment
android:id="@+id/status_fragment" android:id="@+id/status_fragment"

View file

@ -1,14 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="LinphoneLauncherStyle" parent="LinphoneStyleLight">
<!-- Prevent a white screen while app is loading -->
<!-- http://www.tothenew.com/blog/disabling-the-preview-or-start-window-in-android/ -->
<item name="android:windowBackground">@drawable/launch_screen</item>
</style>
<style name="LinphoneStyleLight" parent="Theme.AppCompat.Light.NoActionBar"> <style name="LinphoneStyleLight" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Disable animations between activities --> <!-- Disable animations between activities -->
<item name="android:windowAnimationStyle">@null</item> <item name="android:windowAnimationStyle">@null</item>
<item name="android:windowBackground">@drawable/launch_screen</item>
<!-- Android theme override --> <!-- Android theme override -->
<item name="colorAccent">@color/primary_color</item> <item name="colorAccent">@color/primary_color</item>
@ -20,7 +15,6 @@
<item name="android:textColorHint">@color/light_grey_color</item> <item name="android:textColorHint">@color/light_grey_color</item>
<item name="android:colorBackground">@color/white_color</item> <item name="android:colorBackground">@color/white_color</item>
<item name="android:textColorPrimaryInverse">@color/white_color</item> <item name="android:textColorPrimaryInverse">@color/white_color</item>
<item name="android:windowBackground">@color/white_color</item>
<item name="accentColor">@color/primary_color</item> <item name="accentColor">@color/primary_color</item>
<item name="accentColorLight30">@color/primary_light_color</item> <item name="accentColorLight30">@color/primary_light_color</item>
@ -51,6 +45,7 @@
<style name="LinphoneStyleDark" parent="Theme.AppCompat.NoActionBar"> <style name="LinphoneStyleDark" parent="Theme.AppCompat.NoActionBar">
<!-- Disable animations between activities --> <!-- Disable animations between activities -->
<item name="android:windowAnimationStyle">@null</item> <item name="android:windowAnimationStyle">@null</item>
<item name="android:windowBackground">@drawable/launch_screen</item>
<!-- Android theme override --> <!-- Android theme override -->
<item name="colorAccent">@color/primary_color</item> <item name="colorAccent">@color/primary_color</item>
@ -62,7 +57,6 @@
<item name="android:textColorHint">@color/toolbar_color</item> <item name="android:textColorHint">@color/toolbar_color</item>
<item name="android:colorBackground">@color/dark_grey_color</item> <item name="android:colorBackground">@color/dark_grey_color</item>
<item name="android:textColorPrimaryInverse">@color/dark_grey_color</item> <item name="android:textColorPrimaryInverse">@color/dark_grey_color</item>
<item name="android:windowBackground">@color/dark_grey_color</item>
<item name="accentColor">@color/primary_color</item> <item name="accentColor">@color/primary_color</item>
<item name="accentColorLight30">@color/primary_light_color</item> <item name="accentColorLight30">@color/primary_light_color</item>