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()
|
||||
}
|
||||
|
||||
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() {
|
||||
settings_container.setBackgroundColor(dominantColor)
|
||||
settings_appbar.setBackgroundColor(dominantColor)
|
||||
|
@ -93,6 +77,22 @@ class SettingsActivity: AppCompatActivity(), UIObject {
|
|||
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(
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.finnmglas.launcher.*
|
||||
import com.finnmglas.launcher.list.ListActivity
|
||||
import com.finnmglas.launcher.settings.intendedSettingsPause
|
||||
|
@ -36,17 +35,6 @@ class SettingsFragmentActions : Fragment(), UIObject {
|
|||
override fun onStart() {
|
||||
super<Fragment>.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() {
|
||||
|
|
|
@ -1,20 +1,56 @@
|
|||
package com.finnmglas.launcher.settings.actions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
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.ImageView
|
||||
import android.widget.TextView
|
||||
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.settings.intendedSettingsPause
|
||||
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):
|
||||
RecyclerView.Adapter<ActionsRecyclerAdapter.ViewHolder>() {
|
||||
|
@ -47,6 +83,8 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
|||
.putString("action_$actionName", "") // clear it
|
||||
.apply()
|
||||
|
||||
loadSettings() // apply new settings to the app
|
||||
|
||||
viewHolder.fontAwesome.visibility = View.INVISIBLE
|
||||
viewHolder.img.visibility = View.INVISIBLE
|
||||
viewHolder.removeAction.visibility = View.GONE
|
|
@ -1,6 +1,7 @@
|
|||
package com.finnmglas.launcher.tutorial
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
@ -31,6 +32,9 @@ class TutorialActivity: AppCompatActivity(), UIObject {
|
|||
// Check if the app was started before
|
||||
if (launcherPreferences.getBoolean("startedBefore", false))
|
||||
tutorial_appbar.visibility = View.VISIBLE
|
||||
else resetSettings(this)
|
||||
|
||||
loadSettings()
|
||||
|
||||
// set up tabs and swiping in settings
|
||||
val sectionsPagerAdapter = TutorialSectionsPagerAdapter(this, supportFragmentManager)
|
||||
|
@ -54,6 +58,30 @@ class TutorialActivity: AppCompatActivity(), UIObject {
|
|||
override fun setOnClicks() {
|
||||
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(){
|
||||
var defaultApps = mutableListOf<String>()
|
||||
defaultApps = resetSettings(context!!) // UP, DOWN, RIGHT, LEFT, VOLUME_UP, VOLUME_DOWN
|
||||
|
||||
super<Fragment>.onStart()
|
||||
super<UIObject>.onStart()
|
||||
}
|
||||
|
|
|
@ -9,17 +9,16 @@
|
|||
android:paddingTop="16sp"
|
||||
android:paddingRight="32sp">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/settings_actions_rview"
|
||||
<fragment
|
||||
android:id="@+id/settings_actions_rview_fragment"
|
||||
android:name="com.finnmglas.launcher.settings.actions.SettingsFragmentActionsRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/settings_actions_buttons"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<LinearLayout
|
||||
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_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>
|
Loading…
Add table
Reference in a new issue