Even better main/settings layout for best display on every screen + fix crazy fragments issue

This commit is contained in:
Sylvain Berfini 2012-08-08 13:29:14 +02:00
parent de116b0677
commit c17eb9046b
11 changed files with 158 additions and 162 deletions

BIN
res/drawable-hdpi/mark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

BIN
res/drawable-mdpi/mark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

View file

@ -1,120 +0,0 @@
<?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">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true">
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="75dp"
android:paddingTop="20dp" />
<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="wrap_content"
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:adjustViewBounds="true"
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="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
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.2"
android:adjustViewBounds="true"
android:contentDescription="@string/content_description_dialer"
android:scaleType="fitXY"
android:src="@drawable/dialer" />
<ImageView
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
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="wrap_content"
android:adjustViewBounds="true"
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

@ -5,9 +5,65 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Hack to adjust perfectly on every screen the bottom of the fragment with the curved menu -->
<LinearLayout
android:id="@+id/mark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/mark"
android:layout_alignParentTop="true">
<LinearLayout
@ -15,7 +71,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="65dp"
android:paddingTop="20dp" />
<fragment
@ -68,7 +123,7 @@
android:contentDescription="@string/content_description_contacts"
android:scaleType="fitXY"
android:src="@drawable/contacts" />
<ImageView
android:id="@+id/dialer"
android:layout_width="match_parent"
@ -113,6 +168,7 @@
android:gravity="center"
android:textSize="20dp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>

View file

@ -3,11 +3,66 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Hack to adjust perfectly on every screen the bottom of the fragment with the curved menu -->
<LinearLayout
android:id="@+id/mark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark"
android:visibility="invisible" />
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_above="@id/mark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="75dp" />
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/menu"

View file

@ -34,26 +34,26 @@
android:layout_height="20dp"
android:scaleType="fitXY"
android:src="@drawable/statebar_background"/>
<TextView
android:id="@+id/statusText"
android:text="@string/status_not_connected"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:contentDescription="@string/content_description_led"
android:id="@+id/statusLed"
android:paddingLeft="5dp"
android:src="@drawable/led_disconnected"
android:layout_toRightOf="@id/statusText"
android:src="@drawable/led_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/statusText"
android:text="@string/status_not_connected"
android:textColor="@android:color/white"
android:paddingLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/statusLed" />
<LinearLayout
android:id="@+id/moreStatusLed"
android:paddingLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:orientation="horizontal"
@ -79,7 +79,7 @@
<TextView
android:id="@+id/exit"
android:text="EXIT"
android:text="@string/menu_exit"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -260,10 +260,10 @@
<string name="chat">Chat</string>
<string name="call">Call</string>
<string name="add_to_contacts">Add to contacts</string>
<string name="status_connected">CONNECTED</string>
<string name="status_not_connected">NOT CONNECTED</string>
<string name="status_in_progress">CONNECTING</string>
<string name="status_error">ERROR</string>
<string name="status_connected">Registered</string>
<string name="status_not_connected">Not Registered</string>
<string name="status_in_progress">Registration in progress</string>
<string name="status_error">Registration failed</string>
<string name="addressHint">Number or address</string>

View file

@ -60,8 +60,8 @@ import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;
import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
@ -107,6 +107,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
@Override
protected void onCreate(Bundle savedInstanceState) {
FragmentManager.enableDebugLogging(true);
super.onCreate(savedInstanceState);
if (!LinphoneManager.isInstanciated()) {
@ -124,18 +125,19 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}
setContentView(R.layout.main);
instance = this;
initButtons();
if (LinphoneManager.isInstanciated()) {
LinphoneManager.addListener(this);
}
currentFragment = FragmentsAvailable.DIALER;
if (savedInstanceState != null) {
return;
}
if (findViewById(R.id.fragmentContainer) != null) {
dialerFragment = new DialerFragment();
dialerFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, dialerFragment).commit();
currentFragment = FragmentsAvailable.DIALER;
}
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
@ -150,8 +152,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
LinphoneManager.getLc().setDeviceRotation(rotation);
mAlwaysChangingPhoneAngle = rotation;
instance = this;
}
private void initButtons() {
@ -174,7 +174,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
changeCurrentFragment(newFragmentType, extras, false);
}
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) {
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) {
if (newFragmentType == currentFragment && newFragmentType != FragmentsAvailable.CHAT) {
return;
}
@ -241,15 +241,16 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}
}
try {
getSupportFragmentManager().popBackStack(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
getSupportFragmentManager().popBackStackImmediate(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (java.lang.IllegalStateException e) {
}
transaction.addToBackStack(newFragmentType.toString());
transaction.replace(R.id.fragmentContainer, newFragment);
transaction.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
currentFragment = newFragmentType;
}
@ -266,9 +267,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
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)) {
@ -282,16 +280,17 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
ll.setVisibility(View.GONE);
try {
getSupportFragmentManager().popBackStack(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
getSupportFragmentManager().popBackStackImmediate(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (java.lang.IllegalStateException e) {
}
transaction.addToBackStack(newFragmentType.toString());
transaction.replace(R.id.fragmentContainer, newFragment);
transaction.commitAllowingStateLoss();
}
transaction.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
currentFragment = newFragmentType;
}
@ -787,13 +786,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(resultCode, requestCode, data);
if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
if (data.getExtras().getBoolean("Exit", false)) {
exit();
} else {
FragmentsAvailable newFragment = (FragmentsAvailable) data.getExtras().getSerializable("FragmentToDisplay");
changeCurrentFragment(newFragment, null, true);
selectMenu(newFragment);
changeCurrentFragment(newFragment, null, true);
}
}
else if (requestCode == callActivity) {
@ -804,13 +804,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
}
}
super.onActivityResult(resultCode, requestCode, data);
}
@Override
protected void onResume() {
protected void onResume() {
super.onResume();
LinphoneManager.addListener(this);
prepareContactsInBackground();
if (chatStorage != null) {
@ -832,6 +833,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
@Override
protected void onDestroy() {
LinphoneManager.removeListener(this);
if (chatStorage != null) {
chatStorage.close();
chatStorage = null;

View file

@ -36,7 +36,9 @@ public class NetworkManager extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Boolean lNoConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,false);
LinphoneManager.getInstance().connectivityChanged(cm, lNoConnectivity);
if (LinphoneManager.isInstanciated()) {
LinphoneManager.getInstance().connectivityChanged(cm, lNoConnectivity);
}
}
}

View file

@ -175,7 +175,7 @@ public class StatusFragment extends Fragment {
private int getStatusIconResource(LinphoneCore.RegistrationState state, boolean isDefaultAccount) {
try {
boolean defaultAccountConnected = (isDefaultAccount && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) || !isDefaultAccount;
boolean defaultAccountConnected = (isDefaultAccount && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getDefaultProxyConfig().isRegistered()) || !isDefaultAccount;
if (state == RegistrationState.RegistrationOk && defaultAccountConnected) {
return R.drawable.led_connected;
} else if (state == RegistrationState.RegistrationProgress) {
@ -194,7 +194,7 @@ public class StatusFragment extends Fragment {
private String getStatusIconText(LinphoneCore.RegistrationState state) {
try {
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getDefaultProxyConfig().isRegistered()) {
return getString(R.string.status_connected);
} else if (state == RegistrationState.RegistrationProgress) {
return getString(R.string.status_in_progress);