From 4422ebb77bc0266d47bb5414ffa015e9c7d508b8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 27 Jun 2019 12:25:16 +0200 Subject: [PATCH 1/5] Remove old menu --- .../main/res/layout/fragment_home_drawer.xml | 1 + .../res/menu/vector_home_sliding_menu.xml | 58 ------------------- 2 files changed, 1 insertion(+), 58 deletions(-) delete mode 100755 vector/src/main/res/menu/vector_home_sliding_menu.xml diff --git a/vector/src/main/res/layout/fragment_home_drawer.xml b/vector/src/main/res/layout/fragment_home_drawer.xml index f12c5f8536..72371d251d 100644 --- a/vector/src/main/res/layout/fragment_home_drawer.xml +++ b/vector/src/main/res/layout/fragment_home_drawer.xml @@ -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" diff --git a/vector/src/main/res/menu/vector_home_sliding_menu.xml b/vector/src/main/res/menu/vector_home_sliding_menu.xml deleted file mode 100755 index a206bd09bf..0000000000 --- a/vector/src/main/res/menu/vector_home_sliding_menu.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 40bf3a15cde72ab134477e0eb8f835bcd96231e3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 27 Jun 2019 12:35:52 +0200 Subject: [PATCH 2/5] Move signout action to the settings General --- .../riotredesign/core/extensions/Session.kt | 4 ++++ .../features/home/HomeActivity.kt | 13 ++++++------ .../settings/VectorSettingsGeneralFragment.kt | 20 +++++++++++++++++++ .../workers/signout/SignOutUiWorker.kt | 4 ++-- .../main/res/xml/vector_settings_general.xml | 9 +++++++++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/core/extensions/Session.kt b/vector/src/main/java/im/vector/riotredesign/core/extensions/Session.kt index cc7ca45963..a3c90e3b93 100644 --- a/vector/src/main/java/im/vector/riotredesign/core/extensions/Session.kt +++ b/vector/src/main/java/im/vector/riotredesign/core/extensions/Session.kt @@ -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 } \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt index b1d1022125..1d04e3767e 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt @@ -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,10 +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()) - return true - } +// TODO Remove +// R.id.sliding_menu_sign_out -> { +// SignOutUiWorker(this, notificationDrawerManager) +// .perform(Matrix.getInstance().currentSession!!) +// return true +// } } return true diff --git a/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsGeneralFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsGeneralFragment.kt index 8b52cebc72..23c0ee7bc1 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsGeneralFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsGeneralFragment.kt @@ -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() private var mDisplayedPhoneNumber = ArrayList() @@ -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 diff --git a/vector/src/main/java/im/vector/riotredesign/features/workers/signout/SignOutUiWorker.kt b/vector/src/main/java/im/vector/riotredesign/features/workers/signout/SignOutUiWorker.kt index 3257685186..6767dfece7 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/workers/signout/SignOutUiWorker.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/workers/signout/SignOutUiWorker.kt @@ -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) { diff --git a/vector/src/main/res/xml/vector_settings_general.xml b/vector/src/main/res/xml/vector_settings_general.xml index 152bc64d4c..8bc15fefac 100644 --- a/vector/src/main/res/xml/vector_settings_general.xml +++ b/vector/src/main/res/xml/vector_settings_general.xml @@ -93,6 +93,15 @@ + + + + + + From a550743f2f35ed0f9f58561a48edee0bf33be5ab Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 27 Jun 2019 13:53:19 +0200 Subject: [PATCH 3/5] Report suggestion feature --- .../features/home/HomeActivity.kt | 10 ++--- .../features/rageshake/BugReportActivity.kt | 39 +++++++++++++++++-- .../features/rageshake/BugReporter.kt | 20 +++++++++- .../main/res/layout/activity_bug_report.xml | 5 ++- vector/src/main/res/menu/home.xml | 6 +-- vector/src/main/res/values/strings_riotX.xml | 6 +++ 6 files changed, 70 insertions(+), 16 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt index 1d04e3767e..e25e270e71 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt @@ -165,12 +165,10 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { -// TODO Remove -// R.id.sliding_menu_sign_out -> { -// SignOutUiWorker(this, notificationDrawerManager) -// .perform(Matrix.getInstance().currentSession!!) -// return true -// } + R.id.menu_home_suggestion -> { + BugReporter.openBugReportScreen(this, true) + return true + } } return true diff --git a/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReportActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReportActivity.kt index 28e3f21236..45486ee12c 100755 --- a/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReportActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReportActivity.kt @@ -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,8 +125,13 @@ class BugReportActivity : VectorBaseActivity() { override fun onUploadFailed(reason: String?) { try { if (!TextUtils.isEmpty(reason)) { - Toast.makeText(this@BugReportActivity, - getString(R.string.send_bug_report_failed, reason), Toast.LENGTH_LONG).show() + 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 { - Toast.makeText(this@BugReportActivity, R.string.send_bug_report_sent, Toast.LENGTH_LONG).show() + 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) } diff --git a/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt index 1808b47105..4b2a71502e 100755 --- a/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt @@ -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) } diff --git a/vector/src/main/res/layout/activity_bug_report.xml b/vector/src/main/res/layout/activity_bug_report.xml index 4ccb9c5ec3..bbe819769a 100644 --- a/vector/src/main/res/layout/activity_bug_report.xml +++ b/vector/src/main/res/layout/activity_bug_report.xml @@ -61,6 +61,7 @@ android:orientation="vertical"> @@ -103,6 +105,7 @@ android:textSize="12sp" /> + android:id="@+id/menu_home_suggestion" + android:icon="@drawable/ic_material_bug_report" + android:title="@string/send_suggestion" /> \ No newline at end of file diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index e2fd753e54..a338a2075b 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -40,4 +40,10 @@ Register token + Propose a suggestion + Please write your suggestion below. + Describe your suggestion here + Thanks, the suggestion has been successfully sent + The suggestion failed to be sent (%s) + \ No newline at end of file From 519f49b50d53fa8433a5f7958e4b8e5a17b2711f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 27 Jun 2019 14:01:44 +0200 Subject: [PATCH 4/5] Add report bug in the menu --- .../im/vector/riotredesign/features/home/HomeActivity.kt | 4 ++++ vector/src/main/res/menu/home.xml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt index e25e270e71..7447cb3d44 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt @@ -169,6 +169,10 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { BugReporter.openBugReportScreen(this, true) return true } + R.id.menu_home_report_bug -> { + BugReporter.openBugReportScreen(this, false) + return true + } } return true diff --git a/vector/src/main/res/menu/home.xml b/vector/src/main/res/menu/home.xml index d3b026e6db..5bfa5ac331 100644 --- a/vector/src/main/res/menu/home.xml +++ b/vector/src/main/res/menu/home.xml @@ -6,4 +6,9 @@ android:icon="@drawable/ic_material_bug_report" android:title="@string/send_suggestion" /> + + \ No newline at end of file From 2ef53e2066f16841556dc874b27f36d56108b408 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 28 Jun 2019 10:44:02 +0200 Subject: [PATCH 5/5] Fix compilation issue after rebase --- .../java/im/vector/riotredesign/features/home/HomeActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt index 7447cb3d44..71d40de54b 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt @@ -166,11 +166,11 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_home_suggestion -> { - BugReporter.openBugReportScreen(this, true) + bugReporter.openBugReportScreen(this, true) return true } R.id.menu_home_report_bug -> { - BugReporter.openBugReportScreen(this, false) + bugReporter.openBugReportScreen(this, false) return true } }