mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Fill Setup
tab (4) of the tutorial
From there, apps can be chosen for actions (like in settings) Closes #51
This commit is contained in:
parent
63ec10f2b1
commit
909a3d5725
8 changed files with 142 additions and 40 deletions
|
@ -59,22 +59,6 @@ class SettingsActivity: AppCompatActivity(), UIObject {
|
||||||
if (!intendedSettingsPause) finish()
|
if (!intendedSettingsPause) finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
||||||
when (requestCode) {
|
|
||||||
REQUEST_CHOOSE_APP -> {
|
|
||||||
val value = data?.getStringExtra("value")
|
|
||||||
val forApp = data?.getStringExtra("forApp") ?: return
|
|
||||||
|
|
||||||
launcherPreferences.edit()
|
|
||||||
.putString("action_$forApp", value.toString())
|
|
||||||
.apply()
|
|
||||||
|
|
||||||
loadSettings()
|
|
||||||
}
|
|
||||||
else -> super.onActivityResult(requestCode, resultCode, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun applyTheme() {
|
override fun applyTheme() {
|
||||||
settings_container.setBackgroundColor(dominantColor)
|
settings_container.setBackgroundColor(dominantColor)
|
||||||
settings_appbar.setBackgroundColor(dominantColor)
|
settings_appbar.setBackgroundColor(dominantColor)
|
||||||
|
@ -93,6 +77,22 @@ class SettingsActivity: AppCompatActivity(), UIObject {
|
||||||
startActivity(Intent(Settings.ACTION_SETTINGS))
|
startActivity(Intent(Settings.ACTION_SETTINGS))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
when (requestCode) {
|
||||||
|
REQUEST_CHOOSE_APP -> {
|
||||||
|
val value = data?.getStringExtra("value")
|
||||||
|
val forApp = data?.getStringExtra("forApp") ?: return
|
||||||
|
|
||||||
|
launcherPreferences.edit()
|
||||||
|
.putString("action_$forApp", value.toString())
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
loadSettings()
|
||||||
|
}
|
||||||
|
else -> super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val TAB_TITLES = arrayOf(
|
private val TAB_TITLES = arrayOf(
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import com.finnmglas.launcher.*
|
import com.finnmglas.launcher.*
|
||||||
import com.finnmglas.launcher.list.ListActivity
|
import com.finnmglas.launcher.list.ListActivity
|
||||||
import com.finnmglas.launcher.settings.intendedSettingsPause
|
import com.finnmglas.launcher.settings.intendedSettingsPause
|
||||||
|
@ -36,17 +35,6 @@ class SettingsFragmentActions : Fragment(), UIObject {
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super<Fragment>.onStart()
|
super<Fragment>.onStart()
|
||||||
super<UIObject>.onStart()
|
super<UIObject>.onStart()
|
||||||
|
|
||||||
// set up the list / recycler
|
|
||||||
val actionViewManager = LinearLayoutManager(context)
|
|
||||||
val actionViewAdapter = ActionsRecyclerAdapter( activity!! )
|
|
||||||
|
|
||||||
settings_actions_rview.apply {
|
|
||||||
// improve performance (since content changes don't change the layout size)
|
|
||||||
setHasFixedSize(true)
|
|
||||||
layoutManager = actionViewManager
|
|
||||||
adapter = actionViewAdapter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyTheme() {
|
override fun applyTheme() {
|
||||||
|
|
|
@ -1,20 +1,56 @@
|
||||||
package com.finnmglas.launcher.settings.actions
|
package com.finnmglas.launcher.settings.actions
|
||||||
|
|
||||||
import android.app.Activity
|
import android.os.Bundle
|
||||||
import android.content.Intent
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.finnmglas.launcher.*
|
||||||
|
import com.finnmglas.launcher.list.ListActivity
|
||||||
|
import kotlinx.android.synthetic.main.settings_actions_recycler.*
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.finnmglas.launcher.*
|
|
||||||
import com.finnmglas.launcher.list.ListActivity
|
|
||||||
import com.finnmglas.launcher.libraries.FontAwesome
|
import com.finnmglas.launcher.libraries.FontAwesome
|
||||||
import com.finnmglas.launcher.settings.intendedSettingsPause
|
import com.finnmglas.launcher.settings.intendedSettingsPause
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The [SettingsFragmentActionsRecycler] is a fragment containing the [ActionsRecyclerAdapter],
|
||||||
|
* which displays all selected actions / apps.
|
||||||
|
*
|
||||||
|
* It is used in the Tutorial and in Settings
|
||||||
|
*/
|
||||||
|
class SettingsFragmentActionsRecycler : Fragment(), UIObject {
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.settings_actions_recycler, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super<Fragment>.onStart()
|
||||||
|
|
||||||
|
// set up the list / recycler
|
||||||
|
val actionViewManager = LinearLayoutManager(context)
|
||||||
|
val actionViewAdapter = ActionsRecyclerAdapter( activity!! )
|
||||||
|
|
||||||
|
settings_actions_rview.apply {
|
||||||
|
// improve performance (since content changes don't change the layout size)
|
||||||
|
setHasFixedSize(true)
|
||||||
|
layoutManager = actionViewManager
|
||||||
|
adapter = actionViewAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
super<UIObject>.onStart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ActionsRecyclerAdapter(val activity: Activity):
|
class ActionsRecyclerAdapter(val activity: Activity):
|
||||||
RecyclerView.Adapter<ActionsRecyclerAdapter.ViewHolder>() {
|
RecyclerView.Adapter<ActionsRecyclerAdapter.ViewHolder>() {
|
||||||
|
@ -47,6 +83,8 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
||||||
.putString("action_$actionName", "") // clear it
|
.putString("action_$actionName", "") // clear it
|
||||||
.apply()
|
.apply()
|
||||||
|
|
||||||
|
loadSettings() // apply new settings to the app
|
||||||
|
|
||||||
viewHolder.fontAwesome.visibility = View.INVISIBLE
|
viewHolder.fontAwesome.visibility = View.INVISIBLE
|
||||||
viewHolder.img.visibility = View.INVISIBLE
|
viewHolder.img.visibility = View.INVISIBLE
|
||||||
viewHolder.removeAction.visibility = View.GONE
|
viewHolder.removeAction.visibility = View.GONE
|
|
@ -1,6 +1,7 @@
|
||||||
package com.finnmglas.launcher.tutorial
|
package com.finnmglas.launcher.tutorial
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
@ -31,6 +32,9 @@ class TutorialActivity: AppCompatActivity(), UIObject {
|
||||||
// Check if the app was started before
|
// Check if the app was started before
|
||||||
if (launcherPreferences.getBoolean("startedBefore", false))
|
if (launcherPreferences.getBoolean("startedBefore", false))
|
||||||
tutorial_appbar.visibility = View.VISIBLE
|
tutorial_appbar.visibility = View.VISIBLE
|
||||||
|
else resetSettings(this)
|
||||||
|
|
||||||
|
loadSettings()
|
||||||
|
|
||||||
// set up tabs and swiping in settings
|
// set up tabs and swiping in settings
|
||||||
val sectionsPagerAdapter = TutorialSectionsPagerAdapter(this, supportFragmentManager)
|
val sectionsPagerAdapter = TutorialSectionsPagerAdapter(this, supportFragmentManager)
|
||||||
|
@ -54,6 +58,30 @@ class TutorialActivity: AppCompatActivity(), UIObject {
|
||||||
override fun setOnClicks() {
|
override fun setOnClicks() {
|
||||||
tutorial_close.setOnClickListener() { finish() }
|
tutorial_close.setOnClickListener() { finish() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// same as in SettingsActivity; TODO: Use same function
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
when (requestCode) {
|
||||||
|
REQUEST_CHOOSE_APP -> {
|
||||||
|
val value = data?.getStringExtra("value")
|
||||||
|
val forApp = data?.getStringExtra("forApp") ?: return
|
||||||
|
|
||||||
|
launcherPreferences.edit()
|
||||||
|
.putString("action_$forApp", value.toString())
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
loadSettings()
|
||||||
|
}
|
||||||
|
else -> super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent going back, allow if viewed again later
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (launcherPreferences.getBoolean("startedBefore", false))
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,9 +23,6 @@ class TutorialFragmentSetup(): Fragment(), UIObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart(){
|
override fun onStart(){
|
||||||
var defaultApps = mutableListOf<String>()
|
|
||||||
defaultApps = resetSettings(context!!) // UP, DOWN, RIGHT, LEFT, VOLUME_UP, VOLUME_DOWN
|
|
||||||
|
|
||||||
super<Fragment>.onStart()
|
super<Fragment>.onStart()
|
||||||
super<UIObject>.onStart()
|
super<UIObject>.onStart()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,16 @@
|
||||||
android:paddingTop="16sp"
|
android:paddingTop="16sp"
|
||||||
android:paddingRight="32sp">
|
android:paddingRight="32sp">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<fragment
|
||||||
android:id="@+id/settings_actions_rview"
|
android:id="@+id/settings_actions_rview_fragment"
|
||||||
|
android:name="com.finnmglas.launcher.settings.actions.SettingsFragmentActionsRecycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/settings_actions_buttons"
|
app:layout_constraintBottom_toTopOf="@+id/settings_actions_buttons"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
</androidx.recyclerview.widget.RecyclerView>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/settings_actions_buttons"
|
android:id="@+id/settings_actions_buttons"
|
||||||
|
|
18
app/src/main/res/layout/settings_actions_recycler.xml
Normal file
18
app/src/main/res/layout/settings_actions_recycler.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?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:id="@+id/settings_actions_recycler_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/settings_actions_rview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -22,4 +22,38 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tutorial_setup_subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="We chose some default apps for you, if you want to, you can change them now."
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tutorial_setup_title" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/tutorial_setup_actions_rview_fragment"
|
||||||
|
android:name="com.finnmglas.launcher.settings.actions.SettingsFragmentActionsRecycler"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/tutorial_setup_text_bottom"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tutorial_setup_subtitle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tutorial_setup_text_bottom"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:text="You can also change your selection later."
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Reference in a new issue