This commit is contained in:
lunaticbum
2024-08-12 17:02:52 +09:00
parent bef4031a5c
commit dde2da6989
149 changed files with 12343 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name="android.hardware.telephony"
android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<!-- api 33+ -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
</queries>
<application
android:name=".LunarLauncher"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.LunarLauncher"
android:excludeFromRecents="true"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:screenOrientation="nosensor"
android:windowSoftInputMode="adjustResize"
android:requestLegacyExternalStorage="true">
<activity
android:name=".LauncherActivity"
android:theme="@style/Theme.LunarLauncher.Starting"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".settings.SettingsActivity"
android:label="@string/lunar_settings"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
</intent-filter>
</activity>
<service
android:name=".feeds.rss.RssService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
<service
android:name=".helpers.LockService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="false">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/lock_service" />
</service>
<receiver
android:name=".helpers.AdminReceiver"
android:label="@string/app_name"
android:description="@string/device_admin_description"
android:permission="android.permission.BIND_DEVICE_ADMIN"
android:exported="false">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
@@ -0,0 +1,224 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher
import android.Manifest
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.WindowInsets
import android.view.WindowManager
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.color.DynamicColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import rasel.lunar.launcher.apps.AppDrawer
import rasel.lunar.launcher.databinding.LauncherActivityBinding
import rasel.lunar.launcher.feeds.Feeds
import rasel.lunar.launcher.feeds.WidgetHost
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPLICATION_THEME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_BACK_HOME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_FIRST_LAUNCH
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WINDOW_BACKGROUND
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_FIRST_LAUNCH
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.Constants.Companion.widgetHostId
import rasel.lunar.launcher.helpers.UniUtils.Companion.getColorResId
import rasel.lunar.launcher.helpers.ViewPagerAdapter
import rasel.lunar.launcher.home.LauncherHome
internal class LauncherActivity : AppCompatActivity() {
private lateinit var binding: LauncherActivityBinding
private lateinit var settingsPrefs: SharedPreferences
lateinit var viewPager: ViewPager2
companion object {
@JvmStatic var lActivity: LauncherActivity? = null
@JvmStatic var appWidgetManager: AppWidgetManager? = null
@JvmStatic var appWidgetHost: WidgetHost? = null
}
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
DynamicColors.applyToActivityIfAvailable(this)
settingsPrefs = getSharedPreferences(PREFS_SETTINGS, 0)
AppCompatDelegate.setDefaultNightMode(settingsPrefs.getInt(KEY_APPLICATION_THEME, MODE_NIGHT_FOLLOW_SYSTEM))
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
binding = LauncherActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
lActivity = this
appWidgetManager = AppWidgetManager.getInstance(applicationContext)
appWidgetHost = WidgetHost(applicationContext, widgetHostId)
appWidgetHost?.startListening()
/* if this is the first launch,
then remember the event and show the welcome dialog */
welcomeDialog()
setupView()
/* handle navigation back events */
handleBackPress()
}
override fun onDestroy() {
super.onDestroy()
appWidgetHost?.stopListening()
}
override fun onResume() {
super.onResume()
if (settingsPrefs.getBoolean(KEY_BACK_HOME, false)) viewPager.currentItem = 1
statusBarView()
setBgColor()
}
private fun welcomeDialog() {
getSharedPreferences(PREFS_FIRST_LAUNCH, 0).let {
if (it.getBoolean(KEY_FIRST_LAUNCH, true)) {
it.edit().putBoolean(KEY_FIRST_LAUNCH, false).apply()
MaterialAlertDialogBuilder(this)
.setTitle(R.string.welcome)
.setMessage(R.string.welcome_description)
.setPositiveButton(R.string.got_it) { dialog, _ ->
dialog.dismiss()
askPermissions()
}.show()
}
}
}
/* ask for the permissions */
private fun askPermissions() {
/* phone permission */
if (this.checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(arrayOf(Manifest.permission.CALL_PHONE), 1)
}
/* modify system settings */
if (!Settings.System.canWrite(this)) {
this.startActivity(
Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
.setData(Uri.parse("package:" + this.packageName))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
}
}
/* set up viewpager2 */
private fun setupView() {
viewPager = binding.viewPager.apply {
adapter = ViewPagerAdapter(
supportFragmentManager, mutableListOf(Feeds(), LauncherHome(), AppDrawer()), lifecycle)
offscreenPageLimit = 1
setCurrentItem(1, false)
reduceDragSensitivity()
}
}
private fun setBgColor() {
binding.root.setBackgroundColor(Color.parseColor("#${
settingsPrefs.getString(KEY_WINDOW_BACKGROUND, getString(getColorResId(this, android.R.attr.colorBackground))
.replace("#", ""))}"))
}
private fun statusBarView() {
if (settingsPrefs.getBoolean(KEY_STATUS_BAR, false)) {
/* hide status bar */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.statusBars())
} else {
@Suppress("DEPRECATION")
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
}
topPadding(false)
} else {
/* show status bar */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.show(WindowInsets.Type.statusBars())
} else {
@Suppress("DEPRECATION")
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
}
topPadding(true)
}
}
/* alternative of deprecated onBackPressed method */
private fun handleBackPress() {
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
/* while in to-do manager, go back to home screen */
if (supportFragmentManager.backStackEntryCount != 0) supportFragmentManager.popBackStack()
/* while in feeds or app drawer, go back to home screen */
if (viewPager.currentItem != 1) viewPager.currentItem = 1
}
})
}
private fun topPadding(topPadding: Boolean) {
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, windowInsets ->
windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures()).let {
val topInset = if (topPadding) {
if (it.top == 0) windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()).top
else it.top
} else 0
view.updatePadding(0, topInset, 0, it.bottom)
}
WindowInsetsCompat.CONSUMED
}
}
private fun ViewPager2.reduceDragSensitivity() {
ViewPager2::class.java.getDeclaredField("mRecyclerView").apply {
isAccessible = true
}.let { recyclerViewField ->
(recyclerViewField.get(this) as RecyclerView).let { recyclerView ->
RecyclerView::class.java.getDeclaredField("mTouchSlop").apply {
isAccessible = true
set(recyclerView, this.get(recyclerView) as Int * 8)
}
}
}
}
}
@@ -0,0 +1,33 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher
import android.app.Application
import android.content.ComponentCallbacks2
import android.database.sqlite.SQLiteDatabase
internal class LunarLauncher : Application() {
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) SQLiteDatabase.releaseMemory()
}
}
@@ -0,0 +1,118 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.apps
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.util.TypedValue
import android.view.MotionEvent
import android.view.View
import androidx.core.content.ContextCompat
import rasel.lunar.launcher.apps.AppDrawer.Companion.alphabetList
import rasel.lunar.launcher.apps.AppDrawer.Companion.letterPreview
import rasel.lunar.launcher.apps.AppDrawer.Companion.listenScroll
import rasel.lunar.launcher.apps.AppDrawer.Companion.settingsPrefs
import rasel.lunar.launcher.apps.AppsAdapter.Companion.appsSize
import rasel.lunar.launcher.helpers.Constants
internal class AlphabetScrollbar : View {
private var paint: Paint? = null
private var selectedIndex = -1
private val alphabet get() = alphabetList.distinct()
constructor(context: Context?) : super(context) {
init()
}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
init()
}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init()
}
@SuppressLint("ResourceType")
private fun init() {
paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = defaultTextColor
textSize = 16f
}
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
val width = width
val height = height
val letterHeight: Int = height / alphabet.count()
alphabet.indices.forEach { i: Int ->
val x = width / 2f - paint!!.measureText(alphabet[i]) / 2f
val y = i * letterHeight + letterHeight / 2f
when (i) {
selectedIndex -> paint!!.textSize = 20f
else -> paint!!.textSize = 16f
}
canvas.drawText(alphabet[i], x, y, paint!!)
}
}
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> {
val y = event.y
val index = (y / height * alphabet.count()).toInt()
if (index != selectedIndex) {
selectedIndex = index
invalidate()
}
if (!settingsPrefs!!.getBoolean(Constants.KEY_APPS_COUNT, true)) letterPreview?.visibility = VISIBLE
try { letterPreview?.text = alphabet[selectedIndex] }
catch (exception: Exception) { exception.printStackTrace() }
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
when {
selectedIndex < 0 -> listenScroll(alphabet[0])
selectedIndex > alphabet.count() - 1 -> listenScroll(alphabet[alphabet.count() - 1])
else -> listenScroll(alphabet[selectedIndex])
}
selectedIndex = -1
invalidate()
if (settingsPrefs!!.getBoolean(Constants.KEY_APPS_COUNT, true)) letterPreview?.text = appsSize.toString()
else letterPreview?.visibility = GONE
}
}
return true
}
private val defaultTextColor: Int get() {
val resolvedAttr = TypedValue()
context.theme.resolveAttribute(android.R.attr.textColorPrimary, resolvedAttr, true)
val colorRes = resolvedAttr.run { if (resourceId != 0) resourceId else data }
return ContextCompat.getColor(context, colorRes)
}
}
@@ -0,0 +1,335 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.apps
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.graphics.Rect
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AlertDialog
import androidx.core.view.updateLayoutParams
import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.textview.MaterialTextView
import rasel.lunar.launcher.BuildConfig
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.AppDrawerBinding
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_GRID_COLUMNS
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_SCROLLBAR_HEIGHT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPS_COUNT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPS_LAYOUT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_DRAW_ALIGN
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_GRID_COLUMNS
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_KEYBOARD_SEARCH
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_QUICK_LAUNCH
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SCROLLBAR_HEIGHT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_APP_NAMES
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import java.text.Normalizer
import java.util.*
import java.util.regex.Pattern
internal class AppDrawer : Fragment() {
private lateinit var binding: AppDrawerBinding
private var layoutType: Int = 0
private var isSearchShown: Boolean = false
private var isKeyboardShowing: Boolean = false
companion object {
private var packageManager: PackageManager? = null
private var appsAdapter: AppsAdapter? = null
private var packageInfoList: MutableList<ResolveInfo> = mutableListOf()
private var packageList = mutableListOf<Packages>()
private val numberPattern = Pattern.compile("[0-9]")
private val alphabetPattern = Pattern.compile("[A-Z]")
@JvmStatic var settingsPrefs: SharedPreferences? = null
@JvmStatic var appNamesPrefs: SharedPreferences? = null
@JvmStatic var alphabetList = mutableListOf<String>()
@JvmStatic var letterPreview: MaterialTextView? = null
private fun appName(resolver: ResolveInfo): String {
return appNamesPrefs?.getString(resolver.activityInfo.packageName, resolver.loadLabel(packageManager).toString())!!
}
fun listenScroll(letter: String) {
packageList.clear()
for (resolver in packageInfoList) {
when {
letter == "#" -> {
if (numberPattern.matcher(appName(resolver).first().uppercase()).matches()) {
packageList.add(Packages(resolver.activityInfo.packageName, appName(resolver)))
}
}
alphabetPattern.matcher(letter).matches() -> {
if (appName(resolver).first().uppercase() == letter) {
packageList.add(Packages(resolver.activityInfo.packageName, appName(resolver)))
}
}
letter == "" -> {
if (!numberPattern.matcher(appName(resolver).first().uppercase()).matches() &&
!alphabetPattern.matcher(appName(resolver).first().uppercase()).matches()) {
packageList.add(Packages(resolver.activityInfo.packageName, appName(resolver)))
}
}
}
}
appsAdapter?.updateData(packageList.sortedBy { it.appName.lowercase() })
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = AppDrawerBinding.inflate(inflater, container, false)
settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0)
appNamesPrefs = requireContext().getSharedPreferences(PREFS_APP_NAMES, 0)
layoutType = settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0)
packageManager = lActivity?.packageManager
appsAdapter = AppsAdapter(layoutType, packageManager!!, childFragmentManager, binding.appsCount)
letterPreview = binding.appsCount
binding.appsCount.visibility = if (settingsPrefs!!.getBoolean(KEY_APPS_COUNT, true)) VISIBLE else GONE
setLayout()
fetchApps()
getAlphabetItems()
setKeyboardPadding()
return binding.root
}
@SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.reset.setOnClickListener { onResume() }
binding.moveDown.setOnClickListener {
binding.appsList.smoothScrollToPosition(packageList.size - 1)
}
binding.moveUp.setOnClickListener {
binding.appsList.smoothScrollToPosition(0)
}
binding.search.setOnClickListener {
when (isSearchShown) {
true -> closeSearch()
false -> openSearch()
}
}
binding.searchInput.doOnTextChanged { inputText, _, _, _ ->
binding.searchInput.text?.let { binding.searchInput.setSelection(it.length) }
filterAppsList(inputText.toString())
}
}
override fun onResume() {
super.onResume()
fetchApps()
getAlphabetItems()
binding.appsCount.visibility = if (settingsPrefs!!.getBoolean(KEY_APPS_COUNT, true)) VISIBLE else GONE
if (settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0) in 0..1) {
appsAdapter?.updateGravity(settingsPrefs!!.getInt(KEY_DRAW_ALIGN, Gravity.CENTER))
}
/* pop up the keyboard */
if (settingsPrefs!!.getBoolean(KEY_KEYBOARD_SEARCH, false)) openSearch()
}
override fun onPause() {
super.onPause()
closeSearch()
}
private fun setLayout() {
when (layoutType) {
0, 1 -> {
binding.appsList.layoutManager = LinearLayoutManager(requireContext())
appsAdapter!!.updateGravity(settingsPrefs!!.getInt(KEY_DRAW_ALIGN, Gravity.CENTER))
}
2 -> binding.appsList.layoutManager = GridLayoutManager(requireContext(), settingsPrefs!!.getInt(KEY_GRID_COLUMNS, DEFAULT_GRID_COLUMNS))
}
/* initialize apps list adapter */
binding.appsList.adapter = appsAdapter
}
/* update app list with app and package name */
fun fetchApps() {
packageInfoList = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager?.queryIntentActivities(
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER),
PackageManager.ResolveInfoFlags.of(0)
)
} else {
(packageManager?.queryIntentActivities(
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER), 0))
})?.apply {
removeIf { it.activityInfo.packageName.equals(BuildConfig.APPLICATION_ID) }
sortWith(ResolveInfo.DisplayNameComparator(packageManager))
}!!
/* add package and app names to the list */
packageList.clear()
for (resolver in packageInfoList) {
packageList.add(Packages(resolver.activityInfo.packageName, appName(resolver)))
}
when {
packageList.size < 1 -> return
else -> appsAdapter?.updateData(packageList.sortedBy { it.appName.lowercase() })
}
}
private fun getAlphabetItems() {
// settingsPrefs!!.getInt(KEY_SCROLLBAR_HEIGHT, DEFAULT_SCROLLBAR_HEIGHT).let { height: Int ->
// if (height == 0) { binding.alphabets.visibility = GONE }
// else {
// binding.alphabets.apply {
// if (visibility == GONE) visibility = VISIBLE
// updateLayoutParams { this.height = height }
// }
// alphabetList.clear()
// for (mPackage in packageList) {
// mPackage.appName.first().uppercase().let { firstLetter: String ->
// when {
// numberPattern.matcher(firstLetter).matches() -> alphabetList.add(0, "#")
// alphabetPattern.matcher(firstLetter).matches() -> alphabetList.add(firstLetter)
// !numberPattern.matcher(firstLetter).matches() &&
// !alphabetPattern.matcher(firstLetter).matches() -> alphabetList.add(alphabetList.size,"⠶")
// else -> {}
// }
// }
// }
// binding.alphabets.invalidate()
// }
// }
}
private fun filterAppsList(searchString: String) {
/* check each app name and add if it matches the search string */
packageList.clear()
for (resolver in packageInfoList) {
appName(resolver).let {
if (normalize(it).contains(searchString)) {
packageList.add(Packages(resolver.activityInfo.packageName, it))
}
}
}
if (packageList.size == 1 && settingsPrefs!!.getBoolean(KEY_QUICK_LAUNCH, true)) {
var dialog = AlertDialog.Builder(requireContext())
dialog.setTitle("앱 실행 확인")
dialog.setMessage("${searchString} 검색 결과 '${packageList[0].appName}' 준비됨")
dialog.setCancelable(false)
dialog.setOnCancelListener {
binding.searchInput.setText("")
it.dismiss()
}
dialog.setPositiveButton("실행") { s,d ->
startActivity(packageManager?.getLaunchIntentForPackage(packageList[0].packageName))
s.dismiss()
binding.searchInput.setText("")
}
dialog.show()
}
else appsAdapter?.updateData(packageList.sortedBy { it.appName.lowercase() })
}
private fun normalize(str: String): String {
val normalizedString =
Normalizer.normalize(str.replace("\\W".toRegex(), ""), Normalizer.Form.NFD)
val pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+")
return pattern.matcher(normalizedString).replaceAll("").lowercase()
}
private fun openSearch() {
isSearchShown = true
binding.search.setImageResource(R.drawable.ic_close)
binding.searchInput.apply {
visibility = VISIBLE
requestFocus()
let {
(lActivity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT)
}
}
}
/* clear search string, hide keyboard and search box */
private fun closeSearch() {
isSearchShown = false
binding.search.setImageResource(R.drawable.ic_search)
binding.searchInput.apply {
text?.clear()
visibility = GONE
let {
(lActivity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
.hideSoftInputFromWindow(it.windowToken, 0)
}
}
}
private fun setKeyboardPadding() {
binding.root.viewTreeObserver.addOnGlobalLayoutListener {
val rect = Rect()
binding.root.getWindowVisibleDisplayFrame(rect)
val screenHeight = binding.root.height
val keyboardHeight = screenHeight - (rect.bottom - rect.top)
when {
keyboardHeight > screenHeight * 0.15 -> {
if (!isKeyboardShowing &&
!settingsPrefs!!.getBoolean(KEY_STATUS_BAR, false)) {
isKeyboardShowing = true
binding.root.setPadding(0, 0, 0, keyboardHeight)
}
}
else -> {
if (isKeyboardShowing) {
isKeyboardShowing = false
binding.root.setPadding(0, 0, 0, 0)
}
}
}
}
}
}
@@ -0,0 +1,431 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.apps
import android.annotation.SuppressLint
import android.app.ActivityOptions
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.graphics.Rect
import android.icu.text.SimpleDateFormat
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.FileProvider
import androidx.core.content.pm.PackageInfoCompat
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
import com.google.android.material.button.MaterialButtonToggleGroup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.apps.AppDrawer.Companion.appNamesPrefs
import rasel.lunar.launcher.databinding.ActivityBrowserDialogBinding
import rasel.lunar.launcher.databinding.AppInfoDialogBinding
import rasel.lunar.launcher.databinding.AppMenuBinding
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APP_NO_
import rasel.lunar.launcher.helpers.Constants.Companion.MAX_FAVORITE_APPS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_FAVORITE_APPS
import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard
import rasel.lunar.launcher.helpers.UniUtils.Companion.screenHeight
import rasel.lunar.launcher.helpers.UniUtils.Companion.screenWidth
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
import java.util.*
internal class AppMenu : BottomSheetDialogFragment() {
private lateinit var binding: AppMenuBinding
private lateinit var packageName: String
private lateinit var packageManager: PackageManager
private lateinit var appInfo: ApplicationInfo
private lateinit var defAppName: String
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = AppMenuBinding.inflate(inflater, container, false)
/* get package name from fragment's tag */
packageName = tag.toString()
packageManager = requireContext().packageManager
/* get application info */
appInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.getApplicationInfo(packageName,
PackageManager.ApplicationInfoFlags.of(PackageManager.GET_META_DATA.toLong()))
} else {
packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
}
/* get default app name */
defAppName = packageManager.resolveActivity(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
.setPackage(packageName), 0)?.loadLabel(packageManager).toString()
/* set application name and package name */
binding.appName.apply {
setText(appNamesPrefs?.getString(packageName, defAppName))
hint = defAppName
}
binding.appPackage.text = packageName
/* favorite apps */
favoriteApps()
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* copy package name */
binding.appPackage.setOnClickListener {
copyToClipboard(requireContext(), packageName)
}
appName()
binding.detailedInfo.setOnClickListener { detailedInfo() }
binding.activityBrowser.setOnClickListener { activityBrowser() }
binding.appStore.setOnClickListener { appStore() }
binding.appFreeform.setOnClickListener { freeform() }
binding.appInfo.setOnClickListener { appInfo() }
binding.appShare.setOnClickListener { share() }
binding.appUninstall.setOnClickListener { uninstall() }
}
/* manage initial preview and clicks for favorite apps */
@SuppressLint("PrivateResource")
private fun favoriteApps() {
val sharedPreferences = requireContext().getSharedPreferences(PREFS_FAVORITE_APPS, 0)
val enabledStroke =
ColorStateList.valueOf(requireContext().getColor(com.google.android.material.R.color.material_on_surface_stroke))
val disabledStroke =
ColorStateList.valueOf(requireContext().getColor(com.google.android.material.R.color.m3_chip_stroke_color))
for (position in 1..MAX_FAVORITE_APPS) {
val button = outlinedButton
val savedPackageName = sharedPreferences.getString(KEY_APP_NO_ + position, "")
/* set previews */
if (packageName == savedPackageName) button.isChecked = true
if (savedPackageName?.isNotEmpty() == true) button.strokeColor = enabledStroke
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
packageManager.getPackageInfo(savedPackageName!!, PackageManager.PackageInfoFlags.of(0))
else
packageManager.getPackageInfo(savedPackageName!!, 0)
} catch (e: PackageManager.NameNotFoundException) {
requireContext().getSharedPreferences(PREFS_FAVORITE_APPS, 0)
.edit().remove(KEY_APP_NO_ + position).apply()
button.strokeColor = disabledStroke
e.printStackTrace()
}
/* listen on clicks */
binding.favGroup.addOnButtonCheckedListener { _: MaterialButtonToggleGroup?,
checkedId: Int, isChecked: Boolean ->
try {
if (checkedId == button.id) {
if (isChecked) {
requireContext().getSharedPreferences(PREFS_FAVORITE_APPS, 0)
.edit().putString(KEY_APP_NO_ + position, packageName).apply()
button.strokeColor = enabledStroke
} else {
requireContext().getSharedPreferences(PREFS_FAVORITE_APPS, 0)
.edit().remove(KEY_APP_NO_ + position).apply()
button.strokeColor = disabledStroke
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}
private fun appName() {
binding.appName.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) binding.appName.minWidth = resources.getDimensionPixelOffset(R.dimen.twoSeventySix)
else {
(requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
.hideSoftInputFromWindow(binding.appName.windowToken, 0)
binding.appName.apply {
minWidth = resources.getDimensionPixelOffset(R.dimen.zero)
if (text!!.isBlank()) setText(defAppName)
else setText(text!!.trim())
if (text.toString() == defAppName) appNamesPrefs?.edit()!!.remove(packageName).apply()
else appNamesPrefs?.edit()!!.putString(packageName, text.toString()).apply()
(requireParentFragment() as AppDrawer).fetchApps()
}
}
}
binding.appName.setOnKeyListener { _, keyCode, event ->
if (event.action == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_BACK) {
binding.appName.clearFocus()
return@setOnKeyListener true
}
}
false
}
}
/* detailed info dialog */
@SuppressLint("SetTextI18n")
private fun detailedInfo() {
val dialogBinding = AppInfoDialogBinding.inflate(lActivity!!.layoutInflater)
MaterialAlertDialogBuilder(lActivity!!)
.setView(dialogBinding.root)
.setPositiveButton(android.R.string.cancel, null)
.show()
/* show app name */
dialogBinding.appName.text = packageManager.getApplicationLabel(appInfo)
/* get package info */
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0))
} else {
packageManager.getPackageInfo(packageName, 0)
}
/* show infos */
dialogBinding.mixed.text =
"${resources.getString(R.string.version)}: ${packageInfo.versionName} (${PackageInfoCompat.getLongVersionCode(packageInfo).toInt()})\n" +
"${resources.getString(R.string.sdk)}: ${appInfo.minSdkVersion} ~ ${appInfo.targetSdkVersion}\n" +
"${resources.getString(R.string.uid)}: ${appInfo.uid}\n" +
"${resources.getString(R.string.first_install)}: ${dateTimeFormat(packageInfo.firstInstallTime)}\n" +
"${resources.getString(R.string.last_update)}: ${dateTimeFormat(packageInfo.lastUpdateTime)}"
/* show permissions */
dialogBinding.permissions.text = permissionsList
}
/* activity browser dialog */
private fun activityBrowser() {
val dialogBinding = ActivityBrowserDialogBinding.inflate(lActivity!!.layoutInflater)
val dialogBuilder = MaterialAlertDialogBuilder(lActivity!!)
.setView(dialogBinding.root)
.setPositiveButton(android.R.string.cancel, null)
.show()
/* show app name */
dialogBinding.appName.text = packageManager.getApplicationLabel(appInfo)
/* get activity info */
val activityInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.getPackageInfo(
packageName, PackageManager.PackageInfoFlags.of(PackageManager.GET_ACTIVITIES.toLong())
)
} else {
packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
}
/* show activity list */
val activityAdapter: ArrayAdapter<String> =
ArrayAdapter(requireContext(), R.layout.list_item, R.id.itemText, ArrayList())
if (activityInfo.activities.isNotEmpty()) {
for (activity in activityInfo.activities) {
activityAdapter.add(
activity.toString().split(" ").toTypedArray()[1].replace("}", "")
)
}
dialogBinding.activityList.adapter = activityAdapter
}
/* listen item clicks */
dialogBinding.activityList.onItemClickListener =
AdapterView.OnItemClickListener { _: AdapterView<*>?, _: View?, i: Int, _: Long ->
try {
/* open activity */
val intent = Intent()
intent.component = ComponentName(packageName, activityAdapter.getItem(i).toString())
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
requireContext().startActivity(intent)
} catch (exception: Exception) {
/* couldn't open activity */
exception.printStackTrace()
val exceptionShort = (exception.toString().split(": ").toTypedArray())[0]
Toast.makeText(requireContext(),
"${resources.getString(R.string.unable_to_launch)} -\n$exceptionShort", Toast.LENGTH_LONG).show()
}
dialogBuilder.dismiss()
}
}
/* open app's page in app store/market */
private fun appStore() {
try {
val storeIntent = Intent(Intent.ACTION_VIEW)
storeIntent.data = Uri.parse("market://details?id=$packageName")
storeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
requireContext().startActivity(storeIntent)
} catch (activityNotFoundException: ActivityNotFoundException) {
/* no app store found exception */
Toast.makeText(requireContext(), requireContext().getString(R.string.null_app_store_message),
Toast.LENGTH_SHORT).show()
activityNotFoundException.printStackTrace()
}
this.dismiss()
}
/* launch app as a freeform window */
private fun freeform() {
val freeformIntent = requireContext().packageManager.getLaunchIntentForPackage(packageName)
freeformIntent!!.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT or
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
val rect = Rect(0, screenHeight / 2, screenWidth, screenHeight)
var activityOptions = activityOptions
activityOptions = activityOptions.setLaunchBounds(rect)
requireContext().startActivity(freeformIntent, activityOptions.toBundle())
this.dismiss()
}
/* open android's app info screen */
private fun appInfo() {
val infoIntent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
infoIntent.data = Uri.parse("package:$packageName")
infoIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
requireContext().startActivity(infoIntent)
this.dismiss()
}
private fun share() {
try {
// Create a temporary file to copy the APK
val apkLabel = packageManager.getApplicationLabel(appInfo).toString().lowercase().replace(" ", "_")
val tempApkFile = File(requireContext().externalCacheDir, "$apkLabel.apk")
// Copy the APK file
FileInputStream(File(appInfo.sourceDir)).use { `in` ->
FileOutputStream(tempApkFile).use { out ->
val buffer = ByteArray(1024)
var length: Int
while (`in`.read(buffer).also { length = it } > 0) {
out.write(buffer, 0, length)
}
}
}
// Generate a content URI using FileProvider
val contentUri =
FileProvider.getUriForFile(requireContext(), "${requireContext().packageName}.fileprovider", tempApkFile)
//requireContext().grantUriPermission(receivers.package.name, contentUri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
// Create a Share Intent
Intent(Intent.ACTION_SEND).apply {
type = "application/vnd.android.package-archive"
putExtra(Intent.EXTRA_STREAM, contentUri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}.let {
// Start the chooser activity
startActivity(Intent.createChooser(it, getString(R.string.share_apk_message)))
}
}
catch (e: PackageManager.NameNotFoundException) { e.printStackTrace() }
catch (e: IOException) { e.printStackTrace() }
this.dismiss()
}
/* uninstall the app */
private fun uninstall() {
val uninstallIntent = Intent(Intent.ACTION_DELETE)
uninstallIntent.data = Uri.parse("package:$packageName")
uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
requireContext().startActivity(uninstallIntent)
this.dismiss()
}
/* create and add an outlined button to the toggle group */
private val outlinedButton: MaterialButton get() {
val style = com.google.android.material.R.attr.materialButtonOutlinedStyle
val button = MaterialButton(requireContext(), null, style)
button.layoutParams = LinearLayoutCompat.LayoutParams(
LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
LinearLayoutCompat.LayoutParams.WRAP_CONTENT, 1F
)
binding.favGroup.addView(button)
return button
}
/* long value to local date-time format */
private fun dateTimeFormat(long: Long) : String = SimpleDateFormat.getDateTimeInstance().format(Date(long))
/* get and arrange all the permissions for an application */
private val permissionsList : String get() {
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(PackageManager.GET_PERMISSIONS.toLong()))
} else {
packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS)
}
return if (packageInfo.requestedPermissions.isNotEmpty()) {
val stringBuilder = StringBuilder()
packageInfo.requestedPermissions.indices.forEach { i: Int ->
if (i != packageInfo.requestedPermissions.size - 1)
stringBuilder.append("${packageInfo.requestedPermissions[i]}\n\n")
/* don't add any new line after the last entry */
else
stringBuilder.append(packageInfo.requestedPermissions[i])
}
stringBuilder.toString()
} else {
""
}
}
/* get activity options for launching app in freeform mode */
private val activityOptions: ActivityOptions get() {
val activityOptions = ActivityOptions.makeBasic()
try {
val method =
ActivityOptions::class.java.getMethod("setLaunchWindowingMode", Int::class.javaPrimitiveType)
method.invoke(activityOptions, 5)
} catch (exception: Exception) {
exception.printStackTrace()
}
return activityOptions
}
}
@@ -0,0 +1,159 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.apps
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.util.TypedValue
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.updatePadding
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.textview.MaterialTextView
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.apps.IconPackManager.Companion.getDrawableIconForPackage
import rasel.lunar.launcher.databinding.AppsChildBinding
import rasel.lunar.launcher.helpers.UniUtils.Companion.dpToPx
internal class AppsAdapter(
private val layoutType: Int,
private val packageManager: PackageManager,
private val fragmentManager: FragmentManager,
private val appsCount: MaterialTextView) : RecyclerView.Adapter<AppsAdapter.AppsViewHolder>() {
private var oldList = mutableListOf<Packages>()
private var appGravity: Int = Gravity.CENTER
companion object {
@JvmStatic var appsSize: Int? = null
}
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): AppsViewHolder =
AppsViewHolder(AppsChildBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false))
override fun onBindViewHolder(holder: AppsViewHolder, i: Int) {
val item = oldList[i]
val fourDp = dpToPx(lActivity!!, R.dimen.four)
val eightDp = dpToPx(lActivity!!, R.dimen.eight)
val twelveDp = dpToPx(lActivity!!, R.dimen.twelve)
val sixteenDp = dpToPx(lActivity!!, R.dimen.sixteen)
holder.view.apply {
childTextview.text = item.appName
when (layoutType) {
0 -> {
appIcon.visibility = View.GONE
appIconTwo.visibility = View.GONE
childTextview.apply {
gravity = appGravity
setTextSize(TypedValue.COMPLEX_UNIT_PX, lActivity!!.resources.getDimension(R.dimen.twentyTwo))
}
root.setPadding(sixteenDp, fourDp, sixteenDp, fourDp)
}
1 -> {
appIcon.visibility = View.GONE
appIconTwo.setImageDrawable(getDrawableIconForPackage(item.packageName, packageManager.getApplicationIcon(item.packageName)))
childTextview.apply {
gravity = appGravity or Gravity.CENTER_VERTICAL
setTextSize(TypedValue.COMPLEX_UNIT_PX, lActivity!!.resources.getDimension(R.dimen.twenty))
updatePadding(left = twelveDp)
}
root.setPadding(sixteenDp, eightDp, sixteenDp, eightDp)
}
2 -> {
appIconTwo.visibility = View.GONE
appIcon.setImageDrawable(getDrawableIconForPackage(item.packageName, packageManager.getApplicationIcon(item.packageName)))
childTextview.apply {
gravity = Gravity.CENTER
setTextSize(TypedValue.COMPLEX_UNIT_PX, lActivity!!.resources.getDimension(R.dimen.twelve))
}
root.setPadding(eightDp, eightDp, eightDp, eightDp)
}
}
}
holder.view.root.apply {
/* on click - open app */
setOnClickListener {
context.startActivity(packageManager.getLaunchIntentForPackage(item.packageName))
}
/* on long click - open app menu */
setOnLongClickListener {
AppMenu().show(fragmentManager, item.packageName)
true
}
}
}
override fun getItemCount(): Int = oldList.size
inner class AppsViewHolder(var view: AppsChildBinding) : RecyclerView.ViewHolder(view.root)
/* update app list */
fun updateData(newList: List<Packages>) {
val diffUtilResult = DiffUtil.calculateDiff(AppsDiffUtil(oldList, newList))
oldList.clear()
oldList.addAll(newList)
diffUtilResult.dispatchUpdatesTo(this)
newList.size.let {
appsCount.text = it.toString()
appsSize = it
}
}
/* update text gravity (alignment) */
@SuppressLint("RtlHardcoded", "NotifyDataSetChanged")
fun updateGravity(gravity: Int){
/* the first check is to avoid calling notifyDataSetChanged() everytime */
if (gravity != appGravity &&
(gravity == Gravity.LEFT || gravity == Gravity.CENTER || gravity == Gravity.RIGHT)) {
appGravity = gravity
notifyDataSetChanged()
}
}
}
internal data class Packages (
val packageName: String,
val appName: String
)
internal class AppsDiffUtil(
private val oldList: List<Packages>, private val newList: List<Packages>
) : DiffUtil.Callback() {
override fun getOldListSize(): Int = oldList.size
override fun getNewListSize(): Int = newList.size
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
oldList[oldItemPosition].packageName == newList[newItemPosition].packageName
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
oldList[oldItemPosition] == newList[newItemPosition]
}
@@ -0,0 +1,181 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.apps
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.Log
import androidx.core.content.res.ResourcesCompat
import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParserFactory
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_ICON_PACK
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_PACK
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.utils.BLog
import java.io.IOException
import java.util.Locale
internal class IconPackManager {
@SuppressLint("DiscouragedApi")
companion object {
private val settingsPrefs = lActivity!!.getSharedPreferences(PREFS_SETTINGS, 0)
private val packageName = settingsPrefs.getString(KEY_ICON_PACK, DEFAULT_ICON_PACK)
private var loaded = false
private val packagesDrawables = HashMap<String?, String?>()
private val backImages: MutableList<Bitmap> = ArrayList()
private var maskImage: Bitmap? = null
private var frontImage: Bitmap? = null
private var factor = 1.0f
private var totalIcons = 0
private var iconPackRes: Resources? = null
private fun load() {
/* load appfilter.xml from the icon pack package */
try {
var xpp: XmlPullParser? = null
iconPackRes = lActivity!!.packageManager.getResourcesForApplication(packageName!!)
val appFilterId = iconPackRes!!.getIdentifier("appfilter", "xml", packageName)
if (appFilterId > 0) {
xpp = iconPackRes!!.getXml(appFilterId)
} else {
/* no resource found, try to open it from assets folder */
try {
xpp = XmlPullParserFactory.newInstance().apply { isNamespaceAware = true }
.newPullParser().apply { setInput(iconPackRes!!.assets.open("appfilter.xml"), "utf-8") }
} catch (e: IOException) {
e.printStackTrace()
BLog.w("", "Couldn't find the appfilter.xml file")
}
}
if (xpp != null) {
var eventType = xpp.eventType
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
when (xpp.name) {
"iconback" -> {
for (i in 0 until xpp.attributeCount) {
if (xpp.getAttributeName(i).startsWith("img")) {
loadBitmap(xpp.getAttributeValue(i))?.let { backImages.add(it) }
}
}
}
"iconmask" -> {
if (xpp.attributeCount > 0 && xpp.getAttributeName(0) == "img1") {
maskImage = loadBitmap(xpp.getAttributeValue(0))
}
}
"iconupon" -> {
if (xpp.attributeCount > 0 && xpp.getAttributeName(0) == "img1") {
frontImage = loadBitmap(xpp.getAttributeValue(0))
}
}
"scale" -> {
if (xpp.attributeCount > 0 && xpp.getAttributeName(0) == "factor") {
factor = java.lang.Float.valueOf(xpp.getAttributeValue(0))
}
}
"item" -> {
var componentName: String? = null
var drawableName: String? = null
for (i in 0 until xpp.attributeCount) {
when (xpp.getAttributeName(i)) {
"component" -> componentName = xpp.getAttributeValue(i)
"drawable" -> drawableName = xpp.getAttributeValue(i)
}
}
if (!packagesDrawables.containsKey(componentName)) {
packagesDrawables[componentName] = drawableName
totalIcons += 1
}
}
}
}
eventType = xpp.next()
}
}
loaded = true
} catch (e: PackageManager.NameNotFoundException) {
BLog.w("", "Failed to load the icon pack")
} catch (e: XmlPullParserException) {
BLog.w("", "Failed to parse the appfilter.xml file")
} catch (e: IOException) {
e.printStackTrace()
}
}
private fun loadBitmap(drawableName: String): Bitmap? {
iconPackRes!!.getIdentifier(drawableName, "drawable", packageName).let { id ->
if (id > 0) {
ResourcesCompat.getDrawable(iconPackRes!!, id, null).let {
if (it is BitmapDrawable) return it.bitmap
}
}
}
return null
}
private fun loadDrawable(drawableName: String): Drawable? {
iconPackRes!!.getIdentifier(drawableName, "drawable", packageName).let {
return if (it > 0) ResourcesCompat.getDrawable(iconPackRes!!, it, null)
else null
}
}
fun getDrawableIconForPackage(appPackageName: String?, defaultDrawable: Drawable?): Drawable? {
when (packageName) {
DEFAULT_ICON_PACK -> return defaultDrawable
else -> {
if (!loaded) load()
var componentName: String? = null
if (lActivity!!.packageManager.getLaunchIntentForPackage(appPackageName!!) != null) {
componentName = lActivity!!.packageManager.getLaunchIntentForPackage(appPackageName)!!.component.toString()
}
var drawable = packagesDrawables[componentName]
if (!drawable.isNullOrEmpty()) return loadDrawable(drawable)
else {
/* try to get a resource with the component filename */
if (!componentName.isNullOrEmpty()) {
val start = componentName.indexOf("{") + 1
val end = componentName.indexOf("}", start)
if (end > start) {
drawable = componentName.substring(start, end).lowercase(Locale.getDefault()).replace(".", "_").replace("/", "_")
try {
if (iconPackRes!!.getIdentifier(drawable, "drawable", packageName) > 0) return loadDrawable(drawable)
} catch (e: NullPointerException) {
settingsPrefs.edit().putString(KEY_ICON_PACK, DEFAULT_ICON_PACK).apply()
}
}
}
}
return defaultDrawable
}
}
}
}
}
@@ -0,0 +1,705 @@
package rasel.lunar.launcher.apps
import android.os.SystemClock
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.View.OnTouchListener
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.sqrt
class GestureAnalyser @JvmOverloads constructor(
swipeSlopeIntolerance: Int = 3,
doubleTapMaxDelayMillis: Int = 500,
doubleTapMaxDownMillis: Int = 100
) {
private val initialX = DoubleArray(5)
private val initialY = DoubleArray(5)
private val finalX = DoubleArray(5)
private val finalY = DoubleArray(5)
private val currentX = DoubleArray(5)
private val currentY = DoubleArray(5)
private val delX = DoubleArray(5)
private val delY = DoubleArray(5)
private var numFingers = 0
private var initialT: Long = 0
private var finalT: Long = 0
private var currentT: Long = 0
private var prevInitialT: Long = 0
private var prevFinalT: Long = 0
private var swipeSlopeIntolerance = 3
private val doubleTapMaxDelayMillis: Long
private val doubleTapMaxDownMillis: Long
init {
this.swipeSlopeIntolerance = swipeSlopeIntolerance
this.doubleTapMaxDownMillis = doubleTapMaxDownMillis.toLong()
this.doubleTapMaxDelayMillis = doubleTapMaxDelayMillis.toLong()
}
fun trackGesture(ev: MotionEvent) {
val n = ev.pointerCount
for (i in 0 until n) {
initialX[i] = ev.getX(i).toDouble()
initialY[i] = ev.getY(i).toDouble()
}
numFingers = n
initialT = SystemClock.uptimeMillis()
}
fun untrackGesture() {
numFingers = 0
prevFinalT = SystemClock.uptimeMillis()
prevInitialT = initialT
}
fun getGesture(ev: MotionEvent): GestureType {
var averageDistance = 0.0
for (i in 0 until numFingers) {
finalX[i] = ev.getX(i).toDouble()
finalY[i] = ev.getY(i).toDouble()
delX[i] = finalX[i] - initialX[i]
delY[i] = finalY[i] - initialY[i]
averageDistance += sqrt(
(finalX[i] - initialX[i]).pow(2.0) + (finalY[i] - initialY[i]).pow(
2.0
)
)
}
averageDistance /= numFingers.toDouble()
finalT = SystemClock.uptimeMillis()
val gt = GestureType()
gt.gestureFlag = calcGesture()
gt.gestureDuration = finalT - initialT
gt.gestureDistance = averageDistance
return gt
}
fun getOngoingGesture(ev: MotionEvent): Int {
for (i in 0 until numFingers) {
currentX[i] = ev.getX(i).toDouble()
currentY[i] = ev.getY(i).toDouble()
delX[i] = finalX[i] - initialX[i]
delY[i] = finalY[i] - initialY[i]
}
currentT = SystemClock.uptimeMillis()
return calcGesture()
}
private fun calcGesture(): Int {
if (isDoubleTap) {
return DOUBLE_TAP_1
}
if (numFingers == 1) {
if ((-(delY[0])) > (swipeSlopeIntolerance * (abs(
delX[0]
)))
) {
return SWIPE_1_UP
}
if (((delY[0])) > (swipeSlopeIntolerance * (abs(
delX[0]
)))
) {
return SWIPE_1_DOWN
}
if ((-(delX[0])) > (swipeSlopeIntolerance * (abs(
delY[0]
)))
) {
return SWIPE_1_LEFT
}
if (((delX[0])) > (swipeSlopeIntolerance * (abs(
delY[0]
)))
) {
return SWIPE_1_RIGHT
}
}
if (numFingers == 2) {
if (((-delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
))) && ((-delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
) {
return SWIPE_2_UP
}
if (((delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
))) && ((delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
) {
return SWIPE_2_DOWN
}
if (((-delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
))) && ((-delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
) {
return SWIPE_2_LEFT
}
if (((delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
))) && ((delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
) {
return SWIPE_2_RIGHT
}
if (finalFingDist(0, 1) > 2 * (initialFingDist(0, 1))) {
return UNPINCH_2
}
if (finalFingDist(0, 1) < 0.5 * (initialFingDist(0, 1))) {
return PINCH_2
}
}
if (numFingers == 3) {
if (((-delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((-delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((-delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
) {
return SWIPE_3_UP
}
if (((delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
) {
return SWIPE_3_DOWN
}
if (((-delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((-delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((-delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
) {
return SWIPE_3_LEFT
}
if (((delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
) {
return SWIPE_3_RIGHT
}
if ((finalFingDist(0, 1) > 1.75 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) > 1.75 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 0) > 1.75 * (initialFingDist(2, 0)))
) {
return UNPINCH_3
}
if ((finalFingDist(0, 1) < 0.66 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) < 0.66 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 0) < 0.66 * (initialFingDist(2, 0)))
) {
return PINCH_3
}
}
if (numFingers == 4) {
if (((-delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((-delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((-delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
&& ((-delY[3]) > (swipeSlopeIntolerance * abs(
delX[3]
)))
) {
return SWIPE_4_UP
}
if (((delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
&& ((delY[3]) > (swipeSlopeIntolerance * abs(
delX[3]
)))
) {
return SWIPE_4_DOWN
}
if (((-delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((-delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((-delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
&& ((-delX[3]) > (swipeSlopeIntolerance * abs(
delY[3]
)))
) {
return SWIPE_4_LEFT
}
if (((delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
&& ((delX[3]) > (swipeSlopeIntolerance * abs(
delY[3]
)))
) {
return SWIPE_4_RIGHT
}
if ((finalFingDist(0, 1) > 1.5 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) > 1.5 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 3) > 1.5 * (initialFingDist(2, 3)))
&& (finalFingDist(3, 0) > 1.5 * (initialFingDist(3, 0)))
) {
return UNPINCH_4
}
if ((finalFingDist(0, 1) < 0.8 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) < 0.8 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 3) < 0.8 * (initialFingDist(2, 3)))
&& (finalFingDist(3, 0) < 0.8 * (initialFingDist(3, 0)))
) {
return PINCH_4
}
}
return 0
}
private fun initialFingDist(fingNum1: Int, fingNum2: Int): Double {
return sqrt(
(initialX[fingNum1] - initialX[fingNum2]).pow(2.0) + (initialY[fingNum1] - initialY[fingNum2]).pow(
2.0
)
)
}
private fun finalFingDist(fingNum1: Int, fingNum2: Int): Double {
return sqrt(
(finalX[fingNum1] - finalX[fingNum2]).pow(2.0) + (finalY[fingNum1] - finalY[fingNum2]).pow(
2.0
)
)
}
val isDoubleTap: Boolean
get() = if (initialT - prevFinalT < doubleTapMaxDelayMillis && finalT - initialT < doubleTapMaxDownMillis && prevFinalT - prevInitialT < doubleTapMaxDownMillis) {
true
} else {
false
}
inner class GestureType {
var gestureFlag: Int = 0
var gestureDuration: Long = 0
var gestureDistance: Double = 0.0
}
companion object {
const val DEBUG: Boolean = true
// Finished gestures flags
const val SWIPE_1_UP: Int = 11
const val SWIPE_1_DOWN: Int = 12
const val SWIPE_1_LEFT: Int = 13
const val SWIPE_1_RIGHT: Int = 14
const val SWIPE_2_UP: Int = 21
const val SWIPE_2_DOWN: Int = 22
const val SWIPE_2_LEFT: Int = 23
const val SWIPE_2_RIGHT: Int = 24
const val SWIPE_3_UP: Int = 31
const val SWIPE_3_DOWN: Int = 32
const val SWIPE_3_LEFT: Int = 33
const val SWIPE_3_RIGHT: Int = 34
const val SWIPE_4_UP: Int = 41
const val SWIPE_4_DOWN: Int = 42
const val SWIPE_4_LEFT: Int = 43
const val SWIPE_4_RIGHT: Int = 44
const val PINCH_2: Int = 25
const val UNPINCH_2: Int = 26
const val PINCH_3: Int = 35
const val UNPINCH_3: Int = 36
const val PINCH_4: Int = 45
const val UNPINCH_4: Int = 46
const val DOUBLE_TAP_1: Int = 107
//Ongoing gesture flags
const val SWIPING_1_UP: Int = 101
const val SWIPING_1_DOWN: Int = 102
const val SWIPING_1_LEFT: Int = 103
const val SWIPING_1_RIGHT: Int = 104
const val SWIPING_2_UP: Int = 201
const val SWIPING_2_DOWN: Int = 202
const val SWIPING_2_LEFT: Int = 203
const val SWIPING_2_RIGHT: Int = 204
const val PINCHING: Int = 205
const val UNPINCHING: Int = 206
private const val TAG = "GestureAnalyser"
}
}
class SimpleFingerGestures : OnTouchListener {
private var debug = true
var consumeTouchEvents: Boolean = false
protected var tracking: BooleanArray = booleanArrayOf(false, false, false, false, false)
private var ga: GestureAnalyser
private var onFingerGestureListener: OnFingerGestureListener? = null
/**
* Constructor that creates an internal [in.championswimmer.sfg.lib.GestureAnalyser] object as well
*/
constructor() {
ga = GestureAnalyser()
}
constructor(
swipeSlopeIntolerance: Int,
doubleTapMaxDelayMillis: Int,
doubleTapMaxDownMillis: Int
) {
ga = GestureAnalyser(swipeSlopeIntolerance, doubleTapMaxDelayMillis, doubleTapMaxDownMillis)
}
fun setDebug(debug: Boolean) {
this.debug = debug
}
constructor(omfgl: OnFingerGestureListener?) {
ga = GestureAnalyser()
setOnFingerGestureListener(omfgl)
}
/**
* Register a callback to be invoked when multi-finger gestures take place
*
*
* <br></br>
*
*
* For the callbacks implemented via this, check the interface [in.championswimmer.sfg.lib.SimpleFingerGestures.OnFingerGestureListener]
*
*
* @param omfgl The callback that will run
*/
fun setOnFingerGestureListener(omfgl: OnFingerGestureListener?) {
onFingerGestureListener = omfgl
}
override fun onTouch(view: View, ev: MotionEvent): Boolean {
if (debug) Log.d(TAG, "onTouch")
when (ev.action and MotionEvent.ACTION_MASK) {
MotionEvent.ACTION_DOWN -> {
if (debug) Log.d(TAG, "ACTION_DOWN")
startTracking(0)
ga.trackGesture(ev)
return consumeTouchEvents
}
MotionEvent.ACTION_UP -> {
if (debug) Log.d(TAG, "ACTION_UP")
if (tracking[0]) {
doCallBack(ga.getGesture(ev))
}
stopTracking(0)
ga.untrackGesture()
return consumeTouchEvents
}
MotionEvent.ACTION_POINTER_DOWN -> {
if (debug) Log.d(TAG, "ACTION_POINTER_DOWN" + " " + "num" + ev.pointerCount)
startTracking(ev.pointerCount - 1)
ga.trackGesture(ev)
return consumeTouchEvents
}
MotionEvent.ACTION_POINTER_UP -> {
if (debug) Log.d(TAG, "ACTION_POINTER_UP" + " " + "num" + ev.pointerCount)
if (tracking[1]) {
doCallBack(ga.getGesture(ev))
}
stopTracking(ev.pointerCount - 1)
ga.untrackGesture()
return consumeTouchEvents
}
MotionEvent.ACTION_CANCEL -> {
if (debug) Log.d(TAG, "ACTION_CANCEL")
return true
}
MotionEvent.ACTION_MOVE -> {
if (debug) Log.d(TAG, "ACTION_MOVE")
return consumeTouchEvents
}
}
return consumeTouchEvents
}
private fun doCallBack(mGt: GestureAnalyser.GestureType) {
when (mGt.gestureFlag) {
GestureAnalyser.SWIPE_1_UP -> onFingerGestureListener!!.onSwipeUp(
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_1_DOWN -> onFingerGestureListener!!.onSwipeDown(
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_1_LEFT -> onFingerGestureListener!!.onSwipeLeft(
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_1_RIGHT -> onFingerGestureListener!!.onSwipeRight(
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_UP -> onFingerGestureListener!!.onSwipeUp(
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_DOWN -> onFingerGestureListener!!.onSwipeDown(
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_LEFT -> onFingerGestureListener!!.onSwipeLeft(
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_RIGHT -> onFingerGestureListener!!.onSwipeRight(
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.PINCH_2 -> onFingerGestureListener!!.onPinch(
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.UNPINCH_2 -> onFingerGestureListener!!.onUnpinch(
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_UP -> onFingerGestureListener!!.onSwipeUp(
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_DOWN -> onFingerGestureListener!!.onSwipeDown(
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_LEFT -> onFingerGestureListener!!.onSwipeLeft(
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_RIGHT -> onFingerGestureListener!!.onSwipeRight(
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.PINCH_3 -> onFingerGestureListener!!.onPinch(
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.UNPINCH_3 -> onFingerGestureListener!!.onUnpinch(
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_UP -> onFingerGestureListener!!.onSwipeUp(
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_DOWN -> onFingerGestureListener!!.onSwipeDown(
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_LEFT -> onFingerGestureListener!!.onSwipeLeft(
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_RIGHT -> onFingerGestureListener!!.onSwipeRight(
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.PINCH_4 -> onFingerGestureListener!!.onPinch(
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.UNPINCH_4 -> {
onFingerGestureListener!!.onUnpinch(4, mGt.gestureDuration, mGt.gestureDistance)
onFingerGestureListener!!.onDoubleTap(1)
}
GestureAnalyser.DOUBLE_TAP_1 -> onFingerGestureListener!!.onDoubleTap(1)
}
}
private fun startTracking(nthPointer: Int) {
for (i in 0..nthPointer) {
tracking[i] = true
}
}
private fun stopTracking(nthPointer: Int) {
for (i in nthPointer until tracking.size) {
tracking[i] = false
}
}
/**
* Interface definition for the callback to be invoked when 2-finger gestures are performed
*/
interface OnFingerGestureListener {
/**
* Called when user swipes **up** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeUp(fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user swipes **down** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeDown(fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user swipes **left** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeLeft(fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user swipes **right** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeRight(fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user **pinches** with two fingers (bring together)
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onPinch(fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user **un-pinches** with two fingers (take apart)
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onUnpinch(fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
fun onDoubleTap(fingers: Int): Boolean
}
companion object {
// Will see if these need to be used. For now just returning duration in milliS
const val GESTURE_SPEED_SLOW: Long = 1500
const val GESTURE_SPEED_MEDIUM: Long = 1000
const val GESTURE_SPEED_FAST: Long = 500
private const val TAG = "SimpleFingerGestures"
}
}
@@ -0,0 +1,356 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.feeds
import android.R.attr.*
import android.app.Activity.RESULT_CANCELED
import android.app.Activity.RESULT_OK
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.content.SharedPreferences
import android.os.*
import android.view.*
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.widget.LinearLayoutCompat.LayoutParams
import androidx.appcompat.widget.PopupMenu
import androidx.core.app.JobIntentService.enqueueWork
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.google.android.material.button.MaterialButtonToggleGroup
import kotlinx.coroutines.*
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.FeedsBinding
import rasel.lunar.launcher.feeds.rss.Rss
import rasel.lunar.launcher.feeds.rss.RssAdapter
import rasel.lunar.launcher.feeds.rss.RssService
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_HEIGHTS
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_IDS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_WIDGETS
import rasel.lunar.launcher.helpers.Constants.Companion.RSS_ITEMS
import rasel.lunar.launcher.helpers.Constants.Companion.RSS_RECEIVER
import rasel.lunar.launcher.helpers.Constants.Companion.SEPARATOR
import rasel.lunar.launcher.helpers.Constants.Companion.requestCreateWidget
import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget
import rasel.lunar.launcher.helpers.Constants.Companion.rssJobId
import rasel.lunar.launcher.helpers.UniUtils.Companion.isNetworkAvailable
import java.util.*
internal class Feeds : Fragment() {
private lateinit var binding: FeedsBinding
private val requestCodeString = "requestCode"
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FeedsBinding.inflate(inflater, container, false)
updateWidgets()
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
expandCollapse()
systemInfo()
}
override fun onResume() {
super.onResume()
registerForContextMenu(binding.widgetContainer)
}
override fun onPause() {
super.onPause()
unregisterForContextMenu(binding.widgetContainer)
}
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) {
super.onCreateContextMenu(menu, v, menuInfo)
menu.clearHeader()
lActivity!!.menuInflater.inflate(R.menu.add_widget, menu)
}
override fun onContextItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.add_widget) selectWidget()
return super.onContextItemSelected(item)
}
/* control view's expand-collapse actions */
private fun expandCollapse() {
binding.expandableButtons.addOnButtonCheckedListener { _: MaterialButtonToggleGroup?, checkedId: Int, isChecked: Boolean ->
if (isChecked) {
when (checkedId) {
binding.expandRss.id -> {
binding.feedsSysInfos.expandableSystemInfo.collapse()
binding.feedsRss.expandableRss.expand()
startService()
}
binding.expandSystemInfo.id -> {
binding.feedsRss.expandableRss.collapse()
binding.feedsSysInfos.expandableSystemInfo.expand()
}
}
} else {
when (checkedId) {
binding.expandRss.id -> binding.feedsRss.expandableRss.collapse()
binding.expandSystemInfo.id -> binding.feedsSysInfos.expandableSystemInfo.collapse()
}
}
}
}
/* start rss service if network is active and rss url is not empty */
private fun startService() {
val rssUrl = lActivity!!.getSharedPreferences(PREFS_SETTINGS, 0)
.getString(KEY_RSS_URL, "")
when {
isNetworkAvailable && !rssUrl.isNullOrEmpty() -> {
Intent(lActivity!!, RssService::class.java)
.putExtra(RSS_RECEIVER, resultReceiver).let {
enqueueWork(lActivity!!, RssService::class.java, rssJobId, it)
}
}
else -> resumeService()
}
}
/* retry to start rss service */
private fun resumeService() {
binding.feedsRss.apply {
rss.visibility = View.GONE
loading.visibility = View.GONE
refresh.visibility = View.VISIBLE
refresh.setOnClickListener { startService() }
}
}
/* rss service's result receiver */
@Suppress("UNCHECKED_CAST")
private val resultReceiver: ResultReceiver = object : ResultReceiver(Handler(Looper.getMainLooper())) {
override fun onReceiveResult(resultCode: Int, resultData: Bundle) {
when (val items = resultData.getSerializable(RSS_ITEMS) as List<Rss>?) {
null -> resumeService()
else -> {
binding.feedsRss.apply {
rss.adapter = RssAdapter(items, requireContext())
refresh.visibility = View.GONE
loading.visibility = View.GONE
rss.visibility = View.VISIBLE
}
}
}
}
}
private fun systemInfo() {
viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
SystemStats().apply {
intStorage(binding.feedsSysInfos.intParent)
extStorage(binding.feedsSysInfos.extParent)
while (isActive) {
ram(binding.feedsSysInfos.ramParent)
cpu(binding.feedsSysInfos.cpuParent)
misc(binding.feedsSysInfos.misc)
delay(1000)
}
}
}
}
}
private fun selectWidget() {
Intent(AppWidgetManager.ACTION_APPWIDGET_PICK).apply {
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetHost?.allocateAppWidgetId())
putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, ArrayList())
putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, ArrayList())
putExtra(requestCodeString, requestPickWidget)
}.let { widgetPicker.launch(it) }
}
private val widgetPicker =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
val data = result.data
val appWidgetId = data?.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1)
if (result.resultCode == RESULT_OK) {
when (data?.getIntExtra(requestCodeString, requestPickWidget)) {
requestPickWidget -> configureWidget(appWidgetId!!)
requestCreateWidget -> createWidget(appWidgetId!!, null)
}
} else if (result.resultCode == RESULT_CANCELED && data != null) {
if (appWidgetId != -1) appWidgetHost?.deleteAppWidgetId(appWidgetId!!)
}
}
private fun configureWidget(appWidgetId: Int) {
when (val appWidgetConfig = appWidgetManager!!.getAppWidgetInfo(appWidgetId).configure) {
null -> createWidget(appWidgetId, null)
else -> {
Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE).apply {
component = appWidgetConfig
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
putExtra(requestCodeString, requestCreateWidget)
}.let {
try { widgetPicker.launch(it) }
catch (e: Exception) { e.printStackTrace() }
}
}
}
}
private fun createWidget(appWidgetId: Int, height: Int?) {
if (appWidgetId == -1) return
val appWidgetInfo = appWidgetManager!!.getAppWidgetInfo(appWidgetId)
val params: LayoutParams?
when (height) {
null -> {
params = LayoutParams(LayoutParams.MATCH_PARENT, appWidgetInfo.minHeight)
val updatedIds = splitWidgetIds.plus("$appWidgetId")
val updatedHeights = splitWidgetHeights.plus("${appWidgetInfo.minHeight}")
saveWidgetData(updatedIds, updatedHeights)
}
else -> params = LayoutParams(LayoutParams.MATCH_PARENT, height)
}
(appWidgetHost?.createView(lActivity!!.applicationContext, appWidgetId, appWidgetInfo) as WidgetHostView)
.apply {
setAppWidget(appWidgetId, appWidgetInfo)
}.let {
binding.widgetContainer.addView(it, params)
widgetMenu(it)
}
}
private fun updateWidgets() {
if (splitWidgetIds.size > 0) {
viewLifecycleOwner.lifecycleScope.launch {
binding.widgetContainer.removeAllViews()
splitWidgetIds.indices.forEach { i: Int ->
createWidget(splitWidgetIds[i]!!.int(), splitWidgetHeights[i]!!.int())
}
}
}
}
private fun widgetMenu(hostView: WidgetHostView) {
val appWidgetId = hostView.appWidgetId
hostView.setOnLongClickListener {
PopupMenu(requireContext(), it, Gravity.END).apply {
menuInflater.inflate(R.menu.widget_menu, this.menu)
show()
setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.move_up -> moveWidget(appWidgetId, true)
R.id.move_down -> moveWidget(appWidgetId, false)
R.id.increase_height -> resizeWidget(appWidgetId, true)
R.id.decrease_height -> resizeWidget(appWidgetId, false)
R.id.delete_widget -> removeWidget(it as WidgetHostView)
}
false
}
}
true
}
}
private fun moveWidget(widgetId: Int, moveUp: Boolean) {
val tempIds = splitWidgetIds
val tempHeights = splitWidgetHeights
splitWidgetIds.indexOf(widgetId.toString()).let { i ->
when {
moveUp && i > 0 -> {
tempIds.swap(i-1, i)
tempHeights.swap(i-1, i)
}
!moveUp && i < splitWidgetIds.size - 1 -> {
tempIds.swap(i, i+1)
tempHeights.swap(i, i+1)
}
else -> return
}
}
saveWidgetData(tempIds, tempHeights)
updateWidgets()
}
private fun resizeWidget(widgetId: Int, shouldAdd: Boolean) {
val tempList = splitWidgetHeights
splitWidgetIds.indexOf(widgetId.toString()).let { i ->
tempList[i] = when (shouldAdd) {
true -> (splitWidgetHeights[i]!!.int().plus(50)).toString()
false -> (splitWidgetHeights[i]!!.int().minus(50)).toString()
}
}
widgetPref.edit().putString(KEY_WIDGET_HEIGHTS, tempList.joinToString(separator = SEPARATOR)).apply()
updateWidgets()
}
private fun removeWidget(hostView: WidgetHostView) {
hostView.let { v ->
appWidgetHost?.deleteAppWidgetId(v.appWidgetId)
binding.widgetContainer.removeView(v)
splitWidgetIds.indexOf(v.appWidgetId.toString()).let { i ->
saveWidgetData(splitWidgetIds.minus(splitWidgetIds[i]), splitWidgetHeights.minus(splitWidgetHeights[i]))
}
}
}
private fun saveWidgetData(idList: List<String?>, heightList: List<String?>) {
widgetPref.edit()
.putString(KEY_WIDGET_IDS, idList.joinToString(separator = SEPARATOR))
.putString(KEY_WIDGET_HEIGHTS, heightList.joinToString(separator = SEPARATOR))
.apply()
}
private val widgetPref: SharedPreferences get() = lActivity!!.getSharedPreferences(PREFS_WIDGETS, 0)
private val widgetIds: String? get() = widgetPref.getString(KEY_WIDGET_IDS, "")
private val widgetHeights: String? get() = widgetPref.getString(KEY_WIDGET_HEIGHTS, "")
private val splitWidgetIds: MutableList<String?> get() = widgetIds!!.split(SEPARATOR).toMutableList()
private val splitWidgetHeights: MutableList<String?> get() = widgetHeights!!.split(SEPARATOR).toMutableList()
private fun <T> MutableList<T>.swap(index1: Int, index2: Int){
val temp = this[index1]
this[index1] = this[index2]
this[index2] = temp
}
private fun String.int() : Int {
return try {
this.toInt()
} catch (e: Exception) {
-1
}
}
}
@@ -0,0 +1,297 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.feeds
import android.annotation.SuppressLint
import android.app.ActivityManager
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.*
import android.text.Html
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.ContextCompat
import com.google.android.material.progressindicator.LinearProgressIndicator
import com.google.android.material.textview.MaterialTextView
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.ChildSysInfoBinding
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TEMP_UNIT
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.UniUtils.Companion.isNetworkAvailable
import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader
import java.io.RandomAccessFile
import java.net.NetworkInterface
import java.util.*
import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt
internal class SystemStats {
private val toGb = 1.07374182E9f
private fun string(id: Int) : String { return lActivity!!.getString(id) }
private val inflater : LayoutInflater get() { return lActivity!!.layoutInflater }
/* ram info */
fun ram(ramParent: LinearLayoutCompat) {
val parent = ramParent.findViewById<View>(R.id.childSysInfo)
val indicator = parent.findViewById<LinearProgressIndicator>(R.id.indicator)
val textView = parent.findViewById<MaterialTextView>(R.id.textView)
val totalMem = memoryInfo.totalMem / toGb
val availMem = memoryInfo.availMem / toGb
val usedMem = totalMem - availMem
indicator.progress = (usedMem * 100 / totalMem).toInt()
textView.text = Html.fromHtml(
"<b>${string(R.string.ram)}</b><br>" +
"${string(R.string.total)}: ${String.format("%.03f", totalMem)} GB | " +
"${string(R.string.used)}: ${String.format("%.03f", usedMem)} GB | " +
"${string(R.string.free)}: ${String.format("%.03f", availMem)} GB",
Html.FROM_HTML_MODE_COMPACT)
}
/* cpu and battery info */
fun cpu(cpuParent: LinearLayoutCompat) {
val parent = cpuParent.findViewById<View>(R.id.childSysInfo)
val indicator = parent.findViewById<LinearProgressIndicator>(R.id.indicator)
val textView = parent.findViewById<MaterialTextView>(R.id.textView)
var cpuTemp = 0.0f
try {
val cpuTempProcess = Runtime.getRuntime().exec("cat sys/class/thermal/thermal_zone0/temp")
cpuTempProcess.waitFor()
val cpuTempReader = BufferedReader(InputStreamReader(cpuTempProcess.inputStream))
cpuTemp = cpuTempReader.readLine().toFloat() / 1000.0f
} catch (exception: Exception) {
exception.printStackTrace()
}
val finalCpuTemp = when (tempUnit) {
0 -> "$cpuTemp ºC"
1 -> "${String.format("%.01f", cpuTemp * 1.8 + 32)} ºF"
else -> "$cpuTemp ºC"
}
val cpuFreq = "${String.format("%.02f", minCpuFrequency.toFloat() / 1000)} - " +
"${String.format("%.02f", maxCpuFrequency.toFloat() / 1000)} GHz"
indicator.progress = when (maxCpuFrequency) {
0 -> 30
else -> frequencyOfCore * 100 / maxCpuFrequency
}
textView.text = Html.fromHtml(
"<b>${string(R.string.cpu)}</b><br>" +
"${string(R.string.temperature)}: $finalCpuTemp | " +
"${string(R.string.frequency)}: $cpuFreq",
Html.FROM_HTML_MODE_COMPACT)
}
/* internal storage */
fun intStorage(intParent: LinearLayoutCompat) {
val parent = intParent.findViewById<View>(R.id.childSysInfo)
val indicator = parent.findViewById<LinearProgressIndicator>(R.id.indicator)
val textView = parent.findViewById<MaterialTextView>(R.id.textView)
val intPath = Environment.getExternalStorageDirectory().absolutePath
val statFs = StatFs(intPath)
val totalStorage = statFs.blockCountLong * statFs.blockSizeLong / toGb
val availStorage = statFs.availableBlocksLong * statFs.blockSizeLong / toGb
val usedStorage = totalStorage - availStorage
indicator.progress = (usedStorage * 100 / totalStorage).toInt()
textView.text = Html.fromHtml(
"<b>${intPath + File.separator}</b><br>" +
"${string(R.string.total)}: ${String.format("%.03f", totalStorage)} GB | " +
"${string(R.string.used)}: ${String.format("%.03f", usedStorage)} GB | " +
"${string(R.string.free)}: ${String.format("%.03f", availStorage)} GB",
Html.FROM_HTML_MODE_COMPACT)
}
/* external storage */
fun extStorage(extParent: LinearLayoutCompat) {
val extStorages = ContextCompat.getExternalFilesDirs(lActivity!!, null)
/* sd card is available */
if (extStorages.size > 1) {
extParent.removeAllViews()
for (extStorage in extStorages) {
if (extStorage != null) {
val binding = ChildSysInfoBinding.inflate(inflater)
extParent.addView(binding.root)
val statFs = StatFs(extStorage.path)
val blockSize = statFs.blockSizeLong
val totalStorage = statFs.blockCountLong * blockSize / toGb
val availStorage = statFs.availableBlocksLong * blockSize / toGb
val usedStorage = totalStorage - availStorage
val sdcardPaths = extStorage.path.split(File.separator).toTypedArray()
val sdPath = File.separator + sdcardPaths[1] + File.separator + sdcardPaths[2] + File.separator
binding.indicator.progress = (usedStorage * 100 / totalStorage).toInt()
binding.textView.text = Html.fromHtml(
"<b>$sdPath</b><br>" +
"${string(R.string.total)}: ${String.format("%.03f", totalStorage)} GB | " +
"${string(R.string.used)}: ${String.format("%.03f", usedStorage)} GB | " +
"${string(R.string.free)}: ${String.format("%.03f", availStorage)} GB",
Html.FROM_HTML_MODE_COMPACT)
}
}
} else {
extParent.visibility = View.GONE
}
}
@SuppressLint("SetTextI18n")
fun misc(misc: MaterialTextView) {
val totalRootStorage = StatFs(Environment.getRootDirectory().path).blockCountLong *
StatFs(Environment.getRootDirectory().path).blockSizeLong / toGb
val batteryIntent = lActivity!!.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
val batteryTemp = batteryIntent!!.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0).toFloat() / 10
val voltage = batteryIntent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0).toFloat() / 1000
val finalBatteryTemp = when (tempUnit) {
0 -> "$batteryTemp ºC"
1 -> "${String.format("%.01f", batteryTemp * 1.8 + 32)} ºF"
else -> "$batteryTemp ºC"
}
misc.text =
"${longToString(SystemClock.elapsedRealtime())}\n" +
"${longToString(SystemClock.uptimeMillis())}\n" +
"${String.format("%.02f", memoryInfo.threshold / 1048576f)} MB\n" +
"$finalBatteryTemp\n" +
"$voltage V\n" +
"${String.format("%.03f", totalRootStorage)} GB\n" +
"${getIpAddress(true)}\n" +
getIpAddress(false)
}
private val memoryInfo: ActivityManager.MemoryInfo get() {
val memoryInfo = ActivityManager.MemoryInfo()
val activityManager = lActivity!!.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
activityManager.getMemoryInfo(memoryInfo)
return memoryInfo
}
private val tempUnit: Int get() =
lActivity!!.getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_TEMP_UNIT, 0)
private fun longToString(long: Long) : String {
var seconds = (long.toDouble() / 1000).roundToInt()
val hours = TimeUnit.SECONDS.toHours(seconds.toLong())
if (hours > 0) seconds -= TimeUnit.HOURS.toSeconds(hours).toInt()
val minutes = if (seconds > 0) TimeUnit.SECONDS.toMinutes(seconds.toLong()) else 0
if (minutes > 0) seconds -= TimeUnit.MINUTES.toSeconds(minutes).toInt()
return if (hours > 0) String.format("%02d:%02d:%02d", hours, minutes, seconds)
else String.format("%02d:%02d", minutes, seconds)
}
/* frequency of core */
private val frequencyOfCore: Int get() {
var currentFReq = 0
try {
val currentFreq: Double
val readerCurFreq =
RandomAccessFile("/sys/devices/system/cpu/cpu" + 0 + "/cpufreq/scaling_cur_freq", "r")
val curFreq = readerCurFreq.readLine()
currentFreq = curFreq.toDouble() / 1000
readerCurFreq.close()
currentFReq = currentFreq.toInt()
println("$currentFReq----------------------------------------------------")
} catch (ex: java.lang.Exception) {
ex.printStackTrace()
}
return currentFReq
}
/* minimum cpu frequency */
private val minCpuFrequency: Int get() {
var minFreq = -1
try {
val randomAccessFile =
RandomAccessFile("/sys/devices/system/cpu/cpu" + 0 + "/cpufreq/cpuinfo_min_freq", "r")
while (true) {
val line = randomAccessFile.readLine() ?: break
val timeInState = line.toInt()
if (timeInState > 0) {
val freq = timeInState / 1000
if (freq > minFreq) {
minFreq = freq
}
}
}
} catch (exception: java.lang.Exception) {
exception.printStackTrace()
}
return minFreq
}
/* maximum cpu frequency */
private val maxCpuFrequency: Int get() {
var currentFReq = 0
try {
val currentFreq: Double
val readerCurFreq =
RandomAccessFile("/sys/devices/system/cpu/cpu" + 0 + "/cpufreq/cpuinfo_max_freq", "r")
val curFreq = readerCurFreq.readLine()
currentFreq = curFreq.toDouble() / 1000
readerCurFreq.close()
currentFReq = currentFreq.toInt()
} catch (exception: java.lang.Exception) {
exception.printStackTrace()
}
return currentFReq
}
private fun getIpAddress(getIPv4: Boolean): String {
try {
for (interFace in Collections.list(NetworkInterface.getNetworkInterfaces())) {
for (address in Collections.list(interFace.inetAddresses)) {
if (!address.isLoopbackAddress) {
val addressStr = address.hostAddress
val isIPv4 = addressStr!!.indexOf(':') < 0
if (getIPv4) {
if (isIPv4) return addressStr
} else {
if (!isIPv4 && isNetworkAvailable) {
val endIndex = addressStr.indexOf('%')
return if (endIndex < 0) addressStr
else addressStr.substring(0, endIndex)
}
}
}
}
}
} catch (e: java.lang.Exception) { e.printStackTrace() }
return string(R.string.na)
}
}
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rasel.lunar.launcher.feeds
import android.appwidget.AppWidgetHost
import android.appwidget.AppWidgetHostView
import android.appwidget.AppWidgetProviderInfo
import android.content.Context
internal class WidgetHost(context: Context, hostId: Int) : AppWidgetHost(context, hostId) {
override fun onCreateView(context: Context?, appWidgetId: Int, appWidget: AppWidgetProviderInfo?
): AppWidgetHostView = WidgetHostView(context!!)
override fun stopListening() {
super.stopListening()
clearViews()
}
}
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rasel.lunar.launcher.feeds
import android.appwidget.AppWidgetHostView
import android.content.Context
import android.view.MotionEvent
import android.view.ViewConfiguration
import kotlin.math.abs
internal class WidgetHostView(context: Context) : AppWidgetHostView(context) {
private var hasPerformedLongPress = false
private var pendingCheckForLongPress: CheckForLongPress? = null
private var xPos = 0f
private var yPos = 0f
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
// Consume any touch events for ourselves after longpress is triggered
if (hasPerformedLongPress) {
hasPerformedLongPress = false
return true
}
// Watch for long press events at this level to make sure
// users can always pick up this widget
when (ev.action) {
MotionEvent.ACTION_DOWN -> {
postCheckForLongClick()
xPos = ev.x
yPos = ev.y
}
MotionEvent.ACTION_MOVE -> {
if (abs(ev.x - xPos) > 5 || abs(ev.y - yPos) > 5) {
hasPerformedLongPress = false
if (pendingCheckForLongPress != null) removeCallbacks(pendingCheckForLongPress)
}
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
hasPerformedLongPress = false
if (pendingCheckForLongPress != null) removeCallbacks(pendingCheckForLongPress)
}
}
// Otherwise continue letting touch events fall through to children
return false
}
internal inner class CheckForLongPress : Runnable {
private var originalWindowAttachCount = 0
override fun run() {
if (parent != null && hasWindowFocus()
&& originalWindowAttachCount == windowAttachCount && !hasPerformedLongPress
) {
if (performLongClick()) hasPerformedLongPress = true
}
}
fun rememberWindowAttachCount() { originalWindowAttachCount = windowAttachCount }
}
private fun postCheckForLongClick() {
hasPerformedLongPress = false
if (pendingCheckForLongPress == null) pendingCheckForLongPress = CheckForLongPress()
pendingCheckForLongPress!!.rememberWindowAttachCount()
postDelayed(pendingCheckForLongPress, ViewConfiguration.getLongPressTimeout().toLong())
}
override fun cancelLongPress() {
super.cancelLongPress()
hasPerformedLongPress = false
if (pendingCheckForLongPress != null) removeCallbacks(pendingCheckForLongPress)
}
override fun getDescendantFocusability(): Int = FOCUS_BLOCK_DESCENDANTS
}
@@ -0,0 +1,25 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.feeds.rss
internal class Rss(
val title: String,
val link: String
)
@@ -0,0 +1,85 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.feeds.rss
import androidx.recyclerview.widget.RecyclerView
import android.view.ViewGroup
import android.view.LayoutInflater
import android.annotation.SuppressLint
import android.content.Context
import android.view.Gravity
import androidx.core.content.ContextCompat
import android.graphics.Typeface
import android.util.TypedValue
import android.content.res.ColorStateList
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import rasel.lunar.launcher.databinding.ListItemBinding
import rasel.lunar.launcher.helpers.UniUtils.Companion.getColorResId
internal class RssAdapter(private val items: List<Rss>, private val context: Context) :
RecyclerView.Adapter<RssAdapter.RssViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RssViewHolder {
val binding = ListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return RssViewHolder(binding)
}
override fun getItemCount(): Int = items.size
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: RssViewHolder, position: Int) {
/* customize the first item */
if (position == 0) {
holder.view.itemText.apply {
text = "\u22B6 " + items[position].title + " \u22B7"
gravity = Gravity.CENTER
setTextColor(ContextCompat.getColor(context,
getColorResId(context, com.google.android.material.R.attr.colorPrimary)))
setTypeface(null, Typeface.BOLD)
textSize = 18f
}
/* reset customization for rest */
} else {
holder.view.itemText.apply {
text = items[position].title
gravity = holder.gravity
setTextColor(holder.color)
typeface = holder.typeface
setTextSize(TypedValue.COMPLEX_UNIT_PX, holder.size)
}
}
/* on click - open in browser */
holder.view.itemText.setOnClickListener {
val customTabsIntent = CustomTabsIntent.Builder().setUrlBarHidingEnabled(true).build()
customTabsIntent.launchUrl(context, Uri.parse(items[position].link))
}
}
inner class RssViewHolder(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root) {
/* store previous styles for resetting */
var gravity: Int = view.itemText.gravity
var color: ColorStateList = view.itemText.textColors
var typeface: Typeface = view.itemText.typeface
var size: Float = view.itemText.textSize
}
}
@@ -0,0 +1,98 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.feeds.rss
import kotlin.Throws
import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParser
import android.util.Xml
import java.io.IOException
import java.io.InputStream
import java.util.ArrayList
internal class RssParser {
@Throws(XmlPullParserException::class, IOException::class)
fun parse(inputStream: InputStream): List<Rss> {
return inputStream.use { stream ->
val parser = Xml.newPullParser()
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false)
parser.setInput(stream, null)
parser.nextTag()
readFeed(parser)
}
}
@Throws(XmlPullParserException::class, IOException::class)
private fun readFeed(parser: XmlPullParser): List<Rss> {
parser.require(XmlPullParser.START_TAG, null, "rss")
var title: String? = null
var link: String? = null
val items: MutableList<Rss> = ArrayList()
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.eventType != XmlPullParser.START_TAG) {
continue
}
val name = parser.name
if (name == "title") {
title = readTitle(parser)
} else if (name == "link") {
link = readLink(parser)
}
if (title != null && link != null) {
val item = Rss(title, link)
items.add(item)
title = null
link = null
}
}
return items
}
@Throws(XmlPullParserException::class, IOException::class)
private fun readLink(parser: XmlPullParser): String {
parser.require(XmlPullParser.START_TAG, null, "link")
val link = readText(parser)
parser.require(XmlPullParser.END_TAG, null, "link")
return link
}
@Throws(XmlPullParserException::class, IOException::class)
private fun readTitle(parser: XmlPullParser): String {
parser.require(XmlPullParser.START_TAG, null, "title")
val title = readText(parser)
parser.require(XmlPullParser.END_TAG, null, "title")
return title
}
@Throws(IOException::class, XmlPullParserException::class)
private fun readText(parser: XmlPullParser): String {
var result = ""
if (parser.next() == XmlPullParser.TEXT) {
result = parser.text
parser.nextTag()
}
return result
}
}
@@ -0,0 +1,72 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.feeds.rss
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.ResultReceiver
import androidx.core.app.JobIntentService
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.Constants.Companion.RSS_ITEMS
import rasel.lunar.launcher.helpers.Constants.Companion.RSS_RECEIVER
import java.io.IOException
import java.io.InputStream
import java.io.Serializable
import java.net.URL
internal class RssService : JobIntentService() {
override fun onHandleWork(intent: Intent) {
val settingsPrefs = getSharedPreferences(PREFS_SETTINGS, 0)
val rssUrl = settingsPrefs.getString(KEY_RSS_URL, "")
var rssItems: List<Rss?>? = null
try {
val parser = RssParser()
rssItems = getInputStream(rssUrl)?.let { parser.parse(it) }
} catch (exception: Exception) {
exception.printStackTrace()
}
val bundle = Bundle()
bundle.putSerializable(RSS_ITEMS, rssItems as? Serializable)
val receiver = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra(RSS_RECEIVER, ResultReceiver::class.java)
} else {
@Suppress("DEPRECATION") intent.getParcelableExtra(RSS_RECEIVER)
}
receiver?.send(0, bundle)
}
private fun getInputStream(link: String?): InputStream? {
return try {
val url = URL(link)
url.openConnection().getInputStream()
} catch (ioException: IOException) {
ioException.printStackTrace()
null
}
}
}
@@ -0,0 +1,43 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import android.app.admin.DeviceAdminReceiver
import android.content.Context
import android.content.Intent
import androidx.localbroadcastmanager.content.LocalBroadcastManager
internal class AdminReceiver : DeviceAdminReceiver() {
override fun onDisabled(context: Context, intent: Intent) {
super.onDisabled(context, intent)
LocalBroadcastManager.getInstance(context).sendBroadcast(
Intent("device_admin_action_disabled")
)
}
override fun onEnabled(context: Context, intent: Intent) {
super.onEnabled(context, intent)
LocalBroadcastManager.getInstance(context).sendBroadcast(
Intent("device_admin_action_enabled")
)
}
}
@@ -0,0 +1,100 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import android.annotation.SuppressLint
import android.graphics.Color
import android.text.Editable
import android.text.TextWatcher
import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.material.slider.Slider
import com.google.android.material.textfield.TextInputEditText
internal class ColorPicker(private val initialColor: String,
private val editText: TextInputEditText, private val sliderA: Slider, private val sliderR: Slider,
private val sliderG: Slider, private val sliderB: Slider, private val colorPreview: ConstraintLayout) {
@SuppressLint("SetTextI18n")
fun pickColor() {
editText.setText(initialColor)
stringToSlider(initialColor)
colorPreview.setBackgroundColor(Color.parseColor("#$initialColor"))
editText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) {
if (s.length == 6){
sliderA.value = 255F
sliderR.value = Integer.parseInt(s.substring(0..1), 16).toFloat()
sliderG.value = Integer.parseInt(s.substring(2..3), 16).toFloat()
sliderB.value = Integer.parseInt(s.substring(4..5), 16).toFloat()
} else if (s.length == 8){
stringToSlider(s.toString())
} else if (s.isEmpty()) {
sliderA.value = 0F
sliderR.value = 0F
sliderG.value = 0F
sliderB.value = 0F
}
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
})
sliderA.addOnChangeListener(Slider.OnChangeListener { _: Slider?, _: Float, _: Boolean ->
editText.setText(colorString.uppercase())
colorPreview.setBackgroundColor(Color.parseColor("#$colorString"))
})
sliderR.addOnChangeListener(Slider.OnChangeListener { _: Slider?, _: Float, _: Boolean ->
editText.setText(colorString.uppercase())
colorPreview.setBackgroundColor(Color.parseColor("#$colorString"))
})
sliderG.addOnChangeListener(Slider.OnChangeListener { _: Slider?, _: Float, _: Boolean ->
editText.setText(colorString.uppercase())
colorPreview.setBackgroundColor(Color.parseColor("#$colorString"))
})
sliderB.addOnChangeListener(Slider.OnChangeListener { _: Slider?, _: Float, _: Boolean ->
editText.setText(colorString.uppercase())
colorPreview.setBackgroundColor(Color.parseColor("#$colorString"))
})
}
private fun stringToSlider(s: String) {
sliderA.value = Integer.parseInt(s.substring(0..1), 16).toFloat()
sliderR.value = Integer.parseInt(s.substring(2..3), 16).toFloat()
sliderG.value = Integer.parseInt(s.substring(4..5), 16).toFloat()
sliderB.value = Integer.parseInt(s.substring(6..7), 16).toFloat()
}
private val colorString: String get() {
var a = Integer.toHexString((((255*sliderA.value)/sliderA.valueTo).toInt()))
if(a.length==1) a = "0$a"
var r = Integer.toHexString((((255*sliderR.value)/sliderR.valueTo).toInt()))
if(r.length==1) r = "0$r"
var g = Integer.toHexString((((255*sliderG.value)/sliderG.valueTo).toInt()))
if(g.length==1) g = "0$g"
var b = Integer.toHexString((((255*sliderB.value)/sliderB.valueTo).toInt()))
if(b.length==1) b = "0$b"
return "$a$r$g$b"
}
}
@@ -0,0 +1,110 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK
import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
internal class Constants {
companion object {
/* first launch */
const val PREFS_FIRST_LAUNCH = "rasel.lunar.launcher.FIRST_LAUNCH"
const val KEY_FIRST_LAUNCH = "first_launch"
/* widgets */
const val PREFS_WIDGETS = "rasel.lunar.launcher.WIDGETS"
const val KEY_WIDGET_IDS = "widget_ids"
const val KEY_WIDGET_HEIGHTS = "widget_heights"
/* settings */
const val PREFS_SETTINGS = "rasel.lunar.launcher.SETTINGS"
const val KEY_TIME_FORMAT = "time_format"
const val KEY_DATE_FORMAT = "date_format"
const val KEY_CITY_NAME = "city_name"
const val KEY_OWM_API = "owm_api"
const val KEY_TEMP_UNIT = "temp_unit"
const val KEY_SHOW_CITY = "show_city"
const val KEY_TODO_COUNTS = "todo_count"
const val KEY_TODO_LOCK = "todo_lock"
const val KEY_KEYBOARD_SEARCH = "keyboard_search"
const val KEY_QUICK_LAUNCH = "quick_launch"
const val KEY_APPS_LAYOUT = "apps_layout"
const val KEY_APPS_COUNT = "apps_count"
const val KEY_DRAW_ALIGN = "drawer_alignment"
const val KEY_ICON_PACK = "icon_pack"
const val KEY_GRID_COLUMNS = "grid_columns"
const val KEY_SCROLLBAR_HEIGHT = "scrollbar_height"
const val KEY_WINDOW_BACKGROUND = "window_background"
const val KEY_APPLICATION_THEME = "application_theme"
const val KEY_STATUS_BAR = "status_bar"
const val KEY_BACK_HOME = "back_home"
const val KEY_SHORTCUT_COUNT = "shortcut_count"
const val KEY_ICON_SIZE = "icon_size"
const val KEY_RSS_URL = "rss_url"
const val KEY_LOCK_METHOD = "lock_method"
/* --- */
const val DEFAULT_DATE_FORMAT = "EEE dx MMM, yyyy"
const val DEFAULT_ICON_SIZE = 44
const val DEFAULT_ICON_PACK = "default_icon_pack"
const val DEFAULT_GRID_COLUMNS = 4
const val DEFAULT_SCROLLBAR_HEIGHT = 400
const val MAX_SHORTCUTS = 6
const val MAX_FAVORITE_APPS = 6
const val BOTTOM_SHEET_TAG = "rasel.lunar.launcher.TAG"
const val SEPARATOR = "||"
const val ACCESSIBILITY_SERVICE_LOCK_SCREEN = "rasel.lunar.launcher.LOCK_SCREEN_SERVICE"
const val AUTHENTICATOR_TYPE = BIOMETRIC_WEAK or DEVICE_CREDENTIAL
const val rssJobId = 101
const val widgetHostId = 102
const val requestPickWidget = 103
const val requestCreateWidget = 104
/* app names */
const val PREFS_APP_NAMES = "rasel.lunar.launcher.APP_NAMES"
/* favorite apps */
const val PREFS_FAVORITE_APPS = "rasel.lunar.launcher.FAVORITE_APPS"
const val KEY_APP_NO_ = "app_no_"
/* phone and url shortcuts */
const val PREFS_SHORTCUTS = "rasel.lunar.launcher.SHORTCUTS"
const val KEY_SHORTCUT_NO_ = "shortcut_no_"
const val SHORTCUT_TYPE_URL = "shortcut_type_url"
const val SHORTCUT_TYPE_PHONE = "shortcut_type_phone"
/* to-do database */
const val TODO_DATABASE_NAME = "rasel.lunar.launcher.TODOS"
const val TODO_DATABASE_VERSION = 1
const val TODO_TABLE_NAME = "todo_table"
const val TODO_COLUMN_ID = "todo_column_id"
const val TODO_COLUMN_NAME = "todo_column_name"
const val TODO_COLUMN_CREATED = "todo_column_created"
/* rss feed */
const val RSS_ITEMS = "rss_items"
const val RSS_RECEIVER = "rss_receiver"
}
}
@@ -0,0 +1,56 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import android.accessibilityservice.AccessibilityService
import android.accessibilityservice.AccessibilityServiceInfo
import android.content.Context
import android.content.Intent
import android.os.Build
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityManager
internal class LockService : AccessibilityService() {
override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
override fun onInterrupt() {}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
}
return super.onStartCommand(intent, flags, startId)
}
/* check whether accessibility service is enabled */
fun isAccessibilityServiceEnabled(context: Context): Boolean {
val accessibilityManager =
context.getSystemService(ACCESSIBILITY_SERVICE) as AccessibilityManager
val accessibilityServiceInfoList: List<AccessibilityServiceInfo> =
accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK)
for (enabledService in accessibilityServiceInfoList) {
val enabledServiceInfo = enabledService.resolveInfo.serviceInfo
if (enabledServiceInfo.packageName == context.packageName && enabledServiceInfo.name == LockService::class.java.name) return true
}
return false
}
}
@@ -0,0 +1,101 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import android.annotation.SuppressLint
import android.content.Context
import android.view.GestureDetector
import android.view.GestureDetector.SimpleOnGestureListener
import android.view.MotionEvent
import android.view.View
import android.view.View.OnTouchListener
import android.view.ViewParent
import kotlin.math.abs
internal open class SwipeTouchListener(c: Context?) : OnTouchListener {
private val gestureDetector: GestureDetector = GestureDetector(c, GestureListener())
private lateinit var viewParent: ViewParent
@SuppressLint("ClickableViewAccessibility")
override fun onTouch(view: View, motionEvent: MotionEvent): Boolean {
viewParent = view.parent
return gestureDetector.onTouchEvent(motionEvent)
}
private inner class GestureListener : SimpleOnGestureListener() {
override fun onDown(e: MotionEvent): Boolean {
return true
}
override fun onSingleTapUp(e: MotionEvent): Boolean {
onClick()
return super.onSingleTapUp(e)
}
override fun onDoubleTap(e: MotionEvent): Boolean {
onDoubleClick()
return super.onDoubleTap(e)
}
override fun onLongPress(e: MotionEvent) {
onLongClick()
viewParent.requestDisallowInterceptTouchEvent(true)
super.onLongPress(e)
}
override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
try {
val diffY = e2.y - e1!!.y
val diffX = e2.x - e1.x
val swipeThreshold = 15
val swipeVelocityThreshold = 90
if (abs(diffX) > abs(diffY)) {
if (abs(diffX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold) {
when {
diffX > 0 -> onSwipeRight()
else -> onSwipeLeft()
}
}
} else {
if (abs(diffY) > swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
when {
diffY > 0 -> onSwipeDown()
else -> onSwipeUp()
}
}
}
} catch (exception: Exception) {
exception.printStackTrace()
}
return false
}
}
fun onSwipeRight() {}
fun onSwipeLeft() {}
open fun onSwipeUp() {}
open fun onSwipeDown() {}
open fun onClick() {}
open fun onDoubleClick() {}
open fun onLongClick() {}
}
@@ -0,0 +1,270 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import android.annotation.SuppressLint
import android.app.admin.DevicePolicyManager
import android.content.*
import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.os.Build
import android.os.PowerManager
import android.provider.Settings
import android.util.DisplayMetrics
import android.util.TypedValue
import android.view.View
import android.view.WindowInsets
import android.widget.Toast
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS
import androidx.biometric.BiometricPrompt
import androidx.core.view.isVisible
import com.google.android.material.imageview.ShapeableImageView
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.apps.IconPackManager.Companion.getDrawableIconForPackage
import rasel.lunar.launcher.helpers.Constants.Companion.ACCESSIBILITY_SERVICE_LOCK_SCREEN
import rasel.lunar.launcher.helpers.Constants.Companion.AUTHENTICATOR_TYPE
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_ICON_SIZE
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPS_LAYOUT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APP_NO_
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_SIZE
import rasel.lunar.launcher.helpers.Constants.Companion.MAX_FAVORITE_APPS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_FAVORITE_APPS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import java.io.DataOutputStream
internal class UniUtils {
companion object {
/* get display width */
val screenWidth: Int get() {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val windowMetrics = lActivity!!.windowManager.currentWindowMetrics
val insets = windowMetrics.windowInsets
.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars())
windowMetrics.bounds.width() - insets.left - insets.right
} else {
val displayMetrics = DisplayMetrics()
@Suppress("DEPRECATION") lActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
displayMetrics.widthPixels
}
}
/* get display height */
val screenHeight: Int get() {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val windowMetrics = lActivity!!.windowManager.currentWindowMetrics
val insets = windowMetrics.windowInsets
.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars())
windowMetrics.bounds.height() - insets.top - insets.bottom
} else {
val displayMetrics = DisplayMetrics()
@Suppress("DEPRECATION") lActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
displayMetrics.heightPixels
}
}
/* copy texts to clipboard */
fun copyToClipboard(context: Context, copiedString: String?) {
val clipBoard =
lActivity!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipBoard.setPrimaryClip(ClipData.newPlainText("", copiedString))
Toast.makeText(context, context.getString(R.string.copied_message), Toast.LENGTH_SHORT).show()
}
/* expand notification panel */
@SuppressLint("WrongConstant")
fun expandNotificationPanel(context: Context) {
try {
Class.forName("android.app.StatusBarManager")
.getMethod("expandNotificationsPanel")
.invoke(context.getSystemService("statusbar"))
} catch (exception: Exception) {
exception.printStackTrace()
}
}
/* lock using preferred method */
fun lockMethod(lockMethodValue: Int, context: Context, linearLayoutCompat: LinearLayoutCompat) {
when (lockMethodValue) {
0 -> populateFavApps(context, linearLayoutCompat)
1 -> lockAccessibility()
2 -> lockDeviceAdmin(context)
3 -> lockRoot()
}
}
/* check if the device is rooted */
val isRooted: Boolean get() {
var process: Process? = null
return try {
process = Runtime.getRuntime().exec("su")
true
} catch (exception: Exception) {
exception.printStackTrace()
false
} finally {
if (process != null) {
try {
process.destroy()
} catch (exception: Exception) {
exception.printStackTrace()
}
}
}
}
/* check if the device is connected to the internet */
val isNetworkAvailable: Boolean get() {
val connectivityManager =
lActivity!!.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
@Suppress("DEPRECATION") val activeNetworkInfo = connectivityManager.activeNetworkInfo
@Suppress("DEPRECATION") return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting
}
/* check if authenticator available */
fun canAuthenticate(context: Context): Boolean {
val biometricManager = BiometricManager.from(context)
return biometricManager.canAuthenticate(AUTHENTICATOR_TYPE) == BIOMETRIC_SUCCESS
}
/* show device authenticator */
fun biometricPromptInfo(title: String): BiometricPrompt.PromptInfo {
return BiometricPrompt.PromptInfo.Builder()
.setTitle(title)
.setSubtitle(lActivity!!.getString(R.string.authentication_subtitle))
.setConfirmationRequired(true)
.setAllowedAuthenticators(AUTHENTICATOR_TYPE)
.build()
}
/* get color red id from attribute */
fun getColorResId(context: Context, colorAttr: Int) : Int {
val typedValue = TypedValue()
context.theme.resolveAttribute(colorAttr, typedValue, true)
return typedValue.resourceId
}
/* convert dp value to px */
fun dpToPx(context: Context, id: Int) : Int = (context.resources.getDimension(id) * context.resources.displayMetrics.density).toInt()
/* lock screen using device admin */
private fun lockDeviceAdmin(context: Context) {
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
if (powerManager.isInteractive) {
val policy =
context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
try {
policy.lockNow()
} catch (exception: SecurityException) {
/* open device admin manager screen */
lActivity!!.startActivity(
Intent().setComponent(
ComponentName(
"com.android.settings",
"com.android.settings.DeviceAdminSettings"
)
)
)
exception.printStackTrace()
}
}
}
/* favorite apps */
private fun populateFavApps(context: Context, linearLayoutCompat: LinearLayoutCompat) {
val prefsFavApps = context.getSharedPreferences(PREFS_FAVORITE_APPS, 0)
if (linearLayoutCompat.isVisible || prefsFavApps.all.toString().length < 3) {
linearLayoutCompat.visibility = View.GONE
} else {
linearLayoutCompat.removeAllViews()
linearLayoutCompat.visibility = View.VISIBLE
val iconSize = context.getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_ICON_SIZE, DEFAULT_ICON_SIZE)
for (position in 1..MAX_FAVORITE_APPS) {
val packageName = prefsFavApps.getString(KEY_APP_NO_ + position.toString(), "").toString()
/* package name is not empty for a specific position */
if (packageName.isNotEmpty()) {
try {
ShapeableImageView(context).apply {
layoutParams = LinearLayoutCompat.LayoutParams(
(iconSize * resources.displayMetrics.density).toInt(),
(iconSize * resources.displayMetrics.density).toInt(), 1F)
}.let { sImageView ->
context.packageManager.getApplicationIcon(packageName).let { defaultIcon ->
sImageView.setImageDrawable(
if (context.getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_APPS_LAYOUT, 0) != 0)
getDrawableIconForPackage(packageName, defaultIcon)
else defaultIcon
)
}
sImageView.setOnClickListener {
context.startActivity(context.packageManager.getLaunchIntentForPackage(packageName))
}
linearLayoutCompat.addView(sImageView)
}
} catch (nameNotFoundException: PackageManager.NameNotFoundException) {
context.getSharedPreferences(PREFS_FAVORITE_APPS, 0)
.edit().remove(KEY_APP_NO_ + position).apply()
}
}
}
}
}
/* lock screen using accessibility service */
private fun lockAccessibility() {
if (LockService().isAccessibilityServiceEnabled(lActivity!!.applicationContext)) {
try {
lActivity!!.startService(
Intent(lActivity!!.applicationContext, LockService::class.java)
.setAction(ACCESSIBILITY_SERVICE_LOCK_SCREEN)
)
} catch (exception: Exception) {
exception.printStackTrace()
}
} else {
/* open accessibility service screen */
lActivity!!.startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
}
}
/* lock screen using root */
private fun lockRoot() {
try {
val process = Runtime.getRuntime().exec("su")
val dataOutputStream = DataOutputStream(process.outputStream)
dataOutputStream.writeBytes("input keyevent \${KeyEvent.KEYCODE_POWER}\n")
dataOutputStream.writeBytes("exit\n")
dataOutputStream.flush()
dataOutputStream.close()
process.waitFor()
process.destroy()
} catch (exception: Exception) {
exception.printStackTrace()
}
}
}
}
@@ -0,0 +1,34 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.helpers
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
internal class ViewPagerAdapter(
fragmentManager: FragmentManager, private val fragments: MutableList<Fragment>, lifecycle: Lifecycle) :
FragmentStateAdapter(fragmentManager, lifecycle) {
override fun getItemCount(): Int = fragments.size
override fun createFragment(position: Int): Fragment = fragments[position]
}
@@ -0,0 +1,67 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.home
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.BatteryManager
import android.provider.Settings
import android.view.animation.AnimationUtils
import com.google.android.material.progressindicator.CircularProgressIndicator
import rasel.lunar.launcher.R
internal class BatteryReceiver(private val progressBar: CircularProgressIndicator) : BroadcastReceiver() {
/* get current battery percentage */
private fun batteryPercentage(intent: Intent): Int {
val percentage = (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)) /
(intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)).toFloat()
return (percentage * 100).toInt()
}
/* get current charging status */
private fun chargingStatus(intent: Intent): Int = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
override fun onReceive(context: Context?, intent: Intent?) {
val animationDuration = try {
Settings.Global.getFloat(context?.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE)
} catch (e: Settings.SettingNotFoundException) {
e.printStackTrace()
}
/* set battery percentage value to the circular progress bar */
progressBar.progress = batteryPercentage(intent!!)
/* progress bar animation */
if (chargingStatus(intent) == BatteryManager.BATTERY_STATUS_CHARGING ||
chargingStatus(intent) == BatteryManager.BATTERY_STATUS_FULL) {
if (progressBar.animation == null && animationDuration != 0f) {
progressBar.startAnimation(
AnimationUtils.loadAnimation(context, R.anim.rotate_clockwise)
)
}
} else if (chargingStatus(intent) == BatteryManager.BATTERY_STATUS_DISCHARGING ||
chargingStatus(intent) == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
progressBar.clearAnimation()
}
}
}
@@ -0,0 +1,406 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.home
import android.annotation.SuppressLint
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import android.os.Bundle
import android.provider.AlarmClock
import android.text.format.DateFormat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.biometric.BiometricPrompt
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.LauncherHomeBinding
import rasel.lunar.launcher.helpers.Constants.Companion.BOTTOM_SHEET_TAG
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_DATE_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_DATE_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.SwipeTouchListener
import rasel.lunar.launcher.helpers.UniUtils.Companion.biometricPromptInfo
import rasel.lunar.launcher.helpers.UniUtils.Companion.canAuthenticate
import rasel.lunar.launcher.helpers.UniUtils.Companion.expandNotificationPanel
import rasel.lunar.launcher.helpers.UniUtils.Companion.lockMethod
import rasel.lunar.launcher.home.weather.WeatherExecutor
import rasel.lunar.launcher.qaccess.QuickAccess
import rasel.lunar.launcher.settings.SettingsActivity
import rasel.lunar.launcher.todos.TodoAdapter
import rasel.lunar.launcher.todos.TodoManager
import rasel.lunar.launcher.utils.SimpleFingerGestures
import java.util.*
internal class LauncherHome : Fragment() {
private lateinit var binding: LauncherHomeBinding
private lateinit var fragManager: FragmentManager
private lateinit var settingsPrefs: SharedPreferences
private lateinit var batteryReceiver: BatteryReceiver
private var shouldResume = true
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = LauncherHomeBinding.inflate(inflater, container, false)
fragManager = lActivity!!.supportFragmentManager
settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0)
batteryReceiver = BatteryReceiver(binding.batteryProgress)
binding.favAppsGroup.visibility = View.GONE
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
/* handle gesture events */
rootViewGestures()
batteryProgressGestures()
todosGestures()
/* refresh the to-do list after getting back from TodoManager */
fragManager.addOnBackStackChangedListener {
shouldResume = if (fragManager.backStackEntryCount == 0) {
binding.root.visibility = View.VISIBLE
showTodoList()
true
} else {
binding.root.visibility = View.GONE
false
}
}
}
override fun onResume() {
super.onResume()
if (shouldResume) {
/* register battery changes */
requireContext().registerReceiver(batteryReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
/* time and date */
if (DateFormat.is24HourFormat(requireContext())) {
binding.time.format24Hour = timeFormat
binding.date.format24Hour = dateFormat
} else {
binding.time.format12Hour = timeFormat
binding.date.format12Hour = dateFormat
}
/* show weather */
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
/* show to-do list */
showTodoList()
}
}
override fun onPause() {
super.onPause()
/* unregister battery changes */
if (shouldResume) requireContext().unregisterReceiver(batteryReceiver)
}
var mFingerGestureListener = object : SimpleFingerGestures.OnFingerGestureListener {
override fun onSwipeUp(
targetView: View,
fingers: Int,
gestureDuration: Long,
gestureDistance: Double
): Boolean {
when(fingers) {
1 ->
if (targetView?.equals(binding.batteryProgress) ?: false) {
QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
} else {
QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
}
else -> {}
}
return false
}
override fun onSwipeDown(
targetView: View,
fingers: Int,
gestureDuration: Long,
gestureDistance: Double
): Boolean {
when(fingers) {
1 ->
if (targetView?.equals(binding.batteryProgress) ?: false) {
expandNotificationPanel(requireContext())
} else {
expandNotificationPanel(requireContext())
}
else -> {}
}
return false
}
override fun onSwipeLeft(
targetView: View,
fingers: Int,
gestureDuration: Long,
gestureDistance: Double
): Boolean {
return false
}
override fun onSwipeRight(
targetView: View,
fingers: Int,
gestureDuration: Long,
gestureDistance: Double
): Boolean {
return false
}
override fun onPinch(
targetView: View,
fingers: Int,
gestureDuration: Long,
gestureDistance: Double
): Boolean {
return false
}
override fun onUnpinch(
targetView: View,
fingers: Int,
gestureDuration: Long,
gestureDistance: Double
): Boolean {
return false
}
override fun onDoubleTap(targetView: View,fingers: Int): Boolean {
when(fingers) {
1 -> if (targetView?.equals(binding.batteryProgress) ?: false) {
lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
} else {
lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
}
else -> {}
}
return false
}
override fun onLongPress(targetView: View): Boolean {
if (view?.equals(binding.batteryProgress) ?: false) {
lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java))
} else if (view?.equals(binding.notes) ?: false) {
when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) {
false -> launchTodoManager()
/* show authentication screen if lock is on */
true -> {
if (canAuthenticate(requireContext())) {
val biometricPrompt = BiometricPrompt(lActivity!!, authenticationCallback)
try {
biometricPrompt.authenticate(biometricPromptInfo(lActivity!!.getString(R.string.todo_manager)))
} catch (exception: Exception) {
exception.printStackTrace()
}
}
}
}
}
return false
}
override fun onClick(targetView: View): Boolean {
if (view?.equals(binding.batteryProgress) ?: false) {
requireContext().startActivity(
Intent(AlarmClock.ACTION_SHOW_ALARMS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
} else if (view?.equals(binding.batteryProgress) ?: false) {
}
return false
}
}
/* gestures on root view */
@SuppressLint("ClickableViewAccessibility")
private fun rootViewGestures() {
binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root , mFingerGestureListener))
// {
/* open quick access panel on swipe up */
// override fun onSwipeUp() {
// super.onSwipeUp()
// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
// }
// /* expand notification panel on swipe down */
// override fun onSwipeDown() {
// super.onSwipeDown()
// expandNotificationPanel(requireContext())
// }
// /* lock the screen on double tap (optional) */
// override fun onDoubleClick() {
// super.onDoubleClick()
// lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
// }
// })
}
/* gestures on battery progress indicator area */
@SuppressLint("ClickableViewAccessibility")
private fun batteryProgressGestures() {
binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress , mFingerGestureListener))
// binding.batteryProgress.setOnTouchListener(object : SwipeTouchListener(requireContext()) {
// /* open alarms list with default clock app */
// override fun onClick() {
// super.onClick()
// requireContext().startActivity(
// Intent(AlarmClock.ACTION_SHOW_ALARMS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
// )
// }
// /* open settings activity on long click */
// override fun onLongClick() {
// super.onLongClick()
// lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java))
// }
// /* expand notification panel on swipe down */
// override fun onSwipeDown() {
// super.onSwipeDown()
// expandNotificationPanel(requireContext())
// }
// /* lock the screen on double tap (optional) */
// override fun onDoubleClick() {
// super.onDoubleClick()
// lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
// }
// })
}
/* gestures on to-do area */
@SuppressLint("ClickableViewAccessibility")
private fun todosGestures() {
binding.notes.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.notes , mFingerGestureListener))
// binding.notes.setOnTouchListener(object : SwipeTouchListener(requireContext()) {
// /* open TodoManager on long click */
// override fun onLongClick() {
// super.onLongClick()
// when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) {
// false -> launchTodoManager()
// /* show authentication screen if lock is on */
// true -> {
// if (canAuthenticate(requireContext())) {
// val biometricPrompt = BiometricPrompt(lActivity!!, authenticationCallback)
// try {
// biometricPrompt.authenticate(biometricPromptInfo(lActivity!!.getString(R.string.todo_manager)))
// } catch (exception: Exception) {
// exception.printStackTrace()
// }
// }
// }
// }
// }
// /* open quick access panel on swipe up */
// override fun onSwipeUp() {
// super.onSwipeUp()
// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
// }
// /* expand notification panel on swipe down */
// override fun onSwipeDown() {
// super.onSwipeDown()
// expandNotificationPanel(requireContext())
// }
// /* lock the screen on double tap (optional) */
// override fun onDoubleClick() {
// super.onDoubleClick()
// lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
// }
// })
}
/* authentication callback for TodoManager lock */
private val authenticationCallback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
launchTodoManager()
}
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
Toast.makeText(requireContext(), lActivity!!.getString(R.string.authentication_error), Toast.LENGTH_SHORT).show()
}
override fun onAuthenticationFailed() {
Toast.makeText(requireContext(), lActivity!!.getString(R.string.authentication_failed), Toast.LENGTH_SHORT).show()
}
}
/* launch TodoManager fragment */
private fun launchTodoManager() {
fragManager.beginTransaction().replace(R.id.mainFragmentsContainer, TodoManager())
.addToBackStack("").commit()
}
/* to-do list */
private fun showTodoList() {
binding.notes.adapter = TodoAdapter(null, requireContext())
}
/* get time format string */
private val timeFormat: String? get() {
when (settingsPrefs.getInt(KEY_TIME_FORMAT, 0)) {
0 -> return if (DateFormat.is24HourFormat(requireContext())) {
"kk:mm"
} else {
"h:mm a"
}
1 -> return "h:mm a"
2 -> return "kk:mm"
}
return null
}
/* get date number suffix */
private val dateNumberSuffix: String get() {
return when (Calendar.getInstance()[Calendar.DAY_OF_MONTH]) {
1, 21, 31 -> "ˢᵗ"
2, 22 -> "ⁿᵈ"
3, 23 -> "ʳᵈ"
else -> "ᵗʰ"
}
}
/* get date format string */
private val dateFormat: String get() {
settingsPrefs.getString(KEY_DATE_FORMAT, DEFAULT_DATE_FORMAT).let {
return if (it!!.contains("x")) {
it.replace("x", dateNumberSuffix)
} else {
it
}
}
}
}
@@ -0,0 +1,52 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.home.weather
import org.json.JSONException
import org.json.JSONObject
internal class JsonParser {
fun getMyWeather(jsonStr: String): Weather {
val weather = Weather()
try {
val jsonObject = JSONObject(jsonStr)
/* Get weather condition */
val weatherArray = jsonObject.getJSONArray("weather")
val weatherObject = weatherArray.getJSONObject(0)
weather.weatherCondition = weatherObject.getString("main")
weather.weatherDescription = weatherObject.getString("description")
weather.weatherIconId = weatherObject.getString("icon")
/* Get temperature */
val mainObject = jsonObject.getJSONObject("main")
weather.temperature = mainObject.getDouble("temp").toFloat()
weather.cityName = jsonObject.getString("name")
} catch (jsonException: JSONException) {
jsonException.printStackTrace()
}
return weather
}
}
@@ -0,0 +1,28 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.home.weather
internal class Weather {
var weatherCondition: String? = null
var weatherDescription: String? = null
var weatherIconId: String? = null
var temperature = 0f
var cityName: String? = null
}
@@ -0,0 +1,63 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.home.weather
import java.io.BufferedReader
import java.io.InputStreamReader
import java.lang.Exception
import java.lang.StringBuilder
import java.net.HttpURLConnection
import java.net.URL
internal class WeatherClient {
fun fetchWeather(wUrl: String?): String? {
var httpURLConnection: HttpURLConnection? = null
var bufferedReader: BufferedReader? = null
try {
httpURLConnection = URL(wUrl).openConnection() as HttpURLConnection
httpURLConnection.connect()
bufferedReader = BufferedReader(InputStreamReader(httpURLConnection.inputStream))
val stringBuilder = StringBuilder()
var line: String?
while (bufferedReader.readLine().also { line = it } != null) {
stringBuilder.append("$line\n")
}
if (stringBuilder.isNotEmpty()) return stringBuilder.toString()
} catch (exception: Exception) {
exception.printStackTrace()
} finally {
httpURLConnection?.disconnect()
if (bufferedReader != null) {
try {
bufferedReader.close()
} catch (exception: Exception) {
exception.printStackTrace()
}
}
}
return null
}
}
@@ -0,0 +1,83 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.home.weather
import android.annotation.SuppressLint
import android.content.SharedPreferences
import android.os.Handler
import android.os.Looper
import android.view.View
import com.google.android.material.textview.MaterialTextView
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_CITY_NAME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_OWM_API
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SHOW_CITY
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TEMP_UNIT
import rasel.lunar.launcher.helpers.UniUtils.Companion.isNetworkAvailable
import java.net.URLEncoder
import java.util.concurrent.Executors
internal class WeatherExecutor(sharedPreferences: SharedPreferences) {
private val cityName: String
private val owmApi: String
private val weatherUrl: String
private val tempUnit: Int
private val showCity: Boolean
@SuppressLint("SetTextI18n")
fun generateWeatherString(materialTextView: MaterialTextView) {
materialTextView.visibility = View.GONE
/* run the executor if network is available,
and city name and owm api values are not empty */
if (isNetworkAvailable && cityName.isNotEmpty() && owmApi.isNotEmpty()) {
try {
Executors.newSingleThreadExecutor().execute {
var weather: Weather? = null
WeatherClient().fetchWeather(weatherUrl).let {
if (!it.isNullOrEmpty()) weather = JsonParser().getMyWeather(it)
}
Handler(Looper.getMainLooper()).post {
if (weather != null) {
materialTextView.apply {
visibility = View.VISIBLE
text = weather!!.temperature.toString().substringBefore(".") +
(if (tempUnit == 0) "ºC" else "ºF") +
(if (showCity) " at ${weather!!.cityName}" else "")
}
}
}
}
} catch (exception: Exception) {
exception.printStackTrace()
}
}
}
init {
cityName = sharedPreferences.getString(KEY_CITY_NAME, "").toString()
owmApi = sharedPreferences.getString(KEY_OWM_API, "").toString()
tempUnit = sharedPreferences.getInt(KEY_TEMP_UNIT, 0)
showCity = sharedPreferences.getBoolean(KEY_SHOW_CITY, false)
weatherUrl = URLEncoder.encode("https://api.openweathermap.org/data/2.5/weather?q=$cityName&APPID=$owmApi&units=" + if (tempUnit == 0) "metric" else "imperial","utf-8")
}
}
@@ -0,0 +1,384 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.qaccess
import android.Manifest
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.graphics.*
import android.media.AudioManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.PowerManager
import android.provider.Settings
import android.text.InputType
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.ContextCompat
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButtonToggleGroup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.slider.Slider
import com.google.android.material.textview.MaterialTextView
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.QuickAccessBinding
import rasel.lunar.launcher.databinding.ShortcutMakerBinding
import rasel.lunar.launcher.helpers.ColorPicker
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_ICON_SIZE
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_SIZE
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SHORTCUT_COUNT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SHORTCUT_NO_
import rasel.lunar.launcher.helpers.Constants.Companion.MAX_SHORTCUTS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SHORTCUTS
import rasel.lunar.launcher.helpers.Constants.Companion.SEPARATOR
import rasel.lunar.launcher.helpers.Constants.Companion.SHORTCUT_TYPE_PHONE
import rasel.lunar.launcher.helpers.Constants.Companion.SHORTCUT_TYPE_URL
import java.util.*
import kotlin.properties.Delegates
internal class QuickAccess : BottomSheetDialogFragment() {
private lateinit var binding: QuickAccessBinding
private lateinit var sharedPreferences: SharedPreferences
private var iconSize by Delegates.notNull<Int>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = QuickAccessBinding.inflate(inflater, container, false)
sharedPreferences = requireContext().getSharedPreferences(PREFS_SHORTCUTS, 0)
iconSize = requireContext().getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_ICON_SIZE, DEFAULT_ICON_SIZE)
/* set up volume sliders, brightness slider and favorite apps */
volumeControllers()
controlBrightness()
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
/* enable dismiss animation */
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
}
override fun onResume() {
super.onResume()
/* repopulate shortcuts and apps */
shortcuts()
}
/* control the volumes */
private fun volumeControllers() {
val audioManager = lActivity!!.getSystemService(Context.AUDIO_SERVICE) as AudioManager
/* max value */
binding.notification.valueTo = audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION).toFloat()
binding.alarm.valueTo = audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM).toFloat()
binding.media.valueTo = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC).toFloat()
binding.voice.valueTo = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL).toFloat()
binding.ring.valueTo = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING).toFloat()
/* current value */
binding.notification.value = audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION).toFloat()
binding.alarm.value = audioManager.getStreamVolume(AudioManager.STREAM_ALARM).toFloat()
binding.media.value = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat()
binding.voice.value = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL).toFloat()
binding.ring.value = audioManager.getStreamVolume(AudioManager.STREAM_RING).toFloat()
/* slider change listener for alarm volume */
binding.alarm.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
audioManager.setStreamVolume(AudioManager.STREAM_ALARM, value.toInt(), 0)
})
/* slider change listener for media volume */
binding.media.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, value.toInt(), 0)
})
/* slider change listener for voice call volume */
binding.voice.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, value.toInt(), 0)
})
/* notify and ring volume sliders will work only if
the device isn't in dnd or silent mode */
if (Settings.Global.getInt(lActivity!!.contentResolver, "zen_mode") == 0 &&
audioManager.ringerMode != AudioManager.RINGER_MODE_SILENT) {
/* slider change listener for notify volume */
binding.notification.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, value.toInt(), 0)
})
/* slider change listener for ring volume */
binding.ring.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
audioManager.setStreamVolume(AudioManager.STREAM_RING, value.toInt(), 0)
})
} else {
binding.notification.isEnabled = false
binding.ring.isEnabled = false
}
}
/* set up contact and url shortcuts */
private fun shortcuts() {
binding.shortcutsGroup.removeAllViews()
val shortcutCount =
requireContext().getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_SHORTCUT_COUNT, MAX_SHORTCUTS)
if (shortcutCount == 0) binding.shortcutsGroup.visibility = View.GONE
for (position in 1..shortcutCount) {
val shortcutValue = sharedPreferences.getString(KEY_SHORTCUT_NO_ + position.toString(), "").toString()
val splitShortcutValue = shortcutValue.split(SEPARATOR).toTypedArray()
var shortcutType = ""
var intentString = ""
var thumbLetter = ""
var color = ""
try {
if (splitShortcutValue.size >= 4) {
shortcutType = splitShortcutValue[0]
intentString = splitShortcutValue[1]
thumbLetter = splitShortcutValue[2]
color = splitShortcutValue[3]
}
} catch (exception : Exception) {
exception.printStackTrace()
}
shortcutsUtil(textView, shortcutType, intentString, thumbLetter, color, position)
}
}
/* control the brightness */
private fun controlBrightness() {
val resolver = lActivity!!.contentResolver
/* set max value */
binding.brightness.valueTo = maxBrightness
/* set slider value to current brightness value */
try {
binding.brightness.value = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS).toFloat()
} catch (settingNotFoundException: Settings.SettingNotFoundException) {
settingNotFoundException.printStackTrace()
}
/* listen slider value changes */
binding.brightness.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
/* if write settings permission is not allowed already,
again ask for it to be granted */
if (!Settings.System.canWrite(lActivity!!)) {
lActivity!!.startActivity(
Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
.setData(Uri.parse("package:" + lActivity!!.packageName))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
/* set the brightness according to the slider value */
} else {
Settings.System.putInt(
resolver,
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL
)
Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS, value.toInt())
}
})
}
/* contact/url shortcuts */
private fun shortcutsUtil(textView: MaterialTextView, shortcutType: String, intentString: String,
thumbLetter: String, color: String, position: Int) {
/* show plus sign for empty positions and set click listener */
if (intentString.isEmpty()) {
textView.text = "+"
textView.setOnClickListener {
shortcutsSaverDialog(position, "00000000", "", "", "")
}
} else {
/* show thumbnail letter */
textView.text = thumbLetter
/* set background color */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
textView.background.colorFilter =
BlendModeColorFilter(Color.parseColor("#$color"), BlendMode.MULTIPLY)
} else {
@Suppress("DEPRECATION")
textView.background.setColorFilter(Color.parseColor("#$color"), PorterDuff.Mode.MULTIPLY)
}
/* on normal click */
textView.setOnClickListener {
/* type is url */
if (shortcutType == SHORTCUT_TYPE_URL) {
var url = intentString
/* add http before the url if it doesn't have http/https prefix */
if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "http://$intentString"
}
/* open the url */
lActivity!!.startActivity(
Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
/* type is contact */
} else if (shortcutType == SHORTCUT_TYPE_PHONE) {
/* if the necessary permission is not granted already,
ask for it again */
if (lActivity!!.checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
lActivity!!.requestPermissions(arrayOf(Manifest.permission.CALL_PHONE), 1)
} else {
/* make phone call */
lActivity!!.startActivity(
Intent(Intent.ACTION_CALL, Uri.parse("tel:$intentString"))
)
}
}
this.dismiss()
}
/* reset the shortcut on long click */
textView.setOnLongClickListener {
shortcutsSaverDialog(position, color, thumbLetter, shortcutType, intentString)
true
}
}
}
/* dialog for creating shortcuts */
private fun shortcutsSaverDialog(
position: Int, color: String, thumbLetter: String, shortcutType: String, intentString: String) {
val dialogBinding = ShortcutMakerBinding.inflate(lActivity!!.layoutInflater)
val dialogBuilder = MaterialAlertDialogBuilder(lActivity!!)
.setView(dialogBinding.root)
.setNeutralButton(R.string.delete, null)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, null)
.show()
dialogBinding.thumbField.setText(thumbLetter)
dialogBinding.inputField.setText(intentString)
when (shortcutType) {
SHORTCUT_TYPE_PHONE -> dialogBinding.shortcutType.check(dialogBinding.contact.id)
SHORTCUT_TYPE_URL -> dialogBinding.shortcutType.check(dialogBinding.url.id)
}
/* set up color picker section */
ColorPicker(color, dialogBinding.colorPicker.colorInput, dialogBinding.colorPicker.colorA,
dialogBinding.colorPicker.colorR, dialogBinding.colorPicker.colorG,
dialogBinding.colorPicker.colorB, dialogBinding.root).pickColor()
/* shortcut type chooser - contact/url */
var updatedShortcutType = shortcutType
dialogBinding.shortcutType.addOnButtonCheckedListener {
_: MaterialButtonToggleGroup?, checkedId: Int, isChecked: Boolean ->
if (isChecked) {
when (checkedId) {
dialogBinding.contact.id -> {
updatedShortcutType = SHORTCUT_TYPE_PHONE
dialogBinding.inputField.inputType = InputType.TYPE_CLASS_PHONE
}
dialogBinding.url.id -> {
updatedShortcutType = SHORTCUT_TYPE_URL
dialogBinding.inputField.inputType = InputType.TYPE_TEXT_VARIATION_URI
}
}
}
}
dialogBuilder.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
sharedPreferences.edit().remove(KEY_SHORTCUT_NO_ + position).apply()
dialogBuilder.dismiss()
this.onResume()
}
/* save the shortcut values */
dialogBuilder.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
/* get shortcut value */
val updatedIntentString =
Objects.requireNonNull(dialogBinding.inputField.text).toString().trim { it <= ' ' }
/* get thumbnail letter */
val updatedThumbLetter =
Objects.requireNonNull(dialogBinding.thumbField.text).toString().trim { it <= ' ' }.uppercase()
/* get color value */
val updatedColor =
Objects.requireNonNull(dialogBinding.colorPicker.colorInput.text).toString().trim { it <= ' ' }
/* save the values if every field is filled */
if (updatedShortcutType.isNotEmpty() && updatedIntentString.isNotEmpty() &&
updatedThumbLetter.isNotEmpty() && updatedColor.isNotEmpty()) {
sharedPreferences.edit().putString(KEY_SHORTCUT_NO_ + position,
"$updatedShortcutType$SEPARATOR$updatedIntentString$SEPARATOR" +
"$updatedThumbLetter$SEPARATOR$updatedColor").apply()
dialogBuilder.dismiss()
this.onResume()
}
}
}
/* create text view for shortcut thumbnails */
private val textView: MaterialTextView get() {
val relativeLayout = RelativeLayout(lActivity!!)
relativeLayout.apply {
layoutParams = LinearLayoutCompat.LayoutParams(
LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
LinearLayoutCompat.LayoutParams.WRAP_CONTENT, 1F)
gravity = Gravity.CENTER
}
binding.shortcutsGroup.addView(relativeLayout)
MaterialTextView(requireContext()).apply {
layoutParams = LinearLayoutCompat.LayoutParams(
(iconSize * resources.displayMetrics.density).toInt(),
(iconSize * resources.displayMetrics.density).toInt())
gravity = Gravity.CENTER
textSize = (iconSize / 4) * resources.displayMetrics.density
setTypeface(null, Typeface.BOLD)
background = ContextCompat.getDrawable(requireContext(), R.drawable.rounded_bg)
}.let {
relativeLayout.addView(it)
return it
}
}
/* returns maximum brightness value of the device */
private val maxBrightness: Float get() {
val powerManager = requireContext().getSystemService(Context.POWER_SERVICE) as PowerManager
var value = 255f
for (f in powerManager.javaClass.declaredFields) {
if (f.name.equals("BRIGHTNESS_ON")) {
f.isAccessible = true
value = try {
f.getInt(powerManager).toFloat()
} catch (e: IllegalAccessException) {
255f
}
}
}
return value
}
}
@@ -0,0 +1,148 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings
import android.annotation.SuppressLint
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Resources
import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.color.DynamicColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import rasel.lunar.launcher.BuildConfig
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.AboutBinding
import rasel.lunar.launcher.databinding.SettingsActivityBinding
import rasel.lunar.launcher.helpers.Constants.Companion.BOTTOM_SHEET_TAG
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.settings.childs.*
internal class SettingsActivity : AppCompatActivity() {
private lateinit var binding: SettingsActivityBinding
private val sourceCode = "https://github.com/iamrasel/lunar-launcher"
companion object {
@JvmStatic var settingsPrefs: SharedPreferences? = null
}
@SuppressLint("SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
super.onCreate(savedInstanceState)
/* set up view */
binding = SettingsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
settingsPrefs = this.getSharedPreferences(PREFS_SETTINGS, 0)
/* launch child settings dialogs on button clicks */
binding.timeDate.setOnClickListener {
TimeDate().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
binding.weather.setOnClickListener {
WeatherSettings().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
binding.todo.setOnClickListener {
TodoSettings().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
binding.apps.setOnClickListener {
Apps().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
binding.appearances.setOnClickListener {
Appearances().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
binding.misc.setOnClickListener {
Misc().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
binding.advance.setOnClickListener {
Advance().show(supportFragmentManager, BOTTOM_SHEET_TAG)
}
/* about and support dialogs */
binding.about.setOnClickListener { aboutDialog() }
binding.support.setOnClickListener { supportDialog() }
/* show app version name */
binding.version.text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
}
override fun getTheme(): Resources.Theme {
val theme = super.getTheme()
theme.applyStyle(R.style.SettingsNavBar, true)
return theme
}
/* about dialog */
private fun aboutDialog() {
val bottomSheetDialog = BottomSheetDialog(this)
val aboutBinding = AboutBinding.inflate(this.layoutInflater)
bottomSheetDialog.setContentView(aboutBinding.root)
bottomSheetDialog.show()
bottomSheetDialog.dismissWithAnimation = true
/* source code at github */
aboutBinding.sourceCode.setOnClickListener {
bottomSheetDialog.dismiss()
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(sourceCode)))
}
/* wiki at github */
aboutBinding.wiki.setOnClickListener {
bottomSheetDialog.dismiss()
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("$sourceCode/wiki")))
}
/* telegram community */
aboutBinding.telegramGroup.setOnClickListener {
bottomSheetDialog.dismiss()
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/LunarLauncher_chats")))
}
}
/* support dialog */
private fun supportDialog() {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.support)
.setMessage(R.string.support_message)
/* star button */
.setNeutralButton(R.string.star) { _, _ ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(sourceCode)))
}
/* affiliate button */
.setNegativeButton(R.string.amazon) { _, _ ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://amzn.to/44krAw9")))
}
/* donate button */
.setPositiveButton(R.string.donate) { _, _ ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://iamrasel.github.io/donate")))
}
.show()
}
}
@@ -0,0 +1,72 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.SettingsAdvanceBinding
import kotlin.system.exitProcess
internal class Advance : BottomSheetDialogFragment() {
private lateinit var binding : SettingsAdvanceBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsAdvanceBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* open Default Home App screen from device settings */
binding.chooseLauncher.setOnClickListener {
requireContext().startActivity(Intent(Settings.ACTION_HOME_SETTINGS))
this.dismiss()
}
/* reset and restart button click listeners */
binding.reset.setOnClickListener { reset() }
binding.restart.setOnClickListener { exitProcess(0) }
}
/* reset app data */
private fun reset() {
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.reset)
.setMessage(R.string.reset_message)
.setPositiveButton(R.string.proceed) { dialog, _ ->
dialog.dismiss()
Runtime.getRuntime().exec("pm clear " + requireContext().packageName)
}
.setNeutralButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() }
.show()
}
}
@@ -0,0 +1,204 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.Manifest.permission.READ_EXTERNAL_STORAGE
import android.Manifest.permission.READ_MEDIA_IMAGES
import android.app.Activity.RESULT_OK
import android.app.AlertDialog
import android.app.WallpaperManager
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.graphics.BitmapFactory
import android.graphics.Color
import android.graphics.Matrix
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
import android.text.SpannableStringBuilder
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.ColorPickerBinding
import rasel.lunar.launcher.databinding.SettingsAppearancesBinding
import rasel.lunar.launcher.helpers.ColorPicker
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPLICATION_THEME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WINDOW_BACKGROUND
import rasel.lunar.launcher.helpers.UniUtils.Companion.getColorResId
import rasel.lunar.launcher.settings.SettingsActivity.Companion.settingsPrefs
import java.io.IOException
import java.util.*
internal class Appearances : BottomSheetDialogFragment() {
private lateinit var binding : SettingsAppearancesBinding
private lateinit var windowBackground : String
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsAppearancesBinding.inflate(inflater, container, false)
/* initialize views according to the saved values */
when (settingsPrefs!!.getInt(KEY_APPLICATION_THEME, MODE_NIGHT_FOLLOW_SYSTEM)) {
MODE_NIGHT_FOLLOW_SYSTEM -> binding.followSystemTheme.isChecked = true
MODE_NIGHT_YES -> binding.selectDarkTheme.isChecked = true
MODE_NIGHT_NO -> binding.selectLightTheme.isChecked = true
}
when (settingsPrefs!!.getBoolean(KEY_STATUS_BAR, false)) {
false -> binding.hideStatusNegative.isChecked = true
true -> binding.hideStatusPositive.isChecked = true
}
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* change theme */
binding.themeGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.followSystemTheme.id -> {
settingsPrefs!!.edit().putInt(KEY_APPLICATION_THEME, MODE_NIGHT_FOLLOW_SYSTEM).apply()
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM)
}
binding.selectDarkTheme.id -> {
settingsPrefs!!.edit().putInt(KEY_APPLICATION_THEME, MODE_NIGHT_YES).apply()
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES)
}
binding.selectLightTheme.id -> {
settingsPrefs!!.edit().putInt(KEY_APPLICATION_THEME, MODE_NIGHT_NO).apply()
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO)
}
}
}
binding.background.setOnClickListener { selectBackground() }
binding.changeWallpaper.setOnClickListener { selectWallpaper() }
binding.hideStatusGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.hideStatusNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_STATUS_BAR, false).apply()
binding.hideStatusPositive.id -> settingsPrefs!!.edit().putBoolean(KEY_STATUS_BAR, true).apply()
}
}
}
override fun onResume() {
super.onResume()
windowBackground = settingsPrefs!!.getString(KEY_WINDOW_BACKGROUND, defaultColorString).toString()
binding.background.iconTint = ColorStateList.valueOf(Color.parseColor("#$windowBackground"))
}
private fun selectBackground() {
val colorPickerBinding = ColorPickerBinding.inflate(requireActivity().layoutInflater)
val dialogBuilder = MaterialAlertDialogBuilder(requireActivity())
.setView(colorPickerBinding.root)
.setNeutralButton(R.string.default_, null)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok) { _, _ ->
settingsPrefs!!.edit().putString(KEY_WINDOW_BACKGROUND,
Objects.requireNonNull(colorPickerBinding.colorInput.text).toString().trim { it <= ' ' }).apply()
this.onResume()
}
.show()
/* set up color picker section */
ColorPicker(windowBackground, colorPickerBinding.colorInput,
colorPickerBinding.colorA, colorPickerBinding.colorR, colorPickerBinding.colorG,
colorPickerBinding.colorB, colorPickerBinding.root).pickColor()
dialogBuilder.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
colorPickerBinding.colorInput.text =
SpannableStringBuilder(defaultColorString)
}
}
private fun selectWallpaper() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// only for TIRAMISU and newer versions
if (requireActivity().checkSelfPermission(READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED) {
requireActivity().requestPermissions(arrayOf(READ_MEDIA_IMAGES), 1)
} else {
wallpaperChangeLauncher.launch(Intent(Intent.ACTION_PICK).setType("image/*"))
}
} else {
if (requireActivity().checkSelfPermission(READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requireActivity().requestPermissions(arrayOf(READ_EXTERNAL_STORAGE), 1)
} else {
wallpaperChangeLauncher.launch(Intent(Intent.ACTION_PICK).setType("image/*"))
}
}
}
private val defaultColorString: String get() =
requireActivity().getString(getColorResId(requireContext(), android.R.attr.colorBackground))
.replace("#", "")
private var wallpaperChangeLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == RESULT_OK) {
try {
val uri = result.data?.data
val projection = arrayOf(MediaStore.Images.Media.DATA)
val cursor = requireContext().contentResolver.query(
uri!!, projection, null, null, null
)
cursor?.moveToFirst()
val index = cursor!!.getColumnIndex(projection[0])
val filePath = cursor.getString(index)
cursor.close()
val bitmap = BitmapFactory.decodeFile(filePath)
val matrix = Matrix()
matrix.postRotate(0F)
try {
if (bitmap != null) {
WallpaperManager.getInstance(requireContext()).setBitmap(bitmap)
Toast.makeText(requireContext(),
requireActivity().getString(R.string.wallpaper_change_success), Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(requireContext(),
requireActivity().getString(R.string.image_pick_failed), Toast.LENGTH_SHORT).show()
}
} catch (e: IOException) {
e.printStackTrace()
Toast.makeText(requireContext(),
requireActivity().getString(R.string.something_went_wrong), Toast.LENGTH_SHORT).show()
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}
@@ -0,0 +1,319 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.Toast
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.view.children
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipDrawable
import com.google.android.material.chip.ChipGroup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.slider.Slider
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.SettingsAppsBinding
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_GRID_COLUMNS
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_ICON_PACK
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_SCROLLBAR_HEIGHT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPS_COUNT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPS_LAYOUT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_DRAW_ALIGN
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_GRID_COLUMNS
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_PACK
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_KEYBOARD_SEARCH
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_QUICK_LAUNCH
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SCROLLBAR_HEIGHT
import rasel.lunar.launcher.helpers.UniUtils.Companion.dpToPx
import rasel.lunar.launcher.settings.SettingsActivity.Companion.settingsPrefs
import kotlin.system.exitProcess
internal class Apps : BottomSheetDialogFragment() {
private lateinit var binding: SettingsAppsBinding
private var settingsChanged: Boolean = false
private var packageManager: PackageManager? = null
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val bottomSheetView = View.inflate(context, R.layout.settings_apps, null)
val dialog = super.onCreateDialog(savedInstanceState).apply {
setContentView(bottomSheetView)
}
// Set the height to wrap_content
BottomSheetBehavior.from(bottomSheetView.parent as View)
.peekHeight = resources.displayMetrics.heightPixels // Adjust this if needed
return dialog
}
@SuppressLint("RtlHardcoded")
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsAppsBinding.inflate(inflater, container, false)
packageManager = requireActivity().packageManager
/* initialize views according to the saved values */
when (settingsPrefs!!.getBoolean(KEY_KEYBOARD_SEARCH, false)) {
false -> binding.keyboardAutoNegative.isChecked = true
true -> binding.keyboardAutoPositive.isChecked = true
}
when (settingsPrefs!!.getBoolean(KEY_QUICK_LAUNCH, true)) {
true -> binding.quickLaunchPositive.isChecked = true
false -> binding.quickLaunchNegative.isChecked = true
}
when (settingsPrefs!!.getBoolean(KEY_APPS_COUNT, true)) {
true -> binding.appsCountPositive.isChecked = true
false -> binding.appsCountNegative.isChecked = true
}
when (settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0)) {
0 -> {
binding.drawerLayoutList.isChecked = true
binding.appAlignmentGroup.children.forEach { it.isEnabled = true }
binding.iconPackChooser.isEnabled = false
binding.columnsCount.isEnabled = false
}
1 -> {
binding.drawerLayoutListIcon.isChecked = true
binding.appAlignmentGroup.children.forEach { it.isEnabled = true }
binding.iconPackChooser.isEnabled = true
binding.columnsCount.isEnabled = false
}
2 -> {
binding.drawerLayoutGrid.isChecked = true
binding.appAlignmentGroup.children.forEach { it.isEnabled = false }
binding.iconPackChooser.isEnabled = true
binding.columnsCount.isEnabled = true
}
}
when (settingsPrefs!!.getInt(KEY_DRAW_ALIGN, Gravity.CENTER)) {
Gravity.CENTER -> binding.appAlignmentCenter.isChecked = true
Gravity.LEFT -> binding.appAlignmentLeft.isChecked = true
Gravity.RIGHT -> binding.appAlignmentRight.isChecked = true
}
binding.columnsCount.value = settingsPrefs!!.getInt(KEY_GRID_COLUMNS, DEFAULT_GRID_COLUMNS).toFloat()
binding.scrollbarHeight.value = settingsPrefs!!.getInt(KEY_SCROLLBAR_HEIGHT, DEFAULT_SCROLLBAR_HEIGHT).toFloat()
return binding.root
}
@SuppressLint("RtlHardcoded")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* change search with keyboard value */
binding.keyboardAutoGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.keyboardAutoPositive.id -> settingsPrefs!!.edit().putBoolean(KEY_KEYBOARD_SEARCH, true).apply()
binding.keyboardAutoNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_KEYBOARD_SEARCH, false).apply()
}
}
/* change settings for quick launch */
binding.quickLaunchGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.quickLaunchPositive.id -> settingsPrefs!!.edit().putBoolean(KEY_QUICK_LAUNCH, true).apply()
binding.quickLaunchNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_QUICK_LAUNCH, false).apply()
}
}
binding.appsCountGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.appsCountPositive.id -> settingsPrefs!!.edit().putBoolean(KEY_APPS_COUNT, true).apply()
binding.appsCountNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_APPS_COUNT, false).apply()
}
}
binding.drawerLayoutGroup.setOnCheckedStateChangeListener { group, _ ->
settingsChanged = true
when (group.checkedChipId) {
binding.drawerLayoutList.id -> {
settingsPrefs!!.edit().putInt(KEY_APPS_LAYOUT, 0).apply()
binding.appAlignmentGroup.children.forEach { if (!it.isEnabled) it.isEnabled = true }
binding.iconPackChooser.let { if (it.isEnabled) it.isEnabled = false }
binding.columnsCount.let { if (it.isEnabled) it.isEnabled = false }
}
binding.drawerLayoutListIcon.id -> {
settingsPrefs!!.edit().putInt(KEY_APPS_LAYOUT, 1).apply()
binding.appAlignmentGroup.children.forEach { if (!it.isEnabled) it.isEnabled = true }
binding.iconPackChooser.let { if (!it.isEnabled) it.isEnabled = true }
binding.columnsCount.let { if (it.isEnabled) it.isEnabled = false }
}
binding.drawerLayoutGrid.id -> {
settingsPrefs!!.edit().putInt(KEY_APPS_LAYOUT, 2).apply()
binding.appAlignmentGroup.children.forEach { if (it.isEnabled) it.isEnabled = false }
binding.iconPackChooser.let { if (!it.isEnabled) it.isEnabled = true }
binding.columnsCount.let { if (!it.isEnabled) it.isEnabled = true }
}
}
}
binding.appAlignmentGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.appAlignmentLeft.id -> settingsPrefs!!.edit().putInt(KEY_DRAW_ALIGN, Gravity.LEFT).apply()
binding.appAlignmentCenter.id -> settingsPrefs!!.edit().putInt(KEY_DRAW_ALIGN, Gravity.CENTER).apply()
binding.appAlignmentRight.id -> settingsPrefs!!.edit().putInt(KEY_DRAW_ALIGN, Gravity.RIGHT).apply()
}
}
binding.iconPackChooser.setOnClickListener { iconPackChooser() }
binding.columnsCount.addOnChangeListener(Slider.OnChangeListener { _, value, _ ->
settingsChanged = true
settingsPrefs!!.edit().putInt(KEY_GRID_COLUMNS, value.toInt()).apply()
})
binding.scrollbarHeight.addOnChangeListener(Slider.OnChangeListener { _, value, _ ->
settingsPrefs!!.edit().putInt(KEY_SCROLLBAR_HEIGHT, value.toInt()).apply()
})
}
override fun onDestroyView() {
super.onDestroyView()
if (settingsChanged) {
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.restart_now)
.setMessage(R.string.restart_message)
.setPositiveButton(R.string.restart) { _, _ ->
exitProcess(0)
}
.setNeutralButton(R.string.later, null)
.show()
}
}
private fun iconPackChooser() {
if (installedIconPacks.isNotEmpty()) {
var selectedIconPack: String? = null
val chipGroup = ChipGroup(requireContext()).apply {
layoutParams = LinearLayoutCompat.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
isSingleSelection = true
isSelectionRequired = true
setOnCheckedStateChangeListener { group, _ ->
selectedIconPack = group.findViewById<Chip>(group.checkedChipId).tag as String
}
}
installedIconPacks.indices.forEach { i ->
Chip(requireContext()).apply {
layoutParams = LinearLayoutCompat.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
setChipDrawable(ChipDrawable.createFromAttributes(requireContext(), null, 0,
com.google.android.material.R.style.Widget_Material3_Chip_Filter_Elevated))
text = packageManager?.getApplicationLabel(appInfo(installedIconPacks[i])!!)
tag = installedIconPacks[i]
if (settingsPrefs!!.getString(KEY_ICON_PACK, DEFAULT_ICON_PACK).equals(tag as String)) {
isChecked = true
}
}.let { chipGroup.addView(it) }
}
val eightDp = dpToPx(requireContext(), R.dimen.eight)
val linearLayoutCompat = LinearLayoutCompat(requireContext()).apply {
layoutParams = LinearLayoutCompat.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
gravity = Gravity.CENTER
setPadding(eightDp, eightDp, eightDp, eightDp)
addView(chipGroup)
}
MaterialAlertDialogBuilder(requireActivity()).apply {
setTitle(R.string.choose_icon_pack)
setView(linearLayoutCompat)
setPositiveButton(android.R.string.ok) { dialog, _ ->
when (selectedIconPack) {
null -> dialog.dismiss()
else -> {
if (!selectedIconPack.equals(settingsPrefs!!.getString(KEY_ICON_PACK, DEFAULT_ICON_PACK))) {
settingsChanged = true
settingsPrefs!!.edit().putString(KEY_ICON_PACK, selectedIconPack).apply()
} else { dialog.dismiss() }
}
}
}
setNeutralButton(R.string.default_) { dialog, _ ->
if (DEFAULT_ICON_PACK != settingsPrefs!!.getString(KEY_ICON_PACK, DEFAULT_ICON_PACK)) {
settingsChanged = true
settingsPrefs!!.edit().putString(KEY_ICON_PACK, DEFAULT_ICON_PACK).apply()
} else { dialog.dismiss() }
}
show()
}
} else {
Toast.makeText(requireContext(), R.string.icon_pack_not_found, Toast.LENGTH_SHORT).show()
}
}
private val installedIconPacks: ArrayList<String> get() {
val iconPacks = ArrayList<String>()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager?.queryIntentActivities(
Intent("org.adw.launcher.THEMES"),
PackageManager.ResolveInfoFlags.of(PackageManager.GET_META_DATA.toLong())
)
} else {
@Suppress("DEPRECATION")
(packageManager?.queryIntentActivities(
Intent("org.adw.launcher.THEMES"), PackageManager.GET_META_DATA))
}.let {
it?.indices?.forEach { i ->
it[i].activityInfo.packageName.let { packageName: String? ->
iconPacks.add(packageName!!)
}
}
}
return iconPacks
}
private fun appInfo(packageName: String) : ApplicationInfo? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager?.getApplicationInfo(packageName,
PackageManager.ApplicationInfoFlags.of(PackageManager.GET_META_DATA.toLong()))
} else {
@Suppress("DEPRECATION")
packageManager?.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
}
}
}
@@ -0,0 +1,120 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.content.DialogInterface
import android.os.Build
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.slider.Slider
import rasel.lunar.launcher.databinding.SettingsMiscBinding
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_ICON_SIZE
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_BACK_HOME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_SIZE
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SHORTCUT_COUNT
import rasel.lunar.launcher.helpers.Constants.Companion.MAX_SHORTCUTS
import rasel.lunar.launcher.helpers.UniUtils.Companion.isRooted
import rasel.lunar.launcher.settings.SettingsActivity.Companion.settingsPrefs
import java.util.*
internal class Misc : BottomSheetDialogFragment() {
private lateinit var binding : SettingsMiscBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsMiscBinding.inflate(inflater, container, false)
/* initialize views according to the saved values */
when (settingsPrefs!!.getBoolean(KEY_BACK_HOME, false)) {
true -> binding.backHomePositive.isChecked = true
false -> binding.backHomeNegative.isChecked = true
}
binding.shortcutCount.valueTo = MAX_SHORTCUTS.toFloat()
binding.shortcutCount.value = settingsPrefs!!.getInt(KEY_SHORTCUT_COUNT, MAX_SHORTCUTS).toFloat()
binding.iconSize.value = settingsPrefs!!.getInt(KEY_ICON_SIZE, DEFAULT_ICON_SIZE).toFloat()
binding.inputFeedUrl.text = SpannableStringBuilder(settingsPrefs!!.getString(KEY_RSS_URL, ""))
when (settingsPrefs!!.getInt(KEY_LOCK_METHOD, 0)) {
0 -> binding.selectLockNegative.isChecked = true
1 -> binding.selectLockAccessibility.isChecked = true
2 -> binding.selectLockAdmin.isChecked = true
3 -> binding.selectLockRoot.isChecked = true
}
/* disable accessibility button for devices below android 9 */
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
binding.selectLockAccessibility.isEnabled = false
}
/* disable root button for non-rooted devices */
if (!isRooted) {
binding.selectLockRoot.isEnabled = false
}
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
binding.backHomeGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.backHomePositive.id -> settingsPrefs!!.edit().putBoolean(KEY_BACK_HOME, true).apply()
binding.backHomeNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_BACK_HOME, false).apply()
}
}
/* change shortcut count value */
binding.shortcutCount.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
settingsPrefs!!.edit().putInt(KEY_SHORTCUT_COUNT, value.toInt()).apply()
})
binding.iconSize.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
settingsPrefs!!.edit().putInt(KEY_ICON_SIZE, value.toInt()).apply()
})
/* change lock method value */
binding.lockGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.selectLockNegative.id -> settingsPrefs!!.edit().putInt(KEY_LOCK_METHOD, 0).apply()
binding.selectLockAccessibility.id -> settingsPrefs!!.edit().putInt(KEY_LOCK_METHOD, 1).apply()
binding.selectLockAdmin.id -> settingsPrefs!!.edit().putInt(KEY_LOCK_METHOD, 2).apply()
binding.selectLockRoot.id -> settingsPrefs!!.edit().putInt(KEY_LOCK_METHOD, 3).apply()
}
}
}
/* save input field value while closing the dialog */
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
settingsPrefs!!.edit().putString(KEY_RSS_URL,
Objects.requireNonNull(binding.inputFeedUrl.text).toString().trim { it <= ' ' }).apply()
}
}
@@ -0,0 +1,79 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import rasel.lunar.launcher.databinding.SettingsTimeDateBinding
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_DATE_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_DATE_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT
import rasel.lunar.launcher.settings.SettingsActivity.Companion.settingsPrefs
import java.util.*
internal class TimeDate : BottomSheetDialogFragment() {
private lateinit var binding : SettingsTimeDateBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsTimeDateBinding.inflate(inflater, container, false)
/* initialize views according to the saved values */
when (settingsPrefs!!.getInt(KEY_TIME_FORMAT, 0)) {
0 -> binding.followSystemTime.isChecked = true
1 -> binding.selectTwelve.isChecked = true
2 -> binding.selectTwentyFour.isChecked = true
}
binding.dateFormat
.setText(settingsPrefs!!.getString(KEY_DATE_FORMAT, DEFAULT_DATE_FORMAT).toString())
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* change time format value */
binding.timeGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.followSystemTime.id -> settingsPrefs!!.edit().putInt(KEY_TIME_FORMAT, 0).apply()
binding.selectTwelve.id -> settingsPrefs!!.edit().putInt(KEY_TIME_FORMAT, 1).apply()
binding.selectTwentyFour.id -> settingsPrefs!!.edit().putInt(KEY_TIME_FORMAT, 2).apply()
}
}
}
/* if the input field is empty, then save the default value.
else save the value from input field while closing the dialog */
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
val dateFormat = Objects.requireNonNull(binding.dateFormat.text).toString().trim { it <= ' ' }
if (dateFormat.isEmpty()) settingsPrefs!!.edit().putString(KEY_DATE_FORMAT, DEFAULT_DATE_FORMAT).apply()
else settingsPrefs!!.edit().putString(KEY_DATE_FORMAT, dateFormat).apply()
}
}
@@ -0,0 +1,70 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.slider.Slider
import rasel.lunar.launcher.databinding.SettingsTodoBinding
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_COUNTS
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK
import rasel.lunar.launcher.settings.SettingsActivity.Companion.settingsPrefs
internal class TodoSettings : BottomSheetDialogFragment() {
private lateinit var binding : SettingsTodoBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsTodoBinding.inflate(inflater, container, false)
/* initialize views according to the saved values */
binding.showTodos.value = settingsPrefs!!.getInt(KEY_TODO_COUNTS, 3).toFloat()
when (settingsPrefs!!.getBoolean(KEY_TODO_LOCK, false)) {
false -> binding.todoLockNegative.isChecked = true
true -> binding.todoLockPositive.isChecked = true
}
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* change to-do count value */
binding.showTodos.addOnChangeListener(Slider.OnChangeListener { _: Slider?, value: Float, _: Boolean ->
settingsPrefs!!.edit().putInt(KEY_TODO_COUNTS, value.toInt()).apply()
})
/* change to-do lock state value */
binding.todoLockGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.todoLockPositive.id -> settingsPrefs!!.edit().putBoolean(KEY_TODO_LOCK, true).apply()
binding.todoLockNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_TODO_LOCK, false).apply()
}
}
}
}
@@ -0,0 +1,91 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.settings.childs
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import rasel.lunar.launcher.databinding.SettingsWeatherBinding
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_CITY_NAME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_OWM_API
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SHOW_CITY
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TEMP_UNIT
import rasel.lunar.launcher.settings.SettingsActivity.Companion.settingsPrefs
import java.util.*
internal class WeatherSettings : BottomSheetDialogFragment() {
private lateinit var binding : SettingsWeatherBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = SettingsWeatherBinding.inflate(inflater, container, false)
/* initialize views according to the saved values */
binding.inputCity.setText(settingsPrefs!!.getString(KEY_CITY_NAME, "").toString())
binding.inputOwm.setText(settingsPrefs!!.getString(KEY_OWM_API, "").toString())
when (settingsPrefs!!.getInt(KEY_TEMP_UNIT, 0)) {
0 -> binding.selectCelsius.isChecked = true
1 -> binding.selectFahrenheit.isChecked = true
}
when (settingsPrefs!!.getBoolean(KEY_SHOW_CITY, false)) {
false -> binding.showCityNegative.isChecked = true
true -> binding.showCityPositive.isChecked = true
}
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
/* change temperature unit value */
binding.tempGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.selectCelsius.id -> settingsPrefs!!.edit().putInt(KEY_TEMP_UNIT, 0).apply()
binding.selectFahrenheit.id -> settingsPrefs!!.edit().putInt(KEY_TEMP_UNIT, 1).apply()
}
}
/* change show city value */
binding.cityGroup.setOnCheckedStateChangeListener { group, _ ->
when (group.checkedChipId) {
binding.showCityNegative.id -> settingsPrefs!!.edit().putBoolean(KEY_SHOW_CITY, false).apply()
binding.showCityPositive.id -> settingsPrefs!!.edit().putBoolean(KEY_SHOW_CITY, true).apply()
}
}
}
/* save input field values while closing the dialog */
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
settingsPrefs!!.edit().putString(KEY_CITY_NAME,
Objects.requireNonNull(binding.inputCity.text).toString().trim { it <= ' ' }).apply()
settingsPrefs!!.edit().putString(KEY_OWM_API,
Objects.requireNonNull(binding.inputOwm.text).toString().trim { it <= ' ' }).apply()
}
}
@@ -0,0 +1,107 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.todos
import android.database.sqlite.SQLiteOpenHelper
import android.database.sqlite.SQLiteDatabase
import android.content.ContentValues
import android.annotation.SuppressLint
import android.content.Context
import android.database.DatabaseUtils
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_CREATED
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_ID
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_COLUMN_NAME
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_DATABASE_NAME
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_DATABASE_VERSION
import rasel.lunar.launcher.helpers.Constants.Companion.TODO_TABLE_NAME
import java.util.ArrayList
internal class DatabaseHandler(context: Context?) :
SQLiteOpenHelper(context, TODO_DATABASE_NAME, null, TODO_DATABASE_VERSION) {
/* create database */
override fun onCreate(database: SQLiteDatabase) {
val createTodoTable = "CREATE TABLE " + TODO_TABLE_NAME + " (" +
TODO_COLUMN_ID + " integer PRIMARY KEY AUTOINCREMENT," +
TODO_COLUMN_CREATED + " datetime DEFAULT CURRENT_TIMESTAMP," +
TODO_COLUMN_NAME + " varchar)"
database.execSQL(createTodoTable)
}
override fun onUpgrade(sqLiteDatabase: SQLiteDatabase, i: Int, i1: Int) {}
/* add new to-do entry */
fun addTodo(todo: Todo) {
val database = writableDatabase
val contentValues = ContentValues()
contentValues.put(TODO_COLUMN_NAME, todo.name)
database.insert(TODO_TABLE_NAME, null, contentValues)
}
/* update or edit existing to-do */
fun updateTodo(todo: Todo) {
val database = writableDatabase
val contentValues = ContentValues()
contentValues.put(TODO_COLUMN_NAME, todo.name)
database.update(
TODO_TABLE_NAME,
contentValues,
"$TODO_COLUMN_ID=?",
arrayOf(todo.id.toString())
)
}
/* delete a single to-do */
fun deleteTodo(todoId: Long) {
writableDatabase.delete(TODO_TABLE_NAME,
"$TODO_COLUMN_ID=?", arrayOf(todoId.toString()))
}
/* delete all existing todos at once */
fun deleteAll() {
writableDatabase.delete(TODO_TABLE_NAME, null, null)
}
@get:SuppressLint("Range")
val todos: ArrayList<Todo>
get() {
val todoList = ArrayList<Todo>()
val queryResult =
readableDatabase.rawQuery("SELECT * from $TODO_TABLE_NAME", null)
if (queryResult.moveToFirst()) {
do {
val todo = Todo()
todo.id = queryResult.getLong(queryResult.getColumnIndex(TODO_COLUMN_ID))
todo.name = queryResult.getString(queryResult.getColumnIndex(TODO_COLUMN_NAME))
todoList.add(todo)
} while (queryResult.moveToNext())
}
queryResult.close()
return todoList
}
/* check if any item exists in the database */
val isTodoExists: Boolean get() {
return DatabaseUtils.queryNumEntries(readableDatabase, TODO_TABLE_NAME, 1.toString()) > 0
}
}
@@ -0,0 +1,25 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.todos
internal class Todo {
var id: Long = -1
var name = ""
}
@@ -0,0 +1,127 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.todos
import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetDialog
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.ListItemBinding
import rasel.lunar.launcher.databinding.TodoDialogBinding
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_COUNTS
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard
import java.util.*
internal class TodoAdapter(
private val todoManager: TodoManager?,
private val context: Context) : RecyclerView.Adapter<TodoAdapter.TodoViewHolder>() {
private val currentFragment = lActivity!!.supportFragmentManager.findFragmentById(R.id.mainFragmentsContainer)
private val todoList = DatabaseHandler(context).todos
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): TodoViewHolder {
val binding = ListItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
return TodoViewHolder(binding)
}
override fun getItemCount(): Int {
/* if current fragment is LauncherHome,
then return size following the settings value */
val sharedPreferences = context.getSharedPreferences(PREFS_SETTINGS, 0)
val numberOfTodos = sharedPreferences.getInt(KEY_TODO_COUNTS, 3)
return if (currentFragment !is TodoManager) {
todoList.size.coerceAtMost(numberOfTodos)
} else {
todoList.size
}
}
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: TodoViewHolder, position: Int) {
val todo = todoList[position]
holder.view.itemText.text = "\u25CF ${todo.name}"
if (currentFragment is TodoManager) {
/* multiline texts are enabled for TodoManager */
holder.view.itemText.isSingleLine = false
/* launch edit or update dialog on item click */
holder.view.itemText.setOnClickListener { updateDialog(position) }
/* copy texts on long click */
holder.view.itemText.setOnLongClickListener {
copyToClipboard(context, todo.name)
true
}
} else {
/* single line text for home screen */
holder.view.itemText.isSingleLine = true
}
}
inner class TodoViewHolder(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root)
/* update dialog */
private fun updateDialog(position: Int) {
val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(context))
bottomSheetDialog.setContentView(dialogBinding.root)
bottomSheetDialog.show()
bottomSheetDialog.dismissWithAnimation = true
val databaseHandler = DatabaseHandler(context)
val todo = databaseHandler.todos[position]
dialogBinding.apply {
deleteAllConfirmation.visibility = View.GONE
todoInput.setText(todo.name)
todoCancel.text = context.getString(R.string.delete)
todoCancel.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
todoOk.text = context.getString(R.string.update)
}
/* delete the item */
dialogBinding.todoCancel.setOnClickListener {
databaseHandler.deleteTodo(todo.id)
bottomSheetDialog.dismiss()
todoManager?.refreshList()
}
/* update the item */
dialogBinding.todoOk.setOnClickListener {
val updatedTodoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
if (updatedTodoString.isNotEmpty()) {
todo.name = updatedTodoString
databaseHandler.updateTodo(todo)
bottomSheetDialog.dismiss()
todoManager?.refreshList()
} else {
dialogBinding.todoInput.error = context.getString(R.string.empty_text_field)
}
}
}
}
@@ -0,0 +1,129 @@
/*
* Lunar Launcher
* Copyright (C) 2022 Md Rasel Hossain
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package rasel.lunar.launcher.todos
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.google.android.material.bottomsheet.BottomSheetDialog
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.TodoDialogBinding
import rasel.lunar.launcher.databinding.TodoManagerBinding
import java.util.*
internal class TodoManager : Fragment() {
private lateinit var binding: TodoManagerBinding
private lateinit var databaseHandler: DatabaseHandler
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = TodoManagerBinding.inflate(inflater, container, false)
databaseHandler = DatabaseHandler(requireContext())
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
/* click listeners for add new and delete all buttons */
binding.addNew.setOnClickListener { addNewDialog() }
binding.deleteAll.setOnClickListener { deleteAllDialog() }
}
override fun onResume() {
super.onResume()
refreshList()
lActivity!!.viewPager.isUserInputEnabled = false
}
override fun onPause() {
super.onPause()
lActivity!!.viewPager.isUserInputEnabled = true
}
fun refreshList() {
binding.todos.adapter = TodoAdapter(this, requireContext())
}
/* add new dialog */
private fun addNewDialog() {
val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(requireContext()))
bottomSheetDialog.setContentView(dialogBinding.root)
bottomSheetDialog.show()
bottomSheetDialog.dismissWithAnimation = true
dialogBinding.deleteAllConfirmation.visibility = View.GONE
/* automatic keyboard popup */
dialogBinding.todoInput.requestFocus()
val inputMethodManager = lActivity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.showSoftInput(dialogBinding.todoInput, InputMethodManager.SHOW_IMPLICIT)
/* dismiss the dialog on cancel button click */
dialogBinding.todoCancel.setOnClickListener { bottomSheetDialog.dismiss() }
/* add new item to the database */
dialogBinding.todoOk.setOnClickListener {
val todo = Todo()
val todoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
if (todoString.isNotEmpty()) {
todo.name = todoString
databaseHandler.addTodo(todo)
bottomSheetDialog.dismiss()
refreshList()
} else {
dialogBinding.todoInput.error = getString(R.string.empty_text_field)
}
}
}
/* delete all dialog */
private fun deleteAllDialog() {
val bottomSheetDialog = BottomSheetDialog(lActivity!!)
val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(requireContext()))
bottomSheetDialog.setContentView(dialogBinding.root)
bottomSheetDialog.show()
bottomSheetDialog.dismissWithAnimation = true
/* if any item does not exist, then disable the ok button */
if (!databaseHandler.isTodoExists) {
dialogBinding.todoOk.isEnabled = false
}
dialogBinding.todoInput.visibility = View.GONE
dialogBinding.todoOk.setTextColor(ContextCompat.getColor(requireContext(), android.R.color.holo_red_light))
/* dismiss the dialog on cancel button click */
dialogBinding.todoCancel.setOnClickListener { bottomSheetDialog.dismiss() }
/* delete all the existing items from the database */
dialogBinding.todoOk.setOnClickListener {
databaseHandler.deleteAll()
bottomSheetDialog.dismiss()
refreshList()
}
}
}
@@ -0,0 +1,56 @@
package rasel.lunar.launcher.utils
import android.util.Log
import rasel.lunar.launcher.BuildConfig
import java.lang.Exception
object BLog {
val DEFAULT_TAG = "MyEBook_TAG"
enum class BLogType {
D,I,E
}
fun w(tag : String = DEFAULT_TAG, log: String){
LOG(BLogType.D,tag,log)
}
fun LOGD(tag : String = DEFAULT_TAG, log: String){
LOG(BLogType.D,tag,log)
}
fun LOGI(tag : String = DEFAULT_TAG, log: String){
LOG(BLogType.I,tag,log)
}
fun LOGE(tag : String = DEFAULT_TAG, log: Throwable){
LOG(BLogType.E,tag,log.toString())
}
fun LOGE(tag : String = DEFAULT_TAG, log: Exception){
LOG(BLogType.E,tag,log.toString())
}
fun LOGE(tag : String = DEFAULT_TAG, log: String){
LOG(BLogType.E,tag,log)
}
fun LOGE(log: String){
LOG(BLogType.E,DEFAULT_TAG,log)
}
private fun LOG(type : BLogType, tag : String, log : String) {
if (BuildConfig.DEBUG || BuildConfig.BUILD_TYPE.contains("debug")) {
when(type) {
BLogType.D -> {
Log.d(tag,log)
}
BLogType.I -> {
Log.i(tag,log)
}
BLogType.E -> {
Log.e(tag,log)
}
else -> {}
}
}
}
}
@@ -0,0 +1,781 @@
package rasel.lunar.launcher.utils
import android.content.Context
import android.os.SystemClock
import android.util.DisplayMetrics
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.View.OnTouchListener
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.sqrt
class GestureAnalyser @JvmOverloads constructor(
swipeSlopeIntolerance: Int = 2,
doubleTapMaxDelayMillis: Int = 500,
doubleTapMaxDownMillis: Int = 100
) {
var minValue = 100
private val initialX = DoubleArray(5)
private val initialY = DoubleArray(5)
private val finalX = DoubleArray(5)
private val finalY = DoubleArray(5)
private val currentX = DoubleArray(5)
private val currentY = DoubleArray(5)
private val delX = DoubleArray(5)
private val delY = DoubleArray(5)
private var numFingers = 0
private var initialT: Long = 0
private var finalT: Long = 0
private var currentT: Long = 0
private var prevInitialT: Long = 0
private var prevFinalT: Long = 0
private var swipeSlopeIntolerance = 2
private val doubleTapMaxDelayMillis: Long
private val doubleTapMaxDownMillis: Long
init {
this.swipeSlopeIntolerance = swipeSlopeIntolerance
this.doubleTapMaxDownMillis = doubleTapMaxDownMillis.toLong()
this.doubleTapMaxDelayMillis = doubleTapMaxDelayMillis.toLong()
}
fun trackGesture(ev: MotionEvent) {
val n = ev.pointerCount
for (i in 0 until n) {
initialX[i] = ev.getX(i).toDouble()
initialY[i] = ev.getY(i).toDouble()
}
numFingers = n
initialT = SystemClock.uptimeMillis()
}
fun untrackGesture() {
numFingers = 0
prevFinalT = SystemClock.uptimeMillis()
prevInitialT = initialT
}
fun getGesture(ev: MotionEvent): GestureType {
var averageDistance = 0.0
for (i in 0 until numFingers) {
finalX[i] = ev.getX(i).toDouble()
finalY[i] = ev.getY(i).toDouble()
delX[i] = finalX[i] - initialX[i]
delY[i] = finalY[i] - initialY[i]
averageDistance += sqrt(
(finalX[i] - initialX[i]).pow(2.0) + (finalY[i] - initialY[i]).pow(
2.0
)
)
}
averageDistance /= numFingers.toDouble()
finalT = SystemClock.uptimeMillis()
val gt = GestureType()
gt.gestureFlag = calcGesture()
gt.gestureDuration = finalT - initialT
gt.gestureDistance = averageDistance
return gt
}
fun getOngoingGesture(ev: MotionEvent): Int {
for (i in 0 until numFingers) {
currentX[i] = ev.getX(i).toDouble()
currentY[i] = ev.getY(i).toDouble()
delX[i] = finalX[i] - initialX[i]
delY[i] = finalY[i] - initialY[i]
}
currentT = SystemClock.uptimeMillis()
return calcGesture()
}
private fun calcGesture(): Int {
if (isDoubleTap) {
return DOUBLE_TAP_1
}
if (numFingers == 1) {
if ((-(delY[0])) > (swipeSlopeIntolerance * (abs(
delX[0]
))) && abs(delY[0]) > minValue
) {
return SWIPE_1_UP
}
if (((delY[0])) > (swipeSlopeIntolerance * (abs(
delX[0]
))) && abs(delY[0]) > minValue
) {
return SWIPE_1_DOWN
}
if ((-(delX[0])) > (swipeSlopeIntolerance * (abs(
delY[0]
))) && abs(delX[0]) > minValue
) {
return SWIPE_1_LEFT
}
if (((delX[0])) > (swipeSlopeIntolerance * (abs(
delY[0]
))) && abs(delX[0]) > minValue
) {
return SWIPE_1_RIGHT
}
BLog.LOGE("initialT = ${initialT} , finalT = ${finalT} , result = ${finalT - initialT}")
if (finalT - initialT < 300) {
return CLICK_1
} else if(finalT - initialT > 600) {
return LONG_CLICK_1
}
}
if (numFingers == 2) {
if (((-delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
))) && ((-delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
))) && (abs(delY[0]) > minValue || abs(delY[1]) > minValue)
) {
return SWIPE_2_UP
}
if (((delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
))) && ((delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
))) && (abs(delY[0]) > minValue || abs(delY[1]) > minValue)
) {
return SWIPE_2_DOWN
}
if (((-delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
))) && ((-delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
))) && (abs(delX[0]) > minValue || abs(delX[1]) > minValue)
) {
return SWIPE_2_LEFT
}
if (((delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
))) && ((delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
))) && (abs(delX[0]) > minValue || abs(delX[1]) > minValue)
) {
return SWIPE_2_RIGHT
}
if (finalFingDist(0, 1) > 2 * (initialFingDist(0, 1))) {
return UNPINCH_2
}
if (finalFingDist(0, 1) < 0.5 * (initialFingDist(0, 1))) {
return PINCH_2
}
}
if (numFingers == 3) {
if (((-delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((-delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((-delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
) {
return SWIPE_3_UP
}
if (((delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
) {
return SWIPE_3_DOWN
}
if (((-delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((-delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((-delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
) {
return SWIPE_3_LEFT
}
if (((delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
) {
return SWIPE_3_RIGHT
}
if ((finalFingDist(0, 1) > 1.75 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) > 1.75 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 0) > 1.75 * (initialFingDist(2, 0)))
) {
return UNPINCH_3
}
if ((finalFingDist(0, 1) < 0.66 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) < 0.66 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 0) < 0.66 * (initialFingDist(2, 0)))
) {
return PINCH_3
}
}
if (numFingers == 4) {
if (((-delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((-delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((-delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
&& ((-delY[3]) > (swipeSlopeIntolerance * abs(
delX[3]
)))
) {
return SWIPE_4_UP
}
if (((delY[0]) > (swipeSlopeIntolerance * abs(
delX[0]
)))
&& ((delY[1]) > (swipeSlopeIntolerance * abs(
delX[1]
)))
&& ((delY[2]) > (swipeSlopeIntolerance * abs(
delX[2]
)))
&& ((delY[3]) > (swipeSlopeIntolerance * abs(
delX[3]
)))
) {
return SWIPE_4_DOWN
}
if (((-delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((-delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((-delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
&& ((-delX[3]) > (swipeSlopeIntolerance * abs(
delY[3]
)))
) {
return SWIPE_4_LEFT
}
if (((delX[0]) > (swipeSlopeIntolerance * abs(
delY[0]
)))
&& ((delX[1]) > (swipeSlopeIntolerance * abs(
delY[1]
)))
&& ((delX[2]) > (swipeSlopeIntolerance * abs(
delY[2]
)))
&& ((delX[3]) > (swipeSlopeIntolerance * abs(
delY[3]
)))
) {
return SWIPE_4_RIGHT
}
if ((finalFingDist(0, 1) > 1.5 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) > 1.5 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 3) > 1.5 * (initialFingDist(2, 3)))
&& (finalFingDist(3, 0) > 1.5 * (initialFingDist(3, 0)))
) {
return UNPINCH_4
}
if ((finalFingDist(0, 1) < 0.8 * (initialFingDist(0, 1)))
&& (finalFingDist(1, 2) < 0.8 * (initialFingDist(1, 2)))
&& (finalFingDist(2, 3) < 0.8 * (initialFingDist(2, 3)))
&& (finalFingDist(3, 0) < 0.8 * (initialFingDist(3, 0)))
) {
return PINCH_4
}
}
return 0
}
private fun initialFingDist(fingNum1: Int, fingNum2: Int): Double {
return sqrt(
(initialX[fingNum1] - initialX[fingNum2]).pow(2.0) + (initialY[fingNum1] - initialY[fingNum2]).pow(
2.0
)
)
}
private fun finalFingDist(fingNum1: Int, fingNum2: Int): Double {
return sqrt(
(finalX[fingNum1] - finalX[fingNum2]).pow(2.0) + (finalY[fingNum1] - finalY[fingNum2]).pow(
2.0
)
)
}
val isDoubleTap: Boolean
get() = if (initialT - prevFinalT < doubleTapMaxDelayMillis && finalT - initialT < doubleTapMaxDownMillis && prevFinalT - prevInitialT < doubleTapMaxDownMillis) {
true
} else {
false
}
inner class GestureType {
var gestureFlag: Int = 0
var gestureDuration: Long = 0
var gestureDistance: Double = 0.0
}
companion object {
const val DEBUG: Boolean = true
// Finished gestures flags
const val SWIPE_1_UP: Int = 11
const val SWIPE_1_DOWN: Int = 12
const val SWIPE_1_LEFT: Int = 13
const val SWIPE_1_RIGHT: Int = 14
const val SWIPE_2_UP: Int = 21
const val SWIPE_2_DOWN: Int = 22
const val SWIPE_2_LEFT: Int = 23
const val SWIPE_2_RIGHT: Int = 24
const val SWIPE_3_UP: Int = 31
const val SWIPE_3_DOWN: Int = 32
const val SWIPE_3_LEFT: Int = 33
const val SWIPE_3_RIGHT: Int = 34
const val SWIPE_4_UP: Int = 41
const val SWIPE_4_DOWN: Int = 42
const val SWIPE_4_LEFT: Int = 43
const val SWIPE_4_RIGHT: Int = 44
const val PINCH_2: Int = 25
const val UNPINCH_2: Int = 26
const val PINCH_3: Int = 35
const val UNPINCH_3: Int = 36
const val PINCH_4: Int = 45
const val UNPINCH_4: Int = 46
const val DOUBLE_TAP_1: Int = 107
const val CLICK_1 = 19001
const val CLICK_2 = 19002
const val CLICK_3 = 19003
const val LONG_CLICK_1 = 29001
const val LONG_CLICK_2 = 29002
const val LONG_CLICK_3 = 29003
//Ongoing gesture flags
const val SWIPING_1_UP: Int = 101
const val SWIPING_1_DOWN: Int = 102
const val SWIPING_1_LEFT: Int = 103
const val SWIPING_1_RIGHT: Int = 104
const val SWIPING_2_UP: Int = 201
const val SWIPING_2_DOWN: Int = 202
const val SWIPING_2_LEFT: Int = 203
const val SWIPING_2_RIGHT: Int = 204
const val PINCHING: Int = 205
const val UNPINCHING: Int = 206
private const val TAG = "GestureAnalyser"
}
}
class SimpleFingerGestures : OnTouchListener {
private var debug = true
var consumeTouchEvents: Boolean = false
var screenHeight : Int = 100
protected var tracking: BooleanArray = booleanArrayOf(false, false, false, false, false)
private var ga: GestureAnalyser
private var onFingerGestureListener: OnFingerGestureListener? = null
var targetView : View? = null
var mContext : Context? = null
constructor(context : Context,targetView : View, onFingerGestureListener: OnFingerGestureListener) {
this.mContext = context
this.targetView = targetView
ga = GestureAnalyser()
this.mContext?.resources?.displayMetrics?.let {
screenHeight = (it.heightPixels * 0.18).toInt()
ga.minValue = Math.max(screenHeight, 100)
}
this.onFingerGestureListener = onFingerGestureListener
this.targetView?.setOnClickListener { onFingerGestureListener.onClick(it) }
this.targetView?.setOnLongClickListener { onFingerGestureListener.onLongPress(it) }
}
/**
* Constructor that creates an internal [in.championswimmer.sfg.lib.GestureAnalyser] object as well
*/
constructor() {
ga = GestureAnalyser()
}
constructor(
swipeSlopeIntolerance: Int,
doubleTapMaxDelayMillis: Int,
doubleTapMaxDownMillis: Int
) {
ga = GestureAnalyser(swipeSlopeIntolerance, doubleTapMaxDelayMillis, doubleTapMaxDownMillis)
}
fun setDebug(debug: Boolean) {
this.debug = debug
}
constructor(omfgl: OnFingerGestureListener?) {
ga = GestureAnalyser()
setOnFingerGestureListener(omfgl)
}
/**
* Register a callback to be invoked when multi-finger gestures take place
*
*
* <br></br>
*
*
* For the callbacks implemented via this, check the interface [in.championswimmer.sfg.lib.SimpleFingerGestures.OnFingerGestureListener]
*
*
* @param omfgl The callback that will run
*/
fun setOnFingerGestureListener(omfgl: OnFingerGestureListener?) {
onFingerGestureListener = omfgl
}
override fun onTouch(view: View, ev: MotionEvent): Boolean {
if (debug) Log.d(TAG, "onTouch")
when (ev.action and MotionEvent.ACTION_MASK) {
MotionEvent.ACTION_DOWN -> {
if (debug) Log.d(TAG, "ACTION_DOWN")
startTracking(0)
ga.trackGesture(ev)
return consumeTouchEvents
}
MotionEvent.ACTION_UP -> {
if (debug) Log.d(TAG, "ACTION_UP")
if (tracking[0]) {
doCallBack(view,ga.getGesture(ev))
}
stopTracking(0)
ga.untrackGesture()
return consumeTouchEvents
}
MotionEvent.ACTION_POINTER_DOWN -> {
if (debug) Log.d(TAG, "ACTION_POINTER_DOWN" + " " + "num" + ev.pointerCount)
startTracking(ev.pointerCount - 1)
ga.trackGesture(ev)
return consumeTouchEvents
}
MotionEvent.ACTION_POINTER_UP -> {
if (debug) Log.d(TAG, "ACTION_POINTER_UP" + " " + "num" + ev.pointerCount)
if (tracking[1]) {
doCallBack(view,ga.getGesture(ev))
}
stopTracking(ev.pointerCount - 1)
ga.untrackGesture()
return consumeTouchEvents
}
MotionEvent.ACTION_CANCEL -> {
if (debug) Log.d(TAG, "ACTION_CANCEL")
return true
}
MotionEvent.ACTION_MOVE -> {
if (debug) Log.d(TAG, "ACTION_MOVE")
return consumeTouchEvents
}
}
return consumeTouchEvents
}
private fun doCallBack(targetView : View, mGt: GestureAnalyser.GestureType) {
when (mGt.gestureFlag) {
GestureAnalyser.SWIPE_1_UP -> onFingerGestureListener!!.onSwipeUp(
targetView,
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_1_DOWN -> onFingerGestureListener!!.onSwipeDown(
targetView,
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_1_LEFT -> onFingerGestureListener!!.onSwipeLeft(
targetView,
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_1_RIGHT -> onFingerGestureListener!!.onSwipeRight(
targetView,
1,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_UP -> onFingerGestureListener!!.onSwipeUp(
targetView,
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_DOWN -> onFingerGestureListener!!.onSwipeDown(
targetView,
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_LEFT -> onFingerGestureListener!!.onSwipeLeft(
targetView,
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_2_RIGHT -> onFingerGestureListener!!.onSwipeRight(
targetView,
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.PINCH_2 -> onFingerGestureListener!!.onPinch(
targetView,
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.UNPINCH_2 -> onFingerGestureListener!!.onUnpinch(
targetView,
2,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_UP -> onFingerGestureListener!!.onSwipeUp(
targetView,
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_DOWN -> onFingerGestureListener!!.onSwipeDown(
targetView,
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_LEFT -> onFingerGestureListener!!.onSwipeLeft(
targetView,
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_3_RIGHT -> onFingerGestureListener!!.onSwipeRight(
targetView,
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.PINCH_3 -> onFingerGestureListener!!.onPinch(
targetView,
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.UNPINCH_3 -> onFingerGestureListener!!.onUnpinch(
targetView,
3,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_UP -> onFingerGestureListener!!.onSwipeUp(
targetView,
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_DOWN -> onFingerGestureListener!!.onSwipeDown(
targetView,
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_LEFT -> onFingerGestureListener!!.onSwipeLeft(
targetView,
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.SWIPE_4_RIGHT -> onFingerGestureListener!!.onSwipeRight(
targetView,
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.PINCH_4 -> onFingerGestureListener!!.onPinch(
targetView,
4,
mGt.gestureDuration,
mGt.gestureDistance
)
GestureAnalyser.UNPINCH_4 -> {
onFingerGestureListener!!.onUnpinch(targetView,4, mGt.gestureDuration, mGt.gestureDistance)
// onFingerGestureListener!!.onDoubleTap(1)
}
GestureAnalyser.CLICK_1 -> {
BLog.LOGE("GestureAnalyser.CLICK_1")
onFingerGestureListener!!.onClick(targetView)
// onFingerGestureListener!!.onDoubleTap(1)
}
// GestureAnalyser.CLICK_2 -> {
// onFingerGestureListener!!.onUnpinch(targetView,4, mGt.gestureDuration, mGt.gestureDistance)
//// onFingerGestureListener!!.onDoubleTap(1)
// }
// GestureAnalyser.CLICK_3 -> {
// onFingerGestureListener!!.onUnpinch(targetView,4, mGt.gestureDuration, mGt.gestureDistance)
//// onFingerGestureListener!!.onDoubleTap(1)
// }
GestureAnalyser.LONG_CLICK_1 -> {
BLog.LOGE("GestureAnalyser.LONG_CLICK_1")
onFingerGestureListener!!.onLongPress(targetView)
}
GestureAnalyser.DOUBLE_TAP_1 -> onFingerGestureListener!!.onDoubleTap(targetView,1)
}
}
private fun startTracking(nthPointer: Int) {
for (i in 0..nthPointer) {
tracking[i] = true
}
}
private fun stopTracking(nthPointer: Int) {
for (i in nthPointer until tracking.size) {
tracking[i] = false
}
}
/**
* Interface definition for the callback to be invoked when 2-finger gestures are performed
*/
interface OnFingerGestureListener {
/**
* Called when user swipes **up** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeUp(targetView : View, fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user swipes **down** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeDown(targetView : View,fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user swipes **left** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeLeft(targetView : View,fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user swipes **right** with two fingers
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onSwipeRight(targetView : View,fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user **pinches** with two fingers (bring together)
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onPinch(targetView : View,fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
/**
* Called when user **un-pinches** with two fingers (take apart)
*
* @param fingers number of fingers involved in this gesture
* @param gestureDuration duration in milliSeconds
* @return
*/
fun onUnpinch(targetView : View,fingers: Int, gestureDuration: Long, gestureDistance: Double): Boolean
fun onDoubleTap(targetView : View,fingers: Int): Boolean
fun onLongPress(targetView : View): Boolean
fun onClick(targetView : View): Boolean
}
companion object {
// Will see if these need to be used. For now just returning duration in milliS
const val GESTURE_SPEED_SLOW: Long = 1500
const val GESTURE_SPEED_MEDIUM: Long = 1000
const val GESTURE_SPEED_FAST: Long = 500
private const val TAG = "SimpleFingerGestures"
}
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<rotate
android:repeatCount="infinite"
android:toDegrees="3600"
android:duration="50000"
android:pivotX="50%"
android:pivotY="50%" />
</set>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<corners
android:radius="8dp" />
<solid
android:color="?attr/scrimBackground" />
<stroke
android:width="1dp"
android:color="@android:color/transparent" />
</shape>
</item>
<item android:state_pressed="false">
<shape>
<corners
android:radius="8dp" />
<solid
android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@android:color/transparent" />
</shape>
</item>
</selector>
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M16.35,12.5 L11.55,7.7 16.35,2.9 21.15,7.7ZM3.75,10.9V4.1H10.55V10.9ZM13.15,20.25V13.5H19.9V20.25ZM3.75,20.25V13.45H10.55V20.25ZM5.1,9.55H9.2V5.45H5.1ZM16.375,10.6 L19.25,7.725 16.375,4.85 13.5,7.725ZM14.5,18.9H18.55V14.85H14.5ZM5.1,18.9H9.2V14.8H5.1ZM9.2,9.55ZM13.5,7.725ZM9.2,14.8ZM14.5,14.85Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M11.35,16.75H12.7V12.7H16.75V11.35H12.7V7.25H11.35V11.35H7.25V12.7H11.35ZM12,21.5Q10.025,21.5 8.3,20.75Q6.575,20 5.287,18.725Q4,17.45 3.25,15.712Q2.5,13.975 2.5,12Q2.5,10.025 3.25,8.287Q4,6.55 5.287,5.262Q6.575,3.975 8.3,3.237Q10.025,2.5 12,2.5Q13.975,2.5 15.713,3.237Q17.45,3.975 18.738,5.262Q20.025,6.55 20.763,8.287Q21.5,10.025 21.5,12Q21.5,13.975 20.763,15.7Q20.025,17.425 18.738,18.712Q17.45,20 15.713,20.75Q13.975,21.5 12,21.5ZM12,20.15Q15.425,20.15 17.788,17.787Q20.15,15.425 20.15,12Q20.15,8.575 17.788,6.212Q15.425,3.85 12,3.85Q8.575,3.85 6.213,6.212Q3.85,8.575 3.85,12Q3.85,15.425 6.213,17.787Q8.575,20.15 12,20.15ZM12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Z"/>
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M12,21.425Q10.25,21.425 8.713,20.775Q7.175,20.125 6,18.95Q4.825,17.775 4.175,16.237Q3.525,14.7 3.525,12.95Q3.525,11.2 4.175,9.662Q4.825,8.125 6,6.95Q7.175,5.775 8.713,5.125Q10.25,4.475 12,4.475Q13.75,4.475 15.287,5.125Q16.825,5.775 18,6.95Q19.175,8.125 19.825,9.662Q20.475,11.2 20.475,12.95Q20.475,14.7 19.825,16.237Q19.175,17.775 18,18.95Q16.825,20.125 15.287,20.775Q13.75,21.425 12,21.425ZM12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95Q12,12.95 12,12.95ZM11.325,8.525V12.825Q11.325,13.05 11.388,13.212Q11.45,13.375 11.625,13.55L14.625,16.55Q14.825,16.75 15.075,16.75Q15.325,16.75 15.55,16.525Q15.775,16.3 15.775,16.05Q15.775,15.8 15.55,15.575L12.675,12.7V8.5Q12.675,8.25 12.488,8.05Q12.3,7.85 12,7.85Q11.725,7.85 11.525,8.05Q11.325,8.25 11.325,8.525ZM3.275,7.15Q3.075,7.35 2.825,7.35Q2.575,7.35 2.35,7.125Q2.125,6.9 2.125,6.65Q2.125,6.4 2.35,6.175L5.225,3.3Q5.425,3.1 5.675,3.1Q5.925,3.1 6.15,3.325Q6.375,3.55 6.375,3.8Q6.375,4.05 6.15,4.275ZM20.7,7.125 L17.825,4.25Q17.625,4.05 17.625,3.8Q17.625,3.55 17.85,3.325Q18.075,3.1 18.325,3.1Q18.575,3.1 18.8,3.325L21.675,6.2Q21.875,6.4 21.875,6.65Q21.875,6.9 21.65,7.125Q21.425,7.35 21.175,7.35Q20.925,7.35 20.7,7.125ZM12,20.075Q14.925,20.075 17.025,17.975Q19.125,15.875 19.125,12.95Q19.125,10.025 17.025,7.925Q14.925,5.825 12,5.825Q9.05,5.825 6.963,7.912Q4.875,10 4.875,12.95Q4.875,15.9 6.963,17.988Q9.05,20.075 12,20.075Z"
tools:ignore="VectorPath" />
</vector>
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M9.075,19H6.625Q5.95,19 5.475,18.525Q5,18.05 5,17.375V14.925L3.2,13.125Q2.75,12.675 2.75,12Q2.75,11.325 3.2,10.875L5,9.075V6.625Q5,5.95 5.475,5.475Q5.95,5 6.625,5H9.075L10.875,3.2Q11.325,2.75 12,2.75Q12.675,2.75 13.125,3.2L14.925,5H17.375Q18.05,5 18.525,5.475Q19,5.95 19,6.625V9.075L20.8,10.875Q21.25,11.325 21.25,12Q21.25,12.675 20.8,13.125L19,14.925V17.375Q19,18.05 18.525,18.525Q18.05,19 17.375,19H14.925L13.125,20.8Q12.675,21.25 12,21.25Q11.325,21.25 10.875,20.8ZM12,12ZM12,16.225Q13.75,16.225 14.988,14.988Q16.225,13.75 16.225,12Q16.225,10.25 14.988,9.012Q13.75,7.775 12,7.775ZM12,20.5 L14.5,18H18V14.5L20.5,12L18,9.5V6H14.5L12,3.5L9.5,6H6V9.5L3.5,12L6,14.5V18H9.5Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M6.3,18.7 L5.35,17.7 11.025,12 5.35,6.25 6.3,5.25 12.025,11 17.7,5.25 18.65,6.25 12.975,12 18.65,17.7 17.7,18.7 12.025,12.95Z"/>
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M167,903.5L167,828.5L793,828.5L793,903.5L167,903.5ZM167,131.5L167,56.5L793,56.5L793,131.5L167,131.5ZM479.5,533Q528.25,533 562.38,498.88Q596.5,464.75 596.5,416Q596.5,367.25 562.38,333.13Q528.25,299 479.5,299Q430.75,299 396.63,333.13Q362.5,367.25 362.5,416Q362.5,464.75 396.63,498.88Q430.75,533 479.5,533ZM165,791Q134.06,791 112.03,768.97Q90,746.94 90,716L90,244.5Q90,213.36 112.03,191.18Q134.06,169 165,169L794.5,169Q825.64,169 847.82,191.18Q870,213.36 870,244.5L870,716Q870,746.94 847.82,768.97Q825.64,791 794.5,791L165,791ZM239,716Q283.5,662.5 344.89,632.25Q406.28,602 480.14,602Q554,602 615.5,632.25Q677,662.5 721,716L795,716Q795,716 795,716Q795,716 795,716L795,244Q795,244 795,244Q795,244 795,244L165,244Q165,244 165,244Q165,244 165,244L165,716Q165,716 165,716Q165,716 165,716L239,716ZM350,716L610.5,716Q581.84,696.5 548.74,686.75Q515.64,677 480.07,677Q444.5,677 411.52,686.75Q378.55,696.5 350,716ZM479.5,458Q462,458 449.75,445.75Q437.5,433.5 437.5,416Q437.5,398.5 449.75,386.25Q462,374 479.5,374Q497,374 509.25,386.25Q521.5,398.5 521.5,416Q521.5,433.5 509.25,445.75Q497,458 479.5,458ZM480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"
tools:ignore="VectorPath" />
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M7.7,20.5Q6.775,20.5 6.163,19.887Q5.55,19.275 5.55,18.35V5.9H4.55V4.55H8.95V3.65H15.1V4.55H19.5V5.9H18.5V18.35Q18.5,19.275 17.888,19.887Q17.275,20.5 16.35,20.5ZM17.15,5.9H6.9V18.35Q6.9,18.7 7.125,18.925Q7.35,19.15 7.7,19.15H16.35Q16.65,19.15 16.9,18.9Q17.15,18.65 17.15,18.35ZM9.525,17.125H10.875V7.925H9.525ZM13.175,17.125H14.525V7.925H13.175ZM6.9,5.9V18.35Q6.9,18.7 6.9,18.925Q6.9,19.15 6.9,19.15Q6.9,19.15 6.9,18.925Q6.9,18.7 6.9,18.35Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6 -1.41,-1.41z"/>
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M11.35,16.75H12.7V11H11.35ZM12,9.35Q12.325,9.35 12.538,9.137Q12.75,8.925 12.75,8.6Q12.75,8.275 12.538,8.062Q12.325,7.85 12,7.85Q11.7,7.85 11.475,8.062Q11.25,8.275 11.25,8.6Q11.25,8.9 11.463,9.125Q11.675,9.35 12,9.35ZM12,21.5Q10.025,21.5 8.3,20.75Q6.575,20 5.287,18.725Q4,17.45 3.25,15.712Q2.5,13.975 2.5,12Q2.5,10.025 3.25,8.287Q4,6.55 5.287,5.262Q6.575,3.975 8.3,3.237Q10.025,2.5 12,2.5Q13.975,2.5 15.713,3.237Q17.45,3.975 18.738,5.262Q20.025,6.55 20.763,8.287Q21.5,10.025 21.5,12Q21.5,13.975 20.763,15.7Q20.025,17.425 18.738,18.712Q17.45,20 15.713,20.75Q13.975,21.5 12,21.5ZM12,20.15Q15.425,20.15 17.788,17.787Q20.15,15.425 20.15,12Q20.15,8.575 17.788,6.212Q15.425,3.85 12,3.85Q8.575,3.85 6.213,6.212Q3.85,8.575 3.85,12Q3.85,15.425 6.213,17.787Q8.575,20.15 12,20.15ZM12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Z"
tools:ignore="VectorPath" />
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M678,782Q627.18,782 592.09,746.91Q557,711.82 557,661Q557,610.18 592.09,575.09Q627.18,540 678,540Q728.82,540 763.91,575.09Q799,610.18 799,661Q799,711.82 763.91,746.91Q728.82,782 678,782ZM677.9,728Q705,728 725,708.1Q745,688.2 745,661.1Q745,634 725.1,614Q705.2,594 678.1,594Q651,594 631,613.9Q611,633.8 611,660.9Q611,688 630.9,708Q650.8,728 677.9,728ZM182,688L182,634L458,634L458,688L182,688ZM283,420Q232.18,420 197.09,384.91Q162,349.82 162,299Q162,248.18 197.09,213.09Q232.18,178 283,178Q333.82,178 368.91,213.09Q404,248.18 404,299Q404,349.82 368.91,384.91Q333.82,420 283,420ZM282.9,366Q310,366 330,346.1Q350,326.2 350,299.1Q350,272 330.1,252Q310.2,232 283.1,232Q256,232 236,251.9Q216,271.8 216,298.9Q216,326 235.9,346Q255.8,366 282.9,366ZM504,326L504,272L779,272L779,326L504,326ZM678,661Q678,661 678,661Q678,661 678,661Q678,661 678,661Q678,661 678,661Q678,661 678,661Q678,661 678,661Q678,661 678,661Q678,661 678,661ZM283,299Q283,299 283,299Q283,299 283,299Q283,299 283,299Q283,299 283,299Q283,299 283,299Q283,299 283,299Q283,299 283,299Q283,299 283,299Z"
tools:ignore="VectorPath" />
</vector>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="@color/ic_launcher_secondary"
android:pathData="M0,108 h54 v-108 h-108" />
<path
android:fillColor="@color/ic_launcher_primary"
android:pathData="M54,0 h108 v108 h-108" />
</vector>
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.07733333"
android:scaleY="0.07733333"
android:translateX="34.86"
android:translateY="34.86">
<path
android:fillColor="@color/ic_launcher_primary"
android:pathData="M0,247.5C0,383.97 111.03,495 247.5,495V0C111.03,0 0,111.03 0,247.5z"/>
<path
android:fillColor="@color/ic_launcher_secondary"
android:pathData="M247.5,0v495C383.97,495 495,383.97 495,247.5S383.97,0 247.5,0z"/>
</group>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M133,904.5L133,279.5Q133,248.56 155.03,226.53Q177.06,204.5 208,204.5L602,204.5Q632.94,204.5 654.97,226.53Q677,248.56 677,279.5L677,904.5L405,788L133,904.5ZM208,790L405,705L602,790L602,279.5Q602,279.5 602,279.5Q602,279.5 602,279.5L208,279.5Q208,279.5 208,279.5Q208,279.5 208,279.5L208,790ZM752,791.5L752,129.5Q752,129.5 752,129.5Q752,129.5 752,129.5L248,129.5L248,54.5L752,54.5Q782.94,54.5 804.97,76.53Q827,98.56 827,129.5L827,791.5L752,791.5ZM208,279.5L208,279.5Q208,279.5 208,279.5Q208,279.5 208,279.5L602,279.5Q602,279.5 602,279.5Q602,279.5 602,279.5L602,279.5L405,279.5L208,279.5Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M10,20.35Q8.6,20.35 7.6,19.35Q6.6,18.35 6.6,16.95Q6.6,15.55 7.6,14.55Q8.6,13.55 10,13.55Q10.575,13.55 11.1,13.712Q11.625,13.875 12.05,14.25V5.8Q12.05,4.875 12.663,4.262Q13.275,3.65 14.2,3.65H15.875Q16.525,3.65 16.963,4.087Q17.4,4.525 17.4,5.175Q17.4,5.825 16.963,6.262Q16.525,6.7 15.875,6.7H13.4V16.95Q13.4,18.35 12.4,19.35Q11.4,20.35 10,20.35Z"/>
</vector>
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M4.875,18.7Q4.6,18.7 4.4,18.5Q4.2,18.3 4.2,18.025Q4.2,17.75 4.4,17.55Q4.6,17.35 4.875,17.35H6.225V10.325Q6.225,8.375 7.488,6.737Q8.75,5.1 10.8,4.675V3.975Q10.8,3.45 11.138,3.112Q11.475,2.775 12,2.775Q12.525,2.775 12.863,3.112Q13.2,3.45 13.2,3.975V4.675Q15.25,5.1 16.513,6.75Q17.775,8.4 17.775,10.325V17.35H19.125Q19.4,17.35 19.6,17.55Q19.8,17.75 19.8,18.025Q19.8,18.3 19.6,18.5Q19.4,18.7 19.125,18.7ZM12,11.625Q12,11.625 12,11.625Q12,11.625 12,11.625Q12,11.625 12,11.625Q12,11.625 12,11.625ZM12,22.15Q11.275,22.15 10.738,21.637Q10.2,21.125 10.2,20.35H13.8Q13.8,21.125 13.288,21.637Q12.775,22.15 12,22.15ZM7.575,17.35H16.425V10.325Q16.425,8.475 15.138,7.187Q13.85,5.9 12,5.9Q10.15,5.9 8.863,7.187Q7.575,8.475 7.575,10.325Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M100,396L100,342L236,342L10,118L49,79L273,303L273,181L327,181L327,396L100,396ZM186,778Q149.27,778 124.64,753.36Q100,728.72 100,692L100,496L154,496L154,692Q154,706 163,715Q172,724 186,724L471,724L471,778L186,778ZM807,532L807,267Q807,253 798,244Q789,235 775,235L427,235L427,181L775,181Q811.72,181 836.36,205.64Q861,230.28 861,267L861,532L807,532ZM571,778L571,632L861,632L861,778L571,778Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M12.075,19.55Q8.975,19.55 6.775,17.35Q4.575,15.15 4.575,12.05Q4.575,8.95 6.775,6.7Q8.975,4.45 12.075,4.45Q13.9,4.45 15.475,5.35Q17.05,6.25 18.075,7.7V4.45H19.425V10.5H13.375V9.15H17.425Q16.6,7.675 15.188,6.812Q13.775,5.95 12.075,5.95Q9.5,5.95 7.713,7.725Q5.925,9.5 5.925,12.05Q5.925,14.625 7.713,16.413Q9.5,18.2 12.075,18.2Q14.025,18.2 15.613,17.087Q17.2,15.975 17.825,14.1H19.225Q18.55,16.525 16.575,18.038Q14.6,19.55 12.075,19.55Z"/>
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M3.5,20.35 L1.15,18.05Q0.9,17.8 0.95,17.575Q1,17.35 1.15,17.1Q3.375,14.75 6.263,13.55Q9.15,12.35 12.025,12.35Q14.95,12.35 17.812,13.55Q20.675,14.75 22.9,17.1Q23.05,17.35 23.075,17.6Q23.1,17.85 22.9,18.05L20.55,20.35Q20.4,20.5 20.175,20.525Q19.95,20.55 19.7,20.4L16.875,18.275Q16.675,18.1 16.562,17.875Q16.45,17.65 16.45,17.425V14.45Q15.375,14.05 14.262,13.875Q13.15,13.7 12.025,13.7Q10.925,13.7 9.8,13.875Q8.675,14.05 7.6,14.45V17.425Q7.6,17.65 7.488,17.875Q7.375,18.1 7.175,18.275L4.35,20.4Q4.15,20.55 3.9,20.525Q3.65,20.5 3.5,20.35ZM4.05,19 L6.25,17.3V15Q5.225,15.5 4.263,16.125Q3.3,16.75 2.55,17.5ZM20,19 L21.5,17.55Q20.65,16.775 19.725,16.125Q18.8,15.475 17.8,15V17.25ZM12.025,7.1Q11.75,7.1 11.55,6.9Q11.35,6.7 11.35,6.425V3.375Q11.35,3.1 11.55,2.9Q11.75,2.7 12.025,2.7Q12.3,2.7 12.5,2.9Q12.7,3.1 12.7,3.375V6.425Q12.7,6.7 12.5,6.9Q12.3,7.1 12.025,7.1ZM17.275,9.375Q17.05,9.15 17.05,8.9Q17.05,8.65 17.275,8.425L19.475,6.275Q19.675,6.075 19.938,6.062Q20.2,6.05 20.425,6.275Q20.65,6.5 20.65,6.75Q20.65,7 20.425,7.225L18.225,9.375Q18.025,9.575 17.763,9.587Q17.5,9.6 17.275,9.375ZM5.85,9.4 L3.65,7.25Q3.45,7.025 3.425,6.75Q3.4,6.475 3.625,6.25Q3.85,6.025 4.138,6.037Q4.425,6.05 4.65,6.275L6.825,8.45Q7.025,8.65 7.038,8.938Q7.05,9.225 6.8,9.425Q6.6,9.6 6.325,9.6Q6.05,9.6 5.85,9.4ZM17.8,15Q17.8,15 17.8,15Q17.8,15 17.8,15ZM6.25,15Q6.25,15 6.25,15Q6.25,15 6.25,15Z"
tools:ignore="VectorPath" />
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M781.69,823.08L530.46,571.84Q500.46,596.61 461.46,610.61Q422.46,624.61 380.77,624.61Q278.22,624.61 207.19,553.6Q136.15,482.59 136.15,380.06Q136.15,277.54 207.17,206.46Q278.18,135.39 380.71,135.39Q483.23,135.39 554.31,206.42Q625.38,277.45 625.38,380Q625.38,422.85 611,461.85Q596.61,500.85 572.61,529.69L823.84,780.92L781.69,823.08ZM380.77,564.62Q458.08,564.62 511.73,510.96Q565.39,457.31 565.39,380Q565.39,302.69 511.73,249.04Q458.08,195.38 380.77,195.38Q303.46,195.38 249.81,249.04Q196.15,302.69 196.15,380Q196.15,457.31 249.81,510.96Q303.46,564.62 380.77,564.62Z"/>
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M725.29,872Q680,872 648,840.5Q616,809 616,764Q616,756.23 617.5,747.9Q619,739.57 622,732L314,552Q299,569 278.5,577.5Q258,586 236,586Q190.17,586 158.08,554.5Q126,523 126,478Q126,433 158.08,401.5Q190.17,370 236,370Q258,370 278.5,378.5Q299,387 314,404L622,223.98Q619,216.27 617.5,207.77Q616,199.27 616,192Q616,147 647.71,115.5Q679.41,84 724.71,84Q770,84 802,115.5Q834,147 834,192Q834,237 801.92,268.5Q769.83,300 724,300Q702,300 681.5,291.5Q661,283 646,266L338,446Q341,453.57 342.5,461.83Q344,470.09 344,477.79Q344,485.5 342.5,493.96Q341,502.43 338,510L646,690Q661,673 681.5,664.5Q702,656 724,656Q769.83,656 801.92,687.5Q834,719 834,764Q834,809 802.29,840.5Q770.59,872 725.29,872ZM724.77,246Q747,246 763.5,229.73Q780,213.46 780,191.23Q780,169 763.73,152.5Q747.46,136 725.23,136Q703,136 686.5,152.27Q670,168.54 670,190.77Q670,213 686.27,229.5Q702.54,246 724.77,246ZM234.77,532Q257,532 273.5,515.73Q290,499.46 290,477.23Q290,455 273.73,438.5Q257.46,422 235.23,422Q213,422 196.5,438.27Q180,454.54 180,476.77Q180,499 196.27,515.5Q212.54,532 234.77,532ZM724.77,818Q747,818 763.5,801.73Q780,785.46 780,763.23Q780,741 763.73,724.5Q747.46,708 725.23,708Q703,708 686.5,724.27Q670,740.54 670,762.77Q670,785 686.27,801.5Q702.54,818 724.77,818ZM725,191Q725,191 725,191Q725,191 725,191Q725,191 725,191Q725,191 725,191Q725,191 725,191Q725,191 725,191Q725,191 725,191Q725,191 725,191ZM235,477Q235,477 235,477Q235,477 235,477Q235,477 235,477Q235,477 235,477Q235,477 235,477Q235,477 235,477Q235,477 235,477Q235,477 235,477ZM725,763Q725,763 725,763Q725,763 725,763Q725,763 725,763Q725,763 725,763Q725,763 725,763Q725,763 725,763Q725,763 725,763Q725,763 725,763Z"
tools:ignore="VectorPath" />
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="960" android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M406,679L612,547L406,415L406,679ZM186,820Q149.27,820 124.64,795.36Q100,770.72 100,734L100,274L344,274L344,226Q344,189.28 368.64,164.64Q393.27,140 430,140L530,140Q566.72,140 591.36,164.64Q616,189.28 616,226L616,274L860,274L860,734Q860,770.72 835.36,795.36Q810.72,820 774,820L186,820ZM186,766L774,766Q786,766 796,756Q806,746 806,734L806,328L154,328L154,734Q154,746 164,756Q174,766 186,766ZM398,274L562,274L562,226Q562,214 552,204Q542,194 530,194L430,194Q418,194 408,204Q398,214 398,226L398,274ZM154,766Q154,766 154,756Q154,746 154,734L154,328L154,328L154,734Q154,746 154,756Q154,766 154,766L154,766Z"/>
</vector>
+8
View File
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14l-6,-6z"/>
</vector>
+10
View File
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:height="24dp" android:width="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="?android:attr/textColorPrimary"
android:pathData="M19.7,11.4Q19.45,11.4 19.275,11.225Q19.1,11.05 19.025,10.75Q18.675,8.275 16.875,6.475Q15.075,4.675 12.6,4.325Q12.3,4.25 12.125,4.05Q11.95,3.85 11.95,3.6Q11.95,3.3 12.138,3.137Q12.325,2.975 12.6,3Q15.675,3.35 17.837,5.512Q20,7.675 20.35,10.75Q20.375,11.025 20.188,11.212Q20,11.4 19.7,11.4ZM15.525,11.4Q15.3,11.4 15.138,11.25Q14.975,11.1 14.875,10.825Q14.6,9.975 14,9.35Q13.4,8.725 12.525,8.475Q12.275,8.375 12.113,8.188Q11.95,8 11.95,7.8Q11.95,7.475 12.163,7.275Q12.375,7.075 12.7,7.15Q14,7.45 14.95,8.4Q15.9,9.35 16.225,10.65Q16.3,10.975 16.087,11.188Q15.875,11.4 15.525,11.4ZM19.25,20.35Q16.425,20.35 13.6,18.95Q10.775,17.55 8.5,15.275Q6.225,13 4.812,10.175Q3.4,7.35 3.4,4.5Q3.4,4 3.675,3.725Q3.95,3.45 4.45,3.45H7.4Q7.85,3.45 8.188,3.725Q8.525,4 8.625,4.4L9.175,7.2Q9.25,7.575 9.163,7.887Q9.075,8.2 8.85,8.375L6.5,10.55Q7.8,12.7 9.5,14.412Q11.2,16.125 13.3,17.3L15.75,14.85Q16,14.6 16.175,14.55Q16.35,14.5 16.6,14.575L19.3,15.175Q19.725,15.275 20.013,15.6Q20.3,15.925 20.3,16.35V19.3Q20.3,19.8 20.025,20.075Q19.75,20.35 19.25,20.35ZM5.85,9.3 L7.65,7.7Q7.775,7.6 7.812,7.425Q7.85,7.25 7.8,7.1L7.4,5.2Q7.35,5 7.225,4.9Q7.1,4.8 6.9,4.8H5.15Q5,4.8 4.9,4.9Q4.8,5 4.8,5.15Q4.8,6.175 5.088,7.188Q5.375,8.2 5.85,9.3ZM18.6,18.95Q18.75,19 18.85,18.875Q18.95,18.75 18.95,18.6V16.85Q18.95,16.65 18.85,16.525Q18.75,16.4 18.55,16.35L16.85,16Q16.7,15.95 16.587,15.987Q16.475,16.025 16.35,16.15L14.55,18Q15.575,18.525 16.713,18.712Q17.85,18.9 18.6,18.95ZM14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18Q14.55,18 14.55,18ZM5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Q5.85,9.3 5.85,9.3Z"
tools:ignore="VectorPath" />
</vector>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<corners
android:radius="12dp" />
<solid
android:color="@android:color/transparent" />
<stroke
android:width="0.5dp"
android:color="?attr/scrimBackground" />
</shape>
</item>
<item android:state_pressed="false">
<shape>
<corners
android:radius="12dp" />
<solid
android:color="?attr/scrimBackground" />
</shape>
</item>
</selector>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="24dp"
android:topRightRadius="24dp" />
</shape>
+51
View File
@@ -0,0 +1,51 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group
android:name="group"
android:translateX="34.86"
android:translateY="34.86"
android:scaleX="0.07733333"
android:scaleY="0.07733333">
<path
android:name="left"
android:pathData="M 0 247.5 C 0 383.97 111.03 495 247.5 495 L 247.5 0 C 111.03 0 0 111.03 0 247.5 Z"
android:fillColor="@color/ic_launcher_primary"/>
<path
android:name="right"
android:pathData="M 247.5 0 L 247.5 495 C 383.97 495 495 383.97 495 247.5 C 495 111.03 383.97 0 247.5 0 Z"
android:fillColor="@color/ic_launcher_secondary"/>
</group>
</vector>
</aapt:attr>
<target android:name="left">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:startOffset="400"
android:duration="600"
android:valueFrom="M 0 247.5 C 0 111.03 111.03 0 247.5 0 C 247.5 165 247.5 330 247.5 495 C 111.03 495 0 383.97 0 247.5 L 0 247.5"
android:valueTo="M 247.5 0 C 247.5 0 247.5 0 247.5 0 C 383.97 0 495 111.03 495 247.5 C 495 383.97 383.97 495 247.5 495 L 247.5 0"
android:valueType="pathType"
android:interpolator="@android:anim/decelerate_interpolator"/>
</aapt:attr>
</target>
<target android:name="right">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="600"
android:valueFrom="M 247.5 0 L 247.5 0 C 383.97 0 495 111.03 495 247.5 C 495 383.97 383.97 495 247.5 495 C 247.5 330 247.5 165 247.5 0"
android:valueTo="M 0 247.5 L 0 247.5 C 0 111.03 111.03 0 247.5 0 C 247.5 165 247.5 330 247.5 495 C 111.03 495 0 383.97 0 247.5"
android:valueType="pathType"
android:interpolator="@android:anim/overshoot_interpolator"/>
</aapt:attr>
</target>
</animated-vector>
+83
View File
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/launcherIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_launcher" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appName"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/app_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/launcherIcon" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/developerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/developer_name"
app:fontFamily="sans-serif-smallcaps"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appName" />
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/aboutButtonGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/twentyTwo"
app:layout_constraintBottom_toTopOf="@id/acknowledgements"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/developerName">
<com.google.android.material.button.MaterialButton
android:id="@+id/sourceCode"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/source_code" />
<com.google.android.material.button.MaterialButton
android:id="@+id/wiki"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wiki" />
<com.google.android.material.button.MaterialButton
android:id="@+id/telegramGroup"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/telegram_group" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/acknowledgements"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:gravity="center"
android:lineSpacingExtra="@dimen/lineSpace"
android:text="@string/acknowledgements"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/aboutButtonGroup" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginVertical="@dimen/twelve"
style="@style/TextAppearance.Material3.TitleMedium" />
<ListView
android:id="@+id/activityList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:fadingEdgeLength="@dimen/eight"
android:requiresFadingEdge="vertical"
android:scrollbars="none" />
</androidx.appcompat.widget.LinearLayoutCompat>
+96
View File
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appsCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/colorControlHighlight"
android:textSize="@dimen/appsCountText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/appsList"
app:layout_constraintStart_toStartOf="@id/appsList"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/appsList"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fadingEdgeLength="@dimen/sixteen"
android:overScrollMode="never"
android:requiresFadingEdge="vertical"
android:scrollbars="none"
app:layout_constraintBottom_toTopOf="@+id/searchInput"
app:layout_constraintEnd_toStartOf="@+id/search"
app:layout_constraintStart_toStartOf="parent" />
<rasel.lunar.launcher.apps.AlphabetScrollbar
android:id="@+id/alphabets"
android:layout_width="@dimen/zero"
android:visibility="gone"
android:layout_height="@dimen/zero"
android:layout_marginBottom="@dimen/four"
app:layout_constraintBottom_toTopOf="@+id/reset"
app:layout_constraintStart_toStartOf="@id/reset"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_bg"
android:padding="@dimen/eight"
android:layout_marginBottom="@dimen/four"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/moveUp"
app:srcCompat="@drawable/ic_refresh" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/moveUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_bg"
android:padding="@dimen/eight"
android:layout_marginBottom="@dimen/four"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/moveDown"
app:srcCompat="@drawable/ic_up" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/moveDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_bg"
android:padding="@dimen/eight"
android:layout_marginBottom="@dimen/four"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/search"
app:srcCompat="@drawable/ic_down" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_bg"
android:padding="@dimen/eight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/ic_search" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchInput"
android:layout_width="@dimen/oneThirtySix"
android:layout_height="wrap_content"
android:gravity="center"
android:imeOptions="actionSearch"
android:singleLine="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/appsList"
app:layout_constraintStart_toStartOf="@+id/appsList" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginVertical="@dimen/twelve"
style="@style/TextAppearance.Material3.TitleMedium" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/mixed"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twentyTwo"
android:fadingEdgeLength="@dimen/eight"
android:requiresFadingEdge="vertical"
android:scrollbars="none">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/permissions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true" />
</ScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
+152
View File
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:padding="@dimen/twelve"
android:clickable="true"
android:focusableInTouchMode="true">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/appNameInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:hintEnabled="false"
app:boxStrokeWidth="@dimen/zero"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/zero"
android:gravity="center"
android:padding="@dimen/eight"
android:inputType="textNoSuggestions"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/appPackage"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appNameInputLayout" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/activityBrowser"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_activity"
android:tooltipText="@string/activity_browser"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/detailedInfo"
app:layout_constraintTop_toBottomOf="@+id/appPackage" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/detailedInfo"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:layout_marginEnd="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_info"
android:tooltipText="@string/detailed_info"
app:layout_constraintEnd_toStartOf="@id/activityBrowser"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appPackage" />
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/favGroup"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/detailedInfo"
app:singleSelection="true" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/appInfo"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:layout_marginEnd="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_info2"
android:tooltipText="@string/app_info"
app:layout_constraintEnd_toStartOf="@id/appFreeform"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/favGroup" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/appFreeform"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:layout_marginEnd="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_pip"
android:tooltipText="@string/freeform"
app:layout_constraintEnd_toStartOf="@id/appStore"
app:layout_constraintStart_toEndOf="@id/appInfo"
app:layout_constraintTop_toBottomOf="@+id/favGroup" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/appStore"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:layout_marginEnd="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_store"
android:tooltipText="@string/app_store"
app:layout_constraintEnd_toStartOf="@id/appShare"
app:layout_constraintStart_toEndOf="@id/appFreeform"
app:layout_constraintTop_toBottomOf="@+id/favGroup" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/appShare"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:layout_marginEnd="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_share"
android:tooltipText="@string/share"
app:layout_constraintEnd_toStartOf="@id/appUninstall"
app:layout_constraintStart_toEndOf="@id/appStore"
app:layout_constraintTop_toBottomOf="@+id/favGroup" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/appUninstall"
style="@style/Widget.Material3.ExtendedFloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:contentDescription="@null"
android:src="@drawable/ic_delete"
android:tooltipText="@string/uninstall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/appShare"
app:layout_constraintTop_toBottomOf="@+id/favGroup"
app:tint="@android:color/holo_red_light" />
</androidx.constraintlayout.widget.ConstraintLayout>
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/apps_bg"
android:orientation="vertical">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/appIcon"
android:layout_width="@dimen/forty"
android:layout_height="@dimen/forty"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/four" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/appIconTwo"
android:layout_width="@dimen/forty"
android:layout_height="@dimen/forty" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/childTextview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/childSysInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:background="@drawable/rounded_bg"
android:orientation="vertical"
android:padding="@dimen/twelve">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:trackColor="?attr/scrimBackground"
app:trackThickness="@dimen/twelve" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/four"
android:gravity="center_horizontal" />
</androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout>
+75
View File
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/colorInputLayout"
android:layout_width="@dimen/oneNinetySix"
android:layout_height="wrap_content"
android:hint="@string/argb"
app:boxBackgroundColor="?attr/colorSurface"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/colorInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:imeOptions="actionDone"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.slider.Slider
android:id="@+id/colorA"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="0"
android:valueTo="255"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/colorInputLayout"
app:thumbColor="@android:color/white"
app:trackColorActive="@android:color/white" />
<com.google.android.material.slider.Slider
android:id="@+id/colorR"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="0"
android:valueTo="255"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/colorA"
app:thumbColor="@color/red"
app:trackColorActive="@color/red" />
<com.google.android.material.slider.Slider
android:id="@+id/colorG"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="0"
android:valueTo="255"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/colorR"
app:thumbColor="@color/green"
app:trackColorActive="@color/green" />
<com.google.android.material.slider.Slider
android:id="@+id/colorB"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="0"
android:valueTo="255"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/colorG"
app:thumbColor="@color/blue"
app:trackColorActive="@color/blue" />
</androidx.constraintlayout.widget.ConstraintLayout>
+60
View File
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/expandableButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:singleSelection="true"
android:layout_margin="@dimen/eight">
<com.google.android.material.button.MaterialButton
android:id="@+id/expandRss"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/rss_feed"
style="@style/Widget.Material3.Button.OutlinedButton"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/expandSystemInfo"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/system_stats"
style="@style/Widget.Material3.Button.OutlinedButton"/>
</com.google.android.material.button.MaterialButtonToggleGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/eight"
android:layout_marginBottom="@dimen/eight">
<include
android:id="@+id/feedsRss"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/feeds_rss"/>
<include
android:id="@+id/feedsSysInfos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/feeds_sys_infos"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/widgetContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</ScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
+53
View File
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<net.cachapa.expandablelayout.ExpandableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/expandableRss"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:el_duration="1000"
app:el_expanded="false"
app:el_parallax="0.5">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rss"
android:layout_width="@dimen/zero"
android:layout_height="@dimen/zero"
android:background="@drawable/rounded_bg"
android:scrollbars="none"
android:visibility="gone"
app:layoutManager="LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:trackThickness="@dimen/two" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/refresh"
style="@style/Widget.Material3.FloatingActionButton.Surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_refresh" />
</androidx.constraintlayout.widget.ConstraintLayout>
</net.cachapa.expandablelayout.ExpandableLayout>
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<net.cachapa.expandablelayout.ExpandableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/expandableSystemInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:el_duration="1000"
app:el_expanded="false"
app:el_parallax="0.5">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ramParent"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include
layout="@layout/child_sys_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/cpuParent"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ramParent">
<include
layout="@layout/child_sys_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/intParent"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cpuParent">
<include
layout="@layout/child_sys_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/extParent"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/intParent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:background="@drawable/rounded_bg"
android:padding="@dimen/twelve"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/extParent">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/miscTitles"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:lineSpacingExtra="@dimen/eight"
android:text="@string/misc_info_titles"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/misc"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/misc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:lineSpacingExtra="@dimen/eight"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/miscTitles"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</net.cachapa.expandablelayout.ExpandableLayout>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mainFragmentsContainer"
android:fitsSystemWindows="true">
<androidx.viewpager2.widget.ViewPager2
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewPager"
android:orientation="horizontal" />
</FrameLayout>
+88
View File
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/batteryProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:indeterminate="false"
android:max="100"
app:trackCornerRadius="@dimen/four"
app:showAnimationBehavior="inward"
app:indicatorColor="?android:attr/textColorPrimary"
app:indicatorSize="@dimen/twoSeventySix"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextClock
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:textIsSelectable="false"
android:textSize="@dimen/clockText"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/batteryProgress"
app:layout_constraintEnd_toEndOf="@+id/batteryProgress"
app:layout_constraintStart_toStartOf="@+id/batteryProgress"
app:layout_constraintTop_toTopOf="@+id/batteryProgress"
app:layout_constraintVertical_bias="0.450" />
<TextClock
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:textIsSelectable="false"
app:layout_constraintBottom_toBottomOf="@+id/batteryProgress"
app:layout_constraintEnd_toEndOf="@+id/batteryProgress"
app:layout_constraintStart_toStartOf="@+id/batteryProgress"
app:layout_constraintTop_toBottomOf="@+id/time"
app:layout_constraintVertical_bias="0.075" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:textIsSelectable="false"
app:layout_constraintBottom_toBottomOf="@+id/batteryProgress"
app:layout_constraintEnd_toEndOf="@+id/batteryProgress"
app:layout_constraintStart_toStartOf="@+id/batteryProgress"
app:layout_constraintTop_toBottomOf="@+id/date"
app:layout_constraintVertical_bias="0.100" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notes"
android:layout_width="@dimen/zero"
android:layout_height="@dimen/zero"
android:overScrollMode="never"
android:padding="@dimen/fortyEight"
android:scrollbars="none"
app:layoutManager="LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@id/favAppsGroup"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/batteryProgress" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/favAppsGroup"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twentyTwo"
android:layout_marginBottom="@dimen/twelve"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/notes" />
</androidx.constraintlayout.widget.ConstraintLayout>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/itemText"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:padding="@dimen/twelve"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
+186
View File
@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/notificationLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iconNotification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_notification" />
<com.google.android.material.slider.Slider
android:id="@+id/notification"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconNotification"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/alarmLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/notificationLayout">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iconAlarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_alarm" />
<com.google.android.material.slider.Slider
android:id="@+id/alarm"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconAlarm"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/mediaLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/alarmLayout">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iconMedia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_media" />
<com.google.android.material.slider.Slider
android:id="@+id/media"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconMedia"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/voiceLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mediaLayout">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iconVoice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_voice" />
<com.google.android.material.slider.Slider
android:id="@+id/voice"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconVoice"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ringLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/voiceLayout">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iconRing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_ring" />
<com.google.android.material.slider.Slider
android:id="@+id/ring"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconRing"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/shortcutsGroup"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/twentyTwo"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/brightnessLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ringLayout" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/brightnessLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/shortcutsGroup">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iconBrightness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_brightness" />
<com.google.android.material.slider.Slider
android:id="@+id/brightness"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iconBrightness"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="@dimen/zero"
android:layout_height="@dimen/oneNinetySix"
android:background="@android:color/transparent"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.google.android.material.textview.MaterialTextView
style="@style/TextAppearance.Material3.HeadlineLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lunar_settings"
android:textColor="?attr/colorControlNormal" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="@dimen/zero"
android:layout_height="@dimen/zero"
android:background="@drawable/rounded_bg_top"
android:backgroundTint="?attr/colorSurface"
android:paddingHorizontal="@dimen/thirtySix"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appBar">
<com.google.android.material.button.MaterialButtonToggleGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:singleSelection="true"
android:layout_gravity="center">
<com.google.android.material.button.MaterialButton
android:id="@+id/timeDate"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/time_date"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/weather"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/weather"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/todo"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/todo"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/apps"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_drawer"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/appearances"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/appearances"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/misc"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/misc"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/advance"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/advance"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/about"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/about"
android:textAllCaps="true"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/support"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support"
android:textAllCaps="true"
android:textStyle="bold" />
</com.google.android.material.button.MaterialButtonToggleGroup>
</ScrollView>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/twelve"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.button.MaterialButtonToggleGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.button.MaterialButton
android:id="@+id/chooseLauncher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choose_launcher"
style="@style/Widget.Material3.Button.ElevatedButton"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset"
style="@style/Widget.Material3.Button.ElevatedButton"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/restart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/restart"
style="@style/Widget.Material3.Button.ElevatedButton"/>
</com.google.android.material.button.MaterialButtonToggleGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/applicationTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/application_theme"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/themeGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/applicationTheme"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/selectDarkTheme"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dark_theme" />
<com.google.android.material.chip.Chip
android:id="@+id/followSystemTheme"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/follow_system" />
<com.google.android.material.chip.Chip
android:id="@+id/selectLightTheme"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/light_theme" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/appearancesButtonGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/themeGroup">
<com.google.android.material.button.MaterialButton
android:id="@+id/background"
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/background"
app:icon="@drawable/rounded_bg"
app:iconTintMode="add" />
<com.google.android.material.button.MaterialButton
android:id="@+id/changeWallpaper"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/change_wallpaper" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/hideStatusBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/hide_status_bar"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appearancesButtonGroup" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/hideStatusGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hideStatusBar"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/hideStatusPositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/hideStatusNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
+261
View File
@@ -0,0 +1,261 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/searchWithKeyboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_with_keyboard"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/keyboardAutoGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchWithKeyboard"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/keyboardAutoPositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/keyboardAutoNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/quickLaunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/quick_launch"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/keyboardAutoGroup" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/quickLaunchGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/quickLaunch"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/quickLaunchPositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/quickLaunchNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appsCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/apps_count"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/quickLaunchGroup" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/appsCountGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appsCount"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/appsCountPositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/appsCountNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appDrawerLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/app_drawer_layout"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appsCountGroup" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/drawerLayoutGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appDrawerLayout"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/drawerLayoutList"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/list" />
<com.google.android.material.chip.Chip
android:id="@+id/drawerLayoutListIcon"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/list_with_icon" />
<com.google.android.material.chip.Chip
android:id="@+id/drawerLayoutGrid"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/grid" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appsAlignment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/app_alignment"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/drawerLayoutGroup" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/appAlignmentGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appsAlignment"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/appAlignmentLeft"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/left" />
<com.google.android.material.chip.Chip
android:id="@+id/appAlignmentCenter"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/center" />
<com.google.android.material.chip.Chip
android:id="@+id/appAlignmentRight"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/right" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/iconPackGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appAlignmentGroup">
<com.google.android.material.button.MaterialButton
android:id="@+id/iconPackChooser"
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choose_icon_pack" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/columnsCountTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/grid_columns_count"
android:textSize="@dimen/normalText"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iconPackGroup" />
<com.google.android.material.slider.Slider
android:id="@+id/columnsCount"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="3"
android:valueTo="7"
android:stepSize="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/columnsCountTitle" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/scrollbarHeightTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/scrollbar_height"
android:textSize="@dimen/normalText"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/columnsCount" />
<com.google.android.material.slider.Slider
android:id="@+id/scrollbarHeight"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="0"
android:valueTo="800"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scrollbarHeightTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
+154
View File
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/backHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back_home"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/backHomeGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/backHome"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/backHomePositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/backHomeNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/shortcutCountTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/shortcut_count"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/backHomeGroup" />
<com.google.android.material.slider.Slider
android:id="@+id/shortcutCount"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
android:valueFrom="0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/shortcutCountTitle" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/iconSizeTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/icon_size"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/shortcutCount" />
<com.google.android.material.slider.Slider
android:id="@+id/iconSize"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:valueFrom="20"
android:valueTo="80"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iconSizeTitle" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/feedInputLayout"
android:layout_width="@dimen/threeTwentyFour"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:hint="@string/feed_url"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iconSize">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputFeedUrl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:imeOptions="actionDone"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/doubleTapLock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/double_tap_action"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/feedInputLayout" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/lockGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/doubleTapLock"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/selectLockNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
<com.google.android.material.chip.Chip
android:id="@+id/selectLockAccessibility"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/accessibility" />
<com.google.android.material.chip.Chip
android:id="@+id/selectLockAdmin"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/device_admin" />
<com.google.android.material.chip.Chip
android:id="@+id/selectLockRoot"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/root" />
</com.google.android.material.chip.ChipGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/timeFormat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/time_format"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/timeGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/timeFormat"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/selectTwelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/twelve"
style="@style/Widget.Material3.Chip.Filter.Elevated" />
<com.google.android.material.chip.Chip
android:id="@+id/followSystemTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/follow_system"
style="@style/Widget.Material3.Chip.Filter.Elevated" />
<com.google.android.material.chip.Chip
android:id="@+id/selectTwentyFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/twenty_four"
style="@style/Widget.Material3.Chip.Filter.Elevated" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/dateFormatParent"
android:layout_width="@dimen/twoSeventySix"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:hint="@string/date_format"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/timeGroup">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/dateFormat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:imeOptions="actionDone"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
+64
View File
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/todoCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/todo_count"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.slider.Slider
android:id="@+id/showTodos"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:stepSize="1"
android:valueFrom="0"
android:valueTo="7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/todoCount" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/todoManagerLock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/todo_manager_lock"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/showTodos" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/todoLockGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/todoManagerLock"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/todoLockPositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/todoLockNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cityInputLayout"
android:layout_width="@dimen/oneNinetySix"
android:layout_height="wrap_content"
android:hint="@string/city_name"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputCity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:imeOptions="actionDone"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/owmInputLayout"
android:layout_width="@dimen/threeTwentyFour"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:hint="@string/owm_key"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cityInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputOwm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:imeOptions="actionDone"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/tempUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/twelve"
android:text="@string/temp_unit"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/owmInputLayout" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/tempGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tempUnit"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/selectCelsius"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/celsius" />
<com.google.android.material.chip.Chip
android:id="@+id/selectFahrenheit"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fahrenheit" />
</com.google.android.material.chip.ChipGroup>
<TextView
android:id="@+id/showCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eight"
android:text="@string/show_city"
android:textSize="@dimen/normalText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tempGroup" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/cityGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/showCity"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/showCityPositive"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/positive" />
<com.google.android.material.chip.Chip
android:id="@+id/showCityNegative"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/negative" />
</com.google.android.material.chip.ChipGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/colorPicker"
layout="@layout/color_picker"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/thumbInputLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/twelve"
app:boxBackgroundColor="?attr/colorSurface"
app:endIconMode="clear_text"
app:hintEnabled="false"
app:layout_constraintEnd_toStartOf="@+id/shortcutType"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/colorPicker">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/thumbField"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:imeOptions="actionDone"
android:maxLength="1"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/shortcutType"
android:layout_width="@dimen/zero"
android:layout_height="@dimen/zero"
android:layout_marginHorizontal="@dimen/twelve"
app:layout_constraintBottom_toBottomOf="@+id/thumbInputLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toEndOf="@+id/thumbInputLayout"
app:layout_constraintTop_toTopOf="@+id/thumbInputLayout"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.button.MaterialButton
android:id="@+id/contact"
style="@style/Widget.Material3.Button.IconButton.Outlined"
android:layout_width="@dimen/zero"
android:layout_height="match_parent"
android:layout_weight="1"
android:tooltipText="@string/contact"
app:icon="@drawable/ic_contact"
app:iconGravity="textStart" />
<com.google.android.material.button.MaterialButton
android:id="@+id/url"
style="@style/Widget.Material3.Button.IconButton.Outlined"
android:layout_width="@dimen/zero"
android:layout_height="match_parent"
android:layout_weight="1"
android:tooltipText="@string/url"
app:icon="@drawable/ic_link"
app:iconGravity="textStart" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/twelve"
android:layout_marginTop="@dimen/twelve"
app:boxBackgroundColor="?attr/colorSurface"
app:endIconMode="clear_text"
app:hintEnabled="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/thumbInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
+59
View File
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/twelve">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/deleteAllConfirmation"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/delete_all_confirmation"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/todoInputLayout"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:hint="@string/todo"
app:endIconMode="clear_text"
app:errorEnabled="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/deleteAllConfirmation">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/todoInput"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButtonToggleGroup
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/todoInputLayout">
<com.google.android.material.button.MaterialButton
android:id="@+id/todoCancel"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/cancel" />
<com.google.android.material.button.MaterialButton
android:id="@+id/todoOk"
style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/ok" />
</com.google.android.material.button.MaterialButtonToggleGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
+53
View File
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="@dimen/twelve"
android:paddingVertical="@dimen/four">
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/todoButtonGroup"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/todos">
<com.google.android.material.button.MaterialButton
android:id="@+id/deleteAll"
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/delete_all"
app:icon="@drawable/ic_delete"
app:iconGravity="textStart"
app:iconSize="@dimen/twenty" />
<com.google.android.material.button.MaterialButton
android:id="@+id/addNew"
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:layout_width="@dimen/zero"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/add_new"
app:icon="@drawable/ic_add"
app:iconGravity="textStart"
app:iconSize="@dimen/twenty" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/todos"
android:layout_width="@dimen/zero"
android:layout_height="@dimen/zero"
android:overScrollMode="never"
android:scrollbars="none"
app:layoutManager="LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@+id/todoButtonGroup"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:stackFromEnd="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/add_widget"
android:title="@string/add_widget"/>
</menu>

Some files were not shown because too many files have changed in this diff Show More