OLD | NEW |
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.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.app.ProgressDialog; | 8 import android.app.ProgressDialog; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.content.Intent; | 10 import android.content.Intent; |
11 import android.content.SharedPreferences; | 11 import android.content.SharedPreferences; |
12 import android.content.pm.PackageManager; | 12 import android.content.pm.PackageManager; |
13 import android.content.res.Configuration; | 13 import android.content.res.Configuration; |
14 import android.graphics.drawable.Drawable; | 14 import android.graphics.drawable.Drawable; |
15 import android.os.Bundle; | 15 import android.os.Bundle; |
16 import android.provider.Settings; | 16 import android.provider.Settings; |
| 17 import android.support.v4.content.ContextCompat; |
17 import android.support.v4.graphics.drawable.DrawableCompat; | 18 import android.support.v4.graphics.drawable.DrawableCompat; |
18 import android.support.v4.widget.DrawerLayout; | 19 import android.support.v4.widget.DrawerLayout; |
19 import android.support.v7.app.ActionBarDrawerToggle; | 20 import android.support.v7.app.ActionBarDrawerToggle; |
20 import android.support.v7.app.AlertDialog; | 21 import android.support.v7.app.AlertDialog; |
21 import android.support.v7.app.AppCompatActivity; | 22 import android.support.v7.app.AppCompatActivity; |
22 import android.support.v7.widget.Toolbar; | 23 import android.support.v7.widget.Toolbar; |
23 import android.view.ContextMenu; | 24 import android.view.ContextMenu; |
24 import android.view.Gravity; | 25 import android.view.Gravity; |
25 import android.view.Menu; | 26 import android.view.Menu; |
26 import android.view.MenuItem; | 27 import android.view.MenuItem; |
27 import android.view.View; | 28 import android.view.View; |
28 import android.widget.AdapterView; | 29 import android.widget.AdapterView; |
29 import android.widget.ArrayAdapter; | 30 import android.widget.ArrayAdapter; |
30 import android.widget.LinearLayout; | 31 import android.widget.LinearLayout; |
31 import android.widget.ListView; | 32 import android.widget.ListView; |
32 import android.widget.Toast; | 33 import android.widget.Toast; |
33 | 34 |
34 import org.chromium.base.ApiCompatibilityUtils; | |
35 import org.chromium.base.Log; | 35 import org.chromium.base.Log; |
36 import org.chromium.chromoting.accountswitcher.AccountSwitcher; | 36 import org.chromium.chromoting.accountswitcher.AccountSwitcher; |
37 import org.chromium.chromoting.accountswitcher.AccountSwitcherFactory; | 37 import org.chromium.chromoting.accountswitcher.AccountSwitcherFactory; |
38 import org.chromium.chromoting.base.OAuthTokenFetcher; | 38 import org.chromium.chromoting.base.OAuthTokenFetcher; |
39 import org.chromium.chromoting.help.HelpContext; | 39 import org.chromium.chromoting.help.HelpContext; |
40 import org.chromium.chromoting.help.HelpSingleton; | 40 import org.chromium.chromoting.help.HelpSingleton; |
41 import org.chromium.chromoting.jni.Client; | 41 import org.chromium.chromoting.jni.Client; |
42 import org.chromium.chromoting.jni.ConnectionListener; | 42 import org.chromium.chromoting.jni.ConnectionListener; |
43 import org.chromium.chromoting.jni.JniInterface; | 43 import org.chromium.chromoting.jni.JniInterface; |
44 | 44 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 }); | 195 }); |
196 | 196 |
197 mProgressView = findViewById(R.id.hostList_progress); | 197 mProgressView = findViewById(R.id.hostList_progress); |
198 | 198 |
199 findViewById(R.id.host_setup_link_android).setOnClickListener(this); | 199 findViewById(R.id.host_setup_link_android).setOnClickListener(this); |
200 | 200 |
201 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); | 201 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); |
202 mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, | 202 mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, |
203 R.string.open_navigation_drawer, R.string.close_navigation_drawe
r); | 203 R.string.open_navigation_drawer, R.string.close_navigation_drawe
r); |
204 mDrawerLayout.setDrawerListener(mDrawerToggle); | 204 mDrawerLayout.addDrawerListener(mDrawerToggle); |
205 | 205 |
206 // Disable the hamburger icon animation. This is more complex than it ou
ght to be. | 206 // Disable the hamburger icon animation. This is more complex than it ou
ght to be. |
207 // The animation can be customized by tweaking some style parameters - s
ee | 207 // The animation can be customized by tweaking some style parameters - s
ee |
208 // http://developer.android.com/reference/android/support/v7/appcompat/R
.styleable.html#DrawerArrowToggle . | 208 // http://developer.android.com/reference/android/support/v7/appcompat/R
.styleable.html#DrawerArrowToggle . |
209 // But these can't disable the animation completely. | 209 // But these can't disable the animation completely. |
210 // The icon can only be changed by disabling the drawer indicator, which
has side-effects | 210 // The icon can only be changed by disabling the drawer indicator, which
has side-effects |
211 // that must be worked around. It disables the built-in click listener,
so this has to be | 211 // that must be worked around. It disables the built-in click listener,
so this has to be |
212 // implemented and added. This also requires that the toolbar be passed
to the | 212 // implemented and added. This also requires that the toolbar be passed
to the |
213 // ActionBarDrawerToggle ctor above (otherwise the listener is ignored a
nd warnings are | 213 // ActionBarDrawerToggle ctor above (otherwise the listener is ignored a
nd warnings are |
214 // logged). | 214 // logged). |
(...skipping 10 matching lines...) Expand all Loading... |
225 if (mDrawerLayout.isDrawerOpen(Gravity.START)) { | 225 if (mDrawerLayout.isDrawerOpen(Gravity.START)) { |
226 mDrawerLayout.closeDrawer(Gravity.START); | 226 mDrawerLayout.closeDrawer(Gravity.START); |
227 } else { | 227 } else { |
228 mDrawerLayout.openDrawer(Gravity.START); | 228 mDrawerLayout.openDrawer(Gravity.START); |
229 } | 229 } |
230 } | 230 } |
231 }); | 231 }); |
232 | 232 |
233 // Set the three-line icon instead of the default which is a tinted arro
w icon. | 233 // Set the three-line icon instead of the default which is a tinted arro
w icon. |
234 getSupportActionBar().setDisplayHomeAsUpEnabled(true); | 234 getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
235 Drawable menuIcon = ApiCompatibilityUtils.getDrawable(getResources(), R.
drawable.ic_menu); | 235 Drawable menuIcon = ContextCompat.getDrawable(this, R.drawable.ic_menu); |
236 DrawableCompat.setTint(menuIcon.mutate(), | 236 DrawableCompat.setTint(menuIcon.mutate(), |
237 ChromotingUtil.getColorAttribute(this, R.attr.colorControlNormal
)); | 237 ChromotingUtil.getColorAttribute(this, R.attr.colorControlNormal
)); |
238 getSupportActionBar().setHomeAsUpIndicator(menuIcon); | 238 getSupportActionBar().setHomeAsUpIndicator(menuIcon); |
239 | 239 |
240 mAccountSwitcher = AccountSwitcherFactory.getInstance().createAccountSwi
tcher(this, this); | 240 mAccountSwitcher = AccountSwitcherFactory.getInstance().createAccountSwi
tcher(this, this); |
241 mAccountSwitcher.setNavigation(NavigationMenuAdapter.createNavigationMen
u(this)); | 241 mAccountSwitcher.setNavigation(NavigationMenuAdapter.createNavigationMen
u(this)); |
242 LinearLayout navigationDrawer = (LinearLayout) findViewById(R.id.navigat
ion_drawer); | 242 LinearLayout navigationDrawer = (LinearLayout) findViewById(R.id.navigat
ion_drawer); |
243 mAccountSwitcher.setDrawer(navigationDrawer); | 243 mAccountSwitcher.setDrawer(navigationDrawer); |
244 View switcherView = mAccountSwitcher.getView(); | 244 View switcherView = mAccountSwitcher.getView(); |
245 switcherView.setLayoutParams(new LinearLayout.LayoutParams( | 245 switcherView.setLayoutParams(new LinearLayout.LayoutParams( |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 // Unreachable, but required by Google Java style and findbugs. | 675 // Unreachable, but required by Google Java style and findbugs. |
676 assert false : "Unreached"; | 676 assert false : "Unreached"; |
677 } | 677 } |
678 | 678 |
679 if (dismissProgress && mProgressIndicator != null) { | 679 if (dismissProgress && mProgressIndicator != null) { |
680 mProgressIndicator.dismiss(); | 680 mProgressIndicator.dismiss(); |
681 mProgressIndicator = null; | 681 mProgressIndicator = null; |
682 } | 682 } |
683 } | 683 } |
684 } | 684 } |
OLD | NEW |