EMMA Coverage Report (generated Tue Aug 20 10:07:21 PDT 2013)
[all classes][org.chromium.chromoting]

COVERAGE SUMMARY FOR SOURCE FILE [Desktop.java]

nameclass, %method, %block, %line, %
Desktop.java0%   (0/1)0%   (0/7)0%   (0/104)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Desktop0%   (0/1)0%   (0/7)0%   (0/104)0%   (0/35)
Desktop (): void 0%   (0/1)0%   (0/3)0%   (0/1)
dispatchKeyEvent (KeyEvent): boolean 0%   (0/1)0%   (0/46)0%   (0/16)
onConfigurationChanged (Configuration): void 0%   (0/1)0%   (0/7)0%   (0/3)
onCreate (Bundle): void 0%   (0/1)0%   (0/14)0%   (0/4)
onCreateOptionsMenu (Menu): boolean 0%   (0/1)0%   (0/9)0%   (0/2)
onDestroy (): void 0%   (0/1)0%   (0/4)0%   (0/3)
onOptionsItemSelected (MenuItem): boolean 0%   (0/1)0%   (0/21)0%   (0/6)

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
3// found in the LICENSE file.
4 
5package org.chromium.chromoting;
6 
7import android.app.Activity;
8import android.content.res.Configuration;
9import android.os.Bundle;
10import android.util.Log;
11import android.view.KeyEvent;
12import android.view.Menu;
13import android.view.MenuItem;
14import android.view.WindowManager;
15import android.view.inputmethod.InputMethodManager;
16 
17import org.chromium.chromoting.jni.JniInterface;
18 
19/**
20 * A simple screen that does nothing except display a DesktopView and notify it of rotations.
21 */
22public class Desktop extends Activity {
23    /** The surface that displays the remote host's desktop feed. */
24    private DesktopView remoteHostDesktop;
25 
26    /** Called when the activity is first created. */
27    @Override
28    public void onCreate(Bundle savedInstanceState) {
29        super.onCreate(savedInstanceState);
30        remoteHostDesktop = new DesktopView(this);
31        setContentView(remoteHostDesktop);
32    }
33 
34    /** Called when the activity is finally finished. */
35    @Override
36    public void onDestroy() {
37        super.onDestroy();
38        JniInterface.disconnectFromHost();
39    }
40 
41    /** Called when the display is rotated (as registered in the manifest). */
42    @Override
43    public void onConfigurationChanged(Configuration newConfig) {
44        super.onConfigurationChanged(newConfig);
45        remoteHostDesktop.requestRecheckConstrainingDimension();
46    }
47 
48    /** Called to initialize the action bar. */
49    @Override
50    public boolean onCreateOptionsMenu(Menu menu) {
51        getMenuInflater().inflate(R.menu.desktop_actionbar, menu);
52        return super.onCreateOptionsMenu(menu);
53    }
54 
55    /** Called whenever an action bar button is pressed. */
56    @Override
57    public boolean onOptionsItemSelected(MenuItem item) {
58        switch (item.getItemId()) {
59            case R.id.actionbar_keyboard:
60                ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0, 0);
61                return true;
62            case R.id.actionbar_hide:
63                getActionBar().hide();
64                return true;
65            default:
66                return super.onOptionsItemSelected(item);
67        }
68    }
69 
70    /**
71     * Called once when a keyboard key is pressed, then again when that same key is released. This
72     * is not guaranteed to be notified of all soft keyboard events: certian keyboards might not
73     * call it at all, while others might skip it in certain situations (e.g. swipe input).
74     */
75    @Override
76    public boolean dispatchKeyEvent(KeyEvent event) {
77        boolean depressed = event.getAction() == KeyEvent.ACTION_DOWN;
78 
79        switch (event.getKeyCode()) {
80            case KeyEvent.KEYCODE_AT:
81                JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
82                JniInterface.keyboardAction(KeyEvent.KEYCODE_2, depressed);
83                break;
84            case KeyEvent.KEYCODE_POUND:
85                JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
86                JniInterface.keyboardAction(KeyEvent.KEYCODE_3, depressed);
87                break;
88            case KeyEvent.KEYCODE_STAR:
89                JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
90                JniInterface.keyboardAction(KeyEvent.KEYCODE_8, depressed);
91                break;
92            case KeyEvent.KEYCODE_PLUS:
93                JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
94                JniInterface.keyboardAction(KeyEvent.KEYCODE_EQUALS, depressed);
95                break;
96            default:
97                // We try to send all other key codes to the host directly.
98                JniInterface.keyboardAction(event.getKeyCode(), depressed);
99        }
100 
101        return super.dispatchKeyEvent(event);
102    }
103}

[all classes][org.chromium.chromoting]
EMMA 2.0.5312 (C) Vladimir Roubtsov