Skip to content

Commit

Permalink
Feat: Added the base for the new settings screen (#130)
Browse files Browse the repository at this point in the history
* Feat: Added the base for the new settings screen

* Fix: Removed junk from Home

* Fix: Cleanup Setting

* Fix: Bit more advanced settings

Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
  • Loading branch information
CreativeCodeCat authored Sep 27, 2024
1 parent 9601afa commit 6b72000
Show file tree
Hide file tree
Showing 32 changed files with 2,449 additions and 1,448 deletions.
56 changes: 39 additions & 17 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,25 @@ android {
manifestPlaceholders["coarseLocationPermission"] =
"android.permission.ACCESS_COARSE_LOCATION"
val weatherFile = project.rootProject.file("weather.properties")
val properties = Properties()
properties.load(weatherFile.inputStream())
val apiKey = properties.getProperty("WEATHER_API_KEY") ?: ""
buildConfigField(
type = "String",
name = "API_KEY",
value = "\"$apiKey\""
)
if (weatherFile.exists()) {
val properties = Properties()
weatherFile.inputStream().use { inputStream ->
properties.load(inputStream)
}
val apiKey = properties.getProperty("WEATHER_API_KEY") ?: ""
buildConfigField(
type = "String",
name = "API_KEY",
value = "\"$apiKey\""
)
} else {
buildConfigField(
type = "String",
name = "API_KEY",
value = "\"REMOVE\""
)
println("weather.properties file not found.")
}
}

create("withoutInternet") {
Expand All @@ -105,16 +116,27 @@ android {
applicationIdSuffix = ".nightly"
versionNameSuffix = "-nightly"
manifestPlaceholders["internetPermission"] = "android.permission.INTERNET"
val weatherFile = project.rootProject.file("weather.properties")
val properties = Properties()
properties.load(weatherFile.inputStream())
val apiKey = properties.getProperty("WEATHER_API_KEY") ?: ""
buildConfigField(
type = "String",
name = "API_KEY",
value = "\"$apiKey\""
)
resValue("string", "app_name", "Easy Launcher (Nightly)")
val weatherFile = project.rootProject.file("weather.properties")
if (weatherFile.exists()) {
val properties = Properties()
weatherFile.inputStream().use { inputStream ->
properties.load(inputStream)
}
val apiKey = properties.getProperty("WEATHER_API_KEY") ?: ""
buildConfigField(
type = "String",
name = "API_KEY",
value = "\"$apiKey\""
)
} else {
buildConfigField(
type = "String",
name = "API_KEY",
value = "\"REMOVE\""
)
println("weather.properties file not found.")
}
}

create("withoutInternetNightly") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.content.res.Configuration
import android.content.res.Resources
import android.net.Uri
import android.os.Build
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.Window
Expand All @@ -19,10 +20,10 @@ import androidx.appcompat.widget.LinearLayoutCompat
import androidx.navigation.NavOptions
import com.github.droidworksstudio.common.showLongToast
import com.github.droidworksstudio.launcher.BuildConfig
import com.github.droidworksstudio.launcher.utils.Constants
import com.github.droidworksstudio.launcher.R
import com.github.droidworksstudio.launcher.accessibility.ActionService
import com.github.droidworksstudio.launcher.helper.weather.WeatherResponse
import com.github.droidworksstudio.launcher.utils.Constants
import com.github.droidworksstudio.launcher.utils.WeatherApiService
import com.google.gson.Gson
import retrofit2.Retrofit
Expand Down Expand Up @@ -115,6 +116,7 @@ class AppHelper @Inject constructor() {
// Digital Wellbeing app is not installed or cannot be opened
// Handle this case as needed
context.showLongToast("Digital Wellbeing is not available on this device.")
Log.e("AppHelper", "Digital Wellbeing app not found or cannot be opened.", e)
}
}

Expand Down Expand Up @@ -170,27 +172,34 @@ class AppHelper @Inject constructor() {
return dailyWordsArray[wordIndex]
}

fun shareAppButton(context: Context) {
fun shareApplicationButton(context: Context) {
val shareIntent = Intent(Intent.ACTION_SEND)
val description = context.getString(R.string.advanced_settings_share_application_description, context.getString(R.string.app_name))
shareIntent.type = "text/plain"
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Share Application")
shareIntent.putExtra(
Intent.EXTRA_TEXT,
"https://f-droid.org/packages/" + context.packageName
"$description https://f-droid.org/packages/${context.packageName}"
)
context.startActivity(Intent.createChooser(shareIntent, "Share Application"))
}

fun githubButton(context: Context) {
fun helpFeedbackButton(context: Context) {
val uri = Uri.parse("https://github.com/DroidWorksStudio/EasyLauncher")
val intent = Intent(Intent.ACTION_VIEW, uri)
context.startActivity(intent)
}

fun feedbackButton(context: Context) {
fun communitySupportButton(context: Context) {
val uri = Uri.parse("https://t.me/DroidWorksStudio/")
val intent = Intent(Intent.ACTION_VIEW, uri)
context.startActivity(intent)
}

fun emailButton(context: Context) {
val emailIntent = Intent(Intent.ACTION_SENDTO)
emailIntent.data = Uri.parse("mailto:droidworksstuido@063240.xyz")
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Easy Launcher")
emailIntent.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name)
context.startActivity(Intent.createChooser(emailIntent, "Choose Mail Application"))
}

Expand Down Expand Up @@ -307,6 +316,7 @@ class AppHelper @Inject constructor() {
return WeatherResult.Failure("Failed to fetch weather data: ${response.errorBody()}")
}
} catch (e: UnknownHostException) {
Log.e("AppHelper", "Unknown Host.", e)
return WeatherResult.Failure("Unknown Host : $baseURL")
} catch (e: Exception) {
return WeatherResult.Failure("${e.message}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.github.droidworksstudio.launcher.ui.activities

import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.ActivityInfo
Expand All @@ -24,6 +22,7 @@ import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.findNavController
Expand All @@ -33,6 +32,7 @@ import androidx.navigation.ui.navigateUp
import com.github.droidworksstudio.common.hasInternetPermission
import com.github.droidworksstudio.common.isTablet
import com.github.droidworksstudio.common.showLongToast
import com.github.droidworksstudio.common.showShortToast
import com.github.droidworksstudio.launcher.R
import com.github.droidworksstudio.launcher.databinding.ActivityMainBinding
import com.github.droidworksstudio.launcher.helper.AppHelper
Expand Down Expand Up @@ -89,7 +89,7 @@ class MainActivity : AppCompatActivity() {
setContentView(binding.root)

locationManager = getSystemService(LOCATION_SERVICE) as LocationManager
sharedPreferences = getSharedPreferences(Constants.WEATHER_PREFS, Context.MODE_PRIVATE)
sharedPreferences = getSharedPreferences(Constants.WEATHER_PREFS, MODE_PRIVATE)
handler = Handler(Looper.getMainLooper())

initializeDependencies()
Expand Down Expand Up @@ -218,7 +218,7 @@ class MainActivity : AppCompatActivity() {

onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
backToHomeScreen()
goBackToSettings()
}
})
}
Expand Down Expand Up @@ -268,8 +268,29 @@ class MainActivity : AppCompatActivity() {

private fun backToHomeScreen() {
navController = findNavController(R.id.nav_host_fragment_content_main)
if (navController.currentDestination?.id != R.id.HomeFragment)
navController.navigate(R.id.HomeFragment)
when (navController.currentDestination?.id) {
R.id.HomeFragment -> return
else -> navController.navigate(R.id.HomeFragment)
}
}

private fun goBackToSettings() {
navController = findNavController(R.id.nav_host_fragment_content_main)
val fragmentManager: FragmentManager = supportFragmentManager
when (navController.currentDestination?.id) {
R.id.SettingsFragment,
R.id.SettingsFeaturesFragment,
R.id.SettingsLookFeelFragment,
R.id.FavoriteFragment,
R.id.HiddenFragment,
R.id.SettingsAdvancedFragment -> {
fragmentManager.popBackStack()
}

else -> {
navController.navigate(R.id.HomeFragment)
}
}
}


Expand All @@ -296,7 +317,7 @@ class MainActivity : AppCompatActivity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

if (resultCode != Activity.RESULT_OK) {
if (resultCode != RESULT_OK) {
applicationContext.showLongToast("Intent Error")
return
}
Expand All @@ -320,6 +341,7 @@ class MainActivity : AppCompatActivity() {
prefs.loadFromString(string)
}
}
applicationContext.showShortToast(getString(R.string.settings_reload_app_restore))
Handler(Looper.getMainLooper()).postDelayed({
AppReloader.restartApp(applicationContext)
}, 500)
Expand All @@ -335,6 +357,7 @@ class MainActivity : AppCompatActivity() {
}
}
}
applicationContext.showShortToast(getString(R.string.settings_reload_app_backup))
}
}
}
Expand Down
Loading

0 comments on commit 6b72000

Please sign in to comment.