mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-04 13:21:47 +02:00
tweaking the main activities UI too
This commit is contained in:
parent
ea8e862929
commit
8a520d2e36
@ -63,7 +63,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:1169d9c222'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:f282a1f5ab'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.applauncher.activities
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import com.simplemobiletools.applauncher.BuildConfig
|
import com.simplemobiletools.applauncher.BuildConfig
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.adapters.LaunchersAdapter
|
import com.simplemobiletools.applauncher.adapters.LaunchersAdapter
|
||||||
@ -12,17 +13,19 @@ import com.simplemobiletools.applauncher.extensions.dbHelper
|
|||||||
import com.simplemobiletools.applauncher.extensions.getAllLaunchers
|
import com.simplemobiletools.applauncher.extensions.getAllLaunchers
|
||||||
import com.simplemobiletools.applauncher.extensions.isAPredefinedApp
|
import com.simplemobiletools.applauncher.extensions.isAPredefinedApp
|
||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
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.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
private val MAX_COLUMN_COUNT = 20
|
private val MAX_COLUMN_COUNT = 15
|
||||||
|
|
||||||
private var displayedLaunchers = ArrayList<AppLauncher>()
|
private var displayedLaunchers = ArrayList<AppLauncher>()
|
||||||
private var allLaunchers: ArrayList<AppLauncher>? = null
|
private var allLaunchers: ArrayList<AppLauncher>? = null
|
||||||
@ -32,12 +35,16 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
private var mStoredTextColor = 0
|
private var mStoredTextColor = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
|
||||||
|
updateMaterialActivityViews(main_coordinator, launchers_grid)
|
||||||
|
setupMaterialScrollListener(launchers_grid, main_toolbar)
|
||||||
|
|
||||||
setupEmptyView()
|
setupEmptyView()
|
||||||
setupLaunchers()
|
setupLaunchers()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
@ -67,6 +74,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
updateTextColors(coordinator_layout)
|
updateTextColors(coordinator_layout)
|
||||||
add_icons_placeholder.setTextColor(properPrimaryColor)
|
add_icons_placeholder.setTextColor(properPrimaryColor)
|
||||||
launchers_fastscroller.updateColors(properPrimaryColor)
|
launchers_fastscroller.updateColors(properPrimaryColor)
|
||||||
|
(fab.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin = navigationBarHeight + resources.getDimension(R.dimen.activity_margin).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -75,15 +83,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
val currentColumnCount = if (portrait) {
|
|
||||||
config.portraitColumnCnt
|
|
||||||
} else {
|
|
||||||
config.landscapeColumnCnt
|
|
||||||
}
|
|
||||||
|
|
||||||
main_toolbar.menu.apply {
|
main_toolbar.menu.apply {
|
||||||
findItem(R.id.increase_column_count).isVisible = currentColumnCount < MAX_COLUMN_COUNT
|
|
||||||
findItem(R.id.reduce_column_count).isVisible = currentColumnCount > 1
|
|
||||||
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(R.bool.hide_google_relations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,8 +93,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> showSortingDialog()
|
R.id.sort -> showSortingDialog()
|
||||||
R.id.toggle_app_name -> toggleAppName()
|
R.id.toggle_app_name -> toggleAppName()
|
||||||
R.id.increase_column_count -> increaseColumnCount()
|
R.id.column_count -> changeColumnCount()
|
||||||
R.id.reduce_column_count -> reduceColumnCount()
|
|
||||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
R.id.settings -> launchSettings()
|
R.id.settings -> launchSettings()
|
||||||
R.id.about -> launchAbout()
|
R.id.about -> launchAbout()
|
||||||
@ -183,6 +182,27 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
setupAdapter(displayedLaunchers)
|
setupAdapter(displayedLaunchers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun changeColumnCount() {
|
||||||
|
val items = ArrayList<RadioItem>()
|
||||||
|
for (i in 1..MAX_COLUMN_COUNT) {
|
||||||
|
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
|
||||||
|
}
|
||||||
|
|
||||||
|
val currentColumnCount = (launchers_grid.layoutManager as MyGridLayoutManager).spanCount
|
||||||
|
RadioGroupDialog(this, items, currentColumnCount) {
|
||||||
|
val newColumnCount = it as Int
|
||||||
|
if (currentColumnCount != newColumnCount) {
|
||||||
|
(launchers_grid.layoutManager as MyGridLayoutManager).spanCount = newColumnCount
|
||||||
|
if (portrait) {
|
||||||
|
config.portraitColumnCnt = newColumnCount
|
||||||
|
} else {
|
||||||
|
config.landscapeColumnCnt = newColumnCount
|
||||||
|
}
|
||||||
|
columnCountChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun increaseColumnCount() {
|
private fun increaseColumnCount() {
|
||||||
val newColumnCount = ++(launchers_grid.layoutManager as MyGridLayoutManager).spanCount
|
val newColumnCount = ++(launchers_grid.layoutManager as MyGridLayoutManager).spanCount
|
||||||
if (portrait) {
|
if (portrait) {
|
||||||
|
@ -14,20 +14,15 @@
|
|||||||
android:title="@string/toggle_app_name"
|
android:title="@string/toggle_app_name"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/increase_column_count"
|
android:id="@+id/column_count"
|
||||||
android:showAsAction="never"
|
android:icon="@drawable/ic_column_count_vector"
|
||||||
android:title="@string/increase_column_count"
|
android:title="@string/column_count"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="always" />
|
||||||
<item
|
|
||||||
android:id="@+id/reduce_column_count"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/reduce_column_count"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/more_apps_from_us"
|
android:id="@+id/more_apps_from_us"
|
||||||
android:icon="@drawable/ic_google_play_vector"
|
android:icon="@drawable/ic_google_play_vector"
|
||||||
android:title="@string/more_apps_from_us"
|
android:title="@string/more_apps_from_us"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/settings"
|
android:id="@+id/settings"
|
||||||
android:icon="@drawable/ic_settings_cog_vector"
|
android:icon="@drawable/ic_settings_cog_vector"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user