Skip to content

Commit

Permalink
versatile optimization and fix
Browse files Browse the repository at this point in the history
+ convert png to webp
+ add colored icon preference
+ remove unused resources and classes
+ add hindi for all string resources
  • Loading branch information
ranjanistic committed May 28, 2020
1 parent b0e6450 commit f3334f9
Show file tree
Hide file tree
Showing 56 changed files with 199 additions and 103 deletions.
2 changes: 1 addition & 1 deletion Skivvy.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Skivvy" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<module external.linked.project.id="Skivvy" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
android:label="@string/skivvy_service"
tools:targetApi="Q" />

<activity android:name=".LockScreenActivity" />
<activity android:name=".SkivvyConnect">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Binary file removed app/src/main/ic_launcher-playstore.png
Binary file not shown.
Binary file modified app/src/main/ic_launcher-playstore.webp
Binary file not shown.
12 changes: 0 additions & 12 deletions app/src/main/java/org/ranjanistic/skivvy/LockScreenActivity.kt

This file was deleted.

33 changes: 29 additions & 4 deletions app/src/main/java/org/ranjanistic/skivvy/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ open class MainActivity : AppCompatActivity() {
wifiManager = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
calculation = CalculationManager(skivvy)
greet.text = getString(app_name)
greet.setCompoundDrawablesWithIntrinsicBounds(dots_in_circle, 0, 0, 0)
greet.setCompoundDrawablesWithIntrinsicBounds(
if(skivvy.isColorfulSkivvy()) dots_in_circle_colorful
else dots_in_circle
, 0, 0, 0
)
if (skivvy.isLocaleHindi()) {
greet.typeface = Typeface.DEFAULT
inputText.typeface = Typeface.DEFAULT
Expand Down Expand Up @@ -1701,7 +1705,7 @@ open class MainActivity : AppCompatActivity() {
localText = input.removeBeforeLastStringsIn(
text,
arrayOf(resources.getStringArray(R.array.initiators))
)
).toLowerCase(skivvy.locale)
if (localText == nothing) {
localText = input.removeStringsIn(
text,
Expand Down Expand Up @@ -1740,6 +1744,16 @@ open class MainActivity : AppCompatActivity() {
startActivity(Intent(packages.getPackageIntent(i)))
return true
}
localText.substringAfterLast(space) == packages.getPackageAppName(i)->{
temp.setPackageIndex(i)
successView(packages.getPackageIcon(i))
speakOut(
getString(opening) + packages.getPackageAppName(i)!!
.capitalize(skivvy.locale)
)
startActivity(Intent(packages.getPackageIntent(i)))
return true
}
packages.getPackageName(i)!!.contains(localText) -> {
temp.setPackageIndex(i)
waitingView(packages.getPackageIcon(i))
Expand Down Expand Up @@ -2739,11 +2753,22 @@ open class MainActivity : AppCompatActivity() {
loading.setImageDrawable(
getDrawable(
when (skivvy.getThemeState()) {
R.style.BlueTheme -> dots_in_circle_white
else -> dots_in_circle
R.style.BlueTheme ->{
if(skivvy.isColorfulSkivvy()) dots_in_circle_colorful_white
else dots_in_circle_white
}
else ->{
if(skivvy.isColorfulSkivvy()) dots_in_circle_colorful
else dots_in_circle
}
}
)
)
greet.setCompoundDrawablesWithIntrinsicBounds(
if(skivvy.isColorfulSkivvy()) dots_in_circle_colorful
else dots_in_circle
, 0, 0, 0
)
setOutput(getString(what_next))
setFeedback(null)
icon.setImageDrawable(null)
Expand Down
48 changes: 39 additions & 9 deletions app/src/main/java/org/ranjanistic/skivvy/Setup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.app.admin.DevicePolicyManager
import android.content.Context
import android.content.Intent
import android.graphics.Typeface
import android.media.AudioManager
import android.net.Uri
import android.os.Build
Expand All @@ -13,6 +14,7 @@ import android.provider.Settings
import android.speech.RecognizerIntent
import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener
import android.util.Log
import android.view.View
import android.view.WindowManager
import android.view.animation.Animation
Expand All @@ -24,6 +26,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import com.google.android.material.snackbar.Snackbar
import org.ranjanistic.skivvy.manager.SystemFeatureManager
import org.ranjanistic.skivvy.manager.TempDataManager
Expand Down Expand Up @@ -55,10 +58,11 @@ class Setup : AppCompatActivity() {
lateinit var theme: Switch
lateinit var themeChoices: RadioGroup
lateinit var saveTheme: TextView
lateinit var colorSkivvy:Switch
lateinit var response: Switch
lateinit var handy: Switch
lateinit var onStartup: Switch
lateinit var retryFailure:Switch
lateinit var retryFailure: Switch
lateinit var continueInput: Switch
lateinit var fullScreen: Switch
}
Expand All @@ -67,6 +71,7 @@ class Setup : AppCompatActivity() {
lateinit var notifications: Switch
lateinit var battery: Switch
}

private class Maths {
lateinit var angleUnit: Switch
lateinit var logBaseText: TextView
Expand Down Expand Up @@ -193,6 +198,7 @@ class Setup : AppCompatActivity() {
appSetup.themeChoices = findViewById(R.id.themeChoices)
appSetup.saveTheme = findViewById(R.id.save_theme)
appSetup.response = findViewById(R.id.parallelResponseBtn)
appSetup.colorSkivvy = findViewById(R.id.coloredIcon)
appSetup.handy = findViewById(R.id.handDirectionBtn)
appSetup.onStartup = findViewById(R.id.recordOnStart)
appSetup.retryFailure = findViewById(R.id.retryAfterFailure)
Expand Down Expand Up @@ -225,7 +231,6 @@ class Setup : AppCompatActivity() {
getString(R.string.maths_and_setup)
findViewById<TextView>(R.id.security_group_head).text =
getString(R.string.security_and_setup)
appSetup.saveTheme.setBackgroundResource(R.drawable.button_square_round_spruce)
setPermissionGridData(
arrayOf(
special.permissions,
Expand Down Expand Up @@ -298,6 +303,7 @@ class Setup : AppCompatActivity() {
voice.urgentVolume,
appSetup.theme,
appSetup.response,
appSetup.colorSkivvy,
appSetup.handy,
appSetup.onStartup,
appSetup.retryFailure,
Expand All @@ -317,6 +323,7 @@ class Setup : AppCompatActivity() {
skivvy.getVolumeUrgent(),
skivvy.isCustomTheme(),
skivvy.getParallelResponseStatus(),
skivvy.isColorfulSkivvy(),
skivvy.getLeftHandy(),
skivvy.shouldListenStartup(),
skivvy.shouldRetry(),
Expand All @@ -330,10 +337,13 @@ class Setup : AppCompatActivity() {
)
switchData.onText = arrayOf(
getString(R.string.unmute_text),
getString(R.string.normal_vol_on_text_) + skivvy.getNormalVolume().toString() + getString(R.string.percent),
getString(R.string.urgent_vol_on_text_) + skivvy.getUrgentVolume().toString() + getString(R.string.percent),
getString(R.string.normal_vol_on_text_) + skivvy.getNormalVolume()
.toString() + getString(R.string.percent),
getString(R.string.urgent_vol_on_text_) + skivvy.getUrgentVolume()
.toString() + getString(R.string.percent),
getString(R.string.set_default_theme),
getString(R.string.set_queued_receive),
getString(R.string.color_icon_on),
getString(R.string.left_handy),
getString(R.string.listen_on_click),
getString(R.string.retry_fail_on),
Expand All @@ -351,6 +361,7 @@ class Setup : AppCompatActivity() {
getString(R.string.urgent_vol_off_text),
getString(R.string.customize_theme),
getString(R.string.set_parallel_receive),
getString(R.string.color_icon_off),
getString(R.string.right_handy),
getString(R.string.listen_on_start),
getString(R.string.retry_fail_off),
Expand All @@ -376,7 +387,8 @@ class Setup : AppCompatActivity() {
textViews: Array<TextView>,
textIDs: Array<Int>,
texts: Array<String>? = null,
drawableIDs: Array<Int>) {
drawableIDs: Array<Int>
) {
for ((index, access) in textViews.withIndex()) {
if (texts == null) {
access.text = getString(textIDs[index])
Expand All @@ -401,6 +413,7 @@ class Setup : AppCompatActivity() {
switchData.offText[index]
)
}
it.setTypeface(ResourcesCompat.getFont(context, R.font.jost_light))
}
index++
}
Expand Down Expand Up @@ -620,16 +633,19 @@ class Setup : AppCompatActivity() {
}
}
}

//TODO: log base selector
private fun restarter(){
private fun restarter() {
startActivity(
Intent(
context,
MainActivity::class.java
).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP ).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
finish()
}

private fun setListeners() {
back.setOnClickListener {
finish()
Expand Down Expand Up @@ -724,6 +740,7 @@ class Setup : AppCompatActivity() {
if (fromUser) voice.urgentVolume.text = txt
uPercent = progress
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
skivvy.setVoicePreference(urgentVolumeLevel = uPercent)
Expand Down Expand Up @@ -787,6 +804,15 @@ class Setup : AppCompatActivity() {
}, showSnackbar = true
)
}
appSetup.colorSkivvy.setOnCheckedChangeListener { view, isChecked ->
skivvy.setAppModePref(colorfulIcon = isChecked)
setThumbAttrs(
view as Switch,
isChecked,
getString(R.string.color_icon_on),
getString(R.string.color_icon_off)
)
}
appSetup.handy.setOnCheckedChangeListener { view, isChecked ->
skivvy.setAppModePref(leftHandy = isChecked)
setThumbAttrs(
Expand Down Expand Up @@ -1230,7 +1256,10 @@ class Setup : AppCompatActivity() {
skivvy.CODE_VOICE_AUTH_CONFIRM -> {
if (text == skivvy.getVoiceKeyPhrase()) {
//TODO: recording voice auth phrase locale for if change in default locale occurs.
skivvy.setSecurityPref(vocalAuthPhrase = text, vocalAuthLocale = Locale.getDefault())
skivvy.setSecurityPref(
vocalAuthPhrase = text,
vocalAuthLocale = Locale.getDefault()
)
security.voiceAuth.isChecked = true
skivvy.setSecurityPref(vocalAuthOn = true)
setVisibilityOf(security.deleteVoiceSetup, visible = true)
Expand Down Expand Up @@ -1343,7 +1372,8 @@ class Setup : AppCompatActivity() {
security.biometricPrompt = BiometricPrompt(this, security.executor,
object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationSucceeded(
result: BiometricPrompt.AuthenticationResult) {
result: BiometricPrompt.AuthenticationResult
) {
super.onAuthenticationSucceeded(result)
when (code) {
skivvy.CODE_VOICE_AUTH_CONFIRM -> {
Expand Down
60 changes: 43 additions & 17 deletions app/src/main/java/org/ranjanistic/skivvy/Skivvy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,42 @@ class Skivvy : Application() {
val CODE_CALL_LOG_REQUEST = 1004
val CODE_BODY_SENSOR_REQUEST = 1005
val CODE_CALENDER_REQUEST = 1006
val permissions = arrayOf(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_CONTACTS,
Manifest.permission.READ_CONTACTS,
Manifest.permission.CALL_PHONE,
Manifest.permission.ANSWER_PHONE_CALLS,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.WRITE_CALENDAR,
Manifest.permission.READ_CALENDAR,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.SEND_SMS,
Manifest.permission.READ_SMS,
Manifest.permission.CAMERA,
Manifest.permission.BODY_SENSORS
)
val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
arrayOf(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_CONTACTS,
Manifest.permission.READ_CONTACTS,
Manifest.permission.CALL_PHONE,
Manifest.permission.ANSWER_PHONE_CALLS,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.WRITE_CALENDAR,
Manifest.permission.READ_CALENDAR,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.SEND_SMS,
Manifest.permission.READ_SMS,
Manifest.permission.CAMERA,
Manifest.permission.BODY_SENSORS
)
} else {
arrayOf(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_CONTACTS,
Manifest.permission.READ_CONTACTS,
Manifest.permission.CALL_PHONE,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.WRITE_CALENDAR,
Manifest.permission.READ_CALENDAR,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.SEND_SMS,
Manifest.permission.READ_SMS,
Manifest.permission.CAMERA,
Manifest.permission.BODY_SENSORS
)
}

//defaults
val locale: Locale = Locale.getDefault()
Expand Down Expand Up @@ -112,6 +131,7 @@ class Skivvy : Application() {
val PREF_KEY_THEME = "theme"
val PREF_KEY_CUSTOM_THEME = "customTheme"
val PREF_KEY_PARLLEL_TALK = "parallelResponse"
val PREF_KEY_COLOR_ICON = "colorfulIcon"
val PREF_KEY_HANDY = "handSide"
val PREF_KEY_START_TALK = "talkOnStart"
val PREF_KEY_RETRY_INPUT = "retryAfterFailure"
Expand Down Expand Up @@ -239,6 +259,7 @@ class Skivvy : Application() {
isCustomTheme: Boolean? = null,
customTheme: Int? = null,
parallelListen: Boolean? = null,
colorfulIcon: Boolean? = null,
leftHandy: Boolean? = null,
onStartListen: Boolean? = null,
onFailRetry:Boolean? = null,
Expand All @@ -250,6 +271,7 @@ class Skivvy : Application() {
isCustomTheme?.let { editor.putBoolean(this.PREF_KEY_CUSTOM_THEME, it).apply() }
customTheme?.let { editor.putInt(this.PREF_KEY_THEME, it).apply() }
parallelListen?.let { editor.putBoolean(this.PREF_KEY_PARLLEL_TALK, it).apply() }
colorfulIcon?.let { editor.putBoolean(this.PREF_KEY_COLOR_ICON, it).apply() }
leftHandy?.let { editor.putBoolean(this.PREF_KEY_HANDY, it).apply() }
onStartListen?.let { editor.putBoolean(this.PREF_KEY_START_TALK, it).apply() }
onFailRetry?.let { editor.putBoolean(this.PREF_KEY_RETRY_INPUT, it).apply() }
Expand All @@ -270,6 +292,10 @@ class Skivvy : Application() {
getSharedPreferences(this.PREF_HEAD_APP_SETUP, AppCompatActivity.MODE_PRIVATE)
.getBoolean(this.PREF_KEY_PARLLEL_TALK, false)

fun isColorfulSkivvy():Boolean =
getSharedPreferences(this.PREF_HEAD_APP_SETUP, AppCompatActivity.MODE_PRIVATE)
.getBoolean(this.PREF_KEY_COLOR_ICON, false)

fun getLeftHandy(): Boolean =
getSharedPreferences(this.PREF_HEAD_APP_SETUP, AppCompatActivity.MODE_PRIVATE)
.getBoolean(this.PREF_KEY_HANDY, false)
Expand Down
Binary file removed app/src/main/res/drawable-hdpi/ic_action_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-hdpi/ic_action_name.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-hdpi/ic_stat_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-hdpi/ic_stat_name.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-mdpi/ic_action_name.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-mdpi/ic_stat_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-mdpi/ic_stat_name.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/ic_action_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-xhdpi/ic_action_name.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/ic_stat_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-xhdpi/ic_stat_name.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_action_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-xxhdpi/ic_action_name.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_stat_name.png
Binary file not shown.
Binary file added app/src/main/res/drawable-xxhdpi/ic_stat_name.webp
Binary file not shown.
10 changes: 0 additions & 10 deletions app/src/main/res/drawable/button_square_round_green.xml

This file was deleted.

Loading

0 comments on commit f3334f9

Please sign in to comment.