Start tutorial

This commit is contained in:
Matthieu 2024-08-29 18:17:10 +02:00
parent 12960262b2
commit 40a3a9ba26
11 changed files with 100 additions and 7 deletions

View File

@ -226,6 +226,9 @@ dependencies {
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
//Interactive tutorial
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.14.0'
implementation 'com.google.android.material:material:1.12.0'
//Dagger (dependency injection)

View File

@ -66,6 +66,7 @@ import org.pixeldroid.app.posts.feeds.uncachedFeeds.UncachedPostsFragment
import org.pixeldroid.app.profile.ProfileActivity
import org.pixeldroid.app.searchDiscover.SearchDiscoverFragment
import org.pixeldroid.app.settings.SettingsActivity
import org.pixeldroid.app.settings.TutorialSettingsDialog.Companion.START_TUTORIAL
import org.pixeldroid.app.utils.BaseActivity
import org.pixeldroid.app.utils.Tab
import org.pixeldroid.app.utils.api.objects.Notification
@ -128,9 +129,14 @@ class MainActivity : BaseActivity() {
val showNotification: Boolean = intent.getBooleanExtra(SHOW_NOTIFICATION_TAG, false)
val showTutorial: Int = intent.getIntExtra(START_TUTORIAL, -1)
if(showNotification){
binding.viewPager.currentItem = 3
} else if(showTutorial > 0) {
}
if (ActivityCompat.checkSelfPermission(applicationContext,
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED

View File

@ -107,6 +107,8 @@ class SettingsActivity : ThemedActivity(), SharedPreferences.OnSharedPreferenceC
dialogFragment = LanguageSettingFragment()
} else if (preference.key == "arrange_tabs") {
dialogFragment = ArrangeTabsFragment()
} else if (preference.key == "tutorial") {
dialogFragment = TutorialSettingsDialog()
}
if (dialogFragment != null) {
dialogFragment.setTargetFragment(this, 0)

View File

@ -0,0 +1,67 @@
package org.pixeldroid.app.settings;
import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.graphics.Typeface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.pixeldroid.app.R
import org.pixeldroid.app.main.MainActivity
class TutorialSettingsDialog: DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val items = arrayOf(
Pair(R.string.feeds_tutorial, R.drawable.ic_home_white_24dp),
Pair(R.string.create_tutorial, R.drawable.photo_camera),
Pair(R.string.feeds_tutorial, R.drawable.notifications),
Pair(R.string.feeds_tutorial, R.drawable.outline_bottom_navigation)
)
val adapter = object : ArrayAdapter<Pair<Int, Int>>(requireContext(), android.R.layout.simple_list_item_1, items) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view: TextView = if (convertView == null) {
LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false) as TextView
} else {
convertView as TextView
}
val item = getItem(position)
if (item != null) {
view.setText(item.first)
view.setTypeface(null, Typeface.NORMAL) // Set the typeface to normal
view.setCompoundDrawablesWithIntrinsicBounds(item.second, 0, 0, 0)
view.compoundDrawablePadding = 16 // Add padding between text and drawable
}
view.setPadding(0, 32, 0, 32)
return view
}
}
return MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.tutorial_choice))
.setAdapter(adapter) { _, which ->
val intent = Intent(requireContext(), MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
intent.putExtra(START_TUTORIAL, which)
startActivity(intent)
}
.setNegativeButton(android.R.string.cancel) { dialog, _ ->
dialog.dismiss()
}
.create()
}
companion object {
const val START_TUTORIAL = "tutorial_start_intent"
}
}

View File

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="?attr/colorOnBackground" android:pathData="M19,2L5,2c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h4l3,3 3,-3h4c1.1,0 2,-0.9 2,-2L21,4c0,-1.1 -0.9,-2 -2,-2zM13,18h-2v-2h2v2zM15.07,10.25l-0.9,0.92C13.45,11.9 13,12.5 13,14h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,8c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>

View File

@ -1,5 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
<vector android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
<path android:fillColor="?attr/colorOnBackground" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
</vector>

View File

@ -1,5 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
<path android:fillColor="?attr/colorOnBackground" android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
</vector>

View File

@ -1,6 +1,6 @@
<vector android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path android:fillColor="#FF000000" android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
<path android:fillColor="?attr/colorOnBackground" android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path android:fillColor="?attr/colorOnBackground" android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
</vector>

View File

@ -361,4 +361,9 @@ For more info about Pixelfed, you can check here: https://pixelfed.org"</string>
<string name="dm_target">Target username</string>
<string name="new_dm">Message you want to write. Say hello!</string>
<string name="new_dm_error">Error sending your message! Check the username</string>
<string name="tutorial">Tutorial</string>
<string name="tutorial_explanation">Explanations on how to use PixelDroid and Pixelfed</string>
<string name="feeds_tutorial">Feeds, how do they work? Where do they come from?</string>
<string name="create_tutorial">A little walk through creating posts</string>
<string name="tutorial_choice">What could you use some help with?</string>
</resources>

View File

@ -54,6 +54,11 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/about">
<ListPreference
android:key="tutorial"
android:title="@string/tutorial"
android:summary="@string/tutorial_explanation"
android:icon="@drawable/help" />
<Preference android:title="@string/about"
android:key="about"
android:summary="@string/about_pixeldroid"

@ -1 +1 @@
Subproject commit 702d14fe701343958337efa1b4eb31f0250849f6
Subproject commit def947b5b1392b3282174bebd0217037f66d0362