Merge pull request #233 from vector-im/feature/suggestion
Feature suggestion
This commit is contained in:
commit
83ceb36a12
|
@ -29,4 +29,8 @@ fun Session.configureAndStart(pushRuleTriggerListener: PushRuleTriggerListener)
|
|||
refreshPushers()
|
||||
pushRuleTriggerListener.startWithSession(this)
|
||||
fetchPushRules()
|
||||
|
||||
// TODO P1 From HomeActivity
|
||||
// @Inject lateinit var incomingVerificationRequestHandler: IncomingVerificationRequestHandler
|
||||
// @Inject lateinit var keyRequestHandler: KeyRequestHandler
|
||||
}
|
|
@ -29,7 +29,6 @@ import androidx.fragment.app.FragmentManager
|
|||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import com.airbnb.mvrx.viewModel
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.di.ActiveSessionHolder
|
||||
import im.vector.riotredesign.core.di.ScreenComponent
|
||||
|
@ -44,9 +43,7 @@ import im.vector.riotredesign.features.crypto.keysrequest.KeyRequestHandler
|
|||
import im.vector.riotredesign.features.crypto.verification.IncomingVerificationRequestHandler
|
||||
import im.vector.riotredesign.features.disclaimer.showDisclaimerDialog
|
||||
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
||||
import im.vector.riotredesign.features.rageshake.BugReporter
|
||||
import im.vector.riotredesign.features.rageshake.VectorUncaughtExceptionHandler
|
||||
import im.vector.riotredesign.features.workers.signout.SignOutUiWorker
|
||||
import im.vector.riotredesign.features.workers.signout.SignOutViewModel
|
||||
import im.vector.riotredesign.push.fcm.FcmHelper
|
||||
import kotlinx.android.synthetic.main.activity_home.*
|
||||
|
@ -168,8 +165,12 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.sliding_menu_sign_out -> {
|
||||
SignOutUiWorker(this, notificationDrawerManager).perform(activeSessionHolder.getActiveSession())
|
||||
R.id.menu_home_suggestion -> {
|
||||
bugReporter.openBugReportScreen(this, true)
|
||||
return true
|
||||
}
|
||||
R.id.menu_home_report_bug -> {
|
||||
bugReporter.openBugReportScreen(this, false)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import im.vector.riotredesign.core.di.ScreenComponent
|
|||
import im.vector.riotredesign.core.platform.VectorBaseActivity
|
||||
import kotlinx.android.synthetic.main.activity_bug_report.*
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Form to send a bug report
|
||||
|
@ -42,6 +41,8 @@ class BugReportActivity : VectorBaseActivity() {
|
|||
|
||||
override fun getLayoutRes() = R.layout.activity_bug_report
|
||||
|
||||
private var forSuggestion: Boolean = false
|
||||
|
||||
override fun initUiAndData() {
|
||||
configureToolbar(bugReportToolbar)
|
||||
|
||||
|
@ -52,6 +53,26 @@ class BugReportActivity : VectorBaseActivity() {
|
|||
bug_report_button_include_screenshot.isChecked = false
|
||||
bug_report_button_include_screenshot.isEnabled = false
|
||||
}
|
||||
|
||||
forSuggestion = intent.getBooleanExtra("FOR_SUGGESTION", false)
|
||||
|
||||
// Default screen is for bug report, so modify it for suggestion
|
||||
if (forSuggestion) {
|
||||
supportActionBar?.setTitle(R.string.send_suggestion)
|
||||
|
||||
bug_report_first_text.setText(R.string.send_suggestion_content)
|
||||
bug_report_text_input_layout.hint = getString(R.string.send_suggestion_report_placeholder)
|
||||
|
||||
bug_report_logs_description.isVisible = false
|
||||
|
||||
bug_report_button_include_logs.isChecked = false
|
||||
bug_report_button_include_logs.isVisible = false
|
||||
|
||||
bug_report_button_include_crash_logs.isChecked = false
|
||||
bug_report_button_include_crash_logs.isVisible = false
|
||||
|
||||
// Keep the screenshot
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMenuRes() = R.menu.bug_report
|
||||
|
@ -95,6 +116,7 @@ class BugReportActivity : VectorBaseActivity() {
|
|||
bug_report_progress_view.progress = 0
|
||||
|
||||
bugReporter.sendBugReport(this,
|
||||
forSuggestion,
|
||||
bug_report_button_include_logs.isChecked,
|
||||
bug_report_button_include_crash_logs.isChecked,
|
||||
bug_report_button_include_screenshot.isChecked,
|
||||
|
@ -103,9 +125,14 @@ class BugReportActivity : VectorBaseActivity() {
|
|||
override fun onUploadFailed(reason: String?) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(reason)) {
|
||||
if (forSuggestion) {
|
||||
Toast.makeText(this@BugReportActivity,
|
||||
getString(R.string.send_suggestion_failed, reason), Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
Toast.makeText(this@BugReportActivity,
|
||||
getString(R.string.send_bug_report_failed, reason), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## onUploadFailed() : failed to display the toast " + e.message)
|
||||
}
|
||||
|
@ -131,7 +158,11 @@ class BugReportActivity : VectorBaseActivity() {
|
|||
|
||||
override fun onUploadSucceed() {
|
||||
try {
|
||||
if (forSuggestion) {
|
||||
Toast.makeText(this@BugReportActivity, R.string.send_suggestion_sent, Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
Toast.makeText(this@BugReportActivity, R.string.send_bug_report_sent, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## onUploadSucceed() : failed to dismiss the toast " + e.message)
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
|||
* Send a bug report.
|
||||
*
|
||||
* @param context the application context
|
||||
* @param forSuggestion true to send a suggestion
|
||||
* @param withDevicesLogs true to include the device log
|
||||
* @param withCrashLogs true to include the crash logs
|
||||
* @param withScreenshot true to include the screenshot
|
||||
|
@ -136,6 +137,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
|||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
fun sendBugReport(context: Context,
|
||||
forSuggestion: Boolean,
|
||||
withDevicesLogs: Boolean,
|
||||
withCrashLogs: Boolean,
|
||||
withScreenshot: Boolean,
|
||||
|
@ -208,9 +210,17 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
|||
}
|
||||
|
||||
if (!mIsCancelled) {
|
||||
val text = "[RiotX] " +
|
||||
if (forSuggestion) {
|
||||
"[Suggestion] "
|
||||
} else {
|
||||
""
|
||||
} +
|
||||
bugDescription
|
||||
|
||||
// build the multi part request
|
||||
val builder = BugReporterMultipartBody.Builder()
|
||||
.addFormDataPart("text", "[RiotX] $bugDescription")
|
||||
.addFormDataPart("text", text)
|
||||
.addFormDataPart("app", "riot-android")
|
||||
.addFormDataPart("user_agent", Matrix.getInstance(context).getUserAgent())
|
||||
.addFormDataPart("user_id", userId)
|
||||
|
@ -276,6 +286,11 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
|||
// Special for RiotX
|
||||
builder.addFormDataPart("label", "[RiotX]")
|
||||
|
||||
// Suggestion
|
||||
if (forSuggestion) {
|
||||
builder.addFormDataPart("label", "[Suggestion]")
|
||||
}
|
||||
|
||||
if (getCrashFile(context).exists()) {
|
||||
builder.addFormDataPart("label", "crash")
|
||||
deleteCrashFile(context)
|
||||
|
@ -418,10 +433,11 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
|||
/**
|
||||
* Send a bug report either with email or with Vector.
|
||||
*/
|
||||
fun openBugReportScreen(activity: Activity) {
|
||||
fun openBugReportScreen(activity: Activity, forSuggestion: Boolean = true) {
|
||||
screenshot = takeScreenshot(activity)
|
||||
|
||||
val intent = Intent(activity, BugReportActivity::class.java)
|
||||
intent.putExtra("FOR_SUGGESTION", forSuggestion)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ import androidx.preference.Preference
|
|||
import androidx.preference.PreferenceCategory
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.di.ActiveSessionHolder
|
||||
import im.vector.riotredesign.core.extensions.showPassword
|
||||
import im.vector.riotredesign.core.platform.SimpleTextWatcher
|
||||
import im.vector.riotredesign.core.preference.UserAvatarPreference
|
||||
|
@ -44,15 +46,21 @@ import im.vector.riotredesign.core.utils.allGranted
|
|||
import im.vector.riotredesign.core.utils.copyToClipboard
|
||||
import im.vector.riotredesign.core.utils.toast
|
||||
import im.vector.riotredesign.features.MainActivity
|
||||
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
||||
import im.vector.riotredesign.features.themes.ThemeUtils
|
||||
import im.vector.riotredesign.features.workers.signout.SignOutUiWorker
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
||||
|
||||
override var titleRes = R.string.settings_general_title
|
||||
override val preferenceXmlRes = R.xml.vector_settings_general
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
|
||||
private var mDisplayedEmails = ArrayList<String>()
|
||||
private var mDisplayedPhoneNumber = ArrayList<String>()
|
||||
|
||||
|
@ -227,6 +235,18 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
// Sign out
|
||||
findPreference("SETTINGS_SIGN_OUT_KEY")
|
||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
activity?.let {
|
||||
SignOutUiWorker(requireActivity(), notificationDrawerManager)
|
||||
.perform(activeSessionHolder.getActiveSession())
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
// Deactivate account section
|
||||
|
||||
// deactivate account
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
package im.vector.riotredesign.features.workers.signout
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.platform.VectorBaseActivity
|
||||
import im.vector.riotredesign.features.MainActivity
|
||||
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
||||
|
||||
class SignOutUiWorker(private val activity: VectorBaseActivity,
|
||||
class SignOutUiWorker(private val activity: FragmentActivity,
|
||||
private val notificationDrawerManager: NotificationDrawerManager) {
|
||||
|
||||
fun perform(session: Session) {
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bug_report_first_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
|
@ -71,6 +72,7 @@
|
|||
android:textColor="?riotx_text_primary" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/bug_report_text_input_layout"
|
||||
style="@style/VectorTextInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -79,13 +81,13 @@
|
|||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:hint="@string/send_bug_report_placeholder"
|
||||
android:textColorHint="?attr/vctr_default_text_hint_color">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/bug_report_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/send_bug_report_placeholder"
|
||||
android:minHeight="40dp"
|
||||
android:textColor="?riotx_text_primary" />
|
||||
|
||||
|
@ -103,6 +105,7 @@
|
|||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bug_report_logs_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/room_sliding_menu_settings"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_settings_x"
|
||||
android:tint="@android:color/white"
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_sign_out"
|
||||
android:icon="@drawable/ic_material_exit_to_app"
|
||||
android:title="@string/action_sign_out" />
|
||||
android:id="@+id/menu_home_suggestion"
|
||||
android:icon="@drawable/ic_material_bug_report"
|
||||
android:title="@string/send_suggestion" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_home_report_bug"
|
||||
android:icon="@drawable/ic_material_bug_report"
|
||||
android:title="@string/send_bug_report" />
|
||||
|
||||
</menu>
|
|
@ -1,58 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<group android:id="@+id/account_group">
|
||||
<item
|
||||
android:id="@+id/sliding_menu_messages"
|
||||
android:icon="@drawable/logo_transparent"
|
||||
android:title="@string/room_sliding_menu_messages" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_settings"
|
||||
android:icon="@drawable/ic_settings_x"
|
||||
android:title="@string/room_sliding_menu_settings" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_send_bug_report"
|
||||
android:icon="@drawable/ic_material_bug_report"
|
||||
android:title="@string/send_bug_report" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_exit"
|
||||
android:icon="@drawable/ic_power_settings"
|
||||
android:title="@string/action_exit" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_sign_out"
|
||||
android:icon="@drawable/ic_material_exit_to_app"
|
||||
android:title="@string/action_sign_out" />
|
||||
</group>
|
||||
|
||||
<group android:id="@+id/app_group">
|
||||
<item
|
||||
android:id="@+id/sliding_menu_version"
|
||||
android:title="@string/room_sliding_menu_version" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_copyright_terms"
|
||||
android:title="@string/room_sliding_menu_copyright" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_app_tac"
|
||||
android:title="@string/room_sliding_menu_term_and_conditions" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_privacy_policy"
|
||||
android:title="@string/room_sliding_menu_privacy_policy" />
|
||||
|
||||
<item
|
||||
android:id="@+id/sliding_menu_third_party_notices"
|
||||
android:title="@string/room_sliding_menu_third_party_notices" />
|
||||
</group>
|
||||
|
||||
<group android:visible="@bool/debug_mode">
|
||||
<item
|
||||
android:id="@+id/sliding_menu_debug"
|
||||
android:title="@string/debug_screen" />
|
||||
</group>
|
||||
</menu>
|
|
@ -40,4 +40,10 @@
|
|||
|
||||
<string name="settings_troubleshoot_test_token_registration_quick_fix">Register token</string>
|
||||
|
||||
<string name="send_suggestion">Propose a suggestion</string>
|
||||
<string name="send_suggestion_content">Please write your suggestion below.</string>
|
||||
<string name="send_suggestion_report_placeholder">Describe your suggestion here</string>
|
||||
<string name="send_suggestion_sent">Thanks, the suggestion has been successfully sent</string>
|
||||
<string name="send_suggestion_failed">The suggestion failed to be sent (%s)</string>
|
||||
|
||||
</resources>
|
|
@ -93,6 +93,15 @@
|
|||
|
||||
<im.vector.riotredesign.core.preference.VectorPreferenceDivider />
|
||||
|
||||
<im.vector.riotredesign.core.preference.VectorPreferenceCategory
|
||||
android:title="@string/action_sign_out">
|
||||
|
||||
<im.vector.riotredesign.core.preference.VectorPreference
|
||||
android:key="SETTINGS_SIGN_OUT_KEY"
|
||||
android:title="@string/action_sign_out" />
|
||||
|
||||
</im.vector.riotredesign.core.preference.VectorPreferenceCategory>
|
||||
|
||||
<im.vector.riotredesign.core.preference.VectorPreferenceCategory
|
||||
android:key="SETTINGS_DEACTIVATE_ACCOUNT_CATEGORY_KEY"
|
||||
android:title="@string/settings_deactivate_account_section">
|
||||
|
|
Loading…
Reference in New Issue