mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-22 22:11:27 +01:00
Migrate from Kotlin synthetics to Jetpack view binding
https://developer.android.com/topic/libraries/view-binding/migration
This commit is contained in:
parent
ebc2e5ca2a
commit
178865c6cf
19 changed files with 192 additions and 125 deletions
13
.idea/deviceManager.xml
generated
Normal file
13
.idea/deviceManager.xml
generated
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DeviceTable">
|
||||
<option name="columnSorters">
|
||||
<list>
|
||||
<ColumnSorterState>
|
||||
<option name="column" value="Name" />
|
||||
<option name="order" value="ASCENDING" />
|
||||
</ColumnSorterState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.6.21" />
|
||||
<option name="version" value="2.0.0" />
|
||||
</component>
|
||||
</project>
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
|
@ -8,6 +8,7 @@
|
|||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
|
|
11
.idea/other.xml
generated
11
.idea/other.xml
generated
|
@ -179,17 +179,6 @@
|
|||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="31" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="q2q" />
|
||||
<option name="id" value="q2q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Z Fold3" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1768" />
|
||||
<option name="screenY" value="2208" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 34
|
||||
buildToolsVersion "34.0.0"
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
packaging {
|
||||
resources.excludes.addAll(
|
||||
[
|
||||
"META-INF/LICENSE.md",
|
||||
"META-INF/NOTICE.md",
|
||||
"META-INF/LICENSE-notice.md"
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.jrpie.android.launcher"
|
||||
minSdkVersion 21
|
||||
|
@ -15,6 +28,20 @@ android {
|
|||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '17'
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -42,4 +69,6 @@ dependencies {
|
|||
implementation 'com.google.android.material:material:1.12.0'
|
||||
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||
implementation "com.android.databinding:compiler:$android_plugin_version"
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import androidx.core.view.GestureDetectorCompat
|
|||
import de.jrpie.android.launcher.BuildConfig.VERSION_NAME
|
||||
import de.jrpie.android.launcher.list.other.LauncherAction
|
||||
import de.jrpie.android.launcher.tutorial.TutorialActivity
|
||||
import kotlinx.android.synthetic.main.home.*
|
||||
import de.jrpie.android.launcher.databinding.HomeBinding
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
@ -19,6 +19,8 @@ import kotlin.math.abs
|
|||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* [HomeActivity] is the actual application Launcher,
|
||||
* what makes this application special / unique.
|
||||
|
@ -34,6 +36,11 @@ import kotlin.math.min
|
|||
class HomeActivity: UIObject, AppCompatActivity(),
|
||||
GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
|
||||
|
||||
private lateinit var binding: HomeBinding
|
||||
|
||||
|
||||
|
||||
|
||||
private var bufferedPointerCount = 1 // how many fingers on screen
|
||||
private var pointerBufferTimer = Timer()
|
||||
|
||||
|
@ -83,7 +90,8 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
AsyncTask.execute { loadApps(packageManager) }
|
||||
|
||||
// Initialise layout
|
||||
setContentView(R.layout.home)
|
||||
binding = HomeBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
@ -108,15 +116,16 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
val dateFormat = SimpleDateFormat(upperFMT[dFormat], Locale.getDefault())
|
||||
val timeFormat = SimpleDateFormat(lowerFMT[dFormat], Locale.getDefault())
|
||||
|
||||
|
||||
clockTimer = fixedRateTimer("clockTimer", true, 0L, 100) {
|
||||
this@HomeActivity.runOnUiThread {
|
||||
val t = timeFormat.format(Date())
|
||||
if (home_lower_view.text != t)
|
||||
home_lower_view.text = t
|
||||
if (binding.homeLowerView.text != t)
|
||||
binding.homeLowerView.setText(t)
|
||||
|
||||
val d = dateFormat.format(Date())
|
||||
if (home_upper_view.text != d)
|
||||
home_upper_view.text = d
|
||||
if (binding.homeUpperView.text != d)
|
||||
binding.homeUpperView.setText(d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,14 +232,14 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
override fun setOnClicks() {
|
||||
|
||||
val preferences = getPreferences(this)
|
||||
home_upper_view.setOnClickListener {
|
||||
binding.homeUpperView.setOnClickListener {
|
||||
when (preferences.getInt(PREF_DATE_FORMAT, 0)) {
|
||||
0 -> Gesture.DATE(this)
|
||||
else -> Gesture.TIME(this)
|
||||
}
|
||||
}
|
||||
|
||||
home_lower_view.setOnClickListener {
|
||||
binding.homeLowerView.setOnClickListener {
|
||||
when (preferences.getInt(PREF_DATE_FORMAT, 0)) {
|
||||
0 -> Gesture.TIME(this)
|
||||
else -> Gesture.DATE(this)
|
||||
|
|
|
@ -18,12 +18,11 @@ import de.jrpie.android.launcher.R
|
|||
import de.jrpie.android.launcher.REQUEST_UNINSTALL
|
||||
import de.jrpie.android.launcher.UIObject
|
||||
import de.jrpie.android.launcher.getPreferences
|
||||
import de.jrpie.android.launcher.launch
|
||||
import de.jrpie.android.launcher.list.apps.ListFragmentApps
|
||||
import de.jrpie.android.launcher.list.other.LauncherAction
|
||||
import de.jrpie.android.launcher.list.other.ListFragmentOther
|
||||
import de.jrpie.android.launcher.vibrantColor
|
||||
import kotlinx.android.synthetic.main.list.*
|
||||
import de.jrpie.android.launcher.databinding.ListBinding
|
||||
|
||||
|
||||
var intendedChoosePause = false // know when to close
|
||||
|
@ -40,6 +39,9 @@ var forGesture: String? = null
|
|||
* The activity itself can also be chosen to be launched as an action.
|
||||
*/
|
||||
class ListActivity : AppCompatActivity(), UIObject {
|
||||
private lateinit var binding: ListBinding
|
||||
|
||||
|
||||
enum class ListActivityIntention(val titleResource: Int) {
|
||||
VIEW(R.string.list_title_view), /* view list of apps */
|
||||
PICK(R.string.list_title_pick) /* choose app or action to associate to a gesture */
|
||||
|
@ -48,9 +50,10 @@ class ListActivity : AppCompatActivity(), UIObject {
|
|||
super.onCreate(savedInstanceState)
|
||||
|
||||
// Initialise layout
|
||||
setContentView(R.layout.list)
|
||||
binding = ListBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
list_settings.setOnClickListener {
|
||||
binding.listSettings.setOnClickListener {
|
||||
LauncherAction.SETTINGS.launch(this@ListActivity)
|
||||
}
|
||||
|
||||
|
@ -60,15 +63,15 @@ class ListActivity : AppCompatActivity(), UIObject {
|
|||
val r = Rect()
|
||||
window.decorView.getWindowVisibleDisplayFrame(r)
|
||||
val height: Int =
|
||||
list_container.context.resources.displayMetrics.heightPixels
|
||||
binding.listContainer.context.resources.displayMetrics.heightPixels
|
||||
val diff = height - r.bottom
|
||||
if (diff != 0 && getPreferences(this).getBoolean(PREF_SCREEN_FULLSCREEN, false)) {
|
||||
if (list_container.paddingBottom !== diff) {
|
||||
list_container.setPadding(0, 0, 0, diff)
|
||||
if (binding.listContainer.paddingBottom !== diff) {
|
||||
binding.listContainer.setPadding(0, 0, 0, diff)
|
||||
}
|
||||
} else {
|
||||
if (list_container.paddingBottom !== 0) {
|
||||
list_container.setPadding(0, 0, 0, 0)
|
||||
if (binding.listContainer.paddingBottom !== 0) {
|
||||
binding.listContainer.setPadding(0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,11 +103,11 @@ class ListActivity : AppCompatActivity(), UIObject {
|
|||
override fun applyTheme() {
|
||||
// list_close.setTextColor(vibrantColor)
|
||||
|
||||
list_tabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
binding.listTabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
list_close.setOnClickListener { finish() }
|
||||
binding.listClose.setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
override fun adjustLayout() {
|
||||
|
@ -120,10 +123,10 @@ class ListActivity : AppCompatActivity(), UIObject {
|
|||
|
||||
// Hide tabs for the "view" action
|
||||
if (intention == ListActivityIntention.VIEW) {
|
||||
list_tabs.visibility = View.GONE
|
||||
binding.listTabs.visibility = View.GONE
|
||||
}
|
||||
|
||||
list_heading.text = getString(intention.titleResource)
|
||||
binding.listHeading.text = getString(intention.titleResource)
|
||||
|
||||
val sectionsPagerAdapter = ListSectionsPagerAdapter(this, supportFragmentManager)
|
||||
val viewPager: ViewPager = findViewById(R.id.list_viewpager)
|
||||
|
|
|
@ -8,13 +8,13 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_KEYBOARD
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.databinding.ListAppsBinding
|
||||
import de.jrpie.android.launcher.UIObject
|
||||
import de.jrpie.android.launcher.getPreferences
|
||||
import de.jrpie.android.launcher.list.ListActivity
|
||||
import de.jrpie.android.launcher.list.forGesture
|
||||
import de.jrpie.android.launcher.list.intention
|
||||
import de.jrpie.android.launcher.openSoftKeyboard
|
||||
import kotlinx.android.synthetic.main.list_apps.*
|
||||
|
||||
|
||||
/**
|
||||
|
@ -23,12 +23,14 @@ import kotlinx.android.synthetic.main.list_apps.*
|
|||
* It is a list of all installed applications that are can be launched.
|
||||
*/
|
||||
class ListFragmentApps : Fragment(), UIObject {
|
||||
private lateinit var binding: ListAppsBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.list_apps, container, false)
|
||||
binding = ListAppsBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -46,14 +48,14 @@ class ListFragmentApps : Fragment(), UIObject {
|
|||
val appsRViewAdapter = AppsRecyclerAdapter(activity!!, intention, forGesture)
|
||||
|
||||
// set up the list / recycler
|
||||
list_apps_rview.apply {
|
||||
binding.listAppsRview.apply {
|
||||
// improve performance (since content changes don't change the layout size)
|
||||
setHasFixedSize(true)
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
adapter = appsRViewAdapter
|
||||
}
|
||||
|
||||
list_apps_searchview.setOnQueryTextListener(object :
|
||||
binding.listAppsSearchview.setOnQueryTextListener(object :
|
||||
androidx.appcompat.widget.SearchView.OnQueryTextListener {
|
||||
|
||||
override fun onQueryTextSubmit(query: String): Boolean {
|
||||
|
@ -68,9 +70,9 @@ class ListFragmentApps : Fragment(), UIObject {
|
|||
})
|
||||
|
||||
if (intention == ListActivity.ListActivityIntention.VIEW
|
||||
&& getPreferences(context!!)
|
||||
&& getPreferences(requireContext())
|
||||
.getBoolean(PREF_SEARCH_AUTO_KEYBOARD, true)) {
|
||||
openSoftKeyboard(context!!, list_apps_searchview)
|
||||
openSoftKeyboard(requireContext(), binding.listAppsSearchview)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.view.ViewGroup
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import de.jrpie.android.launcher.R
|
||||
import kotlinx.android.synthetic.main.list_other.*
|
||||
import de.jrpie.android.launcher.databinding.ListOtherBinding
|
||||
|
||||
/**
|
||||
* The [ListFragmentOther] is used as a tab in ListActivity,
|
||||
|
@ -17,19 +17,22 @@ import kotlinx.android.synthetic.main.list_other.*
|
|||
*/
|
||||
class ListFragmentOther : Fragment() {
|
||||
|
||||
private lateinit var binding: ListOtherBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.list_other, container, false)
|
||||
binding = ListOtherBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
// set up the list / recycler
|
||||
val viewManager = LinearLayoutManager(context)
|
||||
val viewAdapter = OtherRecyclerAdapter(activity!!)
|
||||
val viewAdapter = OtherRecyclerAdapter(requireActivity())
|
||||
|
||||
list_other_rview.apply {
|
||||
binding.listOtherRview.apply {
|
||||
// improve performance (since content changes don't change the layout size)
|
||||
setHasFixedSize(true)
|
||||
layoutManager = viewManager
|
||||
|
|
|
@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.viewpager.widget.ViewPager
|
||||
import de.jrpie.android.launcher.*
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import kotlinx.android.synthetic.main.settings.*
|
||||
import de.jrpie.android.launcher.databinding.SettingsBinding
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
|
@ -29,12 +29,14 @@ var intendedSettingsPause = false // know when to close
|
|||
* Settings are closed automatically if the activity goes `onPause` unexpectedly.
|
||||
*/
|
||||
class SettingsActivity: AppCompatActivity(), UIObject {
|
||||
private lateinit var binding: SettingsBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// Initialise layout
|
||||
setContentView(R.layout.settings)
|
||||
binding = SettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
// set up tabs and swiping in settings
|
||||
val sectionsPagerAdapter = SettingsSectionsPagerAdapter(this, supportFragmentManager)
|
||||
|
@ -62,14 +64,14 @@ class SettingsActivity: AppCompatActivity(), UIObject {
|
|||
override fun applyTheme() {
|
||||
//settings_system.setTextColor(vibrantColor)
|
||||
//settings_close.setTextColor(vibrantColor)
|
||||
settings_tabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
binding.settingsTabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks(){
|
||||
// As older APIs somehow do not recognize the xml defined onClick
|
||||
settings_close.setOnClickListener { finish() }
|
||||
binding.settingsClose.setOnClickListener { finish() }
|
||||
// open device settings (see https://stackoverflow.com/a/62092663/12787264)
|
||||
settings_system.setOnClickListener {
|
||||
binding.settingsSystem.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
startActivity(Intent(Settings.ACTION_SETTINGS))
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import androidx.fragment.app.Fragment
|
|||
import de.jrpie.android.launcher.*
|
||||
import de.jrpie.android.launcher.list.ListActivity
|
||||
import de.jrpie.android.launcher.settings.intendedSettingsPause
|
||||
import kotlinx.android.synthetic.main.settings_actions.*
|
||||
import de.jrpie.android.launcher.databinding.SettingsActionsBinding
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,11 +25,13 @@ import kotlinx.android.synthetic.main.settings_actions.*
|
|||
|
||||
class SettingsFragmentActions : Fragment(), UIObject {
|
||||
|
||||
private lateinit var binding: SettingsActionsBinding
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.settings_actions, container, false)
|
||||
binding = SettingsActionsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -38,20 +40,20 @@ class SettingsFragmentActions : Fragment(), UIObject {
|
|||
}
|
||||
|
||||
override fun applyTheme() {
|
||||
setButtonColor(settings_actions_button_view_apps, vibrantColor)
|
||||
setButtonColor(settings_actions_button_install_apps, vibrantColor)
|
||||
setButtonColor(binding.settingsActionsButtonViewApps, vibrantColor)
|
||||
setButtonColor(binding.settingsActionsButtonInstallApps, vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
|
||||
// App management buttons
|
||||
settings_actions_button_view_apps.setOnClickListener{
|
||||
binding.settingsActionsButtonViewApps.setOnClickListener{
|
||||
val intent = Intent(this.context, ListActivity::class.java)
|
||||
intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString())
|
||||
intendedSettingsPause = true
|
||||
startActivity(intent)
|
||||
}
|
||||
settings_actions_button_install_apps.setOnClickListener{
|
||||
binding.settingsActionsButtonInstallApps.setOnClickListener{
|
||||
try {
|
||||
val rateIntent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import de.jrpie.android.launcher.*
|
||||
import de.jrpie.android.launcher.list.ListActivity
|
||||
import kotlinx.android.synthetic.main.settings_actions_recycler.*
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.widget.Button
|
||||
|
@ -17,6 +16,7 @@ import android.widget.TextView
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import de.jrpie.android.launcher.list.other.LauncherAction
|
||||
import de.jrpie.android.launcher.settings.intendedSettingsPause
|
||||
import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding
|
||||
import java.lang.Exception
|
||||
|
||||
/**
|
||||
|
@ -27,11 +27,13 @@ import java.lang.Exception
|
|||
*/
|
||||
class SettingsFragmentActionsRecycler : Fragment(), UIObject {
|
||||
|
||||
private lateinit var binding: SettingsActionsRecyclerBinding
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.settings_actions_recycler, container, false)
|
||||
binding = SettingsActionsRecyclerBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -39,9 +41,9 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject {
|
|||
|
||||
// set up the list / recycler
|
||||
val actionViewManager = LinearLayoutManager(context)
|
||||
val actionViewAdapter = ActionsRecyclerAdapter( activity!! )
|
||||
val actionViewAdapter = ActionsRecyclerAdapter( requireActivity() )
|
||||
|
||||
settings_actions_rview.apply {
|
||||
binding.settingsActionsRview.apply {
|
||||
// improve performance (since content changes don't change the layout size)
|
||||
setHasFixedSize(true)
|
||||
layoutManager = actionViewManager
|
||||
|
|
|
@ -30,7 +30,7 @@ import de.jrpie.android.launcher.setSwitchColor
|
|||
import de.jrpie.android.launcher.setWindowFlags
|
||||
import de.jrpie.android.launcher.settings.intendedSettingsPause
|
||||
import de.jrpie.android.launcher.vibrantColor
|
||||
import kotlinx.android.synthetic.main.settings_launcher.*
|
||||
import de.jrpie.android.launcher.databinding.SettingsLauncherBinding
|
||||
|
||||
|
||||
/**
|
||||
|
@ -40,11 +40,13 @@ import kotlinx.android.synthetic.main.settings_launcher.*
|
|||
*/
|
||||
class SettingsFragmentLauncher : Fragment(), UIObject {
|
||||
|
||||
private lateinit var binding: SettingsLauncherBinding
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.settings_launcher, container, false)
|
||||
binding = SettingsLauncherBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
@ -55,21 +57,21 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
|
||||
override fun applyTheme() {
|
||||
|
||||
setSwitchColor(settings_launcher_switch_screen_timeout, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_screen_full, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_auto_launch, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_auto_keyboard, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_enable_double, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_enable_edge, vibrantColor)
|
||||
setSwitchColor(binding.settingsLauncherSwitchScreenTimeout, vibrantColor)
|
||||
setSwitchColor(binding.settingsLauncherSwitchScreenFull, vibrantColor)
|
||||
setSwitchColor(binding.settingsLauncherSwitchAutoLaunch, vibrantColor)
|
||||
setSwitchColor(binding.settingsLauncherSwitchAutoKeyboard, vibrantColor)
|
||||
setSwitchColor(binding.settingsLauncherSwitchEnableDouble, vibrantColor)
|
||||
setSwitchColor(binding.settingsLauncherSwitchEnableEdge, vibrantColor)
|
||||
|
||||
|
||||
setButtonColor(settings_launcher_button_choose_wallpaper, vibrantColor)
|
||||
settings_seekbar_sensitivity.progressDrawable.setColorFilter(vibrantColor, PorterDuff.Mode.SRC_IN)
|
||||
setButtonColor(binding.settingsLauncherButtonChooseWallpaper, vibrantColor)
|
||||
binding.settingsSeekbarSensitivity.progressDrawable.setColorFilter(vibrantColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
|
||||
val preferences = getPreferences(activity!!)
|
||||
val preferences = getPreferences(requireActivity())
|
||||
|
||||
fun bindSwitchToPref(switch: Switch, pref: String, default: Boolean, onChange: (Boolean) -> Unit){
|
||||
switch.isChecked = preferences.getBoolean(pref, default)
|
||||
|
@ -81,7 +83,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
}
|
||||
}
|
||||
|
||||
settings_launcher_button_choose_wallpaper.setOnClickListener {
|
||||
binding.settingsLauncherButtonChooseWallpaper.setOnClickListener {
|
||||
// https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271
|
||||
val intent = Intent(Intent.ACTION_SET_WALLPAPER)
|
||||
//.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
|
@ -92,26 +94,26 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
|
||||
|
||||
|
||||
bindSwitchToPref(settings_launcher_switch_screen_timeout, PREF_SCREEN_TIMEOUT_DISABLED, false) {
|
||||
bindSwitchToPref(binding.settingsLauncherSwitchScreenTimeout, PREF_SCREEN_TIMEOUT_DISABLED, false) {
|
||||
activity?.let{setWindowFlags(it.window)}
|
||||
}
|
||||
bindSwitchToPref(settings_launcher_switch_screen_full, PREF_SCREEN_FULLSCREEN, true) {
|
||||
bindSwitchToPref(binding.settingsLauncherSwitchScreenFull, PREF_SCREEN_FULLSCREEN, true) {
|
||||
activity?.let{setWindowFlags(it.window)}
|
||||
}
|
||||
bindSwitchToPref(settings_launcher_switch_auto_launch, PREF_SEARCH_AUTO_LAUNCH, false) {}
|
||||
bindSwitchToPref(settings_launcher_switch_auto_keyboard, PREF_SEARCH_AUTO_KEYBOARD, true) {}
|
||||
bindSwitchToPref(settings_launcher_switch_enable_double, PREF_DOUBLE_ACTIONS_ENABLED, false) {
|
||||
bindSwitchToPref(binding.settingsLauncherSwitchAutoLaunch, PREF_SEARCH_AUTO_LAUNCH, false) {}
|
||||
bindSwitchToPref(binding.settingsLauncherSwitchAutoKeyboard, PREF_SEARCH_AUTO_KEYBOARD, true) {}
|
||||
bindSwitchToPref(binding.settingsLauncherSwitchEnableDouble, PREF_DOUBLE_ACTIONS_ENABLED, false) {
|
||||
//intendedSettingsPause = true
|
||||
// TODO fixme: This causes the app to crash on some devices.
|
||||
//activity?.recreate()
|
||||
}
|
||||
bindSwitchToPref(settings_launcher_switch_enable_edge, PREF_EDGE_ACTIONS_ENABLED, false) {
|
||||
bindSwitchToPref(binding.settingsLauncherSwitchEnableEdge, PREF_EDGE_ACTIONS_ENABLED, false) {
|
||||
//intendedSettingsPause = true
|
||||
// TODO fixme
|
||||
//activity?.recreate()
|
||||
}
|
||||
|
||||
settings_seekbar_sensitivity.setOnSeekBarChangeListener(
|
||||
binding.settingsSeekbarSensitivity.setOnSeekBarChangeListener(
|
||||
object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {}
|
||||
override fun onStartTrackingTouch(p0: SeekBar?) {}
|
||||
|
@ -126,18 +128,18 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
|
||||
override fun adjustLayout() {
|
||||
|
||||
val preferences = getPreferences(activity!!)
|
||||
val preferences = getPreferences(requireActivity())
|
||||
// Load values into the date-format spinner
|
||||
val staticAdapter = ArrayAdapter.createFromResource(
|
||||
activity!!, R.array.settings_launcher_time_format_spinner_items,
|
||||
requireActivity(), R.array.settings_launcher_time_format_spinner_items,
|
||||
android.R.layout.simple_spinner_item )
|
||||
|
||||
staticAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
settings_launcher_format_spinner.adapter = staticAdapter
|
||||
binding.settingsLauncherFormatSpinner.adapter = staticAdapter
|
||||
|
||||
settings_launcher_format_spinner.setSelection(preferences.getInt(PREF_DATE_FORMAT, 0))
|
||||
binding.settingsLauncherFormatSpinner.setSelection(preferences.getInt(PREF_DATE_FORMAT, 0))
|
||||
|
||||
settings_launcher_format_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
binding.settingsLauncherFormatSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
preferences.edit()
|
||||
.putInt(PREF_DATE_FORMAT, position)
|
||||
|
@ -153,7 +155,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
android.R.layout.simple_spinner_item )
|
||||
|
||||
staticThemeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
settings_launcher_theme_spinner.adapter = staticThemeAdapter
|
||||
binding.settingsLauncherThemeSpinner.adapter = staticThemeAdapter
|
||||
|
||||
val themeInt = when (getSavedTheme(activity!!)) {
|
||||
"finn" -> 0
|
||||
|
@ -161,9 +163,9 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
else -> 0
|
||||
}
|
||||
|
||||
settings_launcher_theme_spinner.setSelection(themeInt)
|
||||
binding.settingsLauncherThemeSpinner.setSelection(themeInt)
|
||||
|
||||
settings_launcher_theme_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
binding.settingsLauncherThemeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
when (position) {
|
||||
0 -> if (getSavedTheme(activity!!) != "finn") resetToDefaultTheme(activity!!)
|
||||
|
@ -173,6 +175,6 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
override fun onNothingSelected(parent: AdapterView<*>?) { }
|
||||
}
|
||||
|
||||
settings_seekbar_sensitivity.progress = preferences.getInt(PREF_SLIDE_SENSITIVITY, 2) * 4 / 100
|
||||
binding.settingsSeekbarSensitivity.progress = preferences.getInt(PREF_SLIDE_SENSITIVITY, 2) * 4 / 100
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import de.jrpie.android.launcher.setButtonColor
|
|||
import de.jrpie.android.launcher.settings.intendedSettingsPause
|
||||
import de.jrpie.android.launcher.tutorial.TutorialActivity
|
||||
import de.jrpie.android.launcher.vibrantColor
|
||||
import kotlinx.android.synthetic.main.settings_meta.*
|
||||
import de.jrpie.android.launcher.databinding.SettingsMetaBinding
|
||||
|
||||
/**
|
||||
* The [SettingsFragmentMeta] is a used as a tab in the SettingsActivity.
|
||||
|
@ -29,11 +29,13 @@ import kotlinx.android.synthetic.main.settings_meta.*
|
|||
*/
|
||||
class SettingsFragmentMeta : Fragment(), UIObject {
|
||||
|
||||
private lateinit var binding: SettingsMetaBinding
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.settings_meta, container, false)
|
||||
binding = SettingsMetaBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -57,37 +59,37 @@ class SettingsFragmentMeta : Fragment(), UIObject {
|
|||
}
|
||||
|
||||
override fun applyTheme() {
|
||||
setButtonColor(settings_meta_button_select_launcher, vibrantColor)
|
||||
setButtonColor(settings_meta_button_view_tutorial, vibrantColor)
|
||||
setButtonColor(settings_meta_button_reset_settings, vibrantColor)
|
||||
setButtonColor(settings_meta_button_report_bug, vibrantColor)
|
||||
setButtonColor(settings_meta_button_contact, vibrantColor)
|
||||
setButtonColor(settings_meta_button_fork_contact, vibrantColor)
|
||||
setButtonColor(settings_meta_button_privacy, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonSelectLauncher, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonViewTutorial, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonResetSettings, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonReportBug, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonContact, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonForkContact, vibrantColor)
|
||||
setButtonColor(binding.settingsMetaButtonPrivacy, vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
|
||||
settings_meta_button_select_launcher.setOnClickListener {
|
||||
binding.settingsMetaButtonSelectLauncher.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
|
||||
startActivity(callHomeSettingIntent)
|
||||
}
|
||||
|
||||
settings_meta_button_view_tutorial.setOnClickListener {
|
||||
binding.settingsMetaButtonViewTutorial.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
startActivity(Intent(this.context, TutorialActivity::class.java))
|
||||
}
|
||||
|
||||
// prompting for settings-reset confirmation
|
||||
settings_meta_button_reset_settings.setOnClickListener {
|
||||
AlertDialog.Builder(this.context!!, R.style.AlertDialogCustom)
|
||||
binding.settingsMetaButtonResetSettings.setOnClickListener {
|
||||
AlertDialog.Builder(this.requireContext(), R.style.AlertDialogCustom)
|
||||
.setTitle(getString(R.string.settings_meta_reset))
|
||||
.setMessage(getString(R.string.settings_meta_reset_confirm))
|
||||
.setPositiveButton(android.R.string.ok
|
||||
) { _, _ ->
|
||||
resetSettings(this.context!!)
|
||||
activity!!.finish()
|
||||
resetSettings(this.requireContext())
|
||||
requireActivity().finish()
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
|
@ -96,7 +98,7 @@ class SettingsFragmentMeta : Fragment(), UIObject {
|
|||
|
||||
|
||||
// report a bug
|
||||
settings_meta_button_report_bug.setOnClickListener {
|
||||
binding.settingsMetaButtonReportBug.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
openNewTabWindow(
|
||||
getString(R.string.settings_meta_report_bug_link),
|
||||
|
@ -107,7 +109,7 @@ class SettingsFragmentMeta : Fragment(), UIObject {
|
|||
|
||||
|
||||
// contact developer
|
||||
settings_meta_button_contact.setOnClickListener {
|
||||
binding.settingsMetaButtonContact.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
openNewTabWindow(
|
||||
getString(R.string.settings_meta_contact_url),
|
||||
|
@ -116,7 +118,7 @@ class SettingsFragmentMeta : Fragment(), UIObject {
|
|||
}
|
||||
|
||||
// contact fork developer
|
||||
settings_meta_button_fork_contact.setOnClickListener {
|
||||
binding.settingsMetaButtonForkContact.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
openNewTabWindow(
|
||||
getString(R.string.settings_meta_fork_contact_url),
|
||||
|
@ -125,7 +127,7 @@ class SettingsFragmentMeta : Fragment(), UIObject {
|
|||
}
|
||||
|
||||
// privacy policy
|
||||
settings_meta_button_privacy.setOnClickListener {
|
||||
binding.settingsMetaButtonPrivacy.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
openNewTabWindow(
|
||||
getString(R.string.settings_meta_privacy_url),
|
||||
|
|
|
@ -8,23 +8,22 @@ import androidx.fragment.app.Fragment
|
|||
import de.jrpie.android.launcher.BuildConfig
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.UIObject
|
||||
import kotlinx.android.synthetic.main.tutorial_concept.*
|
||||
import kotlinx.android.synthetic.main.tutorial_concept.view.*
|
||||
|
||||
import de.jrpie.android.launcher.databinding.TutorialConceptBinding
|
||||
/**
|
||||
* The [TutorialFragmentConcept] is a used as a tab in the TutorialActivity.
|
||||
*
|
||||
* It is used to display info about Launchers concept (open source, efficiency ...)
|
||||
*/
|
||||
class TutorialFragmentConcept : Fragment(), UIObject {
|
||||
private lateinit var binding: TutorialConceptBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val layout = inflater.inflate(R.layout.tutorial_concept, container, false)
|
||||
layout.tutorial_concept_badge_version.text = BuildConfig.VERSION_NAME
|
||||
return layout
|
||||
val binding = TutorialConceptBinding.inflate(inflater, container, false)
|
||||
binding.tutorialConceptBadgeVersion.text = BuildConfig.VERSION_NAME
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import de.jrpie.android.launcher.*
|
||||
import de.jrpie.android.launcher.BuildConfig.VERSION_NAME
|
||||
import kotlinx.android.synthetic.main.tutorial_finish.*
|
||||
import de.jrpie.android.launcher.databinding.TutorialFinishBinding
|
||||
|
||||
/**
|
||||
* The [TutorialFragmentFinish] is a used as a tab in the TutorialActivity.
|
||||
|
@ -16,11 +16,14 @@ import kotlinx.android.synthetic.main.tutorial_finish.*
|
|||
*/
|
||||
class TutorialFragmentFinish : Fragment(), UIObject {
|
||||
|
||||
private lateinit var binding: TutorialFinishBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.tutorial_finish, container, false)
|
||||
binding = TutorialFinishBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -29,13 +32,13 @@ class TutorialFragmentFinish : Fragment(), UIObject {
|
|||
}
|
||||
|
||||
override fun applyTheme() {
|
||||
setButtonColor(tutorial_finish_button_start, vibrantColor)
|
||||
tutorial_finish_button_start.blink()
|
||||
setButtonColor(binding.tutorialFinishButtonStart, vibrantColor)
|
||||
binding.tutorialFinishButtonStart.blink()
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
super.setOnClicks()
|
||||
tutorial_finish_button_start.setOnClickListener{ finishTutorial() }
|
||||
binding.tutorialFinishButtonStart.setOnClickListener{ finishTutorial() }
|
||||
}
|
||||
|
||||
private fun finishTutorial() {
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import de.jrpie.android.launcher.*
|
||||
import kotlinx.android.synthetic.main.tutorial_start.*
|
||||
import de.jrpie.android.launcher.databinding.TutorialStartBinding
|
||||
|
||||
/**
|
||||
* The [TutorialFragmentStart] is a used as a tab in the TutorialActivity.
|
||||
|
@ -15,11 +15,13 @@ import kotlinx.android.synthetic.main.tutorial_start.*
|
|||
*/
|
||||
class TutorialFragmentStart : Fragment(), UIObject {
|
||||
|
||||
private lateinit var binding: TutorialStartBinding
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.tutorial_start, container, false)
|
||||
binding = TutorialStartBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
@ -29,8 +31,8 @@ class TutorialFragmentStart : Fragment(), UIObject {
|
|||
|
||||
override fun applyTheme() {
|
||||
|
||||
tutorial_start_icon_right.setTextColor(vibrantColor)
|
||||
tutorial_start_icon_right.blink()
|
||||
binding.tutorialStartIconRight.setTextColor(vibrantColor)
|
||||
binding.tutorialStartIconRight.blink()
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +1,18 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.6.21'
|
||||
ext.kotlin_version = '2.0.0'
|
||||
ext.android_plugin_version = '8.5.1'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.5.0'
|
||||
classpath 'com.android.tools.build:gradle:8.5.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.android.tools.build:gradle:$android_plugin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
@ -27,3 +30,4 @@ allprojects {
|
|||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Wed Dec 30 21:50:58 CET 2020
|
||||
#Wed Jul 31 15:46:24 CEST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
|
|
Loading…
Add table
Reference in a new issue