Fix UI issue on BugReportActivity (send button not visible)

This commit is contained in:
Benoit Marty 2019-06-18 09:53:09 +02:00 committed by Benoit Marty
parent 51879845f2
commit 53bdd58c1b
7 changed files with 62 additions and 132 deletions

View File

@ -332,7 +332,7 @@ abstract class VectorBaseActivity : BaseMvRxActivity() {
open fun getMenuRes() = -1

@AttrRes
open fun getMenuTint() = R.attr.vctr_icon_tint_on_dark_action_bar_color
open fun getMenuTint() = R.attr.vctr_icon_tint_on_light_action_bar_color

/**
* Return a object containing other themes for this activity

View File

@ -19,10 +19,8 @@ package im.vector.riotredesign.features.rageshake
import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.*
import android.widget.Toast
import androidx.core.view.isVisible
import butterknife.BindView
import butterknife.OnCheckedChanged
import butterknife.OnTextChanged
import im.vector.riotredesign.R
@ -35,48 +33,17 @@ import timber.log.Timber
*/
class BugReportActivity : VectorBaseActivity() {

/* ==========================================================================================
* UI
* ========================================================================================== */

@BindView(R.id.bug_report_edit_text)
lateinit var mBugReportText: EditText

@BindView(R.id.bug_report_button_include_logs)
lateinit var mIncludeLogsButton: CheckBox

@BindView(R.id.bug_report_button_include_crash_logs)
lateinit var mIncludeCrashLogsButton: CheckBox

@BindView(R.id.bug_report_button_include_screenshot)
lateinit var mIncludeScreenShotButton: CheckBox

@BindView(R.id.bug_report_screenshot_preview)
lateinit var mScreenShotPreview: ImageView

@BindView(R.id.bug_report_progress_view)
lateinit var mProgressBar: ProgressBar

@BindView(R.id.bug_report_progress_text_view)
lateinit var mProgressTextView: TextView

@BindView(R.id.bug_report_scrollview)
lateinit var mScrollView: View

@BindView(R.id.bug_report_mask_view)
lateinit var mMaskView: View

override fun getLayoutRes() = R.layout.activity_bug_report

override fun initUiAndData() {
configureToolbar(bugReportToolbar)

if (BugReporter.screenshot != null) {
mScreenShotPreview.setImageBitmap(BugReporter.screenshot)
bug_report_screenshot_preview.setImageBitmap(BugReporter.screenshot)
} else {
mScreenShotPreview.isVisible = false
mIncludeScreenShotButton.isChecked = false
mIncludeScreenShotButton.isEnabled = false
bug_report_screenshot_preview.isVisible = false
bug_report_button_include_screenshot.isChecked = false
bug_report_button_include_screenshot.isEnabled = false
}
}

@ -84,8 +51,8 @@ class BugReportActivity : VectorBaseActivity() {

override fun onPrepareOptionsMenu(menu: Menu): Boolean {
menu.findItem(R.id.ic_action_send_bug_report)?.let {
val isValid = mBugReportText.text.toString().trim().length > 10
&& !mMaskView.isVisible
val isValid = bug_report_edit_text.text.toString().trim().length > 10
&& !bug_report_mask_view.isVisible

it.isEnabled = isValid
it.icon.alpha = if (isValid) 255 else 100
@ -109,22 +76,22 @@ class BugReportActivity : VectorBaseActivity() {
* Send the bug report
*/
private fun sendBugReport() {
mScrollView.alpha = 0.3f
mMaskView.isVisible = true
bug_report_scrollview.alpha = 0.3f
bug_report_mask_view.isVisible = true

invalidateOptionsMenu()

mProgressTextView.isVisible = true
mProgressTextView.text = getString(R.string.send_bug_report_progress, 0.toString() + "")
bug_report_progress_text_view.isVisible = true
bug_report_progress_text_view.text = getString(R.string.send_bug_report_progress, "0")

mProgressBar.isVisible = true
mProgressBar.progress = 0
bug_report_progress_view.isVisible = true
bug_report_progress_view.progress = 0

BugReporter.sendBugReport(this,
mIncludeLogsButton.isChecked,
mIncludeCrashLogsButton.isChecked,
mIncludeScreenShotButton.isChecked,
mBugReportText.text.toString(),
bug_report_button_include_logs.isChecked,
bug_report_button_include_crash_logs.isChecked,
bug_report_button_include_screenshot.isChecked,
bug_report_edit_text.text.toString(),
object : BugReporter.IMXBugReportListener {
override fun onUploadFailed(reason: String?) {
try {
@ -136,10 +103,10 @@ class BugReportActivity : VectorBaseActivity() {
Timber.e(e, "## onUploadFailed() : failed to display the toast " + e.message)
}

mMaskView.isVisible = false
mProgressBar.isVisible = false
mProgressTextView.isVisible = false
mScrollView.alpha = 1.0f
bug_report_mask_view.isVisible = false
bug_report_progress_view.isVisible = false
bug_report_progress_text_view.isVisible = false
bug_report_scrollview.alpha = 1.0f

invalidateOptionsMenu()
}
@ -149,17 +116,10 @@ class BugReportActivity : VectorBaseActivity() {
}

override fun onProgress(progress: Int) {
var progress = progress
if (progress > 100) {
Timber.e("## onProgress() : progress > 100")
progress = 100
} else if (progress < 0) {
Timber.e("## onProgress() : progress < 0")
progress = 0
}
val myProgress = progress.coerceIn(0, 100)

mProgressBar.progress = progress
mProgressTextView.text = getString(R.string.send_bug_report_progress, progress.toString() + "")
bug_report_progress_view.progress = myProgress
bug_report_progress_text_view.text = getString(R.string.send_bug_report_progress, "$myProgress")
}

override fun onUploadSucceed() {
@ -174,7 +134,6 @@ class BugReportActivity : VectorBaseActivity() {
} catch (e: Exception) {
Timber.e(e, "## onUploadSucceed() : failed to dismiss the dialog " + e.message)
}

}
})
}
@ -190,7 +149,7 @@ class BugReportActivity : VectorBaseActivity() {

@OnCheckedChanged(R.id.bug_report_button_include_screenshot)
internal fun onSendScreenshotChanged() {
mScreenShotPreview.isVisible = mIncludeScreenShotButton.isChecked && BugReporter.screenshot != null
bug_report_screenshot_preview.isVisible = bug_report_button_include_screenshot.isChecked && BugReporter.screenshot != null
}

override fun onBackPressed() {
@ -199,12 +158,4 @@ class BugReportActivity : VectorBaseActivity() {

super.onBackPressed()
}

/* ==========================================================================================
* Companion
* ========================================================================================== */

companion object {
private val LOG_TAG = BugReportActivity::class.java.simpleName
}
}

View File

@ -7,6 +7,7 @@

<androidx.appcompat.widget.Toolbar
android:id="@+id/bugReportToolbar"
style="@style/VectorToolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp" />
@ -28,6 +29,7 @@
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_progress"
android:textColor="?riotx_text_primary"
android:visibility="gone"
tools:visibility="visible" />

@ -65,7 +67,8 @@
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_description" />
android:text="@string/send_bug_report_description"
android:textColor="?riotx_text_primary" />

<com.google.android.material.textfield.TextInputLayout
style="@style/VectorTextInputLayout"
@ -96,6 +99,7 @@
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_description_in_english"
android:textColor="?riotx_text_secondary"
android:textSize="12sp" />

<TextView
@ -106,67 +110,41 @@
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_logs_description" />
android:text="@string/send_bug_report_logs_description"
android:textColor="?riotx_text_primary" />

<LinearLayout
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/bug_report_button_include_logs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:checked="true"
android:text="@string/send_bug_report_include_logs" />

<CheckBox
android:id="@+id/bug_report_button_include_logs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/send_bug_report_include_logs" />
</LinearLayout>

<LinearLayout
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/bug_report_button_include_crash_logs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:checked="true"
android:text="@string/send_bug_report_include_crash_logs" />

<CheckBox
android:id="@+id/bug_report_button_include_crash_logs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/send_bug_report_include_crash_logs" />
</LinearLayout>

<LinearLayout
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/bug_report_button_include_screenshot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:id="@+id/bug_report_button_include_screenshot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/send_bug_report_include_screenshot" />
</LinearLayout>
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:checked="true"
android:text="@string/send_bug_report_include_screenshot" />

<ImageView
android:id="@+id/bug_report_screenshot_preview"
@ -189,5 +167,6 @@
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:clickable="true"
android:focusable="true"
android:visibility="gone" />
</LinearLayout>

View File

@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.matrix.vector.activity.RoomActivity">
tools:context=".features.rageshake.BugReportActivity">

<item
android:id="@+id/ic_action_send_bug_report"

View File

@ -135,7 +135,7 @@

<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@android:color/white</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@android:color/white</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@color/riotx_accent</item>
<item name="vctr_icon_tint_on_dark_action_bar_color">@android:color/white</item>

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->

View File

@ -136,7 +136,7 @@

<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@android:color/black</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@android:color/white</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@color/riotx_accent</item>
<item name="vctr_icon_tint_on_dark_action_bar_color">@android:color/white</item>

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->

View File

@ -94,7 +94,7 @@

<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@color/accent_color_status</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@android:color/white</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@color/riotx_accent</item>
<item name="vctr_icon_tint_on_dark_action_bar_color">@android:color/white</item>

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->