Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/Chromoting.java

Issue 2389153003: [remoting android] Close navigation drawer before opening Help/Feedback. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/Chromoting.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
index 6cfd884171550c02d3043f7bd5212d8ee15caedd..45c4627c53f1f00d36ff81930aa99ee2a79764f9 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -108,6 +108,12 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
private ActionBarDrawerToggle mDrawerToggle;
+ /**
+ * Task to be run after the navigation drawer is closed. Can be null. This is used to run
+ * Help/Feedback tasks which require a screenshot with the drawer closed.
+ */
+ private Runnable mPendingDrawerCloseTask;
+
private AccountSwitcher mAccountSwitcher;
/** The currently-connected Client, if any. */
@@ -167,6 +173,44 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
mProgressView.setVisibility(View.GONE);
}
+ private void runPendingDrawerCloseTask() {
+ // Avoid potential recursion problems by null-ing the task first.
+ Runnable task = mPendingDrawerCloseTask;
Yuwei 2016/10/04 23:41:14 Optionally you can have a queue of pending tasks r
Lambros 2016/10/05 00:03:15 Acknowledged. No need for a queue just yet.
+ mPendingDrawerCloseTask = null;
+ if (task != null) {
+ task.run();
+ }
+ }
+
+ private void closeDrawerThenRun(Runnable task) {
Yuwei 2016/10/04 23:41:14 Instead of having extra launch* methods here, coul
Lambros 2016/10/05 00:03:15 If I'm not mistaken, this would mean doubly-nested
Yuwei 2016/10/05 00:27:02 Yep. Callback hell :) Though it can be simplified
+ mPendingDrawerCloseTask = task;
+ if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
+ mDrawerLayout.closeDrawer(Gravity.START);
+ } else {
+ runPendingDrawerCloseTask();
+ }
+ }
+
+ /** Closes any navigation drawer, then shows the Help screen. */
+ public void launchHelp(final HelpContext helpContext) {
+ closeDrawerThenRun(new Runnable() {
+ @Override
+ public void run() {
+ HelpSingleton.getInstance().launchHelp(Chromoting.this, helpContext);
+ }
+ });
+ }
+
+ /** Closes any navigation drawer, then shows the Feedback screen. */
+ public void launchFeedback() {
+ closeDrawerThenRun(new Runnable() {
+ @Override
+ public void run() {
+ HelpSingleton.getInstance().launchFeedback(Chromoting.this);
+ }
+ });
+ }
+
/**
* Called when the activity is first created. Loads the native library and requests an
* authentication token from the system.
@@ -200,7 +244,13 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
- R.string.open_navigation_drawer, R.string.close_navigation_drawer);
+ R.string.open_navigation_drawer, R.string.close_navigation_drawer) {
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ runPendingDrawerCloseTask();
+ }
+ };
mDrawerLayout.addDrawerListener(mDrawerToggle);
// Disable the hamburger icon animation. This is more complex than it ought to be.
@@ -440,7 +490,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
/** Called when the user touches hyperlinked text. */
@Override
public void onClick(View view) {
- HelpSingleton.getInstance().launchHelp(this, HelpContext.HOST_SETUP);
+ launchHelp(HelpContext.HOST_SETUP);
}
private void onDeleteHostClicked(int hostIndex) {
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698