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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/Desktop.java

Issue 273313003: Fix lint issues with Chromoting for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.annotation.TargetApi;
7 import android.app.Activity; 8 import android.app.Activity;
8 import android.content.res.Configuration; 9 import android.content.res.Configuration;
9 import android.os.Build; 10 import android.os.Build;
10 import android.os.Bundle; 11 import android.os.Bundle;
11 import android.view.KeyEvent; 12 import android.view.KeyEvent;
12 import android.view.Menu; 13 import android.view.Menu;
13 import android.view.MenuItem; 14 import android.view.MenuItem;
14 import android.view.View; 15 import android.view.View;
15 import android.view.inputmethod.InputMethodManager; 16 import android.view.inputmethod.InputMethodManager;
16 import android.widget.ImageButton; 17 import android.widget.ImageButton;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 @Override 73 @Override
73 public void onSystemUiVisibilityChange(int visibility) { 74 public void onSystemUiVisibilityChange(int visibility) {
74 // Ensure the action-bar's visibility matches that of the system control s. This 75 // Ensure the action-bar's visibility matches that of the system control s. This
75 // minimizes the number of states the UI can be in, to keep things simpl e for the user. 76 // minimizes the number of states the UI can be in, to keep things simpl e for the user.
76 77
77 // Determine if the system is in fullscreen/lights-out mode. LOW_PROFILE is needed since 78 // Determine if the system is in fullscreen/lights-out mode. LOW_PROFILE is needed since
78 // it's the only flag supported in 4.0. But it is not sufficient in itse lf; when 79 // it's the only flag supported in 4.0. But it is not sufficient in itse lf; when
79 // IMMERSIVE_STICKY mode is used, the system clears this flag (leaving t he FULLSCREEN flag 80 // IMMERSIVE_STICKY mode is used, the system clears this flag (leaving t he FULLSCREEN flag
80 // set) when the user swipes the edge to reveal the bars temporarily. Wh en this happens, 81 // set) when the user swipes the edge to reveal the bars temporarily. Wh en this happens,
81 // the action-bar should remain hidden. 82 // the action-bar should remain hidden.
82 int fullscreenFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; 83 int fullscreenFlags = getSystemUiFlags();
83 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
84 fullscreenFlags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
85 }
86 if ((visibility & fullscreenFlags) != 0) { 84 if ((visibility & fullscreenFlags) != 0) {
87 hideActionBar(); 85 hideActionBar();
88 } else { 86 } else {
89 showActionBar(); 87 showActionBar();
90 } 88 }
91 } 89 }
92 90
91 @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
92 private int getSystemUiFlags() {
93 int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
94 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
95 flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
96 }
97 return flags;
98 }
99
93 public void showActionBar() { 100 public void showActionBar() {
94 mOverlayButton.setVisibility(View.INVISIBLE); 101 mOverlayButton.setVisibility(View.INVISIBLE);
95 getActionBar().show(); 102 getActionBar().show();
96 103
97 View decorView = getWindow().getDecorView(); 104 View decorView = getWindow().getDecorView();
98 decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); 105 decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
99 } 106 }
100 107
101 public void hideActionBar() { 108 public void hideActionBar() {
102 mOverlayButton.setVisibility(View.VISIBLE); 109 mOverlayButton.setVisibility(View.VISIBLE);
103 getActionBar().hide(); 110 getActionBar().hide();
104 111
105 View decorView = getWindow().getDecorView(); 112 View decorView = getWindow().getDecorView();
106 113
107 // LOW_PROFILE gives the status and navigation bars a "lights-out" appea rance. 114 // LOW_PROFILE gives the status and navigation bars a "lights-out" appea rance.
108 // FULLSCREEN hides the status bar on supported devices (4.1 and above). 115 // FULLSCREEN hides the status bar on supported devices (4.1 and above).
109 int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE; 116 int flags = getSystemUiFlags();
110 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
111 flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
112 }
113 117
114 // HIDE_NAVIGATION hides the navigation bar. However, if the user touche s the screen, the 118 // HIDE_NAVIGATION hides the navigation bar. However, if the user touche s the screen, the
115 // event is not seen by the application and instead the navigation bar i s re-shown. 119 // event is not seen by the application and instead the navigation bar i s re-shown.
116 // IMMERSIVE(_STICKY) fixes this problem and allows the user to interact with the app while 120 // IMMERSIVE(_STICKY) fixes this problem and allows the user to interact with the app while
117 // keeping the navigation controls hidden. This flag was introduced in 4 .4, later than 121 // keeping the navigation controls hidden. This flag was introduced in 4 .4, later than
118 // HIDE_NAVIGATION, and so a runtime check is needed before setting eith er of these flags. 122 // HIDE_NAVIGATION, and so a runtime check is needed before setting eith er of these flags.
119 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 123 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
120 flags |= (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_ IMMERSIVE_STICKY); 124 flags |= (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_ IMMERSIVE_STICKY);
121 } 125 }
122 126
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 break; 216 break;
213 217
214 default: 218 default:
215 // We try to send all other key codes to the host directly. 219 // We try to send all other key codes to the host directly.
216 JniInterface.sendKeyEvent(event.getKeyCode(), depressed); 220 JniInterface.sendKeyEvent(event.getKeyCode(), depressed);
217 } 221 }
218 222
219 return super.dispatchKeyEvent(event); 223 return super.dispatchKeyEvent(event);
220 } 224 }
221 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698