Skip to content

Commit

Permalink
make toolbar title center
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Mar 24, 2021
1 parent 60a80e8 commit 59e44c0
Show file tree
Hide file tree
Showing 22 changed files with 213 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ class DrawerActivity : BaseStatusActivity(), bbsPrivateMessageFragment.OnNewMess
binding.bbsPortalNavView.inflateMenu(R.menu.bottom_incognitive_nav_menu)
return
}
user = viewModel!!.currentForumUserBriefInfoMutableLiveData.value
user = viewModel.currentForumUserBriefInfoMutableLiveData.value
if (user == null) {
Log.d(TAG, "Current incognitive user $user")
binding.bbsPortalNavViewpager.adapter = anonymousViewPagerAdapter(supportFragmentManager, FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
Expand Down Expand Up @@ -743,10 +743,7 @@ class DrawerActivity : BaseStatusActivity(), bbsPrivateMessageFragment.OnNewMess

override fun setNotificationsNum(notificationsNum: noticeNumInfo) {
Log.d(TAG, "Notification fragment $notificationsFragment notification $notificationsNum")
if (notificationsNum == null) {
return
}
//noticeNumInfo = notificationsNum;

Log.d(TAG, "notification number " + notificationsNum.allNoticeInfo)
if (notificationsFragment != null) {
notificationsFragment!!.renderTabNumber(notificationsNum)
Expand Down Expand Up @@ -775,7 +772,7 @@ class DrawerActivity : BaseStatusActivity(), bbsPrivateMessageFragment.OnNewMess
finishAfterTransition()
false
} else if (id == R.id.bbs_share) {
val bbsInfo = viewModel!!.currentBBSInformationMutableLiveData.value
val bbsInfo = viewModel.currentBBSInformationMutableLiveData.value
if (bbsInfo != null) {
val sendIntent = Intent()
sendIntent.action = Intent.ACTION_SEND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,16 @@ public void onChanged(ForumResult forumResult) {

Forum forum = forumResult.forumVariables.forum;
ForumActivity.this.forum = forum;
if(getSupportActionBar()!=null){
getSupportActionBar().setTitle(forum.name);
getSupportActionBar().setSubtitle(forum.description);
binding.toolbarTitle.setText(forum.name);
if(forum.description.isEmpty()){
binding.toolbarSubtitle.setVisibility(View.GONE);
}
else{
binding.toolbarSubtitle.setVisibility(View.VISIBLE);
binding.toolbarSubtitle.setText(forum.description);
}


}
}
}
Expand Down Expand Up @@ -412,9 +418,11 @@ private void configureActionBar(){
setSupportActionBar(binding.toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(bbsInfo.site_name);

binding.toolbarTitle.setText(bbsInfo.site_name);
if(forum.name !=null){
getSupportActionBar().setSubtitle(forum.name);
binding.toolbarTitle.setText(forum.name);
//getSupportActionBar().setSubtitle(forum.name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void setInformation(){
binding.loginBbsUrl.setText(bbsInfo.base_url);
}
else {
binding.toolbarTitle.setText(getString(R.string.user_relogin, user.username));
binding.loginBbsUrl.setText(getString(R.string.user_relogin, user.username));
binding.loginBbsAccountTextInputEditText.setText(user.username);
}
Expand Down Expand Up @@ -265,6 +266,8 @@ public void run() {

}
else{
// refresh the captcha
viewModel.loadSecureInfo();
if(key.equals("login_seccheck2")){
// need captcha
viewModel.loadSecureInfo();
Expand Down Expand Up @@ -390,7 +393,7 @@ void configureActionBar(){
setSupportActionBar(binding.toolbar);
if(getSupportActionBar() !=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
binding.toolbarTitle.setText(getString(R.string.login_bbs_title,bbsInfo.site_name));
if(bbsInfo.isSecureClient()){
binding.loginBbsNotice.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void configureActionBar(){
setSupportActionBar(binding.toolbar);
if(getSupportActionBar() !=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(R.string.manage_bbs_title);
binding.toolbarTitle.setText(R.string.manage_bbs_title);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ void configureActionBar(){
setSupportActionBar(binding.toolbar);
if(getSupportActionBar() !=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(bbsInfo.site_name);
getSupportActionBar().setSubtitle(bbsInfo.base_url);
binding.toolbarTitle.setText(bbsInfo.site_name);
binding.toolbarSubtitle.setText(bbsInfo.base_url);

}

}
Expand Down
25 changes: 14 additions & 11 deletions app/src/main/java/com/kidozh/discuzhub/activities/ThreadActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,15 @@ class ThreadActivity : BaseStatusActivity(), OnSmileyPressedInteraction, onFilte
threadDetailViewModel.formHash.observe(this, { s -> formHash = s })
threadDetailViewModel.threadStatusMutableLiveData.observe(this, { viewThreadQueryStatus ->
Log.d(TAG, "Livedata changed " + viewThreadQueryStatus.datelineAscend)
if (supportActionBar != null) {
if (viewThreadQueryStatus.datelineAscend) {
supportActionBar!!.setSubtitle(getString(R.string.bbs_thread_status_ascend))
} else {
supportActionBar!!.setSubtitle(getString(R.string.bbs_thread_status_descend))
}
}
// if (supportActionBar != null) {
// if (viewThreadQueryStatus.datelineAscend) {
// binding.toolbarSubtitle.setText(getString(R.string.bbs_thread_status_ascend))
//
// } else {
// binding.toolbarSubtitle.setText(getString(R.string.bbs_thread_status_descend))
//
// }
// }
})
threadDetailViewModel.detailedThreadInfoMutableLiveData.observe(this, { detailedThreadInfo -> // closed situation
// prepare notification list
Expand Down Expand Up @@ -459,9 +461,10 @@ class ThreadActivity : BaseStatusActivity(), OnSmileyPressedInteraction, onFilte
val sp = Html.fromHtml(threadResult.threadPostVariables.detailedThreadInfo.subject,HtmlCompat.FROM_HTML_MODE_COMPACT)
val spannableString = SpannableString(sp)
binding.bbsThreadSubject.setText(spannableString, TextView.BufferType.SPANNABLE)
if (supportActionBar != null) {
supportActionBar!!.setTitle(threadResult.threadPostVariables.detailedThreadInfo.subject)
}
// if (supportActionBar != null) {
// supportActionBar!!.setTitle(threadResult.threadPostVariables.detailedThreadInfo.subject)
// }
// binding.toolbarTitle.text = threadResult.threadPostVariables.detailedThreadInfo.subject
// check with comments

postAdapter.mergeCommentMap(threadResult.threadPostVariables.commentList)
Expand Down Expand Up @@ -1429,7 +1432,7 @@ class ThreadActivity : BaseStatusActivity(), OnSmileyPressedInteraction, onFilte
private fun configureToolbar() {
setSupportActionBar(binding.toolbar)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
supportActionBar!!.setDisplayShowTitleEnabled(true)
binding.toolbarSubtitle.text = thread?.tid.toString()

//getSupportActionBar().setTitle(subject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ private void configureIntentData(){

private void configureActionBar(){
setSupportActionBar(binding.toolbar);
binding.toolbarTitle.setText(getString(R.string.bbs_draft_box));
binding.toolbarSubtitle.setText(bbsInfo.site_name);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(getString(R.string.bbs_draft_box));
getSupportActionBar().setSubtitle(bbsInfo.site_name);
}

private void configureRecyclerview(){
Expand Down
29 changes: 28 additions & 1 deletion app/src/main/res/layout/activity_bbs_show_forum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,33 @@
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textAlignment="center" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:textAlignment="center"
android:visibility="gone" />
</LinearLayout>

</androidx.appcompat.widget.Toolbar>



<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bbs_forum_constraintLayout"
Expand All @@ -45,6 +71,7 @@
android:drawableStart="@drawable/ic_forum_description_outlined_24px"
android:gravity="top"
android:text="@string/bbs_forum_description_not_set"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
16 changes: 14 additions & 2 deletions app/src/main/res/layout/activity_login_bbs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="18dp"
tools:text="@tools:sample/full_names" />
</androidx.appcompat.widget.Toolbar>



<ProgressBar
android:id="@+id/login_bbs_progressBar"
Expand Down
23 changes: 22 additions & 1 deletion app/src/main/res/layout/activity_manage_bbs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,28 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways" />
app:layout_scrollFlags="scroll|enterAlways" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>


</com.google.android.material.appbar.AppBarLayout>

<androidx.core.widget.NestedScrollView
Expand Down
23 changes: 22 additions & 1 deletion app/src/main/res/layout/activity_manage_user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,28 @@
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>


</com.google.android.material.appbar.AppBarLayout>

<androidx.core.widget.NestedScrollView
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/activity_new_main_drawer.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -10,7 +11,6 @@


<LinearLayout
xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -48,15 +48,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAlignment="viewStart"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
tools:text="@tools:sample/full_names" />

<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:textAlignment="center"
tools:text="@tools:sample/cities" />
</LinearLayout>

Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/layout/activity_view_thread.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@
android:layout_height="wrap_content"
android:theme="?attr/actionBarTheme">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:text="@string/view_thread_title"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="@color/colorTextDefault" />

<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp"
tools:text="@tools:sample/us_zipcodes" />
</LinearLayout>

</androidx.appcompat.widget.Toolbar>

Expand Down
Loading

0 comments on commit 59e44c0

Please sign in to comment.