Skip to content

Commit

Permalink
Merge branch 'main' into translate_main
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeCodeCat authored Sep 27, 2024
2 parents 7d9c4cc + e1dbaeb commit 0a22ae4
Show file tree
Hide file tree
Showing 34 changed files with 2,464 additions and 1,455 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ All notable changes to this project will be documented in this file. See [conven

### Implemented Enhancements:

- Added the base for the new settings screen ([#130](https://github.com/DroidWorksStudio/EasyLauncher/issues/130)) - ([6b72000](https://github.com/DroidWorksStudio/EasyLauncher/commit/6b72000c6033f68499ae76a0865b7109c7a464c0))
- Added a default search engine so can use other apps other then ones selected - ([630e5c6](https://github.com/DroidWorksStudio/EasyLauncher/commit/630e5c6b2c765fc6abc481e066c9807ff57036f2))

### Bug Fixes:

- Fixed issue with layoutParams - ([a16b664](https://github.com/DroidWorksStudio/EasyLauncher/commit/a16b664b4d41884e1813a70fb438363679f7b2fa))

### Feature Removal:

- Remove trash files. ([#140](https://github.com/DroidWorksStudio/EasyLauncher/issues/140)) - ([d27ccc8](https://github.com/DroidWorksStudio/EasyLauncher/commit/d27ccc8cf6711d962c1b41504b52d77553d8fa4b))
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import android.os.Handler
import android.os.Looper
import android.text.format.DateFormat
import android.util.Log
import android.view.*
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatTextView
Expand Down Expand Up @@ -193,30 +196,30 @@ class HomeFragment : Fragment(),
private fun setupRecyclerView() {
val marginTopInPixels = 128
val params: ViewGroup.LayoutParams = binding.appListAdapter.layoutParams
var layoutParams = if (params is LinearLayout.LayoutParams) {
val layoutParam = if (params is LinearLayout.LayoutParams) {
params
} else {
LinearLayout.LayoutParams(params)
}
layoutParams.topMargin = marginTopInPixels
layoutParam.topMargin = marginTopInPixels

when (preferenceHelper.homeAppAlignment) {
Gravity.START -> {
layoutParams.gravity = Gravity.START
layoutParam.gravity = Gravity.START
}

Gravity.CENTER -> {
layoutParams.gravity = Gravity.CENTER
layoutParam.gravity = Gravity.CENTER
}

Gravity.END -> {
layoutParams.gravity = Gravity.END
layoutParam.gravity = Gravity.END
}
}

binding.appListAdapter.apply {
adapter = homeAdapter
layoutParams = layoutParams
layoutParams = layoutParam
setHasFixedSize(false)
layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
isNestedScrollingEnabled = false
Expand Down
Loading

0 comments on commit 0a22ae4

Please sign in to comment.