updating commons

This commit is contained in:
tibbi
2022-07-08 11:39:44 +02:00
parent 10f971aad8
commit f372f71141
8 changed files with 242 additions and 193 deletions

View File

@ -63,7 +63,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:c070dff787' implementation 'com.github.SimpleMobileTools:Simple-Commons:903dad2409'
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'
} }

View File

@ -2,8 +2,6 @@ package com.simplemobiletools.applauncher.activities
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
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
@ -36,6 +34,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
setupOptionsMenu()
refreshMenuItems()
appLaunched(BuildConfig.APPLICATION_ID) appLaunched(BuildConfig.APPLICATION_ID)
setupEmptyView() setupEmptyView()
setupLaunchers() setupLaunchers()
@ -50,6 +51,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
setupToolbar(main_toolbar)
if (mStoredTextColor != getProperTextColor()) { if (mStoredTextColor != getProperTextColor()) {
getGridAdapter()?.updateTextColor(getProperTextColor()) getGridAdapter()?.updateTextColor(getProperTextColor())
} }
@ -72,33 +74,49 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
storeStateVariables() storeStateVariables()
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { private fun refreshMenuItems() {
menuInflater.inflate(R.menu.menu, menu)
val currentColumnCount = if (portrait) { val currentColumnCount = if (portrait) {
config.portraitColumnCnt config.portraitColumnCnt
} else { } else {
config.landscapeColumnCnt config.landscapeColumnCnt
} }
menu.apply { main_toolbar.menu.apply {
findItem(R.id.increase_column_count).isVisible = currentColumnCount < MAX_COLUMN_COUNT findItem(R.id.increase_column_count).isVisible = currentColumnCount < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = currentColumnCount > 1 findItem(R.id.reduce_column_count).isVisible = currentColumnCount > 1
updateMenuItemColors(menu)
} }
return true
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { private fun setupOptionsMenu() {
when (item.itemId) { main_toolbar.setOnMenuItemClickListener { menuItem ->
R.id.sort -> showSortingDialog() when (menuItem.itemId) {
R.id.toggle_app_name -> toggleAppName() R.id.sort -> {
R.id.increase_column_count -> increaseColumnCount() showSortingDialog()
R.id.reduce_column_count -> reduceColumnCount() true
R.id.settings -> launchSettings() }
R.id.about -> launchAbout() R.id.toggle_app_name -> {
else -> return super.onOptionsItemSelected(item) toggleAppName()
true
}
R.id.increase_column_count -> {
increaseColumnCount()
true
}
R.id.reduce_column_count -> {
reduceColumnCount()
true
}
R.id.settings -> {
launchSettings()
true
}
R.id.about -> {
launchAbout()
true
}
else -> false
}
} }
return true
} }
private fun launchSettings() { private fun launchSettings() {
@ -199,7 +217,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
} }
private fun columnCountChanged() { private fun columnCountChanged() {
invalidateOptionsMenu() refreshMenuItems()
getGridAdapter()?.apply { getGridAdapter()?.apply {
calculateIconWidth() calculateIconWidth()
notifyItemRangeChanged(0, launchers.size) notifyItemRangeChanged(0, launchers.size)

View File

@ -1,10 +1,10 @@
package com.simplemobiletools.applauncher.activities package com.simplemobiletools.applauncher.activities
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import com.simplemobiletools.applauncher.R import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.extensions.config import com.simplemobiletools.applauncher.extensions.config
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
import kotlinx.android.synthetic.main.activity_settings.* import kotlinx.android.synthetic.main.activity_settings.*
import java.util.* import java.util.*
@ -17,6 +17,7 @@ class SettingsActivity : SimpleActivity() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
setupPurchaseThankYou() setupPurchaseThankYou()
setupCustomizeColors() setupCustomizeColors()
@ -33,11 +34,6 @@ class SettingsActivity : SimpleActivity() {
} }
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean {
updateMenuItemColors(menu)
return super.onCreateOptionsMenu(menu)
}
private fun setupPurchaseThankYou() { private fun setupPurchaseThankYou() {
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled()) settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())

View File

@ -1,33 +1,28 @@
package com.simplemobiletools.applauncher.dialogs package com.simplemobiletools.applauncher.dialogs
import android.app.Activity import android.app.Activity
import android.app.AlertDialog
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.AppCompatEditText
import com.simplemobiletools.applauncher.R import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.extensions.dbHelper import com.simplemobiletools.applauncher.extensions.dbHelper
import com.simplemobiletools.applauncher.models.AppLauncher import com.simplemobiletools.applauncher.models.AppLauncher
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_edit_launcher.view.*
class EditDialog(val activity: Activity, val appLauncher: AppLauncher, val callback: () -> Unit) { class EditDialog(val activity: Activity, val appLauncher: AppLauncher, val callback: () -> Unit) {
init { init {
val layoutId = if (activity.baseConfig.isUsingSystemTheme) { val view = (activity.layoutInflater.inflate(R.layout.dialog_edit_launcher, null) as ViewGroup)
R.layout.dialog_edit_launcher_material view.edit_launcher_edittext.setText(appLauncher.title)
} else {
R.layout.dialog_edit_launcher
}
val view = (activity.layoutInflater.inflate(layoutId, null) as ViewGroup)
view.findViewById<AppCompatEditText>(R.id.edit_launcher_edittext).setText(appLauncher.title)
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(view, this, R.string.rename) { alertDialog -> activity.setupDialogStuff(view, this, R.string.rename) { alertDialog ->
alertDialog.showKeyboard(view.findViewById(R.id.edit_launcher_edittext)) alertDialog.showKeyboard(view.edit_launcher_edittext)
alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val newName = view.findViewById<AppCompatEditText>(R.id.edit_launcher_edittext).value val newName = view.edit_launcher_edittext.value
if (!newName.isEmpty()) { if (!newName.isEmpty()) {
if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) { if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) {
callback() callback()

View File

@ -2,6 +2,35 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/main_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/main_nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator_layout" android:id="@+id/coordinator_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -65,4 +94,6 @@
android:layout_margin="@dimen/activity_margin" android:layout_margin="@dimen/activity_margin"
android:src="@drawable/ic_plus_vector" /> android:src="@drawable/ic_plus_vector" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,9 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/settings_scrollview" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/settings_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/settings_app_bar_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/settings_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/settings"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/settings_nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout <LinearLayout
android:id="@+id/settings_holder" android:id="@+id/settings_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -106,4 +130,5 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -5,12 +5,18 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/activity_margin"> android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyEditText <com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/edit_launcher_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_launcher_edittext" android:id="@+id/edit_launcher_edittext"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:inputType="textCapWords" android:inputType="textCapWords"
android:textCursorDrawable="@null" android:textSize="@dimen/bigger_text_size" />
android:textSize="@dimen/normal_text_size" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
</FrameLayout> </FrameLayout>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_launcher_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_margin">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_launcher_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_launcher_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:textSize="@dimen/bigger_text_size" />
</com.google.android.material.textfield.TextInputLayout>
</FrameLayout>