Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add TRY button in the Skills List #2493 #2494

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface SkillFragmentCallback {
fun loadDetailFragment(skillData: SkillData?, skillGroup: String?, skillTag: String)

fun loadGroupWiseSkillsFragment(group: String)

fun tryButtonClicked(position: Int, data: SkillData)
}
12 changes: 12 additions & 0 deletions app/src/main/java/org/fossasia/susi/ai/skills/SkillsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ class SkillsActivity : AppCompatActivity(), SkillFragmentCallback {
.commit()
}

override fun tryButtonClicked(position: Int, data: SkillData) {
overridePendingTransition(R.anim.trans_right_in, R.anim.trans_right_out)
val intent = Intent(this@SkillsActivity, ChatActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
if (data.examples.isNotEmpty())
intent.putExtra("example", data.examples[0])
else
intent.putExtra("example", "")
startActivity(intent)
finish()
}

fun handleOnLoadingFragment() {
hideSoftKeyboard(this, window.decorView)
if (isSearchOpened) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.support.annotation.NonNull
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.fossasia.susi.ai.R
import org.fossasia.susi.ai.helper.Utils
Expand Down Expand Up @@ -45,6 +46,15 @@ class SkillListAdapter(val context: Context, private val skillDetails: List<Skil
holder.skillRatingBar.rating = stars.averageStar
holder.totalRatings.text = stars.totalStar.toString()
}

// if skill data is empty, button visibility gone
if (skillData.examples.isEmpty()) {
holder.skillItemTryButton.visibility = View.GONE
}
// sent skill data on try button clicked
holder.skillItemTryButton.setOnClickListener({
skillCallback.tryButtonClicked(position, skillDetails?.get(position))
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package org.fossasia.susi.ai.skills.skilllisting.adapters.viewholders

import android.support.v7.widget.RecyclerView
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.RatingBar
import android.widget.TextView
import kotlinx.android.synthetic.main.fragment_skill_details.*
import kotterknife.bindView
import org.fossasia.susi.ai.R

Expand All @@ -15,6 +17,7 @@ class SkillViewHolder(itemView: View, private val listener: ClickListener?) : Re
val skillPreviewExample: TextView by bindView(R.id.skill_preview_example)
val skillRatingBar: RatingBar by bindView(R.id.cv_rating_bar)
val totalRatings: TextView by bindView(R.id.cv_total_ratings)
val skillItemTryButton: Button by bindView(R.id.skillItemTryButton)

init {
itemView.setOnClickListener(this)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/item_skill.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@
android:text="@string/digit_zero"
android:textColor="@color/colorPrimary" />

<Button
android:id="@+id/skillItemTryButton"
android:layout_width="@dimen/button_width_skill_details"
android:layout_height="@dimen/button_height_skill_details"
android:layout_marginEnd="@dimen/margin_small"
android:layout_marginRight="@dimen/margin_small"
android:layout_marginBottom="@dimen/margin_small"
android:backgroundTint="@color/colorPrimary"
android:text="@string/try_it"
android:textColor="@color/md_white_1000" />

</LinearLayout>
</LinearLayout>

Expand Down