forked from AndraxDev/speak-gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interstitial commit AndraxDev#2 for v1.10.0-beta11
- Loading branch information
Showing
43 changed files
with
910 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
app/src/main/java/org/teslasoft/assistant/AboutActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.teslasoft.assistant | ||
|
||
import android.content.Intent | ||
import android.content.pm.PackageInfo | ||
import android.content.pm.PackageManager | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.fragment.app.FragmentActivity | ||
import com.google.android.material.button.MaterialButton | ||
import org.teslasoft.core.auth.BuildConfig | ||
|
||
|
||
class AboutActivity : FragmentActivity() { | ||
|
||
private var appIcon: ImageView? = null | ||
private var btnProjects: MaterialButton? = null | ||
private var btnTerms: MaterialButton? = null | ||
private var btnPrivacy: MaterialButton? = null | ||
private var btnFeedback: MaterialButton? = null | ||
private var appVer: TextView? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContentView(R.layout.activity_about) | ||
|
||
appIcon = findViewById(R.id.app_icon) | ||
btnProjects = findViewById(R.id.btn_projects) | ||
btnTerms = findViewById(R.id.btn_terms) | ||
btnPrivacy = findViewById(R.id.btn_privacy) | ||
btnFeedback = findViewById(R.id.btn_feedback) | ||
appVer = findViewById(R.id.app_ver) | ||
|
||
appIcon?.setImageResource(R.drawable.assistant) | ||
|
||
try { | ||
val pInfo: PackageInfo = | ||
packageManager.getPackageInfo(packageName, 0) | ||
val version = pInfo.versionName | ||
|
||
appVer?.text = "App version: $version" | ||
} catch (e: PackageManager.NameNotFoundException) { | ||
appVer?.text = "App version: unknown" | ||
} | ||
|
||
btnProjects?.setOnClickListener { | ||
val i = Intent() | ||
i.data = Uri.parse("https://andrax.teslasoft.org/") | ||
i.action = Intent.ACTION_VIEW | ||
startActivity(i) | ||
} | ||
|
||
btnTerms?.setOnClickListener { | ||
val i = Intent() | ||
i.data = Uri.parse("https://teslasoft.org/tos") | ||
i.action = Intent.ACTION_VIEW | ||
startActivity(i) | ||
} | ||
|
||
btnPrivacy?.setOnClickListener { | ||
val i = Intent() | ||
i.data = Uri.parse("https://teslasoft.org/privacy") | ||
i.action = Intent.ACTION_VIEW | ||
startActivity(i) | ||
} | ||
|
||
btnFeedback?.setOnClickListener { | ||
val i = Intent() | ||
i.data = Uri.parse("mailto:[email protected]") | ||
i.action = Intent.ACTION_VIEW | ||
startActivity(i) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.teslasoft.assistant | ||
|
||
class Api { | ||
companion object { | ||
public val API_KEY: String = "1e6e81f0c6c940c82046680efd088e74" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/org/teslasoft/assistant/PromptViewActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.teslasoft.assistant | ||
|
||
import android.os.Bundle | ||
import android.widget.TextView | ||
import androidx.core.content.ContextCompat | ||
import androidx.fragment.app.FragmentActivity | ||
|
||
class PromptViewActivity : FragmentActivity() { | ||
|
||
private var activityTitle: TextView? = null | ||
|
||
private var id = "" | ||
private var title = "" | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
window.statusBarColor = ContextCompat.getColor(this, R.color.accent_100) | ||
|
||
val extras: Bundle? = intent.extras | ||
|
||
if (extras == null) { | ||
finish() | ||
} else { | ||
id = extras.getString("id", "") | ||
title = extras.getString("title", "") | ||
|
||
if (id == "" || title == "") { | ||
finish() | ||
} else { | ||
setContentView(R.layout.activity_view_prompt) | ||
activityTitle = findViewById(R.id.activity_view_title) | ||
|
||
activityTitle?.text = title | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/src/main/java/org/teslasoft/assistant/fragments/PostPromptDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.teslasoft.assistant.fragments | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.EditText | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.fragment.app.DialogFragment | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import org.teslasoft.assistant.R | ||
|
||
class PostPromptDialog : DialogFragment() { | ||
companion object { | ||
public fun newInstance(name: String, title: String, desc: String, prompt: String) : PostPromptDialog { | ||
val postPromptDialog = PostPromptDialog() | ||
|
||
val args = Bundle() | ||
args.putString("name", name) | ||
args.putString("title", title) | ||
args.putString("desc", desc) | ||
args.putString("prompt", prompt) | ||
|
||
postPromptDialog.arguments = args | ||
|
||
return postPromptDialog | ||
} | ||
} | ||
|
||
private var builder: AlertDialog.Builder? = null | ||
|
||
private var context: Context? = null | ||
|
||
private var listener: StateChangesListener? = null | ||
|
||
private var fieldName: EditText? = null | ||
private var fieldTitle: EditText? = null | ||
private var fieldDesc: EditText? = null | ||
private var fieldPrompt: EditText? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
context = this.activity | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_post_prompt, container, false) | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
builder = MaterialAlertDialogBuilder(this.requireContext()) | ||
|
||
val view: View = this.layoutInflater.inflate(R.layout.fragment_post_prompt, null) | ||
|
||
fieldName = view.findViewById(R.id.field_author_name) | ||
fieldTitle = view.findViewById(R.id.field_prompt_title) | ||
fieldDesc = view.findViewById(R.id.field_prompt_desc) | ||
fieldPrompt = view.findViewById(R.id.field_prompt) | ||
|
||
fieldName?.setText(requireArguments().getString("name")) | ||
fieldTitle?.setText(requireArguments().getString("title")) | ||
fieldDesc?.setText(requireArguments().getString("desc")) | ||
fieldPrompt?.setText(requireArguments().getString("prompt")) | ||
|
||
builder!!.setView(view) | ||
.setCancelable(false) | ||
.setPositiveButton("Post") { _, _ -> validateForm() } | ||
.setNegativeButton("Cancel") { _, _ -> listener!!.onCanceled() } | ||
|
||
return builder!!.create() | ||
} | ||
|
||
private fun validateForm() { | ||
if (fieldName?.text.toString().trim() == "" || fieldTitle?.text.toString().trim() == "" || fieldDesc?.text.toString().trim() == "" || fieldPrompt?.text.toString().trim() == "") { | ||
listener!!.onFormError(fieldName?.text.toString(), fieldTitle?.text.toString(), fieldDesc?.text.toString(), fieldPrompt?.text.toString()) | ||
} else { | ||
listener!!.onFormFilled(fieldName?.text.toString(), fieldTitle?.text.toString(), fieldDesc?.text.toString(), fieldPrompt?.text.toString()) | ||
} | ||
} | ||
|
||
fun setStateChangedListener(listener: StateChangesListener) { | ||
this.listener = listener | ||
} | ||
|
||
public interface StateChangesListener { | ||
public fun onFormFilled(name: String, title: String, desc: String, prompt: String) | ||
|
||
public fun onFormError(name: String, title: String, desc: String, prompt: String) | ||
public fun onCanceled() | ||
} | ||
} |
Oops, something went wrong.