Migrate to viewbinding and kotlin gradle scripts
This commit is contained in:
parent
b2a2ee653c
commit
c15b3e4c6f
21 changed files with 475 additions and 398 deletions
|
@ -1,71 +0,0 @@
|
||||||
apply plugin: 'com.android.application'
|
|
||||||
apply plugin: 'kotlin-android'
|
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
apply plugin: 'kotlin-kapt'
|
|
||||||
|
|
||||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
||||||
def keystoreProperties = new Properties()
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 34
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.simplemobiletools.launcher"
|
|
||||||
minSdkVersion 26
|
|
||||||
targetSdkVersion 34
|
|
||||||
versionCode 8
|
|
||||||
versionName "5.0.6"
|
|
||||||
setProperty("archivesBaseName", "launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
signingConfigs {
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
release {
|
|
||||||
keyAlias keystoreProperties['keyAlias']
|
|
||||||
keyPassword keystoreProperties['keyPassword']
|
|
||||||
storeFile file(keystoreProperties['storeFile'])
|
|
||||||
storePassword keystoreProperties['storePassword']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
debug {
|
|
||||||
applicationIdSuffix ".debug"
|
|
||||||
}
|
|
||||||
release {
|
|
||||||
minifyEnabled true
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
signingConfig signingConfigs.release
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavorDimensions "variants"
|
|
||||||
productFlavors {
|
|
||||||
core {}
|
|
||||||
fdroid {}
|
|
||||||
prepaid {}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
|
||||||
}
|
|
||||||
|
|
||||||
lintOptions {
|
|
||||||
checkReleaseBuilds false
|
|
||||||
abortOnError false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0'
|
|
||||||
|
|
||||||
kapt "androidx.room:room-compiler:2.5.2"
|
|
||||||
implementation "androidx.room:room-runtime:2.5.2"
|
|
||||||
annotationProcessor "androidx.room:room-compiler:2.5.2"
|
|
||||||
}
|
|
96
app/build.gradle.kts
Normal file
96
app/build.gradle.kts
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.jetbrains.kotlin.konan.properties.Properties
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android)
|
||||||
|
alias(libs.plugins.kotlinAndroid)
|
||||||
|
alias(libs.plugins.ksp)
|
||||||
|
}
|
||||||
|
|
||||||
|
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = libs.versions.app.version.appId.get()
|
||||||
|
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
|
||||||
|
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
|
||||||
|
versionName = project.libs.versions.app.version.versionName.get()
|
||||||
|
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
|
||||||
|
setProperty("archivesBaseName", "launcher")
|
||||||
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
register("release") {
|
||||||
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||||
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||||
|
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||||
|
storePassword = keystoreProperties.getProperty("storePassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding = true
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix = ".debug"
|
||||||
|
}
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
signingConfig = signingConfigs.getByName("release")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flavorDimensions.add("variants")
|
||||||
|
productFlavors {
|
||||||
|
register("core")
|
||||||
|
register("fdroid")
|
||||||
|
register("prepaid")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
getByName("main").java.srcDirs("src/main/kotlin")
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
|
||||||
|
sourceCompatibility = currentJavaVersionFromLibs
|
||||||
|
targetCompatibility = currentJavaVersionFromLibs
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace = libs.versions.app.version.appId.get()
|
||||||
|
|
||||||
|
lint {
|
||||||
|
checkReleaseBuilds = false
|
||||||
|
abortOnError = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.simple.tools.commons)
|
||||||
|
|
||||||
|
implementation(libs.bundles.room)
|
||||||
|
ksp(libs.androidx.room.compiler)
|
||||||
|
}
|
|
@ -9,31 +9,33 @@ import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.launcher.R
|
|
||||||
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
||||||
|
import com.simplemobiletools.launcher.databinding.ActivityHiddenIconsBinding
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
||||||
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
||||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||||
import kotlinx.android.synthetic.main.activity_hidden_icons.*
|
|
||||||
|
|
||||||
class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
private lateinit var binding: ActivityHiddenIconsBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_hidden_icons)
|
binding = ActivityHiddenIconsBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
updateIcons()
|
updateIcons()
|
||||||
|
|
||||||
updateMaterialActivityViews(manage_hidden_icons_coordinator, manage_hidden_icons_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.manageHiddenIconsCoordinator, binding.manageHiddenIconsList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(manage_hidden_icons_list, manage_hidden_icons_toolbar)
|
setupMaterialScrollListener(binding.manageHiddenIconsList, binding.manageHiddenIconsToolbar)
|
||||||
|
|
||||||
val layoutManager = manage_hidden_icons_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.manageHiddenIconsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = config.drawerColumnCount
|
layoutManager.spanCount = config.drawerColumnCount
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(manage_hidden_icons_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.manageHiddenIconsToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateIcons() {
|
private fun updateIcons() {
|
||||||
|
@ -48,7 +50,7 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
val hiddenIconsEmpty = hiddenIcons.isEmpty()
|
val hiddenIconsEmpty = hiddenIcons.isEmpty()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
manage_hidden_icons_placeholder.beVisibleIf(hiddenIconsEmpty)
|
binding.manageHiddenIconsPlaceholder.beVisibleIf(hiddenIconsEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hiddenIcons.isNotEmpty()) {
|
if (hiddenIcons.isNotEmpty()) {
|
||||||
|
@ -77,9 +79,9 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
HiddenIconsAdapter(this, hiddenIcons, this, manage_hidden_icons_list) {
|
HiddenIconsAdapter(this, hiddenIcons, this, binding.manageHiddenIconsList) {
|
||||||
}.apply {
|
}.apply {
|
||||||
manage_hidden_icons_list.adapter = this
|
binding.manageHiddenIconsList.adapter = this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,25 +33,24 @@ import androidx.core.view.GestureDetectorCompat
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.iterator
|
import androidx.core.view.iterator
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.launcher.BuildConfig
|
import com.simplemobiletools.launcher.BuildConfig
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
|
import com.simplemobiletools.launcher.databinding.ActivityMainBinding
|
||||||
|
import com.simplemobiletools.launcher.databinding.AllAppsFragmentBinding
|
||||||
|
import com.simplemobiletools.launcher.databinding.WidgetsFragmentBinding
|
||||||
import com.simplemobiletools.launcher.dialogs.RenameItemDialog
|
import com.simplemobiletools.launcher.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.launcher.extensions.*
|
import com.simplemobiletools.launcher.extensions.*
|
||||||
import com.simplemobiletools.launcher.fragments.AllAppsFragment
|
|
||||||
import com.simplemobiletools.launcher.fragments.MyFragment
|
import com.simplemobiletools.launcher.fragments.MyFragment
|
||||||
import com.simplemobiletools.launcher.fragments.WidgetsFragment
|
|
||||||
import com.simplemobiletools.launcher.helpers.*
|
import com.simplemobiletools.launcher.helpers.*
|
||||||
import com.simplemobiletools.launcher.interfaces.FlingListener
|
import com.simplemobiletools.launcher.interfaces.FlingListener
|
||||||
import com.simplemobiletools.launcher.models.AppLauncher
|
import com.simplemobiletools.launcher.models.AppLauncher
|
||||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import kotlinx.android.synthetic.main.activity_main.view.*
|
|
||||||
import kotlinx.android.synthetic.main.all_apps_fragment.view.*
|
|
||||||
import kotlinx.android.synthetic.main.widgets_fragment.view.*
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), FlingListener {
|
class MainActivity : SimpleActivity(), FlingListener {
|
||||||
private var mTouchDownX = -1
|
private var mTouchDownX = -1
|
||||||
|
@ -72,6 +71,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
private var wasJustPaused: Boolean = false
|
private var wasJustPaused: Boolean = false
|
||||||
|
|
||||||
private lateinit var mDetector: GestureDetectorCompat
|
private lateinit var mDetector: GestureDetectorCompat
|
||||||
|
private lateinit var binding: ActivityMainBinding
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var mLastUpEvent = 0L
|
private var mLastUpEvent = 0L
|
||||||
|
@ -83,7 +83,8 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
|
|
||||||
mDetector = GestureDetectorCompat(this, MyGestureListener(this))
|
mDetector = GestureDetectorCompat(this, MyGestureListener(this))
|
||||||
|
@ -95,7 +96,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
mWidgetsFragmentY = mScreenHeight
|
mWidgetsFragmentY = mScreenHeight
|
||||||
mMoveGestureThreshold = resources.getDimensionPixelSize(R.dimen.move_gesture_threshold)
|
mMoveGestureThreshold = resources.getDimensionPixelSize(R.dimen.move_gesture_threshold)
|
||||||
|
|
||||||
arrayOf(all_apps_fragment as MyFragment, widgets_fragment as MyFragment).forEach { fragment ->
|
arrayOf(binding.allAppsFragment.root as MyFragment<*>, binding.widgetsFragment.root as MyFragment<*>).forEach { fragment ->
|
||||||
fragment.setupFragment(this)
|
fragment.setupFragment(this)
|
||||||
fragment.y = mScreenHeight.toFloat()
|
fragment.y = mScreenHeight.toFloat()
|
||||||
fragment.beVisible()
|
fragment.beVisible()
|
||||||
|
@ -103,12 +104,12 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
handleIntentAction(intent)
|
handleIntentAction(intent)
|
||||||
|
|
||||||
home_screen_grid.itemClickListener = {
|
binding.homeScreenGrid.root.itemClickListener = {
|
||||||
performItemClick(it)
|
performItemClick(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
home_screen_grid.itemLongClickListener = {
|
binding.homeScreenGrid.root.itemLongClickListener = {
|
||||||
performItemLongClick(home_screen_grid.getClickableRect(it).left.toFloat(), it)
|
performItemLongClick(binding.homeScreenGrid.root.getClickableRect(it).left.toFloat(), it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,10 +117,10 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
if (wasJustPaused) {
|
if (wasJustPaused) {
|
||||||
if (isAllAppsFragmentExpanded()) {
|
if (isAllAppsFragmentExpanded()) {
|
||||||
hideFragment(all_apps_fragment)
|
hideFragment(binding.allAppsFragment)
|
||||||
}
|
}
|
||||||
if (isWidgetsFragmentExpanded()) {
|
if (isWidgetsFragmentExpanded()) {
|
||||||
hideFragment(widgets_fragment)
|
hideFragment(binding.widgetsFragment)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
closeAppDrawer()
|
closeAppDrawer()
|
||||||
|
@ -163,14 +164,14 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
)
|
)
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
home_screen_grid.skipToPage(page)
|
binding.homeScreenGrid.root.skipToPage(page)
|
||||||
}
|
}
|
||||||
// delay showing the shortcut both to let the user see adding it in realtime and hackily avoid concurrent modification exception at HomeScreenGrid
|
// delay showing the shortcut both to let the user see adding it in realtime and hackily avoid concurrent modification exception at HomeScreenGrid
|
||||||
Thread.sleep(2000)
|
Thread.sleep(2000)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item.accept()
|
item.accept()
|
||||||
home_screen_grid.storeAndShowGridItem(gridItem)
|
binding.homeScreenGrid.root.storeAndShowGridItem(gridItem)
|
||||||
} catch (ignored: IllegalStateException) {
|
} catch (ignored: IllegalStateException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +206,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
home_screen_grid.appWidgetHost.startListening()
|
binding.homeScreenGrid.root.appWidgetHost.startListening()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -213,11 +214,11 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
wasJustPaused = false
|
wasJustPaused = false
|
||||||
updateStatusbarColor(Color.TRANSPARENT)
|
updateStatusbarColor(Color.TRANSPARENT)
|
||||||
|
|
||||||
main_holder.onGlobalLayout {
|
binding.mainHolder.onGlobalLayout {
|
||||||
if (isPiePlus()) {
|
if (isPiePlus()) {
|
||||||
val addTopPadding = main_holder.rootWindowInsets?.displayCutout != null
|
val addTopPadding = binding.mainHolder.rootWindowInsets?.displayCutout != null
|
||||||
(all_apps_fragment as AllAppsFragment).setupViews(addTopPadding)
|
binding.allAppsFragment.root.setupViews(addTopPadding)
|
||||||
(widgets_fragment as WidgetsFragment).setupViews(addTopPadding)
|
binding.widgetsFragment.root.setupViews(addTopPadding)
|
||||||
updateStatusbarColor(Color.TRANSPARENT)
|
updateStatusbarColor(Color.TRANSPARENT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,7 +240,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
showIcon
|
showIcon
|
||||||
}.toMutableList() as ArrayList<AppLauncher>
|
}.toMutableList() as ArrayList<AppLauncher>
|
||||||
|
|
||||||
(all_apps_fragment as AllAppsFragment).gotLaunchers(mCachedLaunchers)
|
binding.allAppsFragment.root.gotLaunchers(mCachedLaunchers)
|
||||||
}
|
}
|
||||||
|
|
||||||
refetchLaunchers()
|
refetchLaunchers()
|
||||||
|
@ -250,16 +251,16 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
window.navigationBarColor = Color.TRANSPARENT
|
window.navigationBarColor = Color.TRANSPARENT
|
||||||
}
|
}
|
||||||
|
|
||||||
home_screen_grid?.resizeGrid(
|
binding.homeScreenGrid.root.resizeGrid(
|
||||||
newRowCount = config.homeRowCount,
|
newRowCount = config.homeRowCount,
|
||||||
newColumnCount = config.homeColumnCount
|
newColumnCount = config.homeColumnCount
|
||||||
)
|
)
|
||||||
(all_apps_fragment as? AllAppsFragment)?.onResume()
|
binding.allAppsFragment.root.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onStop()
|
super.onStop()
|
||||||
home_screen_grid?.appWidgetHost?.stopListening()
|
binding.homeScreenGrid.root.appWidgetHost?.stopListening()
|
||||||
wasJustPaused = false
|
wasJustPaused = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,15 +269,16 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
wasJustPaused = true
|
wasJustPaused = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingSuperCall")
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (isAllAppsFragmentExpanded()) {
|
if (isAllAppsFragmentExpanded()) {
|
||||||
if ((all_apps_fragment as? AllAppsFragment)?.onBackPressed() == false) {
|
if (!binding.allAppsFragment.root.onBackPressed()) {
|
||||||
hideFragment(all_apps_fragment)
|
hideFragment(binding.allAppsFragment)
|
||||||
}
|
}
|
||||||
} else if (isWidgetsFragmentExpanded()) {
|
} else if (isWidgetsFragmentExpanded()) {
|
||||||
hideFragment(widgets_fragment)
|
hideFragment(binding.widgetsFragment)
|
||||||
} else if (home_screen_grid.resize_frame.isVisible) {
|
} else if (binding.homeScreenGrid.resizeFrame.isVisible) {
|
||||||
home_screen_grid.hideResizeLines()
|
binding.homeScreenGrid.root.hideResizeLines()
|
||||||
} else {
|
} else {
|
||||||
// this is a home launcher app, avoid glitching by pressing Back
|
// this is a home launcher app, avoid glitching by pressing Back
|
||||||
//super.onBackPressed()
|
//super.onBackPressed()
|
||||||
|
@ -311,8 +313,8 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
(all_apps_fragment as? AllAppsFragment)?.onConfigurationChanged()
|
binding.allAppsFragment.root.onConfigurationChanged()
|
||||||
(widgets_fragment as? WidgetsFragment)?.onConfigurationChanged()
|
binding.widgetsFragment.root.onConfigurationChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
||||||
|
@ -333,8 +335,8 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
mTouchDownX = event.x.toInt()
|
mTouchDownX = event.x.toInt()
|
||||||
mTouchDownY = event.y.toInt()
|
mTouchDownY = event.y.toInt()
|
||||||
mAllAppsFragmentY = all_apps_fragment.y.toInt()
|
mAllAppsFragmentY = binding.allAppsFragment.root.y.toInt()
|
||||||
mWidgetsFragmentY = widgets_fragment.y.toInt()
|
mWidgetsFragmentY = binding.widgetsFragment.root.y.toInt()
|
||||||
mIgnoreUpEvent = false
|
mIgnoreUpEvent = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,12 +353,12 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
if (mLongPressedIcon != null && mOpenPopupMenu != null && hasFingerMoved) {
|
if (mLongPressedIcon != null && mOpenPopupMenu != null && hasFingerMoved) {
|
||||||
mOpenPopupMenu?.dismiss()
|
mOpenPopupMenu?.dismiss()
|
||||||
mOpenPopupMenu = null
|
mOpenPopupMenu = null
|
||||||
home_screen_grid.itemDraggingStarted(mLongPressedIcon!!)
|
binding.homeScreenGrid.root.itemDraggingStarted(mLongPressedIcon!!)
|
||||||
hideFragment(all_apps_fragment)
|
hideFragment(binding.allAppsFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLongPressedIcon != null && hasFingerMoved) {
|
if (mLongPressedIcon != null && hasFingerMoved) {
|
||||||
home_screen_grid.draggedItemMoved(event.x.toInt(), event.y.toInt())
|
binding.homeScreenGrid.root.draggedItemMoved(event.x.toInt(), event.y.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFingerMoved && !mIgnoreMoveEvents) {
|
if (hasFingerMoved && !mIgnoreMoveEvents) {
|
||||||
|
@ -364,10 +366,10 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
if (isWidgetsFragmentExpanded()) {
|
if (isWidgetsFragmentExpanded()) {
|
||||||
val newY = mWidgetsFragmentY - diffY
|
val newY = mWidgetsFragmentY - diffY
|
||||||
widgets_fragment.y = Math.min(Math.max(0f, newY), mScreenHeight.toFloat())
|
binding.widgetsFragment.root.y = Math.min(Math.max(0f, newY), mScreenHeight.toFloat())
|
||||||
} else if (mLongPressedIcon == null) {
|
} else if (mLongPressedIcon == null) {
|
||||||
val newY = mAllAppsFragmentY - diffY
|
val newY = mAllAppsFragmentY - diffY
|
||||||
all_apps_fragment.y = Math.min(Math.max(0f, newY), mScreenHeight.toFloat())
|
binding.allAppsFragment.root.y = Math.min(Math.max(0f, newY), mScreenHeight.toFloat())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,19 +384,19 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
mLongPressedIcon = null
|
mLongPressedIcon = null
|
||||||
mLastTouchCoords = Pair(-1f, -1f)
|
mLastTouchCoords = Pair(-1f, -1f)
|
||||||
resetFragmentTouches()
|
resetFragmentTouches()
|
||||||
home_screen_grid.itemDraggingStopped()
|
binding.homeScreenGrid.root.itemDraggingStopped()
|
||||||
|
|
||||||
if (!mIgnoreUpEvent) {
|
if (!mIgnoreUpEvent) {
|
||||||
if (all_apps_fragment.y < mScreenHeight * 0.5) {
|
if (binding.allAppsFragment.root.y < mScreenHeight * 0.5) {
|
||||||
showFragment(all_apps_fragment)
|
showFragment(binding.allAppsFragment)
|
||||||
} else if (isAllAppsFragmentExpanded()) {
|
} else if (isAllAppsFragmentExpanded()) {
|
||||||
hideFragment(all_apps_fragment)
|
hideFragment(binding.allAppsFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widgets_fragment.y < mScreenHeight * 0.5) {
|
if (binding.widgetsFragment.root.y < mScreenHeight * 0.5) {
|
||||||
showFragment(widgets_fragment)
|
showFragment(binding.widgetsFragment)
|
||||||
} else if (isWidgetsFragmentExpanded()) {
|
} else if (isWidgetsFragmentExpanded()) {
|
||||||
hideFragment(widgets_fragment)
|
hideFragment(binding.widgetsFragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,8 +411,8 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
private fun refetchLaunchers() {
|
private fun refetchLaunchers() {
|
||||||
val launchers = getAllAppLaunchers()
|
val launchers = getAllAppLaunchers()
|
||||||
(all_apps_fragment as AllAppsFragment).gotLaunchers(launchers)
|
binding.allAppsFragment.root.gotLaunchers(launchers)
|
||||||
(widgets_fragment as WidgetsFragment).getAppWidgets()
|
binding.widgetsFragment.root.getAppWidgets()
|
||||||
|
|
||||||
var hasDeletedAnything = false
|
var hasDeletedAnything = false
|
||||||
mCachedLaunchers.map { it.packageName }.forEach { packageName ->
|
mCachedLaunchers.map { it.packageName }.forEach { packageName ->
|
||||||
|
@ -422,7 +424,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDeletedAnything) {
|
if (hasDeletedAnything) {
|
||||||
home_screen_grid.fetchGridItems()
|
binding.homeScreenGrid.root.fetchGridItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
mCachedLaunchers = launchers
|
mCachedLaunchers = launchers
|
||||||
|
@ -431,52 +433,52 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
getDefaultAppPackages(launchers)
|
getDefaultAppPackages(launchers)
|
||||||
config.wasHomeScreenInit = true
|
config.wasHomeScreenInit = true
|
||||||
home_screen_grid.fetchGridItems()
|
binding.homeScreenGrid.root.fetchGridItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isAllAppsFragmentExpanded() = all_apps_fragment.y != mScreenHeight.toFloat()
|
fun isAllAppsFragmentExpanded() = binding.allAppsFragment.root.y != mScreenHeight.toFloat()
|
||||||
|
|
||||||
private fun isWidgetsFragmentExpanded() = widgets_fragment.y != mScreenHeight.toFloat()
|
private fun isWidgetsFragmentExpanded() = binding.widgetsFragment.root.y != mScreenHeight.toFloat()
|
||||||
|
|
||||||
fun startHandlingTouches(touchDownY: Int) {
|
fun startHandlingTouches(touchDownY: Int) {
|
||||||
mLongPressedIcon = null
|
mLongPressedIcon = null
|
||||||
mTouchDownY = touchDownY
|
mTouchDownY = touchDownY
|
||||||
mAllAppsFragmentY = all_apps_fragment.y.toInt()
|
mAllAppsFragmentY = binding.allAppsFragment.root.y.toInt()
|
||||||
mWidgetsFragmentY = widgets_fragment.y.toInt()
|
mWidgetsFragmentY = binding.widgetsFragment.root.y.toInt()
|
||||||
mIgnoreUpEvent = false
|
mIgnoreUpEvent = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showFragment(fragment: View) {
|
private fun showFragment(fragment: ViewBinding) {
|
||||||
ObjectAnimator.ofFloat(fragment, "y", 0f).apply {
|
ObjectAnimator.ofFloat(fragment.root, "y", 0f).apply {
|
||||||
duration = ANIMATION_DURATION
|
duration = ANIMATION_DURATION
|
||||||
interpolator = DecelerateInterpolator()
|
interpolator = DecelerateInterpolator()
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.navigationBarColor = resources.getColor(R.color.semitransparent_navigation)
|
window.navigationBarColor = resources.getColor(R.color.semitransparent_navigation)
|
||||||
home_screen_grid.fragmentExpanded()
|
binding.homeScreenGrid.root.fragmentExpanded()
|
||||||
home_screen_grid.hideResizeLines()
|
binding.homeScreenGrid.root.hideResizeLines()
|
||||||
fragment.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null)
|
fragment.root.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideFragment(fragment: View) {
|
private fun hideFragment(fragment: ViewBinding) {
|
||||||
ObjectAnimator.ofFloat(fragment, "y", mScreenHeight.toFloat()).apply {
|
ObjectAnimator.ofFloat(fragment.root, "y", mScreenHeight.toFloat()).apply {
|
||||||
duration = ANIMATION_DURATION
|
duration = ANIMATION_DURATION
|
||||||
interpolator = DecelerateInterpolator()
|
interpolator = DecelerateInterpolator()
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.navigationBarColor = Color.TRANSPARENT
|
window.navigationBarColor = Color.TRANSPARENT
|
||||||
home_screen_grid.fragmentCollapsed()
|
binding.homeScreenGrid.root.fragmentCollapsed()
|
||||||
Handler().postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
if (fragment is AllAppsFragment) {
|
if (fragment is AllAppsFragmentBinding) {
|
||||||
fragment.all_apps_grid.scrollToPosition(0)
|
fragment.allAppsGrid.scrollToPosition(0)
|
||||||
fragment.touchDownY = -1
|
fragment.root.touchDownY = -1
|
||||||
} else if (fragment is WidgetsFragment) {
|
} else if (fragment is WidgetsFragmentBinding) {
|
||||||
fragment.widgets_list.scrollToPosition(0)
|
fragment.widgetsList.scrollToPosition(0)
|
||||||
fragment.touchDownY = -1
|
fragment.root.touchDownY = -1
|
||||||
}
|
}
|
||||||
}, ANIMATION_DURATION)
|
}, ANIMATION_DURATION)
|
||||||
}
|
}
|
||||||
|
@ -486,22 +488,22 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val (x, y) = home_screen_grid.intoViewSpaceCoords(eventX, eventY)
|
val (x, y) = binding.homeScreenGrid.root.intoViewSpaceCoords(eventX, eventY)
|
||||||
mIgnoreMoveEvents = true
|
mIgnoreMoveEvents = true
|
||||||
val clickedGridItem = home_screen_grid.isClickingGridItem(x.toInt(), y.toInt())
|
val clickedGridItem = binding.homeScreenGrid.root.isClickingGridItem(x.toInt(), y.toInt())
|
||||||
if (clickedGridItem != null) {
|
if (clickedGridItem != null) {
|
||||||
performItemLongClick(x, clickedGridItem)
|
performItemLongClick(x, clickedGridItem)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
main_holder.performHapticFeedback()
|
binding.mainHolder.performHapticFeedback()
|
||||||
showMainLongPressMenu(x, y)
|
showMainLongPressMenu(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun homeScreenClicked(eventX: Float, eventY: Float) {
|
fun homeScreenClicked(eventX: Float, eventY: Float) {
|
||||||
home_screen_grid.hideResizeLines()
|
binding.homeScreenGrid.root.hideResizeLines()
|
||||||
val (x, y) = home_screen_grid.intoViewSpaceCoords(eventX, eventY)
|
val (x, y) = binding.homeScreenGrid.root.intoViewSpaceCoords(eventX, eventY)
|
||||||
val clickedGridItem = home_screen_grid.isClickingGridItem(x.toInt(), y.toInt())
|
val clickedGridItem = binding.homeScreenGrid.root.isClickingGridItem(x.toInt(), y.toInt())
|
||||||
if (clickedGridItem != null) {
|
if (clickedGridItem != null) {
|
||||||
performItemClick(clickedGridItem)
|
performItemClick(clickedGridItem)
|
||||||
}
|
}
|
||||||
|
@ -510,10 +512,10 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
fun closeAppDrawer(delayed: Boolean = false) {
|
fun closeAppDrawer(delayed: Boolean = false) {
|
||||||
if (isAllAppsFragmentExpanded()) {
|
if (isAllAppsFragmentExpanded()) {
|
||||||
val close = {
|
val close = {
|
||||||
all_apps_fragment.y = mScreenHeight.toFloat()
|
binding.allAppsFragment.root.y = mScreenHeight.toFloat()
|
||||||
all_apps_fragment.all_apps_grid.scrollToPosition(0)
|
binding.allAppsFragment.allAppsGrid.scrollToPosition(0)
|
||||||
(all_apps_fragment as AllAppsFragment).touchDownY = -1
|
binding.allAppsFragment.root.touchDownY = -1
|
||||||
home_screen_grid.fragmentCollapsed()
|
binding.homeScreenGrid.root.fragmentCollapsed()
|
||||||
}
|
}
|
||||||
if (delayed) {
|
if (delayed) {
|
||||||
Handler(Looper.getMainLooper()).postDelayed(close, APP_DRAWER_CLOSE_DELAY)
|
Handler(Looper.getMainLooper()).postDelayed(close, APP_DRAWER_CLOSE_DELAY)
|
||||||
|
@ -526,10 +528,10 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
fun closeWidgetsFragment(delayed: Boolean = false) {
|
fun closeWidgetsFragment(delayed: Boolean = false) {
|
||||||
if (isWidgetsFragmentExpanded()) {
|
if (isWidgetsFragmentExpanded()) {
|
||||||
val close = {
|
val close = {
|
||||||
widgets_fragment.y = mScreenHeight.toFloat()
|
binding.widgetsFragment.root.y = mScreenHeight.toFloat()
|
||||||
widgets_fragment.widgets_list.scrollToPosition(0)
|
binding.widgetsFragment.widgetsList.scrollToPosition(0)
|
||||||
(widgets_fragment as WidgetsFragment).touchDownY = -1
|
binding.widgetsFragment.root.touchDownY = -1
|
||||||
home_screen_grid.fragmentCollapsed()
|
binding.homeScreenGrid.root.fragmentCollapsed()
|
||||||
}
|
}
|
||||||
if (delayed) {
|
if (delayed) {
|
||||||
Handler(Looper.getMainLooper()).postDelayed(close, APP_DRAWER_CLOSE_DELAY)
|
Handler(Looper.getMainLooper()).postDelayed(close, APP_DRAWER_CLOSE_DELAY)
|
||||||
|
@ -546,7 +548,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
val id = clickedGridItem.shortcutId
|
val id = clickedGridItem.shortcutId
|
||||||
val packageName = clickedGridItem.packageName
|
val packageName = clickedGridItem.packageName
|
||||||
val userHandle = android.os.Process.myUserHandle()
|
val userHandle = android.os.Process.myUserHandle()
|
||||||
val shortcutBounds = home_screen_grid.getClickableRect(clickedGridItem)
|
val shortcutBounds = binding.homeScreenGrid.root.getClickableRect(clickedGridItem)
|
||||||
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
launcherApps.startShortcut(packageName, id, shortcutBounds, null, userHandle)
|
launcherApps.startShortcut(packageName, id, shortcutBounds, null, userHandle)
|
||||||
}
|
}
|
||||||
|
@ -554,44 +556,44 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
private fun performItemLongClick(x: Float, clickedGridItem: HomeScreenGridItem) {
|
private fun performItemLongClick(x: Float, clickedGridItem: HomeScreenGridItem) {
|
||||||
if (clickedGridItem.type == ITEM_TYPE_ICON || clickedGridItem.type == ITEM_TYPE_SHORTCUT) {
|
if (clickedGridItem.type == ITEM_TYPE_ICON || clickedGridItem.type == ITEM_TYPE_SHORTCUT) {
|
||||||
main_holder.performHapticFeedback()
|
binding.mainHolder.performHapticFeedback()
|
||||||
}
|
}
|
||||||
|
|
||||||
val anchorY = home_screen_grid.sideMargins.top + (clickedGridItem.top * home_screen_grid.cellHeight.toFloat())
|
val anchorY = binding.homeScreenGrid.root.sideMargins.top + (clickedGridItem.top * binding.homeScreenGrid.root.cellHeight.toFloat())
|
||||||
showHomeIconMenu(x, anchorY, clickedGridItem, false)
|
showHomeIconMenu(x, anchorY, clickedGridItem, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showHomeIconMenu(x: Float, y: Float, gridItem: HomeScreenGridItem, isOnAllAppsFragment: Boolean) {
|
fun showHomeIconMenu(x: Float, y: Float, gridItem: HomeScreenGridItem, isOnAllAppsFragment: Boolean) {
|
||||||
home_screen_grid.hideResizeLines()
|
binding.homeScreenGrid.root.hideResizeLines()
|
||||||
mLongPressedIcon = gridItem
|
mLongPressedIcon = gridItem
|
||||||
val anchorY = if (isOnAllAppsFragment || gridItem.type == ITEM_TYPE_WIDGET) {
|
val anchorY = if (isOnAllAppsFragment || gridItem.type == ITEM_TYPE_WIDGET) {
|
||||||
val iconSize = realScreenSize.x / config.drawerColumnCount
|
val iconSize = realScreenSize.x / config.drawerColumnCount
|
||||||
y - iconSize / 2f
|
y - iconSize / 2f
|
||||||
} else {
|
} else {
|
||||||
val clickableRect = home_screen_grid.getClickableRect(gridItem)
|
val clickableRect = binding.homeScreenGrid.root.getClickableRect(gridItem)
|
||||||
clickableRect.top.toFloat() - home_screen_grid.getCurrentIconSize() / 2f
|
clickableRect.top.toFloat() - binding.homeScreenGrid.root.getCurrentIconSize() / 2f
|
||||||
}
|
}
|
||||||
|
|
||||||
home_screen_popup_menu_anchor.x = x
|
binding.homeScreenPopupMenuAnchor.x = x
|
||||||
home_screen_popup_menu_anchor.y = anchorY
|
binding.homeScreenPopupMenuAnchor.y = anchorY
|
||||||
|
|
||||||
if (mOpenPopupMenu == null) {
|
if (mOpenPopupMenu == null) {
|
||||||
mOpenPopupMenu = handleGridItemPopupMenu(home_screen_popup_menu_anchor, gridItem, isOnAllAppsFragment)
|
mOpenPopupMenu = handleGridItemPopupMenu(binding.homeScreenPopupMenuAnchor, gridItem, isOnAllAppsFragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun widgetLongPressedOnList(gridItem: HomeScreenGridItem) {
|
fun widgetLongPressedOnList(gridItem: HomeScreenGridItem) {
|
||||||
mLongPressedIcon = gridItem
|
mLongPressedIcon = gridItem
|
||||||
hideFragment(widgets_fragment)
|
hideFragment(binding.widgetsFragment)
|
||||||
home_screen_grid.itemDraggingStarted(mLongPressedIcon!!)
|
binding.homeScreenGrid.root.itemDraggingStarted(mLongPressedIcon!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showMainLongPressMenu(x: Float, y: Float) {
|
private fun showMainLongPressMenu(x: Float, y: Float) {
|
||||||
home_screen_grid.hideResizeLines()
|
binding.homeScreenGrid.root.hideResizeLines()
|
||||||
home_screen_popup_menu_anchor.x = x
|
binding.homeScreenPopupMenuAnchor.x = x
|
||||||
home_screen_popup_menu_anchor.y = y - resources.getDimension(R.dimen.long_press_anchor_button_offset_y) * 2
|
binding.homeScreenPopupMenuAnchor.y = y - resources.getDimension(R.dimen.long_press_anchor_button_offset_y) * 2
|
||||||
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
|
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
|
||||||
PopupMenu(contextTheme, home_screen_popup_menu_anchor, Gravity.TOP or Gravity.END).apply {
|
PopupMenu(contextTheme, binding.homeScreenPopupMenuAnchor, Gravity.TOP or Gravity.END).apply {
|
||||||
inflate(R.menu.menu_home_screen)
|
inflate(R.menu.menu_home_screen)
|
||||||
setOnMenuItemClickListener { item ->
|
setOnMenuItemClickListener { item ->
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
|
@ -624,9 +626,9 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.hide_icon -> hideIcon(gridItem)
|
R.id.hide_icon -> hideIcon(gridItem)
|
||||||
R.id.rename -> renameItem(gridItem)
|
R.id.rename -> renameItem(gridItem)
|
||||||
R.id.resize -> home_screen_grid.widgetLongPressed(gridItem)
|
R.id.resize -> binding.homeScreenGrid.root.widgetLongPressed(gridItem)
|
||||||
R.id.app_info -> launchAppInfo(gridItem.packageName)
|
R.id.app_info -> launchAppInfo(gridItem.packageName)
|
||||||
R.id.remove -> home_screen_grid.removeAppIcon(gridItem)
|
R.id.remove -> binding.homeScreenGrid.root.removeAppIcon(gridItem)
|
||||||
R.id.uninstall -> uninstallApp(gridItem.packageName)
|
R.id.uninstall -> uninstallApp(gridItem.packageName)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
@ -651,19 +653,19 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetFragmentTouches() {
|
private fun resetFragmentTouches() {
|
||||||
(widgets_fragment as WidgetsFragment).apply {
|
binding.widgetsFragment.root.apply {
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
ignoreTouches = false
|
ignoreTouches = false
|
||||||
}
|
}
|
||||||
|
|
||||||
(all_apps_fragment as AllAppsFragment).apply {
|
binding.allAppsFragment.root.apply {
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
ignoreTouches = false
|
ignoreTouches = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showWidgetsFragment() {
|
private fun showWidgetsFragment() {
|
||||||
showFragment(widgets_fragment)
|
showFragment(binding.widgetsFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideIcon(item: HomeScreenGridItem) {
|
private fun hideIcon(item: HomeScreenGridItem) {
|
||||||
|
@ -672,14 +674,14 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
hiddenIconsDB.insert(hiddenIcon)
|
hiddenIconsDB.insert(hiddenIcon)
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
(all_apps_fragment as AllAppsFragment).hideIcon(item)
|
binding.allAppsFragment.root.hideIcon(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameItem(homeScreenGridItem: HomeScreenGridItem) {
|
private fun renameItem(homeScreenGridItem: HomeScreenGridItem) {
|
||||||
RenameItemDialog(this, homeScreenGridItem) {
|
RenameItemDialog(this, homeScreenGridItem) {
|
||||||
home_screen_grid.fetchGridItems()
|
binding.homeScreenGrid.root.fetchGridItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,7 +691,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.no_app_found)
|
toast(CommonsR.string.no_app_found)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -732,7 +734,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
override fun onFlingUp() {
|
override fun onFlingUp() {
|
||||||
if (!isWidgetsFragmentExpanded()) {
|
if (!isWidgetsFragmentExpanded()) {
|
||||||
mIgnoreUpEvent = true
|
mIgnoreUpEvent = true
|
||||||
showFragment(all_apps_fragment)
|
showFragment(binding.allAppsFragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,9 +742,9 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
override fun onFlingDown() {
|
override fun onFlingDown() {
|
||||||
mIgnoreUpEvent = true
|
mIgnoreUpEvent = true
|
||||||
if (isAllAppsFragmentExpanded()) {
|
if (isAllAppsFragmentExpanded()) {
|
||||||
hideFragment(all_apps_fragment)
|
hideFragment(binding.allAppsFragment)
|
||||||
} else if (isWidgetsFragmentExpanded()) {
|
} else if (isWidgetsFragmentExpanded()) {
|
||||||
hideFragment(widgets_fragment)
|
hideFragment(binding.widgetsFragment)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Class.forName("android.app.StatusBarManager").getMethod("expandNotificationsPanel").invoke(getSystemService("statusbar"))
|
Class.forName("android.app.StatusBarManager").getMethod("expandNotificationsPanel").invoke(getSystemService("statusbar"))
|
||||||
|
@ -753,12 +755,12 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
|
|
||||||
override fun onFlingRight() {
|
override fun onFlingRight() {
|
||||||
mIgnoreUpEvent = true
|
mIgnoreUpEvent = true
|
||||||
home_screen_grid.prevPage(redraw = true)
|
binding.homeScreenGrid.root.prevPage(redraw = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFlingLeft() {
|
override fun onFlingLeft() {
|
||||||
mIgnoreUpEvent = true
|
mIgnoreUpEvent = true
|
||||||
home_screen_grid.nextPage(redraw = true)
|
binding.homeScreenGrid.root.nextPage(redraw = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
|
|
|
@ -10,29 +10,33 @@ import com.simplemobiletools.commons.models.FAQItem
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.launcher.BuildConfig
|
import com.simplemobiletools.launcher.BuildConfig
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
|
import com.simplemobiletools.launcher.databinding.ActivitySettingsBinding
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.helpers.MAX_COLUMN_COUNT
|
import com.simplemobiletools.launcher.helpers.MAX_COLUMN_COUNT
|
||||||
import com.simplemobiletools.launcher.helpers.MAX_ROW_COUNT
|
import com.simplemobiletools.launcher.helpers.MAX_ROW_COUNT
|
||||||
import com.simplemobiletools.launcher.helpers.MIN_COLUMN_COUNT
|
import com.simplemobiletools.launcher.helpers.MIN_COLUMN_COUNT
|
||||||
import com.simplemobiletools.launcher.helpers.MIN_ROW_COUNT
|
import com.simplemobiletools.launcher.helpers.MIN_ROW_COUNT
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
|
private lateinit var binding: ActivitySettingsBinding
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
|
||||||
setupPurchaseThankYou()
|
setupPurchaseThankYou()
|
||||||
|
@ -45,20 +49,20 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupHomeColumnCount()
|
setupHomeColumnCount()
|
||||||
setupLanguage()
|
setupLanguage()
|
||||||
setupManageHiddenIcons()
|
setupManageHiddenIcons()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(binding.settingsHolder)
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
settings_color_customization_section_label,
|
binding.settingsColorCustomizationLabel,
|
||||||
settings_general_settings_label,
|
binding.settingsGeneralSettingsLabel,
|
||||||
settings_drawer_settings_label,
|
binding.settingsDrawerSettingsLabel,
|
||||||
settings_home_screen_label
|
binding.settingsHomeScreenLabel
|
||||||
).forEach {
|
).forEach {
|
||||||
it.setTextColor(getProperPrimaryColor())
|
it.setTextColor(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
settings_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.settingsToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.about -> launchAbout()
|
R.id.about -> launchAbout()
|
||||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
|
@ -69,50 +73,50 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
settings_toolbar.menu.apply {
|
binding.settingsToolbar.menu.apply {
|
||||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(CommonsR.bool.hide_google_relations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPurchaseThankYou() {
|
private fun setupPurchaseThankYou() {
|
||||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||||
settings_purchase_thank_you_holder.setOnClickListener {
|
binding.settingsPurchaseThankYouHolder.setOnClickListener {
|
||||||
launchPurchaseThankYouIntent()
|
launchPurchaseThankYouIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_color_customization_label.text = getCustomizeColorsString()
|
binding.settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||||
settings_color_customization_holder.setOnClickListener {
|
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||||
startCustomizationActivity()
|
startCustomizationActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
private fun setupUseEnglish() {
|
||||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||||
settings_use_english.isChecked = config.useEnglish
|
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||||
settings_use_english_holder.setOnClickListener {
|
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||||
settings_use_english.toggle()
|
binding.settingsUseEnglish.toggle()
|
||||||
config.useEnglish = settings_use_english.isChecked
|
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCloseAppDrawerOnOtherAppOpen() {
|
private fun setupCloseAppDrawerOnOtherAppOpen() {
|
||||||
settings_close_app_drawer_on_other_app.isChecked = config.closeAppDrawer
|
binding.settingsCloseAppDrawerOnOtherApp.isChecked = config.closeAppDrawer
|
||||||
settings_close_app_drawer_on_other_app_holder.setOnClickListener {
|
binding.settingsCloseAppDrawerOnOtherAppHolder.setOnClickListener {
|
||||||
settings_close_app_drawer_on_other_app.toggle()
|
binding.settingsCloseAppDrawerOnOtherApp.toggle()
|
||||||
config.closeAppDrawer = settings_close_app_drawer_on_other_app.isChecked
|
config.closeAppDrawer = binding.settingsCloseAppDrawerOnOtherApp.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDrawerColumnCount() {
|
private fun setupDrawerColumnCount() {
|
||||||
val currentColumnCount = config.drawerColumnCount
|
val currentColumnCount = config.drawerColumnCount
|
||||||
settings_drawer_column_count.text = currentColumnCount.toString()
|
binding.settingsDrawerColumnCount.text = currentColumnCount.toString()
|
||||||
settings_drawer_column_count_holder.setOnClickListener {
|
binding.settingsDrawerColumnCountHolder.setOnClickListener {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
for (i in 1..MAX_COLUMN_COUNT) {
|
for (i in 1..MAX_COLUMN_COUNT) {
|
||||||
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
|
items.add(RadioItem(i, resources.getQuantityString(CommonsR.plurals.column_counts, i, i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioGroupDialog(this, items, currentColumnCount) {
|
RadioGroupDialog(this, items, currentColumnCount) {
|
||||||
|
@ -127,20 +131,20 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupDrawerSearchBar() {
|
private fun setupDrawerSearchBar() {
|
||||||
val showSearchBar = config.showSearchBar
|
val showSearchBar = config.showSearchBar
|
||||||
settings_show_search_bar.isChecked = showSearchBar
|
binding.settingsShowSearchBar.isChecked = showSearchBar
|
||||||
settings_drawer_search_holder.setOnClickListener {
|
binding.settingsDrawerSearchHolder.setOnClickListener {
|
||||||
settings_show_search_bar.toggle()
|
binding.settingsShowSearchBar.toggle()
|
||||||
config.showSearchBar = settings_show_search_bar.isChecked
|
config.showSearchBar = binding.settingsShowSearchBar.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHomeRowCount() {
|
private fun setupHomeRowCount() {
|
||||||
val currentRowCount = config.homeRowCount
|
val currentRowCount = config.homeRowCount
|
||||||
settings_home_screen_row_count.text = currentRowCount.toString()
|
binding.settingsHomeScreenRowCount.text = currentRowCount.toString()
|
||||||
settings_home_screen_row_count_holder.setOnClickListener {
|
binding.settingsHomeScreenRowCountHolder.setOnClickListener {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
for (i in MIN_ROW_COUNT..MAX_ROW_COUNT) {
|
for (i in MIN_ROW_COUNT..MAX_ROW_COUNT) {
|
||||||
items.add(RadioItem(i, resources.getQuantityString(R.plurals.row_counts, i, i)))
|
items.add(RadioItem(i, resources.getQuantityString(CommonsR.plurals.row_counts, i, i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioGroupDialog(this, items, currentRowCount) {
|
RadioGroupDialog(this, items, currentRowCount) {
|
||||||
|
@ -155,11 +159,11 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupHomeColumnCount() {
|
private fun setupHomeColumnCount() {
|
||||||
val currentColumnCount = config.homeColumnCount
|
val currentColumnCount = config.homeColumnCount
|
||||||
settings_home_screen_column_count.text = currentColumnCount.toString()
|
binding.settingsHomeScreenColumnCount.text = currentColumnCount.toString()
|
||||||
settings_home_screen_column_count_holder.setOnClickListener {
|
binding.settingsHomeScreenColumnCountHolder.setOnClickListener {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
for (i in MIN_COLUMN_COUNT..MAX_COLUMN_COUNT) {
|
for (i in MIN_COLUMN_COUNT..MAX_COLUMN_COUNT) {
|
||||||
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
|
items.add(RadioItem(i, resources.getQuantityString(CommonsR.plurals.column_counts, i, i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioGroupDialog(this, items, currentColumnCount) {
|
RadioGroupDialog(this, items, currentColumnCount) {
|
||||||
|
@ -173,15 +177,15 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||||
settings_language_holder.setOnClickListener {
|
binding.settingsLanguageHolder.setOnClickListener {
|
||||||
launchChangeAppLanguageIntent()
|
launchChangeAppLanguageIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageHiddenIcons() {
|
private fun setupManageHiddenIcons() {
|
||||||
settings_manage_hidden_icons_holder.setOnClickListener {
|
binding.settingsManageHiddenIconsHolder.setOnClickListener {
|
||||||
startActivity(Intent(this, HiddenIconsActivity::class.java))
|
startActivity(Intent(this, HiddenIconsActivity::class.java))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,9 +194,9 @@ class SettingsActivity : SimpleActivity() {
|
||||||
val licenses = 0L
|
val licenses = 0L
|
||||||
val faqItems = ArrayList<FAQItem>()
|
val faqItems = ArrayList<FAQItem>()
|
||||||
|
|
||||||
if (!resources.getBoolean(R.bool.hide_google_relations)) {
|
if (!resources.getBoolean(CommonsR.bool.hide_google_relations)) {
|
||||||
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
|
faqItems.add(FAQItem(CommonsR.string.faq_2_title_commons, CommonsR.string.faq_2_text_commons))
|
||||||
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons))
|
faqItems.add(FAQItem(CommonsR.string.faq_6_title_commons, CommonsR.string.faq_6_text_commons))
|
||||||
}
|
}
|
||||||
|
|
||||||
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
||||||
|
|
|
@ -15,9 +15,9 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
|
import com.simplemobiletools.launcher.databinding.ItemHiddenIconBinding
|
||||||
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
||||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||||
import kotlinx.android.synthetic.main.item_hidden_icon.view.*
|
|
||||||
|
|
||||||
class HiddenIconsAdapter(
|
class HiddenIconsAdapter(
|
||||||
activity: BaseSimpleActivity,
|
activity: BaseSimpleActivity,
|
||||||
|
@ -56,7 +56,9 @@ class HiddenIconsAdapter(
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_hidden_icon, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemHiddenIconBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val folder = hiddenIcons[position]
|
val folder = hiddenIcons[position]
|
||||||
|
@ -101,11 +103,11 @@ class HiddenIconsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, icon: HiddenIcon) {
|
private fun setupView(view: View, icon: HiddenIcon) {
|
||||||
view.apply {
|
ItemHiddenIconBinding.bind(view).apply {
|
||||||
hidden_icon_holder?.isSelected = selectedKeys.contains(icon.hashCode())
|
hiddenIconHolder.isSelected = selectedKeys.contains(icon.hashCode())
|
||||||
hidden_icon_label.text = icon.title
|
hiddenIconLabel.text = icon.title
|
||||||
hidden_icon_label.setTextColor(textColor)
|
hiddenIconLabel.setTextColor(textColor)
|
||||||
hidden_icon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
hiddenIcon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
||||||
|
|
||||||
val factory = DrawableCrossFadeFactory.Builder(150).setCrossFadeEnabled(true).build()
|
val factory = DrawableCrossFadeFactory.Builder(150).setCrossFadeEnabled(true).build()
|
||||||
|
|
||||||
|
@ -113,7 +115,7 @@ class HiddenIconsAdapter(
|
||||||
.load(icon.drawable)
|
.load(icon.drawable)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.transition(DrawableTransitionOptions.withCrossFade(factory))
|
.transition(DrawableTransitionOptions.withCrossFade(factory))
|
||||||
.into(hidden_icon)
|
.into(hiddenIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.SimpleActivity
|
import com.simplemobiletools.launcher.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.launcher.databinding.ItemLauncherLabelBinding
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
||||||
import com.simplemobiletools.launcher.models.AppLauncher
|
import com.simplemobiletools.launcher.models.AppLauncher
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
|
||||||
|
|
||||||
class LaunchersAdapter(
|
class LaunchersAdapter(
|
||||||
val activity: SimpleActivity,
|
val activity: SimpleActivity,
|
||||||
|
@ -44,8 +44,8 @@ class LaunchersAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_launcher_label, parent, false)
|
val binding = ItemLauncherLabelBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
return ViewHolder(view)
|
return ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
@ -103,10 +103,11 @@ class LaunchersAdapter(
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(launcher: AppLauncher): View {
|
fun bindView(launcher: AppLauncher): View {
|
||||||
|
val binding = ItemLauncherLabelBinding.bind(itemView)
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
launcher_label.text = launcher.title
|
binding.launcherLabel.text = launcher.title
|
||||||
launcher_label.setTextColor(textColor)
|
binding.launcherLabel.setTextColor(textColor)
|
||||||
launcher_icon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
binding.launcherIcon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
||||||
|
|
||||||
val factory = DrawableCrossFadeFactory.Builder(150).setCrossFadeEnabled(true).build()
|
val factory = DrawableCrossFadeFactory.Builder(150).setCrossFadeEnabled(true).build()
|
||||||
val placeholderDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.placeholder_drawable, launcher.thumbnailColor)
|
val placeholderDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.placeholder_drawable, launcher.thumbnailColor)
|
||||||
|
@ -116,7 +117,7 @@ class LaunchersAdapter(
|
||||||
.placeholder(placeholderDrawable)
|
.placeholder(placeholderDrawable)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.transition(DrawableTransitionOptions.withCrossFade(factory))
|
.transition(DrawableTransitionOptions.withCrossFade(factory))
|
||||||
.into(launcher_icon)
|
.into(binding.launcherIcon)
|
||||||
|
|
||||||
setOnClickListener { itemClick(launcher) }
|
setOnClickListener { itemClick(launcher) }
|
||||||
setOnLongClickListener { view ->
|
setOnLongClickListener { view ->
|
||||||
|
|
|
@ -9,15 +9,16 @@ import com.bumptech.glide.Glide
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.SimpleActivity
|
import com.simplemobiletools.launcher.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.launcher.databinding.ItemWidgetListItemsHolderBinding
|
||||||
|
import com.simplemobiletools.launcher.databinding.ItemWidgetListSectionBinding
|
||||||
|
import com.simplemobiletools.launcher.databinding.ItemWidgetPreviewBinding
|
||||||
import com.simplemobiletools.launcher.helpers.WIDGET_LIST_ITEMS_HOLDER
|
import com.simplemobiletools.launcher.helpers.WIDGET_LIST_ITEMS_HOLDER
|
||||||
import com.simplemobiletools.launcher.helpers.WIDGET_LIST_SECTION
|
import com.simplemobiletools.launcher.helpers.WIDGET_LIST_SECTION
|
||||||
import com.simplemobiletools.launcher.interfaces.WidgetsFragmentListener
|
import com.simplemobiletools.launcher.interfaces.WidgetsFragmentListener
|
||||||
import com.simplemobiletools.launcher.models.WidgetsListItem
|
import com.simplemobiletools.launcher.models.WidgetsListItem
|
||||||
import com.simplemobiletools.launcher.models.WidgetsListItemsHolder
|
import com.simplemobiletools.launcher.models.WidgetsListItemsHolder
|
||||||
import com.simplemobiletools.launcher.models.WidgetsListSection
|
import com.simplemobiletools.launcher.models.WidgetsListSection
|
||||||
import kotlinx.android.synthetic.main.item_widget_list_items_holder.view.*
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
import kotlinx.android.synthetic.main.item_widget_list_section.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_widget_preview.view.*
|
|
||||||
|
|
||||||
class WidgetsAdapter(
|
class WidgetsAdapter(
|
||||||
val activity: SimpleActivity,
|
val activity: SimpleActivity,
|
||||||
|
@ -29,13 +30,13 @@ class WidgetsAdapter(
|
||||||
private var textColor = activity.getProperTextColor()
|
private var textColor = activity.getProperTextColor()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val layoutId = when (viewType) {
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
WIDGET_LIST_SECTION -> R.layout.item_widget_list_section
|
val binding = when (viewType) {
|
||||||
else -> R.layout.item_widget_list_items_holder
|
WIDGET_LIST_SECTION -> ItemWidgetListSectionBinding.inflate(inflater, parent, false)
|
||||||
|
else -> ItemWidgetListItemsHolderBinding.inflate(inflater, parent, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val view = LayoutInflater.from(parent.context).inflate(layoutId, parent, false)
|
return ViewHolder(binding.root)
|
||||||
return ViewHolder(view)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
@ -56,43 +57,44 @@ class WidgetsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListSection(view: View, section: WidgetsListSection) {
|
private fun setupListSection(view: View, section: WidgetsListSection) {
|
||||||
view.apply {
|
ItemWidgetListSectionBinding.bind(view).apply {
|
||||||
widget_app_title.text = section.appTitle
|
widgetAppTitle.text = section.appTitle
|
||||||
widget_app_title.setTextColor(textColor)
|
widgetAppTitle.setTextColor(textColor)
|
||||||
widget_app_icon.setImageDrawable(section.appIcon)
|
widgetAppIcon.setImageDrawable(section.appIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListItemsHolder(view: View, listItem: WidgetsListItemsHolder) {
|
private fun setupListItemsHolder(view: View, listItem: WidgetsListItemsHolder) {
|
||||||
view.widget_list_items_holder.removeAllViews()
|
val binding = ItemWidgetListItemsHolderBinding.bind(view)
|
||||||
view.widget_list_items_scroll_view.scrollX = 0
|
binding.widgetListItemsHolder.removeAllViews()
|
||||||
|
binding.widgetListItemsScrollView.scrollX = 0
|
||||||
listItem.widgets.forEachIndexed { index, widget ->
|
listItem.widgets.forEachIndexed { index, widget ->
|
||||||
val imageSize = activity.resources.getDimension(R.dimen.widget_preview_size).toInt()
|
val imageSize = activity.resources.getDimension(R.dimen.widget_preview_size).toInt()
|
||||||
val widgetPreview = LayoutInflater.from(activity).inflate(R.layout.item_widget_preview, null)
|
val widgetPreview = ItemWidgetPreviewBinding.inflate(LayoutInflater.from(activity))
|
||||||
view.widget_list_items_holder.addView(widgetPreview)
|
binding.widgetListItemsHolder.addView(widgetPreview.root)
|
||||||
|
|
||||||
val endMargin = if (index == listItem.widgets.size - 1) {
|
val endMargin = if (index == listItem.widgets.size - 1) {
|
||||||
activity.resources.getDimension(R.dimen.medium_margin).toInt()
|
activity.resources.getDimension(CommonsR.dimen.medium_margin).toInt()
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
widgetPreview.widget_title.apply {
|
widgetPreview.widgetTitle.apply {
|
||||||
text = widget.widgetTitle
|
text = widget.widgetTitle
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
widgetPreview.widget_size.apply {
|
widgetPreview.widgetSize.apply {
|
||||||
text = if (widget.isShortcut) {
|
text = if (widget.isShortcut) {
|
||||||
activity.getString(R.string.shortcut)
|
activity.getString(CommonsR.string.shortcut)
|
||||||
} else {
|
} else {
|
||||||
"${widget.widthCells} x ${widget.heightCells}"
|
"${widget.widthCells} x ${widget.heightCells}"
|
||||||
}
|
}
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
(widgetPreview.widget_image.layoutParams as RelativeLayout.LayoutParams).apply {
|
(widgetPreview.widgetImage.layoutParams as RelativeLayout.LayoutParams).apply {
|
||||||
marginStart = activity.resources.getDimension(R.dimen.activity_margin).toInt()
|
marginStart = activity.resources.getDimension(CommonsR.dimen.activity_margin).toInt()
|
||||||
marginEnd = endMargin
|
marginEnd = endMargin
|
||||||
width = imageSize
|
width = imageSize
|
||||||
height = imageSize
|
height = imageSize
|
||||||
|
@ -100,11 +102,11 @@ class WidgetsAdapter(
|
||||||
|
|
||||||
Glide.with(activity)
|
Glide.with(activity)
|
||||||
.load(widget.widgetPreviewImage)
|
.load(widget.widgetPreviewImage)
|
||||||
.into(widgetPreview.widget_image)
|
.into(widgetPreview.widgetImage)
|
||||||
|
|
||||||
widgetPreview.setOnClickListener { itemClick() }
|
widgetPreview.root.setOnClickListener { itemClick() }
|
||||||
|
|
||||||
widgetPreview.setOnLongClickListener { view ->
|
widgetPreview.root.setOnLongClickListener { view ->
|
||||||
widgetsFragmentListener.onWidgetLongPressed(widget)
|
widgetsFragmentListener.onWidgetLongPressed(widget)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,41 +2,41 @@ package com.simplemobiletools.launcher.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.helpers.mydebug
|
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
|
import com.simplemobiletools.launcher.databinding.DialogRenameItemBinding
|
||||||
import com.simplemobiletools.launcher.extensions.homeScreenGridItemsDB
|
import com.simplemobiletools.launcher.extensions.homeScreenGridItemsDB
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
import kotlinx.android.synthetic.main.dialog_rename_item.view.*
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
|
|
||||||
class RenameItemDialog(val activity: Activity, val item: HomeScreenGridItem, val callback: () -> Unit) {
|
class RenameItemDialog(val activity: Activity, val item: HomeScreenGridItem, val callback: () -> Unit) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_rename_item, null) as ViewGroup)
|
val binding = DialogRenameItemBinding.inflate(activity.layoutInflater)
|
||||||
view.rename_item_edittext.setText(item.title)
|
val view = binding.root
|
||||||
|
binding.renameItemEdittext.setText(item.title)
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(CommonsR.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(CommonsR.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.rename) { alertDialog ->
|
activity.setupDialogStuff(view, this, CommonsR.string.rename) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.rename_item_edittext)
|
alertDialog.showKeyboard(binding.renameItemEdittext)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val newTitle = view.rename_item_edittext.value
|
val newTitle = binding.renameItemEdittext.value
|
||||||
if (!newTitle.isEmpty()) {
|
if (newTitle.isNotEmpty()) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val result = activity.homeScreenGridItemsDB.updateItemTitle(newTitle, item.id!!)
|
val result = activity.homeScreenGridItemsDB.updateItemTitle(newTitle, item.id!!)
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
callback()
|
callback()
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
} else {
|
} else {
|
||||||
activity.toast(R.string.unknown_error_occurred)
|
activity.toast(CommonsR.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activity.toast(R.string.value_cannot_be_empty)
|
activity.toast(CommonsR.string.value_cannot_be_empty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,18 @@ import android.view.WindowManager
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.launcher.R
|
|
||||||
import com.simplemobiletools.launcher.activities.MainActivity
|
import com.simplemobiletools.launcher.activities.MainActivity
|
||||||
import com.simplemobiletools.launcher.adapters.LaunchersAdapter
|
import com.simplemobiletools.launcher.adapters.LaunchersAdapter
|
||||||
|
import com.simplemobiletools.launcher.databinding.AllAppsFragmentBinding
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.launchApp
|
import com.simplemobiletools.launcher.extensions.launchApp
|
||||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_ICON
|
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_ICON
|
||||||
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
import com.simplemobiletools.launcher.interfaces.AllAppsListener
|
||||||
import com.simplemobiletools.launcher.models.AppLauncher
|
import com.simplemobiletools.launcher.models.AppLauncher
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
import kotlinx.android.synthetic.main.all_apps_fragment.view.*
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
|
|
||||||
class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment(context, attributeSet), AllAppsListener {
|
class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment<AllAppsFragmentBinding>(context, attributeSet), AllAppsListener {
|
||||||
private var lastTouchCoords = Pair(0f, 0f)
|
private var lastTouchCoords = Pair(0f, 0f)
|
||||||
var touchDownY = -1
|
var touchDownY = -1
|
||||||
var ignoreTouches = false
|
var ignoreTouches = false
|
||||||
|
@ -30,8 +30,9 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun setupFragment(activity: MainActivity) {
|
override fun setupFragment(activity: MainActivity) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
|
this.binding = AllAppsFragmentBinding.bind(this)
|
||||||
|
|
||||||
all_apps_grid.setOnTouchListener { v, event ->
|
binding.allAppsGrid.setOnTouchListener { v, event ->
|
||||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) {
|
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) {
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
}
|
}
|
||||||
|
@ -42,30 +43,26 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
fun onResume() {
|
fun onResume() {
|
||||||
if (all_apps_grid?.layoutManager == null || all_apps_grid?.adapter == null) {
|
if (binding.allAppsGrid.layoutManager == null || binding.allAppsGrid.adapter == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.allAppsGrid.layoutManager as MyGridLayoutManager
|
||||||
if (layoutManager.spanCount != context.config.drawerColumnCount) {
|
if (layoutManager.spanCount != context.config.drawerColumnCount) {
|
||||||
onConfigurationChanged()
|
onConfigurationChanged()
|
||||||
// Force redraw due to changed item size
|
// Force redraw due to changed item size
|
||||||
(all_apps_grid.adapter as LaunchersAdapter).notifyDataSetChanged()
|
(binding.allAppsGrid.adapter as LaunchersAdapter).notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onConfigurationChanged() {
|
fun onConfigurationChanged() {
|
||||||
if (all_apps_grid == null) {
|
binding.allAppsGrid.scrollToPosition(0)
|
||||||
return
|
binding.allAppsFastscroller.resetManualScrolling()
|
||||||
}
|
|
||||||
|
|
||||||
all_apps_grid.scrollToPosition(0)
|
|
||||||
all_apps_fastscroller.resetManualScrolling()
|
|
||||||
setupViews()
|
setupViews()
|
||||||
|
|
||||||
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.allAppsGrid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context.config.drawerColumnCount
|
layoutManager.spanCount = context.config.drawerColumnCount
|
||||||
val launchers = (all_apps_grid.adapter as LaunchersAdapter).launchers
|
val launchers = (binding.allAppsGrid.adapter as LaunchersAdapter).launchers
|
||||||
setupAdapter(launchers)
|
setupAdapter(launchers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +84,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
|
|
||||||
// pull the whole fragment down if it is scrolled way to the top and the users pulls it even further
|
// pull the whole fragment down if it is scrolled way to the top and the users pulls it even further
|
||||||
if (touchDownY != -1) {
|
if (touchDownY != -1) {
|
||||||
shouldIntercept = touchDownY - event.y.toInt() < 0 && all_apps_grid.computeVerticalScrollOffset() == 0
|
shouldIntercept = touchDownY - event.y.toInt() < 0 && binding.allAppsGrid.computeVerticalScrollOffset() == 0
|
||||||
if (shouldIntercept) {
|
if (shouldIntercept) {
|
||||||
activity?.startHandlingTouches(touchDownY)
|
activity?.startHandlingTouches(touchDownY)
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
|
@ -113,10 +110,10 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
|
|
||||||
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
val layoutManager = all_apps_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.allAppsGrid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context.config.drawerColumnCount
|
layoutManager.spanCount = context.config.drawerColumnCount
|
||||||
|
|
||||||
val currAdapter = all_apps_grid.adapter
|
val currAdapter = binding.allAppsGrid.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
LaunchersAdapter(activity!!, launchers, this) {
|
LaunchersAdapter(activity!!, launchers, this) {
|
||||||
activity?.launchApp((it as AppLauncher).packageName, it.activityName)
|
activity?.launchApp((it as AppLauncher).packageName, it.activityName)
|
||||||
|
@ -126,7 +123,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
ignoreTouches = false
|
ignoreTouches = false
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
}.apply {
|
}.apply {
|
||||||
all_apps_grid.adapter = this
|
binding.allAppsGrid.adapter = this
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as LaunchersAdapter).updateItems(launchers)
|
(currAdapter as LaunchersAdapter).updateItems(launchers)
|
||||||
|
@ -135,7 +132,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hideIcon(item: HomeScreenGridItem) {
|
fun hideIcon(item: HomeScreenGridItem) {
|
||||||
(all_apps_grid.adapter as? LaunchersAdapter)?.hideIcon(item)
|
(binding.allAppsGrid.adapter as? LaunchersAdapter)?.hideIcon(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setupViews(addTopPadding: Boolean = hasTopPadding) {
|
fun setupViews(addTopPadding: Boolean = hasTopPadding) {
|
||||||
|
@ -143,7 +140,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
all_apps_fastscroller.updateColors(context.getProperPrimaryColor())
|
binding.allAppsFastscroller.updateColors(context.getProperPrimaryColor())
|
||||||
|
|
||||||
var bottomListPadding = 0
|
var bottomListPadding = 0
|
||||||
var leftListPadding = 0
|
var leftListPadding = 0
|
||||||
|
@ -169,29 +166,29 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
all_apps_grid.setPadding(0, 0, resources.getDimension(R.dimen.medium_margin).toInt(), bottomListPadding)
|
binding.allAppsGrid.setPadding(0, 0, resources.getDimension(CommonsR.dimen.medium_margin).toInt(), bottomListPadding)
|
||||||
all_apps_fastscroller.setPadding(leftListPadding, 0, rightListPadding, 0)
|
binding.allAppsFastscroller.setPadding(leftListPadding, 0, rightListPadding, 0)
|
||||||
|
|
||||||
hasTopPadding = addTopPadding
|
hasTopPadding = addTopPadding
|
||||||
val topPadding = if (addTopPadding) activity!!.statusBarHeight else 0
|
val topPadding = if (addTopPadding) activity!!.statusBarHeight else 0
|
||||||
setPadding(0, topPadding, 0, 0)
|
setPadding(0, topPadding, 0, 0)
|
||||||
background = ColorDrawable(context.getProperBackgroundColor())
|
background = ColorDrawable(context.getProperBackgroundColor())
|
||||||
(all_apps_grid.adapter as? LaunchersAdapter)?.updateTextColor(context.getProperTextColor())
|
(binding.allAppsGrid.adapter as? LaunchersAdapter)?.updateTextColor(context.getProperTextColor())
|
||||||
|
|
||||||
search_bar.beVisibleIf(context.config.showSearchBar)
|
binding.searchBar.beVisibleIf(context.config.showSearchBar)
|
||||||
search_bar.getToolbar()?.beGone()
|
binding.searchBar.getToolbar()?.beGone()
|
||||||
search_bar.updateColors()
|
binding.searchBar.updateColors()
|
||||||
search_bar.setupMenu()
|
binding.searchBar.setupMenu()
|
||||||
|
|
||||||
search_bar.onSearchTextChangedListener = {
|
binding.searchBar.onSearchTextChangedListener = {
|
||||||
(all_apps_grid.adapter as? LaunchersAdapter)?.updateSearchQuery(it)
|
(binding.allAppsGrid.adapter as? LaunchersAdapter)?.updateSearchQuery(it)
|
||||||
showNoResultsPlaceholderIfNeeded()
|
showNoResultsPlaceholderIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showNoResultsPlaceholderIfNeeded() {
|
private fun showNoResultsPlaceholderIfNeeded() {
|
||||||
val itemCount = all_apps_grid.adapter?.itemCount
|
val itemCount = binding.allAppsGrid.adapter?.itemCount
|
||||||
no_results_placeholder.beVisibleIf(itemCount != null && itemCount == 0)
|
binding.noResultsPlaceholder.beVisibleIf(itemCount != null && itemCount == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
|
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
|
||||||
|
@ -217,12 +214,12 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
activity?.showHomeIconMenu(x, y, gridItem, true)
|
activity?.showHomeIconMenu(x, y, gridItem, true)
|
||||||
ignoreTouches = true
|
ignoreTouches = true
|
||||||
|
|
||||||
search_bar.closeSearch()
|
binding.searchBar.closeSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onBackPressed(): Boolean {
|
fun onBackPressed(): Boolean {
|
||||||
if (search_bar.isSearchOpen) {
|
if (binding.searchBar.isSearchOpen) {
|
||||||
search_bar.closeSearch()
|
binding.searchBar.closeSearch()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,12 @@ package com.simplemobiletools.launcher.fragments
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.simplemobiletools.launcher.activities.MainActivity
|
import com.simplemobiletools.launcher.activities.MainActivity
|
||||||
|
|
||||||
abstract class MyFragment(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
abstract class MyFragment<BINDING : ViewBinding>(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
||||||
protected var activity: MainActivity? = null
|
protected var activity: MainActivity? = null
|
||||||
|
protected lateinit var binding: BINDING
|
||||||
|
|
||||||
abstract fun setupFragment(activity: MainActivity)
|
abstract fun setupFragment(activity: MainActivity)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,15 @@ import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.MainActivity
|
import com.simplemobiletools.launcher.activities.MainActivity
|
||||||
import com.simplemobiletools.launcher.adapters.WidgetsAdapter
|
import com.simplemobiletools.launcher.adapters.WidgetsAdapter
|
||||||
|
import com.simplemobiletools.launcher.databinding.WidgetsFragmentBinding
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.getInitialCellSize
|
import com.simplemobiletools.launcher.extensions.getInitialCellSize
|
||||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_SHORTCUT
|
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_SHORTCUT
|
||||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_WIDGET
|
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_WIDGET
|
||||||
import com.simplemobiletools.launcher.interfaces.WidgetsFragmentListener
|
import com.simplemobiletools.launcher.interfaces.WidgetsFragmentListener
|
||||||
import com.simplemobiletools.launcher.models.*
|
import com.simplemobiletools.launcher.models.*
|
||||||
import kotlinx.android.synthetic.main.widgets_fragment.view.*
|
|
||||||
|
|
||||||
class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment(context, attributeSet), WidgetsFragmentListener {
|
class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment<WidgetsFragmentBinding>(context, attributeSet), WidgetsFragmentListener {
|
||||||
private var lastTouchCoords = Pair(0f, 0f)
|
private var lastTouchCoords = Pair(0f, 0f)
|
||||||
var touchDownY = -1
|
var touchDownY = -1
|
||||||
var ignoreTouches = false
|
var ignoreTouches = false
|
||||||
|
@ -35,9 +35,10 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun setupFragment(activity: MainActivity) {
|
override fun setupFragment(activity: MainActivity) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
|
this.binding = WidgetsFragmentBinding.bind(this)
|
||||||
getAppWidgets()
|
getAppWidgets()
|
||||||
|
|
||||||
widgets_list.setOnTouchListener { v, event ->
|
binding.widgetsList.setOnTouchListener { v, event ->
|
||||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) {
|
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) {
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
}
|
}
|
||||||
|
@ -47,14 +48,14 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onConfigurationChanged() {
|
fun onConfigurationChanged() {
|
||||||
if (widgets_list == null) {
|
if (binding.widgetsList == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets_list.scrollToPosition(0)
|
binding.widgetsList.scrollToPosition(0)
|
||||||
setupViews()
|
setupViews()
|
||||||
|
|
||||||
val appWidgets = (widgets_list.adapter as WidgetsAdapter).widgetListItems
|
val appWidgets = (binding.widgetsList.adapter as WidgetsAdapter).widgetListItems
|
||||||
setupAdapter(appWidgets)
|
setupAdapter(appWidgets)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
|
|
||||||
// pull the whole fragment down if it is scrolled way to the top and the users pulls it even further
|
// pull the whole fragment down if it is scrolled way to the top and the users pulls it even further
|
||||||
if (touchDownY != -1) {
|
if (touchDownY != -1) {
|
||||||
shouldIntercept = touchDownY - event.y.toInt() < 0 && widgets_list.computeVerticalScrollOffset() == 0
|
shouldIntercept = touchDownY - event.y.toInt() < 0 && binding.widgetsList.computeVerticalScrollOffset() == 0
|
||||||
if (shouldIntercept) {
|
if (shouldIntercept) {
|
||||||
activity?.startHandlingTouches(touchDownY)
|
activity?.startHandlingTouches(touchDownY)
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
|
@ -159,14 +160,14 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
|
|
||||||
private fun setupAdapter(widgetsListItems: ArrayList<WidgetsListItem>) {
|
private fun setupAdapter(widgetsListItems: ArrayList<WidgetsListItem>) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
val currAdapter = widgets_list.adapter
|
val currAdapter = binding.widgetsList.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
WidgetsAdapter(activity!!, widgetsListItems, this) {
|
WidgetsAdapter(activity!!, widgetsListItems, this) {
|
||||||
context.toast(R.string.touch_hold_widget)
|
context.toast(R.string.touch_hold_widget)
|
||||||
ignoreTouches = false
|
ignoreTouches = false
|
||||||
touchDownY = -1
|
touchDownY = -1
|
||||||
}.apply {
|
}.apply {
|
||||||
widgets_list.adapter = this
|
binding.widgetsList.adapter = this
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as WidgetsAdapter).updateItems(widgetsListItems)
|
(currAdapter as WidgetsAdapter).updateItems(widgetsListItems)
|
||||||
|
@ -179,7 +180,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets_fastscroller.updateColors(context.getProperPrimaryColor())
|
binding.widgetsFastscroller.updateColors(context.getProperPrimaryColor())
|
||||||
|
|
||||||
var bottomListPadding = 0
|
var bottomListPadding = 0
|
||||||
var leftListPadding = 0
|
var leftListPadding = 0
|
||||||
|
@ -205,14 +206,14 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets_list.setPadding(0, 0, 0, bottomListPadding)
|
binding.widgetsList.setPadding(0, 0, 0, bottomListPadding)
|
||||||
widgets_fastscroller.setPadding(leftListPadding, 0, rightListPadding, 0)
|
binding.widgetsFastscroller.setPadding(leftListPadding, 0, rightListPadding, 0)
|
||||||
|
|
||||||
hasTopPadding = addTopPadding
|
hasTopPadding = addTopPadding
|
||||||
val topPadding = if (addTopPadding) activity!!.statusBarHeight else 0
|
val topPadding = if (addTopPadding) activity!!.statusBarHeight else 0
|
||||||
setPadding(0, topPadding, 0, 0)
|
setPadding(0, topPadding, 0, 0)
|
||||||
background = ColorDrawable(context.getProperBackgroundColor())
|
background = ColorDrawable(context.getProperBackgroundColor())
|
||||||
(widgets_list.adapter as? WidgetsAdapter)?.updateTextColor(context.getProperTextColor())
|
(binding.widgetsList.adapter as? WidgetsAdapter)?.updateTextColor(context.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAppMetadataFromPackage(packageName: String): WidgetsListSection? {
|
private fun getAppMetadataFromPackage(packageName: String): WidgetsListSection? {
|
||||||
|
|
|
@ -31,20 +31,22 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.helpers.isSPlus
|
import com.simplemobiletools.commons.helpers.isSPlus
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.MainActivity
|
import com.simplemobiletools.launcher.activities.MainActivity
|
||||||
|
import com.simplemobiletools.launcher.databinding.HomeScreenGridBinding
|
||||||
import com.simplemobiletools.launcher.extensions.config
|
import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
||||||
import com.simplemobiletools.launcher.extensions.homeScreenGridItemsDB
|
import com.simplemobiletools.launcher.extensions.homeScreenGridItemsDB
|
||||||
import com.simplemobiletools.launcher.helpers.*
|
import com.simplemobiletools.launcher.helpers.*
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
import kotlinx.android.synthetic.main.activity_main.view.*
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
|
|
||||||
class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) {
|
class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) {
|
||||||
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
|
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
|
||||||
|
|
||||||
|
private lateinit var binding: HomeScreenGridBinding
|
||||||
private var columnCount = context.config.homeColumnCount
|
private var columnCount = context.config.homeColumnCount
|
||||||
private var rowCount = context.config.homeRowCount
|
private var rowCount = context.config.homeRowCount
|
||||||
private var cellXCoords = ArrayList<Int>(columnCount)
|
private var cellXCoords = ArrayList<Int>(columnCount)
|
||||||
|
@ -55,8 +57,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
private var extraYMargin = 0
|
private var extraYMargin = 0
|
||||||
|
|
||||||
private var iconMargin = (context.resources.getDimension(R.dimen.icon_side_margin) * 5 / columnCount).toInt()
|
private var iconMargin = (context.resources.getDimension(R.dimen.icon_side_margin) * 5 / columnCount).toInt()
|
||||||
private var labelSideMargin = context.resources.getDimension(R.dimen.small_margin).toInt()
|
private var labelSideMargin = context.resources.getDimension(CommonsR.dimen.small_margin).toInt()
|
||||||
private var roundedCornerRadius = context.resources.getDimension(R.dimen.activity_margin)
|
private var roundedCornerRadius = context.resources.getDimension(CommonsR.dimen.activity_margin)
|
||||||
private var pageIndicatorRadius = context.resources.getDimension(R.dimen.page_indicator_dot_radius)
|
private var pageIndicatorRadius = context.resources.getDimension(R.dimen.page_indicator_dot_radius)
|
||||||
private var pageIndicatorMargin = context.resources.getDimension(R.dimen.page_indicator_margin)
|
private var pageIndicatorMargin = context.resources.getDimension(R.dimen.page_indicator_margin)
|
||||||
private var textPaint: TextPaint
|
private var textPaint: TextPaint
|
||||||
|
@ -117,13 +119,13 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
|
|
||||||
textPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
|
textPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
color = Color.WHITE
|
color = Color.WHITE
|
||||||
textSize = context.resources.getDimension(R.dimen.smaller_text_size)
|
textSize = context.resources.getDimension(CommonsR.dimen.smaller_text_size)
|
||||||
setShadowLayer(2f, 0f, 0f, Color.BLACK)
|
setShadowLayer(2f, 0f, 0f, Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
dragShadowCirclePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
dragShadowCirclePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
color = context.resources.getColor(R.color.hint_white)
|
color = context.resources.getColor(CommonsR.color.hint_white)
|
||||||
strokeWidth = context.resources.getDimension(R.dimen.small_margin)
|
strokeWidth = context.resources.getDimension(CommonsR.dimen.small_margin)
|
||||||
style = Paint.Style.STROKE
|
style = Paint.Style.STROKE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,11 +133,11 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
strokeWidth = context.resources.getDimension(R.dimen.page_indicator_stroke_width)
|
strokeWidth = context.resources.getDimension(R.dimen.page_indicator_stroke_width)
|
||||||
}
|
}
|
||||||
currentPageIndicatorPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
currentPageIndicatorPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
color = context.resources.getColor(R.color.white)
|
color = context.resources.getColor(android.R.color.white)
|
||||||
style = Paint.Style.FILL
|
style = Paint.Style.FILL
|
||||||
}
|
}
|
||||||
|
|
||||||
val sideMargin = context.resources.getDimension(R.dimen.normal_margin).toInt()
|
val sideMargin = context.resources.getDimension(CommonsR.dimen.normal_margin).toInt()
|
||||||
sideMargins.apply {
|
sideMargins.apply {
|
||||||
top = context.statusBarHeight
|
top = context.statusBarHeight
|
||||||
bottom = context.navigationBarHeight
|
bottom = context.navigationBarHeight
|
||||||
|
@ -146,6 +148,11 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
fetchGridItems()
|
fetchGridItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = HomeScreenGridBinding.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
fun fetchGridItems() {
|
fun fetchGridItems() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val providers = appWidgetManager.installedProviders
|
val providers = appWidgetManager.installedProviders
|
||||||
|
@ -304,20 +311,20 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
redrawGrid()
|
redrawGrid()
|
||||||
|
|
||||||
val widgetView = widgetViews.firstOrNull { it.tag == resizedWidget!!.widgetId }
|
val widgetView = widgetViews.firstOrNull { it.tag == resizedWidget!!.widgetId }
|
||||||
resize_frame.beGone()
|
binding.resizeFrame.beGone()
|
||||||
if (widgetView != null) {
|
if (widgetView != null) {
|
||||||
val viewX = widgetView.x.toInt()
|
val viewX = widgetView.x.toInt()
|
||||||
val viewY = widgetView.y.toInt()
|
val viewY = widgetView.y.toInt()
|
||||||
val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height)
|
val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height)
|
||||||
val otherGridItems = gridItems.filter { it.widgetId != item.widgetId }.toMutableList() as ArrayList<HomeScreenGridItem>
|
val otherGridItems = gridItems.filter { it.widgetId != item.widgetId }.toMutableList() as ArrayList<HomeScreenGridItem>
|
||||||
resize_frame.updateFrameCoords(frameRect, cellWidth, cellHeight, sideMargins, item, otherGridItems)
|
binding.resizeFrame.updateFrameCoords(frameRect, cellWidth, cellHeight, sideMargins, item, otherGridItems)
|
||||||
resize_frame.beVisible()
|
binding.resizeFrame.beVisible()
|
||||||
resize_frame.z = 1f // make sure the frame isnt behind the widget itself
|
binding.resizeFrame.z = 1f // make sure the frame isnt behind the widget itself
|
||||||
resize_frame.onClickListener = {
|
binding.resizeFrame.onClickListener = {
|
||||||
hideResizeLines()
|
hideResizeLines()
|
||||||
}
|
}
|
||||||
|
|
||||||
resize_frame.onResizeListener = { cellsRect ->
|
binding.resizeFrame.onResizeListener = { cellsRect ->
|
||||||
item.left = cellsRect.left
|
item.left = cellsRect.left
|
||||||
item.top = cellsRect.top
|
item.top = cellsRect.top
|
||||||
item.right = cellsRect.right
|
item.right = cellsRect.right
|
||||||
|
@ -334,7 +341,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
|
|
||||||
widgetView.ignoreTouches = true
|
widgetView.ignoreTouches = true
|
||||||
widgetView.setOnTouchListener { v, event ->
|
widgetView.setOnTouchListener { v, event ->
|
||||||
resize_frame.onTouchEvent(event)
|
binding.resizeFrame.onTouchEvent(event)
|
||||||
return@setOnTouchListener true
|
return@setOnTouchListener true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +352,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resize_frame.beGone()
|
binding.resizeFrame.beGone()
|
||||||
widgetViews.firstOrNull { it.tag == resizedWidget!!.widgetId }?.apply {
|
widgetViews.firstOrNull { it.tag == resizedWidget!!.widgetId }?.apply {
|
||||||
ignoreTouches = false
|
ignoreTouches = false
|
||||||
setOnTouchListener(null)
|
setOnTouchListener(null)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simplemobiletools.launcher.extensions.config
|
||||||
import com.simplemobiletools.launcher.extensions.getCellCount
|
import com.simplemobiletools.launcher.extensions.getCellCount
|
||||||
import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION
|
import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION
|
||||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||||
|
import com.simplemobiletools.commons.R as CommonsR
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) {
|
class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) {
|
||||||
|
@ -48,7 +49,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
||||||
|
|
||||||
resizeWidgetLinePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
resizeWidgetLinePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
color = Color.WHITE
|
color = Color.WHITE
|
||||||
strokeWidth = context.resources.getDimension(R.dimen.tiny_margin)
|
strokeWidth = context.resources.getDimension(CommonsR.dimen.tiny_margin)
|
||||||
style = Paint.Style.STROKE
|
style = Paint.Style.STROKE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.simplemobiletools.launcher.views.HomeScreenGrid
|
<include
|
||||||
android:id="@+id/home_screen_grid"
|
android:id="@+id/home_screen_grid"
|
||||||
android:layout_width="match_parent"
|
layout="@layout/home_screen_grid" />
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<com.simplemobiletools.launcher.views.MyAppWidgetResizeFrame
|
|
||||||
android:id="@+id/resize_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</com.simplemobiletools.launcher.views.HomeScreenGrid>
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/all_apps_fragment"
|
android:id="@+id/all_apps_fragment"
|
||||||
|
|
13
app/src/main/res/layout/home_screen_grid.xml
Normal file
13
app/src/main/res/layout/home_screen_grid.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.simplemobiletools.launcher.views.HomeScreenGrid xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/home_screen_grid"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.simplemobiletools.launcher.views.MyAppWidgetResizeFrame
|
||||||
|
android:id="@+id/resize_frame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</com.simplemobiletools.launcher.views.HomeScreenGrid>
|
30
build.gradle
30
build.gradle
|
@ -1,30 +0,0 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
ext.kotlin_version = '1.7.10'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
maven { url 'https://jitpack.io' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task clean(type: Delete) {
|
|
||||||
delete rootProject.buildDir
|
|
||||||
}
|
|
5
build.gradle.kts
Normal file
5
build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android).apply(false)
|
||||||
|
alias(libs.plugins.kotlinAndroid).apply(false)
|
||||||
|
alias(libs.plugins.ksp).apply(false)
|
||||||
|
}
|
37
gradle/libs.versions.toml
Normal file
37
gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
[versions]
|
||||||
|
#jetbrains
|
||||||
|
kotlin = "1.9.0"
|
||||||
|
#KSP
|
||||||
|
ksp = "1.9.0-1.0.12"
|
||||||
|
#Room
|
||||||
|
room = "2.6.0-alpha02"
|
||||||
|
#Simple tools
|
||||||
|
simple-commons = "c5a32fb1f3"
|
||||||
|
#Gradle
|
||||||
|
gradlePlugins-agp = "8.1.0"
|
||||||
|
#build
|
||||||
|
app-build-compileSDKVersion = "34"
|
||||||
|
app-build-targetSDK = "34"
|
||||||
|
app-build-minimumSDK = "26"
|
||||||
|
app-build-javaVersion = "VERSION_17"
|
||||||
|
app-build-kotlinJVMTarget = "17"
|
||||||
|
#versioning
|
||||||
|
app-version-appId = "com.simplemobiletools.launcher"
|
||||||
|
app-version-versionCode = "8"
|
||||||
|
app-version-versionName = "5.0.6"
|
||||||
|
[libraries]
|
||||||
|
#Room
|
||||||
|
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
||||||
|
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
|
||||||
|
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||||
|
#Simple Mobile Tools
|
||||||
|
simple-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" }
|
||||||
|
[bundles]
|
||||||
|
room = [
|
||||||
|
"androidx-room-ktx",
|
||||||
|
"androidx-room-runtime",
|
||||||
|
]
|
||||||
|
[plugins]
|
||||||
|
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
|
||||||
|
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#Mon Aug 01 22:01:46 CEST 2022
|
#Mon Aug 01 22:01:46 CEST 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
@ -1 +1,16 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven { setUrl("https://jitpack.io") }
|
||||||
|
}
|
||||||
|
}
|
||||||
include ':app'
|
include ':app'
|
||||||
|
|
Loading…
Reference in a new issue