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

View file

@ -48,7 +48,6 @@ import org.linphone.mediastream.Log;
public class AboutFragment extends Fragment implements OnClickListener { public class AboutFragment extends Fragment implements OnClickListener {
View sendLogButton = null; View sendLogButton = null;
View resetLogButton = null; View resetLogButton = null;
ImageView cancel;
CoreListenerStub mListener; CoreListenerStub mListener;
private ProgressDialog progress; private ProgressDialog progress;
private boolean uploadInProgress; 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())); 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)); 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 = view.findViewById(R.id.send_log);
sendLogButton.setOnClickListener(this); sendLogButton.setOnClickListener(this);
sendLogButton.setVisibility(LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE); sendLogButton.setVisibility(LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
@ -162,8 +158,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
if (lc != null) { if (lc != null) {
lc.resetLogCollection(); lc.resetLogCollection();
} }
} else if (v == cancel) {
LinphoneActivity.instance().goToDialerFragment();
} }
} }
} }

View file

@ -4,40 +4,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> 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 <LinearLayout
android:baselineAligned="false" android:baselineAligned="false"
android:background="@color/colorC" android:background="@color/colorC"

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout <LinearLayout
android:id="@+id/top_bar" android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF" android:background="@color/colorF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" 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"/>
<ImageView <ImageView
android:id="@+id/cancel" 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:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="15dp" android:layout_weight="0.2"
android:layout_centerInParent="true" android:padding="15dp"/>
android:layout_alignParentRight="true"/>
</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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -202,6 +208,7 @@
android:layout_alignParentEnd="true"/> android:layout_alignParentEnd="true"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -212,6 +219,7 @@
android:orientation="vertical"> android:orientation="vertical">
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<!-- Side Menu --> <!-- Side Menu -->
@ -285,8 +293,9 @@
android:background="@color/colorE"/> android:background="@color/colorE"/>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout <LinearLayout
android:id="@+id/top_bar" android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF" android:background="@color/colorF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" 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"/>
<ImageView <ImageView
android:id="@+id/cancel" 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:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="15dp" android:layout_weight="0.2"
android:layout_centerInParent="true" android:padding="15dp"/>
android:layout_alignParentRight="true"/>
</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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -89,6 +95,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
@ -223,7 +230,9 @@
android:layout_alignParentEnd="true"/> android:layout_alignParentEnd="true"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<!-- Side Menu --> <!-- Side Menu -->
@ -292,6 +301,6 @@
</RelativeLayout> </RelativeLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout <LinearLayout
android:id="@+id/top_bar" android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF" android:background="@color/colorF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" 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"/>
<ImageView <ImageView
android:id="@+id/cancel" 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:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="15dp" android:layout_weight="0.2"
android:layout_centerInParent="true" android:padding="15dp"/>
android:layout_alignParentRight="true"/>
</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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -88,7 +94,9 @@
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
@ -222,7 +230,9 @@
android:visibility="gone"/> android:visibility="gone"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<!-- Side Menu --> <!-- Side Menu -->
@ -291,6 +301,6 @@
</RelativeLayout> </RelativeLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -5,40 +5,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> 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 <LinearLayout
android:background="@color/colorC" android:background="@color/colorC"
android:orientation="vertical" android:orientation="vertical"

View file

@ -22,34 +22,40 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout <LinearLayout
android:id="@+id/top_bar" android:id="@+id/top_bar"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorF" android:background="@color/colorF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" 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"/>
<ImageView <ImageView
android:id="@+id/cancel" 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:contentDescription="@string/content_description_dialer_back"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="15dp" android:layout_weight="0.2"
android:layout_centerInParent="true" android:padding="15dp"/>
android:layout_alignParentRight="true"/>
</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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -196,6 +202,7 @@
android:visibility="gone"/> android:visibility="gone"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -206,6 +213,7 @@
android:orientation="vertical"> android:orientation="vertical">
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<!-- Side Menu --> <!-- Side Menu -->
@ -279,8 +287,9 @@
android:background="@color/colorE"/> android:background="@color/colorE"/>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
</RelativeLayout> </RelativeLayout>