Back button for landing activities.

This commit is contained in:
Anton Chekulaev 2020-09-18 16:54:40 +10:00
parent 707ff9063c
commit 6b134a8403
4 changed files with 70 additions and 16 deletions

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?actionBarSize">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/session_logo"/>
<FrameLayout
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="@dimen/small_spacing"
android:padding="@dimen/small_spacing"
android:background="@drawable/circle_touch_highlight_background"
android:clickable="true"
android:focusable="true">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_baseline_arrow_back_24"
android:alpha="0.5"/>
</FrameLayout>
</RelativeLayout>

View File

@ -40,7 +40,7 @@ class LandingActivity : BaseActionBarActivity(), LinkDeviceSlaveModeDialogDelega
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_landing)
setUpActionBarSessionLogo()
setUpActionBarSessionLogo(true)
fakeChatView.startAnimating()
registerButton.setOnClickListener { register() }
restoreButton.setOnClickListener { restore() }

View File

@ -1,24 +1,36 @@
package org.thoughtcrime.securesms.loki.utilities
import android.content.Intent
import androidx.appcompat.app.ActionBar
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import android.view.Gravity
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.appcompat.widget.Toolbar
import network.loki.messenger.R
import org.thoughtcrime.securesms.BaseActionBarActivity
fun AppCompatActivity.setUpActionBarSessionLogo() {
supportActionBar!!.setDisplayShowHomeEnabled(false)
supportActionBar!!.setDisplayShowTitleEnabled(false)
val logoImageView = ImageView(this)
logoImageView.setImageResource(R.drawable.session_logo)
val logoImageViewContainer = RelativeLayout(this)
logoImageViewContainer.addView(logoImageView)
logoImageViewContainer.gravity = Gravity.CENTER
val logoImageViewContainerLayoutParams = ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT)
supportActionBar!!.setCustomView(logoImageViewContainer, logoImageViewContainerLayoutParams)
supportActionBar!!.setDisplayShowCustomEnabled(true)
fun BaseActionBarActivity.setUpActionBarSessionLogo(hideBackButton: Boolean = false) {
val actionbar = supportActionBar!!
actionbar.setDisplayShowHomeEnabled(false)
actionbar.setDisplayShowTitleEnabled(false)
actionbar.setDisplayHomeAsUpEnabled(false)
actionbar.setHomeButtonEnabled(false)
actionbar.setCustomView(R.layout.session_logo_action_bar_content)
actionbar.setDisplayShowCustomEnabled(true)
val rootView: Toolbar = actionbar.customView!!.parent as Toolbar
rootView.setPadding(0,0,0,0)
rootView.setContentInsetsAbsolute(0,0);
val backButton = actionbar.customView!!.findViewById<View>(R.id.back_button)
if (hideBackButton) {
backButton.visibility = View.GONE
} else {
backButton.visibility = View.VISIBLE
backButton.setOnClickListener {
onSupportNavigateUp()
}
}
}
val AppCompatActivity.defaultSessionRequestCode: Int