Skip to content

Commit

Permalink
Tutorial 3 fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPio committed Aug 4, 2023
1 parent ebb5fd5 commit 76a50e1
Show file tree
Hide file tree
Showing 21 changed files with 391 additions and 58 deletions.
24 changes: 12 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,49 @@
android:supportsRtl = "true"
android:theme = "@style/Theme.SpottedKotlin"
tools:targetApi = "tiramisu">

<activity
android:name = ".view.TutorialActivity"
android:exported = "false"
android:label = "@string/title_activity_tutorial"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar"/>
<activity
android:name = ".view.ViewPostActivity"
android:exported = "false"
android:screenOrientation="portrait"
android:screenOrientation = "portrait"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar"/>

<activity
android:name = ".view.CommentsActivity"
android:exported = "false"
android:screenOrientation="portrait"
android:screenOrientation = "portrait"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar"/>

<activity
android:name = ".view.MainActivity"
android:exported = "true"
android:screenOrientation="portrait"
android:screenOrientation = "portrait"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar">
</activity>

<activity
android:name = ".view.AccountActivity"
android:exported = "true"
android:screenOrientation="portrait"
android:screenOrientation = "portrait"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar">
</activity>

<activity
android:name = ".view.FirstActivity"
android:exported = "true"
android:screenOrientation="portrait"
android:screenOrientation = "portrait"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar"
android:windowSoftInputMode = "adjustPan">
<intent-filter>
<action android:name = "android.intent.action.MAIN"/>

<category android:name = "android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity
android:name = ".view.SettingsActivity"
android:exported = "true"
android:screenOrientation="portrait"
android:screenOrientation = "portrait"
android:theme = "@style/Theme.SpottedKotlin.NoActionBar">
</activity>
</application>
Expand Down
23 changes: 14 additions & 9 deletions app/src/main/java/it/univpm/spottedkotlin/view/FirstActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import it.univpm.spottedkotlin.databinding.FirstActivityBinding
import it.univpm.spottedkotlin.extension.function.checkAndAskPermission
import it.univpm.spottedkotlin.extension.function.goto
import it.univpm.spottedkotlin.extension.function.metrics
import it.univpm.spottedkotlin.managers.*
import it.univpm.spottedkotlin.model.Post
Expand Down Expand Up @@ -37,16 +38,18 @@ class FirstActivity : AppCompatActivity() {
}
DeviceManager.loadTheme()
DeviceManager.loadUiDensity(this)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
this.checkAndAskPermission(Manifest.permission.POST_NOTIFICATIONS)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) this.checkAndAskPermission(
Manifest.permission.POST_NOTIFICATIONS
)
}

fun goToMainActivity(activity: Class<*> = MainActivity::class.java) {
runOnUiThread {
val intent = Intent(this, activity).apply {
if (activity == ViewPostActivity::class.java)
this.putExtra("postUID", intent.getStringExtra("postUID"))
.putExtra("comments", intent.getBooleanExtra("comments", false))
if (activity == ViewPostActivity::class.java) this.putExtra(
"postUID",
intent.getStringExtra("postUID")
).putExtra("comments", intent.getBooleanExtra("comments", false))
}
startActivity(intent)
finish()
Expand All @@ -56,6 +59,10 @@ class FirstActivity : AppCompatActivity() {
override fun onStart() {
super.onStart()

if (IOManager.readKey("first_access") != false) {
goto<TutorialActivity>()
finish()
}
// ======= DEBUG ZONE ========
//☢️☢️☢️☢️☢️☢️☢️☢️☢️☢️☢️☢️

Expand All @@ -67,10 +74,8 @@ class FirstActivity : AppCompatActivity() {
binding.firstLoadingView.loadingViewRoot.visibility = View.VISIBLE
MainScope().launch {
if (AccountManager.cacheLogin()) {
if (intent.hasExtra("goto"))
goToMainActivity(intent.getSerializableExtra("goto") as Class<*>)
else
goToMainActivity()
if (intent.hasExtra("goto")) goToMainActivity(intent.getSerializableExtra("goto") as Class<*>)
else goToMainActivity()

}
runOnUiThread {
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/java/it/univpm/spottedkotlin/view/TutorialActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package it.univpm.spottedkotlin.view

import android.os.Bundle
import android.view.MotionEvent
import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import it.univpm.spottedkotlin.R
import it.univpm.spottedkotlin.databinding.ActivityTutorialBinding
import it.univpm.spottedkotlin.extension.function.goto
import it.univpm.spottedkotlin.managers.IOManager

class TutorialActivity : AppCompatActivity() {

private lateinit var binding: ActivityTutorialBinding
private var index = 0;

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTutorialBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.tutorialContainer.setOnClickListener{
if (index>=2){
goto<FirstActivity>()
IOManager.writeKey("first_access",false)
return@setOnClickListener
}
binding.tutorialContainer.findNavController().navigate(
if (index == 0) R.id.tutorial_fragment_1_to_tutorial_fragment_2 else R.id.tutorial_fragment_2_to_tutorial_fragment_3
)
index++
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package it.univpm.spottedkotlin.view.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import it.univpm.spottedkotlin.R
import it.univpm.spottedkotlin.databinding.FirstFragmentBinding
import it.univpm.spottedkotlin.databinding.Tutorial1FragmentBinding
import it.univpm.spottedkotlin.viewmodel.FirstActivityViewModel


class Tutorial1Fragment : Fragment() {
private lateinit var binding: Tutorial1FragmentBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = Tutorial1FragmentBinding.inflate(inflater, container, false)
return binding.root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package it.univpm.spottedkotlin.view.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import it.univpm.spottedkotlin.R
import it.univpm.spottedkotlin.databinding.FirstFragmentBinding
import it.univpm.spottedkotlin.databinding.Tutorial1FragmentBinding
import it.univpm.spottedkotlin.databinding.Tutorial2FragmentBinding
import it.univpm.spottedkotlin.viewmodel.FirstActivityViewModel


class Tutorial2Fragment : Fragment() {
private lateinit var binding: Tutorial2FragmentBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = Tutorial2FragmentBinding.inflate(inflater, container, false)
return binding.root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package it.univpm.spottedkotlin.view.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import it.univpm.spottedkotlin.R
import it.univpm.spottedkotlin.databinding.FirstFragmentBinding
import it.univpm.spottedkotlin.databinding.Tutorial1FragmentBinding
import it.univpm.spottedkotlin.databinding.Tutorial3FragmentBinding
import it.univpm.spottedkotlin.viewmodel.FirstActivityViewModel


class Tutorial3Fragment : Fragment() {
private lateinit var binding: Tutorial3FragmentBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = Tutorial3FragmentBinding.inflate(inflater, container, false)
return binding.root
}
}
Binary file added app/src/main/res/drawable/spotted_tutorial_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/spotted_tutorial_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/spotted_tutorial_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions app/src/main/res/layout/activity_tutorial.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent">

<androidx.fragment.app.FragmentContainerView
android:id = "@+id/tutorial_container"
android:name = "androidx.navigation.fragment.NavHostFragment"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
app:defaultNavHost = "true"
app:navGraph = "@navigation/tutorial_nav_graph"/>

</RelativeLayout>
49 changes: 49 additions & 0 deletions app/src/main/res/layout/tutorial1_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background = "@color/grey">
<LinearLayout android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginTop = "160dp"
android:orientation = "vertical"
android:paddingHorizontal = "80dp"
app:layout_constraintTop_toTopOf = "parent"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent">

<TextView style = "@style/LabelBold"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:textAlignment="center"
android:textSize="28sp"
android:text = "Dai un nome ai volti"/>
<View android:layout_width = "wrap_content"
android:layout_height = "14dp"/>
<TextView style = "@style/LabelRegular"
android:layout_width = "match_parent"
android:textAlignment="center"
android:textSize="18sp"
android:layout_height = "wrap_content"
android:lineHeight="23dp"
android:text = "Scopri l'identità delle persone che incortri nelle tue giornate"/>

<!--HLine-->
<View android:layout_width = "50dp"
android:layout_height = "6dp"
android:layout_marginTop = "30dp"
android:layout_gravity="center"
android:foreground = "@drawable/border_rounded_black_small"/>

</LinearLayout>

<ImageView android:layout_width = "wrap_content"
android:layout_height = "300dp"
android:adjustViewBounds = "true"
android:scaleType = "centerCrop"
android:src = "@drawable/spotted_tutorial_1"
app:layout_constraintBottom_toBottomOf = "parent"
app:layout_constraintEnd_toEndOf = "parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
53 changes: 53 additions & 0 deletions app/src/main/res/layout/tutorial2_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background = "@color/black">
<LinearLayout android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginTop = "140dp"
android:orientation = "vertical"
android:paddingHorizontal = "80dp"
app:layout_constraintTop_toTopOf = "parent"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent">

<TextView style = "@style/LabelBold"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:textAlignment="center"
android:textSize="28sp"
android:textColor="@color/white"
android:text = "Interagisci con la community"/>
<View android:layout_width = "wrap_content"
android:layout_height = "14dp"/>
<TextView style = "@style/LabelRegular"
android:layout_width = "match_parent"
android:textAlignment="center"
android:textSize="18sp"
android:textColor="@color/white"
android:layout_height = "wrap_content"
android:lineHeight="23dp"
android:text = "Commenta, segui e riconosciti negli spot"/>

<!--HLine-->
<View android:layout_width = "50dp"
android:layout_height = "6dp"
android:layout_marginTop = "30dp"
android:layout_gravity="center"
android:foreground = "@drawable/border_rounded_white_small"/>

</LinearLayout>

<ImageView android:layout_width = "wrap_content"
android:layout_height = "300dp"
android:adjustViewBounds = "true"
android:scaleType = "centerCrop"
android:src = "@drawable/spotted_tutorial_2"
app:layout_constraintBottom_toBottomOf = "parent"
android:layout_marginBottom="20dp"

app:layout_constraintEnd_toEndOf = "parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 76a50e1

Please sign in to comment.