Improved code related to top bar in some views

This commit is contained in:
Sylvain Berfini 2018-11-23 18:09:34 +01:00
parent f7c2f01a31
commit 92b33ef71c
8 changed files with 1035 additions and 1059 deletions

View file

@ -136,7 +136,8 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
private TextView missedCalls, missedChats;
private RelativeLayout contacts, history, dialer, chat;
private View contacts_selected, history_selected, dialer_selected, chat_selected;
private RelativeLayout mTopBar;
private LinearLayout mTopBar;
private TextView mTopBarTitle;
private ImageView cancel;
private FragmentsAvailable pendingFragmentTransaction, currentFragment, leftFragment;
private Fragment fragment;
@ -303,6 +304,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
private void initButtons() {
mTabBar = findViewById(R.id.footer);
mTopBar = findViewById(R.id.top_bar);
mTopBarTitle = findViewById(R.id.top_bar_title);
cancel = findViewById(R.id.cancel);
cancel.setOnClickListener(this);
@ -847,6 +849,16 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
public void hideTopBar() {
mTopBar.setVisibility(View.GONE);
mTopBarTitle.setText("");
}
public void showTopBar() {
mTopBar.setVisibility(View.VISIBLE);
}
public void showTopBarWithTitle(String title) {
showTopBar();
mTopBarTitle.setText(title);
}
@SuppressWarnings("incomplete-switch")
@ -880,9 +892,10 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
case SETTINGS:
case ACCOUNT_SETTINGS:
hideTabBar(hideBottomBar);
mTopBar.setVisibility(View.VISIBLE);
showTopBarWithTitle(getString(R.string.settings));
break;
case ABOUT:
showTopBarWithTitle(getString(R.string.about));
hideTabBar(hideBottomBar);
break;
case CHAT_LIST:

View file

@ -48,7 +48,6 @@ import org.linphone.mediastream.Log;
public class AboutFragment extends Fragment implements OnClickListener {
View sendLogButton = null;
View resetLogButton = null;
ImageView cancel;
CoreListenerStub mListener;
private ProgressDialog progress;
private boolean uploadInProgress;
@ -62,9 +61,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
aboutLiblinphoneVersion.setText(String.format(getString(R.string.about_liblinphone_version), LinphoneManager.getLc().getVersion()));
aboutVersion.setText(String.format(getString(R.string.about_version), BuildConfig.VERSION_NAME));
cancel = view.findViewById(R.id.cancel);
cancel.setOnClickListener(this);
sendLogButton = view.findViewById(R.id.send_log);
sendLogButton.setOnClickListener(this);
sendLogButton.setVisibility(LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
@ -162,8 +158,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
if (lc != null) {
lc.resetLogCollection();
}
} else if (v == cancel) {
LinphoneActivity.instance().goToDialerFragment();
}
}
}

View file

@ -4,40 +4,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/top_bar"
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"/>
<TextView
android:id="@+id/menu_name"
android:text="@string/about"
style="@style/font1"
android:maxLines="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:padding="15dp"/>
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_dialer_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="15dp"/>
</LinearLayout>
<LinearLayout
android:baselineAligned="false"
android:background="@color/colorC"

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
<LinearLayout
android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:visibility="gone"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/menu_name"
android:text="@string/settings"
style="@style/font1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"/>
android:layout_height="60dp">
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:src="@drawable/back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:padding="15dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"/>
android:layout_weight="0.2"
android:padding="15dp"/>
</RelativeLayout>
<TextView
android:id="@+id/top_bar_title"
style="@style/font1"
android:maxLines="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:padding="15dp"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -202,6 +208,7 @@
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
@ -212,6 +219,7 @@
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
<!-- Side Menu -->
@ -285,8 +293,9 @@
android:background="@color/colorE"/>
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
<LinearLayout
android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:visibility="gone"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/menu_name"
android:text="@string/settings"
style="@style/font1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"/>
android:layout_height="60dp">
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:src="@drawable/back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:padding="15dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"/>
android:layout_weight="0.2"
android:padding="15dp"/>
</RelativeLayout>
<TextView
android:id="@+id/top_bar_title"
style="@style/font1"
android:maxLines="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:padding="15dp"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -89,6 +95,7 @@
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
@ -223,7 +230,9 @@
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<!-- Side Menu -->
@ -292,6 +301,6 @@
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
<LinearLayout
android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:visibility="gone"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/menu_name"
android:text="@string/settings"
style="@style/font1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"/>
android:layout_height="60dp">
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:src="@drawable/back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:padding="15dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"/>
android:layout_weight="0.2"
android:padding="15dp"/>
</RelativeLayout>
<TextView
android:id="@+id/top_bar_title"
style="@style/font1"
android:maxLines="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:padding="15dp"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -88,7 +94,9 @@
android:layout_height="match_parent"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
@ -222,7 +230,9 @@
android:visibility="gone"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<!-- Side Menu -->
@ -291,6 +301,6 @@
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>

View file

@ -5,40 +5,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/top_bar"
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"/>
<TextView
android:id="@+id/menu_name"
android:text="@string/about"
style="@style/font1"
android:maxLines="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:padding="15dp"/>
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_dialer_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="15dp"/>
</LinearLayout>
<LinearLayout
android:background="@color/colorC"
android:orientation="vertical"

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
<LinearLayout
android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:visibility="gone"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/menu_name"
android:text="@string/settings"
style="@style/font1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"/>
android:layout_height="60dp">
<ImageView
android:id="@+id/cancel"
android:src="@drawable/dialer_back"
android:src="@drawable/back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:padding="15dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"/>
android:layout_weight="0.2"
android:padding="15dp"/>
</RelativeLayout>
<TextView
android:id="@+id/top_bar_title"
style="@style/font1"
android:maxLines="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:padding="15dp"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -196,6 +202,7 @@
android:visibility="gone"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
@ -206,6 +213,7 @@
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
<!-- Side Menu -->
@ -279,8 +287,9 @@
android:background="@color/colorE"/>
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>