Skip to content

Commit

Permalink
Interstitial commit AndraxDev#2 for v1.10.0-beta11
Browse files Browse the repository at this point in the history
  • Loading branch information
AndraxDev committed Mar 25, 2023
1 parent c08407d commit 2710a44
Show file tree
Hide file tree
Showing 43 changed files with 910 additions and 8 deletions.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
20 changes: 19 additions & 1 deletion .idea/sonarlint/issuestore/index.pb

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

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
20 changes: 19 additions & 1 deletion .idea/sonarlint/securityhotspotstore/index.pb

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ dependencies {
implementation "io.noties.markwon:ext-tasklist:4.6.2"
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,27 @@
android:launchMode="singleTask">
</activity>

<activity
android:name=".PromptViewActivity"
android:exported="false"
android:theme="@style/Theme.App"
android:launchMode="singleTask">
</activity>

<activity
android:name=".onboarding.WelcomeActivity"
android:exported="false"
android:theme="@style/UI.Fade"
android:launchMode="singleTask">
</activity>

<activity
android:name=".AboutActivity"
android:exported="false"
android:theme="@style/UI.Fade"
android:launchMode="singleTask">
</activity>

<activity
android:name=".onboarding.TermsActivity"
android:exported="false"
Expand Down
76 changes: 76 additions & 0 deletions app/src/main/java/org/teslasoft/assistant/AboutActivity.kt
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)
}
}
}
7 changes: 7 additions & 0 deletions app/src/main/java/org/teslasoft/assistant/Api.kt
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 app/src/main/java/org/teslasoft/assistant/PromptViewActivity.kt
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
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.teslasoft.assistant.adapters

import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.Fragment
import org.teslasoft.assistant.PromptViewActivity
import org.teslasoft.assistant.R

class PromptAdapter(data: ArrayList<HashMap<String, String>>?, context: Fragment) : BaseAdapter() {
Expand Down Expand Up @@ -47,7 +49,10 @@ class PromptAdapter(data: ArrayList<HashMap<String, String>>?, context: Fragment
likesCounter.text = dataArray?.get(position)?.get("likes")

bacground.setOnClickListener {

val i = Intent(mContext.requireActivity(), PromptViewActivity::class.java)
i.putExtra("id", dataArray?.get(position)?.get("id"))
i.putExtra("title", dataArray?.get(position)?.get("name"))
mContext.requireActivity().startActivity(i)
}

return mView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ChatsListFragment : Fragment() {
}

override fun onError() {
Toast.makeText(requireActivity(), "Error", Toast.LENGTH_SHORT).show()
Toast.makeText(requireActivity(), "Please fill name field", Toast.LENGTH_SHORT).show()

val chatDialogFragment: AddChatDialogFragment = AddChatDialogFragment.newInstance("")
chatDialogFragment.setStateChangedListener(this)
Expand Down
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()
}
}
Loading

0 comments on commit 2710a44

Please sign in to comment.