Skip to content

Commit

Permalink
Merge pull request vx#120 from alescdb/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kruton committed Aug 8, 2015
2 parents 9cd914c + 74c3c37 commit a4c5300
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 46 deletions.
56 changes: 51 additions & 5 deletions app/src/main/java/org/connectbot/ConsoleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -116,7 +117,7 @@ public class ConsoleActivity extends Activity {
private TextView booleanPrompt;
private Button booleanYes, booleanNo;

private RelativeLayout keyboardGroup;
private LinearLayout keyboardGroup;
private Runnable keyboardGroupHider;

private TextView empty;
Expand Down Expand Up @@ -371,7 +372,7 @@ public void onClick(View v) {

inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

keyboardGroup = (RelativeLayout) findViewById(R.id.keyboard_group);
keyboardGroup = (LinearLayout) findViewById(R.id.keyboard_group);

mKeyboardButton = (ImageView) findViewById(R.id.button_keyboard);
mKeyboardButton.setOnClickListener(new OnClickListener() {
Expand All @@ -385,7 +386,7 @@ public void onClick(View view) {
}
});

final ImageView ctrlButton = (ImageView) findViewById(R.id.button_ctrl);
final Button ctrlButton = (Button) findViewById(R.id.button_ctrl);
ctrlButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
TerminalView terminal = adapter.getCurrentTerminalView();
Expand All @@ -397,7 +398,7 @@ public void onClick(View view) {
}
});

final ImageView escButton = (ImageView) findViewById(R.id.button_esc);
final Button escButton = (Button) findViewById(R.id.button_esc);
escButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
TerminalView terminal = adapter.getCurrentTerminalView();
Expand All @@ -409,7 +410,7 @@ public void onClick(View view) {
}
});

final ImageView tabButton = (ImageView) findViewById(R.id.button_tab);
final Button tabButton = (Button) findViewById(R.id.button_tab);
tabButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
TerminalView terminal = adapter.getCurrentTerminalView();
Expand All @@ -420,6 +421,51 @@ public void onClick(View view) {
hideEmulatedKeys();
}
});
final Button upButton = (Button) findViewById(R.id.button_up);
upButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
View flip = findCurrentView(R.id.console_flip);
if (flip == null) return;
TerminalView terminal = (TerminalView) flip;


TerminalKeyListener handler = terminal.bridge.getKeyHandler();
handler.sendPressedKey(vt320.KEY_UP);
}
});
final Button dnButton = (Button) findViewById(R.id.button_down);
dnButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
View flip = findCurrentView(R.id.console_flip);
if (flip == null) return;
TerminalView terminal = (TerminalView) flip;

TerminalKeyListener handler = terminal.bridge.getKeyHandler();
handler.sendPressedKey(vt320.KEY_DOWN);
}
});
final Button leftButton = (Button) findViewById(R.id.button_left);
leftButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
View flip = findCurrentView(R.id.console_flip);
if (flip == null) return;
TerminalView terminal = (TerminalView) flip;

TerminalKeyListener handler = terminal.bridge.getKeyHandler();
handler.sendPressedKey(vt320.KEY_LEFT);
}
});
final Button rightButton = (Button) findViewById(R.id.button_right);
rightButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
View flip = findCurrentView(R.id.console_flip);
if (flip == null) return;
TerminalView terminal = (TerminalView) flip;

TerminalKeyListener handler = terminal.bridge.getKeyHandler();
handler.sendPressedKey(vt320.KEY_RIGHT);
}
});

actionBar = ActionBarWrapper.getActionBar(this);
actionBar.setDisplayHomeAsUpEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
}

// look for special chars
switch(keyCode) {
switch (keyCode) {
case KEYCODE_ESCAPE:
sendEscape();
return true;
Expand Down Expand Up @@ -520,6 +520,11 @@ public void sendTab() {
}
}

public void sendPressedKey(int key) {
((vt320) buffer).keyPressed(key, ' ', getStateForBuffer());
bridge.tryKeyVibrate();
}

/**
* @param key
* @return successful
Expand Down
Binary file modified app/src/main/res/drawable/button_keyboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
182 changes: 142 additions & 40 deletions app/src/main/res/layout/act_console.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,59 +120,161 @@

</RelativeLayout>

<RelativeLayout
<LinearLayout
android:id="@+id/keyboard_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="15dip"
android:background="#55000000"
android:padding="0dip"
android:visibility="gone">

<ImageView
android:id="@+id/button_keyboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="@drawable/button_keyboard"
android:contentDescription="@string/image_description_show_keyboard"
/>

<ImageView
<Button
android:id="@+id/button_ctrl"
android:paddingRight="15dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:src="@drawable/button_ctrl"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_toggle_control_character"
android:padding="0dp"
android:text="@string/button_key_ctrl"
android:textSize="10dip"
/>

<ImageView
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<Button
android:id="@+id/button_esc"
android:paddingRight="15dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/button_ctrl"
android:layout_alignParentBottom="true"
android:src="@drawable/button_esc"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_send_escape_character"
android:padding="0dp"
android:text="@string/button_key_esc"
android:textSize="10dip"
/>

<ImageView
android:id="@+id/button_tab"
android:paddingRight="15dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/button_esc"
android:layout_alignParentBottom="true"
android:src="@drawable/button_tab"
android:contentDescription="@string/image_description_send_tab_character"
/>

</RelativeLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<Button
android:id="@+id/button_tab"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_send_tab_character"
android:padding="0dp"
android:text="@string/button_key_tab"
android:textSize="10dip"
/>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<Button
android:id="@+id/button_up"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_up"
android:padding="0dp"
android:text="@string/button_key_up"
android:textSize="10dip"
/>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<Button
android:id="@+id/button_down"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_down"
android:padding="0dp"
android:text="@string/button_key_down"
android:textSize="10dip"
/>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<Button
android:id="@+id/button_left"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_left"
android:padding="0dp"
android:text="@string/button_key_left"
android:textSize="10dip"
/>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<Button
android:id="@+id/button_right"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:background="#55f0f0f0"
android:contentDescription="@string/image_description_right"
android:padding="0dp"
android:text="@string/button_key_right"
android:textSize="10dip"
/>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#90000000"
/>

<ImageView
android:id="@+id/button_keyboard"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="30dip"
android:layout_margin="0dp"
android:contentDescription="@string/image_description_show_keyboard"
android:padding="0dp"
android:src="@drawable/button_keyboard"
android:background="#55f0f0f0"
android:textSize="10dip"
/>

</LinearLayout>

</RelativeLayout>
31 changes: 31 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,35 @@
<!-- Describes the icon of the "show keyboard" button in the terminal view for accessibility
purposes. -->
<string name="image_description_show_keyboard">Show keyboard.</string>

<!-- Describes the icon of the "Arrow up" button in the terminal view for accessibility
purposes. -->
<string name="image_description_up">Arrow up</string>

<!-- Describes the icon of the "Arrow down" button in the terminal view for accessibility
purposes. -->
<string name="image_description_down">Arrow down</string>

<!-- Describes the icon of the "Arrow left" button in the terminal view for accessibility
purposes. -->
<string name="image_description_left">Arrow left</string>

<!-- Describes the icon of the "Arrow right" button in the terminal view for accessibility
purposes. -->
<string name="image_description_right">Arrow right</string>

<!-- Text for the "Esc" button in virtual keyboard. -->
<string name="button_key_esc">Esc</string>
<!-- Text for the "Ctrl" button in virtual keyboard. -->
<string name="button_key_ctrl">Ctrl</string>
<!-- Text for the "Tab" button in virtual keyboard. -->
<string name="button_key_tab">Tab</string>
<!-- Text for the "up" button in virtual keyboard. -->
<string name="button_key_up">Up</string>
<!-- Text for the "down" button in virtual keyboard. -->
<string name="button_key_down">Down</string>
<!-- Text for the "left" button in virtual keyboard. -->
<string name="button_key_left">Left</string>
<!-- Text for the "right" button in virtual keyboard. -->
<string name="button_key_right">Right</string>
</resources>

0 comments on commit a4c5300

Please sign in to comment.