Skip to content

Commit

Permalink
v4.19-pre
Browse files Browse the repository at this point in the history
  • Loading branch information
AndraxDev committed Aug 31, 2024
1 parent f8ef99e commit 2be6a53
Show file tree
Hide file tree
Showing 43 changed files with 190 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId "org.teslasoft.assistant"
minSdk 28
targetSdk 35
versionCode 418
versionName "4.18"
versionCode 419
versionName "4.19"
}

buildTypes {
Expand Down Expand Up @@ -51,6 +51,7 @@ android {

dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.activity:activity-ktx:1.9.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.13.0-alpha05'
implementation 'com.google.code.gson:gson:2.11.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class AboutActivity : FragmentActivity() {
reloadAmoled()
}

@Suppress("deprecation")
private fun reloadAmoled() {
if (isDarkThemeEnabled() && Preferences.getPreferences(this, "").getAmoledPitchBlack()) {
if (android.os.Build.VERSION.SDK_INT <= 34) {
Expand Down Expand Up @@ -230,7 +231,7 @@ class AboutActivity : FragmentActivity() {
}

private fun getDarkDrawable(drawable: Drawable) : Drawable {
DrawableCompat.setTint(DrawableCompat.wrap(drawable), SurfaceColors.SURFACE_2.getColor(this))
DrawableCompat.setTint(DrawableCompat.wrap(drawable), SurfaceColors.SURFACE_1.getColor(this))
return drawable
}

Expand All @@ -253,7 +254,7 @@ class AboutActivity : FragmentActivity() {
return if (isDarkThemeEnabled() && preferences?.getAmoledPitchBlack() == true) {
ResourcesCompat.getColor(resources, R.color.accent_50, theme)
} else {
SurfaceColors.SURFACE_5.getColor(this)
SurfaceColors.SURFACE_1.getColor(this)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import android.content.res.Configuration.KEYBOARD_QWERTY
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.PorterDuff
import android.graphics.PorterDuffXfermode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class PromptViewActivity : FragmentActivity(), SwipeRefreshLayout.OnRefreshListe
}

private fun getDarkDrawable(drawable: Drawable) : Drawable {
DrawableCompat.setTint(DrawableCompat.wrap(drawable), SurfaceColors.SURFACE_2.getColor(this))
DrawableCompat.setTint(DrawableCompat.wrap(drawable), SurfaceColors.SURFACE_1.getColor(this))
return drawable
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class AISetAdapter(private val mContext: Context, private val dataArray: ArrayLi
}

private fun getSurfaceColor() : Int {
return SurfaceColors.SURFACE_4.getColor(mContext)
return SurfaceColors.SURFACE_5.getColor(mContext)
}

private fun getAccentDrawable(drawable: Drawable) : Drawable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageButton
import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.contract.ActivityResultContracts
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.res.ResourcesCompat
Expand Down Expand Up @@ -181,6 +183,8 @@ class ChatsListFragment : Fragment(), Preferences.PreferencesChangedListener, Ch
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

fileIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult(), activityResultCallback)

Thread {
while (!isAttached) {
Thread.sleep(100)
Expand Down Expand Up @@ -426,32 +430,6 @@ class ChatsListFragment : Fragment(), Preferences.PreferencesChangedListener, Ch
})
}

private val fileIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
run {
if (result.resultCode == Activity.RESULT_OK) {
result.data?.data?.also { uri ->
selectedFile = readFile(uri)

if (isValidJson(selectedFile)) {
val chatDialogFragment: AddChatDialogFragment =
AddChatDialogFragment.newInstance(false, "", fromFile = true, disableAutoName = false, saveChat = false, "", "", "", "", "", -1)
chatDialogFragment.setStateChangedListener(chatListUpdatedListener)
chatDialogFragment.show(
parentFragmentManager.beginTransaction(),
"AddChatDialog"
)
} else {
MaterialAlertDialogBuilder(mContext?: return@also, R.style.App_MaterialAlertDialog)
.setTitle(getString(R.string.label_error))
.setMessage(getString(R.string.msg_error_importing_chat))
.setPositiveButton(R.string.btn_close) { _, _ -> }
.show()
}
}
}
}
}

private fun isValidJson(jsonStr: String?): Boolean {
return try {
val gson = Gson()
Expand All @@ -476,6 +454,32 @@ class ChatsListFragment : Fragment(), Preferences.PreferencesChangedListener, Ch
return stringBuilder.toString()
}

val activityResultCallback: ActivityResultCallback<ActivityResult> = ActivityResultCallback<ActivityResult> { result ->
if (result.resultCode == Activity.RESULT_OK) {
result.data?.data?.also { uri ->
selectedFile = readFile(uri)

if (isValidJson(selectedFile)) {
val chatDialogFragment: AddChatDialogFragment =
AddChatDialogFragment.newInstance(false, "", fromFile = true, disableAutoName = false, saveChat = false, "", "", "", "", "", -1)
chatDialogFragment.setStateChangedListener(chatListUpdatedListener)
chatDialogFragment.show(
parentFragmentManager.beginTransaction(),
"AddChatDialog"
)
} else {
MaterialAlertDialogBuilder(mContext?: return@also, R.style.App_MaterialAlertDialog)
.setTitle(getString(R.string.label_error))
.setMessage(getString(R.string.msg_error_importing_chat))
.setPositiveButton(R.string.btn_close) { _, _ -> }
.show()
}
}
}
}

private var fileIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult(), activityResultCallback)

private fun openFile(pickerInitialUri: Uri) {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/anim-v33/mtrl_activity_open_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="50"
android:startOffset="35"
android:duration="83" />

<translate
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/anim-v33/mtrl_activity_open_exit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/accelerate_interpolator"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:startOffset="0"
android:duration="450" />

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/anim-v33/mtrl_fragment_close_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="0"
android:duration="450" />
android:startOffset="200"
android:duration="300" />

<translate
android:fromXDelta="-96dp"
Expand All @@ -35,8 +35,8 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:startOffset="50"
android:duration="600" />

<extend
android:fromExtendLeft="0"
Expand All @@ -48,6 +48,6 @@
android:toExtendRight="96dp"
android:toExtendBottom="0"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:startOffset="50"
android:duration="600" />
</set>
8 changes: 4 additions & 4 deletions app/src/main/res/anim-v33/mtrl_fragment_close_exit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="35"
android:duration="83" />
android:startOffset="0"
android:duration="150" />

<translate
android:fromXDelta="0"
Expand All @@ -36,7 +36,7 @@
android:fillAfter="true"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:duration="600" />

<extend
android:fromExtendLeft="96dp"
Expand All @@ -49,5 +49,5 @@
android:toExtendBottom="0"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:duration="600" />
</set>
11 changes: 6 additions & 5 deletions app/src/main/res/anim-v33/mtrl_fragment_open_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="0"
android:duration="450" />
android:startOffset="200"
android:duration="300" />

<translate
android:fromXDelta="96dp"
android:toXDelta="0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:startOffset="50"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:duration="450" />
android:duration="600" />

<extend
android:fromExtendLeft="96dp"
Expand All @@ -47,6 +48,6 @@
android:toExtendRight="0"
android:toExtendBottom="0"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:startOffset="50"
android:duration="600" />
</set>
8 changes: 4 additions & 4 deletions app/src/main/res/anim-v33/mtrl_fragment_open_exit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/accelerate_interpolator"
android:startOffset="35"
android:duration="83" />
android:startOffset="0"
android:duration="150" />

<translate
android:fromXDelta="0"
Expand All @@ -36,7 +36,7 @@
android:fillAfter="true"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:duration="600" />

<extend
android:fromExtendLeft="0"
Expand All @@ -49,5 +49,5 @@
android:toExtendBottom="0"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:duration="600" />
</set>
2 changes: 1 addition & 1 deletion app/src/main/res/anim/mtrl_activity_open_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="50"
android:startOffset="35"
android:duration="83" />

<translate
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/anim/mtrl_activity_open_exit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/accelerate_interpolator"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="0"
android:duration="450" />

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/anim/mtrl_fragment_close_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="0"
android:duration="450" />
android:startOffset="200"
android:duration="300" />

<translate
android:fromXDelta="-96dp"
Expand All @@ -35,6 +35,6 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:startOffset="50"
android:duration="600" />
</set>
6 changes: 3 additions & 3 deletions app/src/main/res/anim/mtrl_fragment_close_exit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="35"
android:duration="83" />
android:startOffset="0"
android:duration="150" />

<translate
android:fromXDelta="0"
Expand All @@ -36,5 +36,5 @@
android:fillAfter="true"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="450" />
android:duration="600" />
</set>
7 changes: 4 additions & 3 deletions app/src/main/res/anim/mtrl_fragment_open_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="0"
android:duration="450" />
android:startOffset="200"
android:duration="300" />

<translate
android:fromXDelta="96dp"
android:toXDelta="0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:startOffset="0"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:duration="450" />
android:duration="600" />
</set>
Loading

0 comments on commit 2be6a53

Please sign in to comment.