Added first start presentation caroussel

This commit is contained in:
Sylvain Berfini 2023-08-28 13:48:58 +02:00
parent 92b3d08ea0
commit 294410bfd2
13 changed files with 564 additions and 7 deletions

View file

@ -93,9 +93,13 @@ dependencies {
implementation("io.coil-kt:coil-gif:$coil_version")
implementation("io.coil-kt:coil-svg:$coil_version")
implementation("io.coil-kt:coil-video:$coil_version")
// https://github.com/GetStream/avatarview-android/blob/main/LICENSE Apache v2.0
implementation "io.getstream:avatarview-coil:1.0.7"
// https://github.com/tommybuonomo/dotsindicator/blob/master/LICENSE Apache v2.0
implementation("com.tbuonomo:dotsindicator:5.0")
implementation platform('com.google.firebase:firebase-bom:30.3.2')
implementation 'com.google.firebase:firebase-messaging'

View file

@ -40,6 +40,7 @@
<activity
android:name=".ui.main.MainActivity"
android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustResize"
android:exported="true"
android:label="@string/app_name">
@ -51,13 +52,22 @@
</activity>
<!-- Disable enableOnBackInvokedCallback so back gesture will go back in viewPager -->
<activity
android:name=".ui.welcome.WelcomeActivity"
android:enableOnBackInvokedCallback="false"
android:launchMode="singleTask"
android:resizeableActivity="true" />
<activity
android:name=".ui.assistant.AssistantActivity"
android:enableOnBackInvokedCallback="true"
android:launchMode="singleTask"
android:resizeableActivity="true" />
<activity
android:name=".ui.voip.VoipActivity"
android:enableOnBackInvokedCallback="true"
android:launchMode="singleTask"
android:turnScreenOn="true"
android:showWhenLocked="true"

View file

@ -46,6 +46,7 @@ import org.linphone.databinding.MainActivityBinding
import org.linphone.ui.assistant.AssistantActivity
import org.linphone.ui.main.settings.fragment.AccountProfileFragmentDirections
import org.linphone.ui.main.viewmodel.DrawerMenuViewModel
import org.linphone.ui.welcome.WelcomeActivity
import org.linphone.utils.slideInToastFromTopForDuration
@UiThread
@ -124,6 +125,8 @@ class MainActivity : AppCompatActivity() {
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
startActivity(Intent(this, WelcomeActivity::class.java))
if (checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(
arrayOf(Manifest.permission.READ_CONTACTS),

View file

@ -111,12 +111,16 @@ class VoipActivity : AppCompatActivity() {
callsViewModel.goToActiveCallEvent.observe(this) {
it.consume {
val navController = findNavController(R.id.voip_nav_container)
val action = if (navController.currentDestination?.id == R.id.outgoingCallFragment) {
OutgoingCallFragmentDirections.actionOutgoingCallFragmentToActiveCallFragment()
} else if (navController.currentDestination?.id == R.id.outgoingCallFragment) {
IncomingCallFragmentDirections.actionIncomingCallFragmentToActiveCallFragment()
} else {
ActiveCallFragmentDirections.actionGlobalActiveCallFragment()
val action = when (navController.currentDestination?.id) {
R.id.outgoingCallFragment -> {
OutgoingCallFragmentDirections.actionOutgoingCallFragmentToActiveCallFragment()
}
R.id.incomingCallFragment -> {
IncomingCallFragmentDirections.actionIncomingCallFragmentToActiveCallFragment()
}
else -> {
ActiveCallFragmentDirections.actionGlobalActiveCallFragment()
}
}
navController.navigate(action)
}

View file

@ -0,0 +1,125 @@
/*
* Copyright (c) 2010-2023 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.ui.welcome
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.tools.Log
import org.linphone.databinding.WelcomeActivityBinding
import org.linphone.ui.welcome.fragment.WelcomePage1Fragment
import org.linphone.ui.welcome.fragment.WelcomePage2Fragment
import org.linphone.ui.welcome.fragment.WelcomePage3Fragment
class WelcomeActivity : AppCompatActivity() {
companion object {
private const val TAG = "[Welcome Activity]"
private const val PAGES = 3
}
private lateinit var binding: WelcomeActivityBinding
private lateinit var viewPager: ViewPager2
private val pageChangedCallback = PageChangedCallback()
override fun onBackPressed() {
if (viewPager.currentItem == 0) {
super.onBackPressed()
} else {
viewPager.currentItem = viewPager.currentItem - 1
}
}
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, true)
super.onCreate(savedInstanceState)
while (!coreContext.isReady()) {
Thread.sleep(20)
}
binding = DataBindingUtil.setContentView(this, R.layout.welcome_activity)
binding.lifecycleOwner = this
viewPager = binding.pager
val pagerAdapter = ScreenSlidePagerAdapter(this)
viewPager.adapter = pagerAdapter
binding.dotsIndicator.attachTo(viewPager)
binding.setSkipClickListener {
Log.i("$TAG User clicked on 'skip' button, going to last page")
viewPager.currentItem = PAGES - 1
}
binding.setNextClickListener {
if (viewPager.currentItem == PAGES - 1) {
Log.i("$TAG User clicked on 'start' button, leaving activity")
finish()
} else {
viewPager.currentItem = viewPager.currentItem + 1
}
}
}
override fun onResume() {
super.onResume()
viewPager.registerOnPageChangeCallback(pageChangedCallback)
}
override fun onPause() {
viewPager.unregisterOnPageChangeCallback(pageChangedCallback)
super.onPause()
}
private inner class ScreenSlidePagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) {
override fun getItemCount(): Int = PAGES
override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> WelcomePage1Fragment()
1 -> WelcomePage2Fragment()
else -> WelcomePage3Fragment()
}
}
}
private inner class PageChangedCallback : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
Log.i("$TAG Current page is [$position]")
if (position == PAGES - 1) {
binding.next.text = "Start"
binding.skip.visibility = View.INVISIBLE
} else {
binding.next.text = "Next"
binding.skip.visibility = View.VISIBLE
}
}
}
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2010-2023 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.ui.welcome.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.linphone.R
class WelcomePage1Fragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = inflater.inflate(R.layout.welcome_page_1, container, false)
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2010-2023 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.ui.welcome.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.linphone.R
class WelcomePage2Fragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = inflater.inflate(R.layout.welcome_page_2, container, false)
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2010-2023 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.ui.welcome.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.linphone.R
class WelcomePage3Fragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = inflater.inflate(R.layout.welcome_page_3, container, false)
}

View file

@ -9,7 +9,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.voip.VoipActivity">
tools:context=".ui.assistant.AssistantActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/assistant_nav_container"

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="skipClickListener"
type="View.OnClickListener" />
<variable
name="nextClickListener"
type="View.OnClickListener" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.welcome.WelcomeActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{skipClickListener}"
style="@style/default_text_style_600"
android:id="@+id/skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:paddingTop="13dp"
android:paddingBottom="13dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Skip"
android:textSize="13sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/pager"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
app:layout_constraintTop_toBottomOf="@id/skip"
app:layout_constraintBottom_toTopOf="@id/dots_indicator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<com.tbuonomo.viewpagerdotsindicator.DotsIndicator
android:id="@+id/dots_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
app:dotsColor="@color/blue_outgoing_message"
app:dotsCornerRadius="8dp"
app:dotsSize="13dp"
app:dotsSpacing="5dp"
app:dotsWidthFactor="2.5"
app:selectedDotColor="@color/primary_color"
app:progressMode="false"
app:layout_constraintTop_toBottomOf="@id/pager"
app:layout_constraintBottom_toTopOf="@id/next"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{nextClickListener}"
style="@style/default_text_style_600"
android:id="@+id/next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Next"
android:textSize="18sp"
android:textColor="@color/primary_button_label_color"
android:gravity="center"
android:background="@drawable/primary_button_background"
app:layout_constraintTop_toBottomOf="@id/dots_indicator"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title_first_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="65dp"
android:text="Welcome"
android:textColor="@color/black"
android:textSize="36sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title_second_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="65dp"
android:text="in Linphone"
android:textColor="@color/black"
android:textSize="26sp"
app:layout_constraintTop_toBottomOf="@id/title_first_line"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/page_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:text="Title 1"
android:textColor="@color/gray_9"
android:textSize="20sp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/title_second_line"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/illu"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toBottomOf="@id/page_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras egestas commodo augue ut dictum. Fusce egestas tellus ut velit pulvinar commodo."
android:textColor="@color/gray_9"
android:textSize="14sp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title_first_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="65dp"
android:text="Welcome"
android:textColor="@color/black"
android:textSize="36sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title_second_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="65dp"
android:text="in Linphone"
android:textColor="@color/black"
android:textSize="26sp"
app:layout_constraintTop_toBottomOf="@id/title_first_line"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/page_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:text="Title 2"
android:textColor="@color/gray_9"
android:textSize="20sp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/title_second_line"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/illu"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toBottomOf="@id/page_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras egestas commodo augue ut dictum. Fusce egestas tellus ut velit pulvinar commodo."
android:textColor="@color/gray_9"
android:textSize="14sp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title_first_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="65dp"
android:text="Welcome"
android:textColor="@color/black"
android:textSize="36sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title_second_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="65dp"
android:text="in Linphone"
android:textColor="@color/black"
android:textSize="26sp"
app:layout_constraintTop_toBottomOf="@id/title_first_line"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/page_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:text="Title 3"
android:textColor="@color/gray_9"
android:textSize="20sp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/title_second_line"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/illu"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toBottomOf="@id/page_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras egestas commodo augue ut dictum. Fusce egestas tellus ut velit pulvinar commodo."
android:textColor="@color/gray_9"
android:textSize="14sp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>