Skip to content

Commit

Permalink
Added a few extra features
Browse files Browse the repository at this point in the history
  • Loading branch information
HeCodes2Much committed May 8, 2024
1 parent b44fdbf commit db922c3
Show file tree
Hide file tree
Showing 24 changed files with 1,082 additions and 121 deletions.
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,11 @@
------------
**Easy Launcher - the minimalist productivity launcher for focus, productivity, keep your focus on what really counts.**
------------
[<img src="https://img.shields.io/github/v/release/DroidWorksStudio/EasyLauncher.svg?logo=github&label=GitHub"
alt="GitHub Releases"
height="22"/>](https://github.com/DroidWorksStudio/EasyLauncher/releases)
[<img src="https://img.shields.io/f-droid/v/com.github.droidworksstuido.easylauncher?logo=f-droid&label=F-Droid"
alt="F-Droid Releases"
height="22"/>](https://f-droid.org/en/packages/com.github.droidworksstuido.easylauncher/)
[<img src="https://img.shields.io/endpoint?color=blue&logo=google-play&logoColor=gery&url=https%3A%2F%2Fplay.cuzi.workers.dev%2Fplay%3Fi%3Dcom.github.droidworksstuido.easylauncher%26l%3DAndroid%26m%3D%24version"
alt="Playstore"
height="22"/>](https://play.google.com/store/apps/details?id=com.github.droidworksstyido.easulauncher)
[<img src="https://img.shields.io/badge/License-GPLv3-blue.svg"
alt="Licenses"
height="22"/>](https://www.gnu.org/licenses/gpl-3.0)
[<img src="https://img.shields.io/github/downloads/DroidWorksStudio/EasyLauncher/total?color=red"
alt="Download from GitHub"
height="22"/>](https://github.com/DroidWorksStudio/EasyLauncher/releases)
[<img src="https://img.shields.io/github/v/release/DroidWorksStudio/EasyLauncher.svg?logo=github&label=GitHub" alt="GitHub Releases" height="22"/>](https://github.com/DroidWorksStudio/EasyLauncher/releases)
[<img src="https://img.shields.io/f-droid/v/com.github.droidworksstuido.easylauncher?logo=f-droid&label=F-Droid" alt="F-Droid Releases" height="22"/>](https://f-droid.org/en/packages/com.github.droidworksstuido.easylauncher/)
[<img src="https://img.shields.io/endpoint?color=blue&logo=google-play&logoColor=gery&url=https%3A%2F%2Fplay.cuzi.workers.dev%2Fplay%3Fi%3Dcom.github.droidworksstuido.easylauncher%26l%3DAndroid%26m%3D%24version" alt="Playstore" height="22"/>](https://play.google.com/store/apps/details?id=com.github.droidworksstyido.easulauncher)
[<img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="Licenses" height="22"/>](https://www.gnu.org/licenses/gpl-3.0)
[<img src="https://img.shields.io/github/downloads/DroidWorksStudio/EasyLauncher/total?color=red" alt="Download from GitHub" height="22"/>](https://github.com/DroidWorksStudio/EasyLauncher/releases)

**Features**
------------
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ android {
isDebuggable = true
applicationIdSuffix = ".debug"
proguardFiles (getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
resValue("string", "app_name", "EasyLauncher Debug")
resValue("string", "app_name", "Easy Launcher (Debug)")
}

getByName("release") {
isMinifyEnabled = false
isShrinkResources = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles (getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
resValue("string", "app_name", "EasyLauncher")
resValue("string", "app_name", "Easy Launcher")
}
}

Expand Down
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission
Expand All @@ -17,7 +16,6 @@
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent>
</queries>
Expand All @@ -30,8 +28,7 @@
android:icon="@drawable/app_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Launcher"
tools:targetApi="31">
android:theme="@style/Theme.Launcher">
<activity
android:name=".ui.activities.SettingsActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.droidworksstudio.launcher
object Constants {
const val PACKAGE_NAME = "com.github.droidworksstudio.launcher"

const val PREFS_FILENAME = "droidworksstudioLauncher.pref"
const val PREFS_FILENAME = "EasyLauncher.pref"
const val FIRST_LAUNCH = "FIRST_LAUNCH"
const val SHOW_DATE = "SHOW_DATE"
const val SHOW_TIME = "SHOW_TIME"
Expand All @@ -18,9 +18,13 @@ object Constants {
const val DAILY_WORD_COLOR = "DAILY_WORD_COLOR"
const val APP_COLOR = "APP_COLOR"

const val BATTERY_TEXT_SIZE = "BATTERY_TEXT_SIZE"
const val DATE_TEXT_SIZE = "DATE_TEXT_SIZE"
const val TIME_TEXT_SIZE = "TIME_TEXT_SIZE"
const val APP_TEXT_SIZE = "APP_TEXT_SIZE"
const val DAILY_WORD_TEXT_SIZE = "DAILY_WORD_TEXT_SIZE"

const val APP_TEXT_PADDING = "APP_TEXT_PADDING"

const val SHOW_APP_ICON = "SHOW_APP_ICON"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package com.github.droidworksstudio.launcher.helper

import android.annotation.SuppressLint
import android.app.SearchManager
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.content.res.Resources
import android.net.Uri
import android.os.Build
import android.provider.AlarmClock
Expand All @@ -27,6 +29,8 @@ import com.github.droidworksstudio.launcher.R
import com.github.droidworksstudio.launcher.accessibility.MyAccessibilityService
import com.github.droidworksstudio.launcher.data.entities.AppInfo
import com.github.droidworksstudio.launcher.ui.activities.FakeHomeActivity
import java.util.Calendar
import java.util.Date
import javax.inject.Inject

class AppHelper @Inject constructor() {
Expand Down Expand Up @@ -92,11 +96,11 @@ class AppHelper @Inject constructor() {
fun dayNightMod(context: Context, view: View) {
when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> {
view.setBackgroundColor(context.resources.getColor(R.color.whiteTrans25))
view.setBackgroundColor(context.resources.getColor(R.color.blackTrans50, context.theme))
}

Configuration.UI_MODE_NIGHT_NO -> {
view.setBackgroundColor(context.resources.getColor(R.color.blackTrans50))
view.setBackgroundColor(context.resources.getColor(R.color.whiteTrans50, context.theme))
}
}
}
Expand Down Expand Up @@ -132,21 +136,53 @@ class AppHelper @Inject constructor() {
}

fun launchCalendar(context: Context) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = CalendarContract.CONTENT_URI
try {
context.startActivity(intent)
val cal: Calendar = Calendar.getInstance()
cal.time = Date()
val time = cal.time.time
val builder: Uri.Builder = CalendarContract.CONTENT_URI.buildUpon()
builder.appendPath("time")
builder.appendPath(time.toString())
context.startActivity(Intent(Intent.ACTION_VIEW, builder.build()))
} catch (e: Exception) {
val pickerIntent = Intent(Intent.ACTION_MAIN)
pickerIntent.addCategory(Intent.CATEGORY_APP_CALENDAR)
try {
context.startActivity(pickerIntent)
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
context.startActivity(intent)
} catch (e: Exception) {
e.printStackTrace()
Log.d("openCalendar", e.toString())
}
}
}

fun openDigitalWellbeing(context: Context) {
try {
val packageName = "com.google.android.apps.wellbeing"
val className = "com.google.android.apps.wellbeing.settings.TopLevelSettingsActivity"

val intent = Intent()
intent.component = ComponentName(packageName, className)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
// Digital Wellbeing app is not installed or cannot be opened
// Handle this case as needed
showToast(context,"Digital Wellbeing is not available on this device.")
}
}

fun openBatteryManager(context: Context) {
try {
val intent = Intent(Intent.ACTION_POWER_USAGE_SUMMARY)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
// Battery manager settings cannot be opened
// Handle this case as needed
showToast(context, "Battery manager settings are not available on this device.")
}
}

fun unInstallApp(context: Context, appInfo: AppInfo) {
val intent = Intent(Intent.ACTION_DELETE)
intent.data = Uri.parse("package:${appInfo.packageName}")
Expand Down Expand Up @@ -215,6 +251,14 @@ class AppHelper @Inject constructor() {
}
}

fun View.showSoftKeyboard() {
if (this.requestFocus()) {
val inputMethodManager: InputMethodManager =
context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
}
}

fun hideKeyboard(context: Context, view: View) {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
Expand All @@ -224,13 +268,21 @@ class AppHelper @Inject constructor() {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(this.windowToken, 0)
}

fun wordOfTheDay(resources: Resources): String {
val dailyWordsArray = resources.getStringArray(R.array.settings_appearance_daily_word_default)
val dayOfYear = Calendar.getInstance().get(Calendar.DAY_OF_YEAR)
val wordIndex = (dayOfYear - 1) % dailyWordsArray.size // Subtracting 1 to align with array indexing
return dailyWordsArray[wordIndex]
}

fun enableAppAsAccessibilityService(context: Context, accessibilityState: Boolean) {

val myAccessibilityService = MyAccessibilityService.instance()

val state: String = if (myAccessibilityService != null) {
context.getString(R.string.accessibility_settings_disable)
}else{
} else {
context.getString(R.string.accessibility_settings_enable)
}

Expand All @@ -242,8 +294,10 @@ class AppHelper @Inject constructor() {
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
context.startActivity(intent)
}
.setNegativeButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() }
.show()
builder.setNegativeButton(android.R.string.cancel) { dialog, _ ->
dialog.dismiss()
}
builder.show()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
set(value) = prefs.edit().putBoolean(Constants.SHOW_BATTERY, value).apply()

var showDailyWord: Boolean
get() = prefs.getBoolean(Constants.SHOW_DAILY_WORD, true)
get() = prefs.getBoolean(Constants.SHOW_DAILY_WORD, false)
set(value) = prefs.edit().putBoolean(Constants.SHOW_DAILY_WORD, value).apply()

var dateColor: Int
Expand All @@ -45,6 +45,7 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
var batteryColor: Int
get() = prefs.getInt(Constants.BATTERY_COLOR, 0xFFFFFFFF.toInt())
set(value) = prefs.edit().putInt(Constants.BATTERY_COLOR, value).apply()

var dailyWordColor: Int
get() = prefs.getInt(Constants.DAILY_WORD_COLOR, 0xFFFFFFFF.toInt())
set(value) = prefs.edit().putInt(Constants.DAILY_WORD_COLOR, value).apply()
Expand All @@ -69,6 +70,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
get() = prefs.getInt(Constants.HOME_APP_ALIGNMENT, Gravity.START)
set(value) = prefs.edit().putInt(Constants.HOME_APP_ALIGNMENT, value).apply()

var homeAppPadding: Float
get() = prefs.getFloat(Constants.APP_TEXT_PADDING, 10f)
set(value) = prefs.edit().putFloat(Constants.APP_TEXT_PADDING, value).apply()

var homeDateAlignment: Int
get() = prefs.getInt(Constants.HOME_DATE_ALIGNMENT, Gravity.START)
set(value) = prefs.edit().putInt(Constants.HOME_DATE_ALIGNMENT, value).apply()
Expand All @@ -81,6 +86,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
get() = prefs.getInt(Constants.HOME_DAILY_WORD_ALIGNMENT, Gravity.START)
set(value) = prefs.edit().putInt(Constants.HOME_DAILY_WORD_ALIGNMENT,value).apply()

var batteryTextSize: Float
get() = prefs.getFloat(Constants.BATTERY_TEXT_SIZE, 12f)
set(value) = prefs.edit().putFloat(Constants.BATTERY_TEXT_SIZE, value).apply()

var dateTextSize: Float
get() = prefs.getFloat(Constants.DATE_TEXT_SIZE, 32f)
set(value) = prefs.edit().putFloat(Constants.DATE_TEXT_SIZE, value).apply()
Expand All @@ -93,6 +102,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
get() = prefs.getFloat(Constants.APP_TEXT_SIZE, 24f)
set(value) = prefs.edit().putFloat(Constants.APP_TEXT_SIZE, value).apply()

var dailyWordTextSize: Float
get() = prefs.getFloat(Constants.DAILY_WORD_TEXT_SIZE, 18f)
set(value) = prefs.edit().putFloat(Constants.DAILY_WORD_TEXT_SIZE, value).apply()

var tapLockScreen: Boolean
get() = prefs.getBoolean(Constants.DOUBLE_TAP_LOCK, false)
set(value) = prefs.edit().putBoolean(Constants.DOUBLE_TAP_LOCK, value).apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import com.github.droidworksstudio.launcher.R
Expand Down Expand Up @@ -145,6 +146,7 @@ class MainActivity : AppCompatActivity() {
}

private fun backToHomeScreen() {
navController = findNavController(R.id.nav_host_fragment_content_main)
if (navController.currentDestination?.id != R.id.HomeFragment)
navController.popBackStack(R.id.HomeFragment, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class AlignmentBottomSheetDialogFragment(context: Context) : BottomSheetDialogFr
binding.selectAppTextSize.apply {
text = appHelper.gravityToString(preferenceHelper.homeAppAlignment)
}

binding.selectWordTextSize.apply {
text = appHelper.gravityToString(preferenceHelper.homeDailyWordAlignment)
}
}

private fun observeClickListener(){
Expand All @@ -87,6 +91,11 @@ class AlignmentBottomSheetDialogFragment(context: Context) : BottomSheetDialogFr
selectedAlignment = REQUEST_KEY_APP_ALIGNMENT
showListDialog(selectedAlignment)
}

binding.bottomAlignmentWordView.setOnClickListener {
selectedAlignment = REQUEST_KEY_WORD_ALIGNMENT
showListDialog(selectedAlignment)
}
}


Expand Down Expand Up @@ -127,6 +136,15 @@ class AlignmentBottomSheetDialogFragment(context: Context) : BottomSheetDialogFr
binding.selectDateTextSize
)
}

REQUEST_KEY_WORD_ALIGNMENT -> {
setAlignment(
selectedAlignment,
selectedItem,
gravity,
binding.selectWordTextSize
)
}
}
}
dialog.show()
Expand Down Expand Up @@ -157,6 +175,11 @@ class AlignmentBottomSheetDialogFragment(context: Context) : BottomSheetDialogFr
alignmentGetter = { preferenceHelper.homeDateAlignment }
}

REQUEST_KEY_WORD_ALIGNMENT -> {
alignmentPreference = { preferenceViewModel.setHomeDailyWordAppAlignment(it) }
alignmentGetter = { preferenceHelper.homeDailyWordAlignment }
}

else -> return
}

Expand All @@ -169,5 +192,6 @@ class AlignmentBottomSheetDialogFragment(context: Context) : BottomSheetDialogFr
private const val REQUEST_KEY_DATE_ALIGNMENT = "REQUEST_KEY_DATE_ALIGNMENT"
private const val REQUEST_KEY_TIME_ALIGNMENT = "REQUEST_KEY_TIME_ALIGNMENT"
private const val REQUEST_KEY_APP_ALIGNMENT = "REQUEST_KEY_APP_ALIGNMENT"
private const val REQUEST_KEY_WORD_ALIGNMENT = "REQUEST_KEY_WORD_ALIGNMENT"
}
}
Loading

0 comments on commit db922c3

Please sign in to comment.