diff --git a/app/src/main/java/com/finnmglas/launcher/Functions.kt b/app/src/main/java/com/finnmglas/launcher/Functions.kt
index d0ecc4f..f7a899c 100644
--- a/app/src/main/java/com/finnmglas/launcher/Functions.kt
+++ b/app/src/main/java/com/finnmglas/launcher/Functions.kt
@@ -8,6 +8,7 @@ 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
@@ -30,6 +31,7 @@ import com.finnmglas.launcher.settings.intendedSettingsPause
import com.finnmglas.launcher.tutorial.TutorialActivity
import kotlin.math.roundToInt
+
/* Preferences (global, initialised when app is started) */
lateinit var launcherPreferences: SharedPreferences
@@ -154,8 +156,10 @@ fun View.fadeRotateIn(duration: Long = 500L) {
}
)
combined.addAnimation(
- RotateAnimation(0F, 180F, Animation.RELATIVE_TO_SELF,
- 0.5f, Animation.RELATIVE_TO_SELF,0.5f).also {
+ RotateAnimation(
+ 0F, 180F, Animation.RELATIVE_TO_SELF,
+ 0.5f, Animation.RELATIVE_TO_SELF, 0.5f
+ ).also {
it.duration = duration * 2
it.interpolator = DecelerateInterpolator()
}
@@ -173,8 +177,10 @@ fun View.fadeRotateOut(duration: Long = 500L) {
}
)
combined.addAnimation(
- RotateAnimation(0F, 180F, Animation.RELATIVE_TO_SELF,
- 0.5f, Animation.RELATIVE_TO_SELF,0.5f).also {
+ RotateAnimation(
+ 0F, 180F, Animation.RELATIVE_TO_SELF,
+ 0.5f, Animation.RELATIVE_TO_SELF, 0.5f
+ ).also {
it.duration = duration
it.interpolator = AccelerateInterpolator()
}
@@ -202,13 +208,17 @@ private fun getIntent(packageName: String, context: Context): Intent? {
return intent
}
-fun launch(data: String, activity: Activity,
- animationIn: Int = android.R.anim.fade_in, animationOut: Int = android.R.anim.fade_out) {
+fun launch(
+ data: String, activity: Activity,
+ animationIn: Int = android.R.anim.fade_in, animationOut: Int = android.R.anim.fade_out
+) {
if (data.startsWith("launcher:")) // [type]:[info]
when(data.split(":")[1]) {
"settings" -> openSettings(activity)
"choose" -> openAppsList(activity)
+ "volumeUp" -> audioVolumeUp(activity)
+ "volumeDown" -> audioVolumeDown(activity)
"tutorial" -> openTutorial(activity)
}
else launchApp(data, activity) // app
@@ -216,6 +226,28 @@ fun launch(data: String, activity: Activity,
activity.overridePendingTransition(animationIn, animationOut)
}
+fun audioVolumeUp(activity: Activity) {
+ val audioManager =
+ activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager
+
+ audioManager.adjustStreamVolume(
+ AudioManager.STREAM_MUSIC,
+ AudioManager.ADJUST_RAISE,
+ AudioManager.FLAG_SHOW_UI
+ )
+}
+
+fun audioVolumeDown(activity: Activity) {
+ val audioManager =
+ activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager
+
+ audioManager.adjustStreamVolume(
+ AudioManager.STREAM_MUSIC,
+ AudioManager.ADJUST_LOWER,
+ AudioManager.FLAG_SHOW_UI
+ )
+}
+
fun launchApp(packageName: String, context: Context) {
val intent = getIntent(packageName, context)
@@ -224,7 +256,8 @@ fun launchApp(packageName: String, context: Context) {
} else {
if (isInstalled(packageName, context)){
- AlertDialog.Builder(context,
+ AlertDialog.Builder(
+ context,
R.style.AlertDialogCustom
)
.setTitle(context.getString(R.string.alert_cant_open_title))
@@ -240,12 +273,16 @@ fun launchApp(packageName: String, context: Context) {
.setIcon(android.R.drawable.ic_dialog_info)
.show()
} else {
- Toast.makeText( context, context.getString(R.string.toast_cant_open_message), Toast.LENGTH_SHORT).show()
+ Toast.makeText(
+ context,
+ context.getString(R.string.toast_cant_open_message),
+ Toast.LENGTH_SHORT
+ ).show()
}
}
}
-fun openNewTabWindow(urls: String, context : Context) {
+fun openNewTabWindow(urls: String, context: Context) {
val uris = Uri.parse(urls)
val intents = Intent(Intent.ACTION_VIEW, uris)
val b = Bundle()
@@ -256,11 +293,11 @@ fun openNewTabWindow(urls: String, context : Context) {
/* Settings related functions */
-fun getSavedTheme(context : Context) : String {
+fun getSavedTheme(context: Context) : String {
return launcherPreferences.getString(PREF_THEME, "finn").toString()
}
-fun saveTheme(themeName : String) : String {
+fun saveTheme(themeName: String) : String {
launcherPreferences.edit()
.putString(PREF_THEME, themeName)
.apply()
@@ -302,7 +339,7 @@ fun resetToDarkTheme(activity: Activity) {
}
-fun openAppSettings(pkg :String, context:Context) {
+fun openAppSettings(pkg: String, context: Context) {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:$pkg")
context.startActivity(intent)
@@ -399,14 +436,18 @@ fun setWindowFlags(window: Window) {
// Display notification bar
if (launcherPreferences.getBoolean(PREF_SCREEN_FULLSCREEN, true))
- window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ window.setFlags(
+ WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN
+ )
else window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
// Screen Timeout
if (launcherPreferences.getBoolean(PREF_SCREEN_TIMEOUT_DISABLED, false))
- window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ window.setFlags(
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ )
else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
diff --git a/app/src/main/java/com/finnmglas/launcher/list/other/OtherRecyclerAdapter.kt b/app/src/main/java/com/finnmglas/launcher/list/other/OtherRecyclerAdapter.kt
index 1e7eb71..cc94637 100644
--- a/app/src/main/java/com/finnmglas/launcher/list/other/OtherRecyclerAdapter.kt
+++ b/app/src/main/java/com/finnmglas/launcher/list/other/OtherRecyclerAdapter.kt
@@ -66,6 +66,14 @@ class OtherRecyclerAdapter(val activity: Activity):
OtherInfo(activity.getString(R.string.list_other_list),
"launcher:choose",
activity.getString(R.string.fas_bars)))
+ othersList.add(
+ OtherInfo(activity.getString(R.string.list_other_volume_up),
+ "launcher:volumeUp",
+ activity.getString(R.string.fas_plus)))
+ othersList.add(
+ OtherInfo(activity.getString(R.string.list_other_volume_down),
+ "launcher:volumeDown",
+ activity.getString(R.string.fas_minus)))
}
/* */
diff --git a/app/src/main/java/com/finnmglas/launcher/settings/actions/SettingsFragmentActionsRecycler.kt b/app/src/main/java/com/finnmglas/launcher/settings/actions/SettingsFragmentActionsRecycler.kt
index d03f39e..f0395c4 100644
--- a/app/src/main/java/com/finnmglas/launcher/settings/actions/SettingsFragmentActionsRecycler.kt
+++ b/app/src/main/java/com/finnmglas/launcher/settings/actions/SettingsFragmentActionsRecycler.kt
@@ -104,6 +104,10 @@ class ActionsRecyclerAdapter(val activity: Activity):
viewHolder.fontAwesome.text = activity.getString(R.string.fas_settings)
"choose" ->
viewHolder.fontAwesome.text = activity.getString(R.string.fas_bars)
+ "volumeUp" ->
+ viewHolder.fontAwesome.text = activity.getString(R.string.fas_plus)
+ "volumeDown" ->
+ viewHolder.fontAwesome.text = activity.getString(R.string.fas_minus)
}
} else {
// Set image icon (by packageName)
diff --git a/app/src/main/res/values/icons.xml b/app/src/main/res/values/icons.xml
index 45b1a61..2a1a2f5 100644
--- a/app/src/main/res/values/icons.xml
+++ b/app/src/main/res/values/icons.xml
@@ -13,6 +13,10 @@
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 32f03cf..324b85a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -144,6 +144,8 @@
Launcher Settings
Launcher AppsList
+ Increase Volume
+ Decrease Volume