Merge pull request #1296 from unstabler/impl-simple-shortcuts
improve usability: add shortcuts for compose/send new toot [#505]
This commit is contained in:
commit
91d01bce05
|
@ -47,6 +47,7 @@ import android.text.TextWatcher;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -539,6 +540,8 @@ public final class ComposeActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
textEditor.setOnKeyListener((view, keyCode, event) -> this.onKeyDown(keyCode, event));
|
||||||
|
|
||||||
textEditor.setAdapter(
|
textEditor.setAdapter(
|
||||||
new ComposeAutoCompleteAdapter(this));
|
new ComposeAutoCompleteAdapter(this));
|
||||||
textEditor.setTokenizer(new ComposeTokenizer());
|
textEditor.setTokenizer(new ComposeTokenizer());
|
||||||
|
@ -1624,6 +1627,7 @@ public final class ComposeActivity
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
// Acting like a teen: deliberately ignoring parent.
|
// Acting like a teen: deliberately ignoring parent.
|
||||||
|
@ -1639,6 +1643,21 @@ public final class ComposeActivity
|
||||||
handleCloseButton();
|
handleCloseButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
Log.d(TAG, event.toString());
|
||||||
|
if (event.isCtrlPressed()) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||||
|
// send toot by pressing CTRL + ENTER
|
||||||
|
this.onSendClicked();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
private void handleCloseButton() {
|
private void handleCloseButton() {
|
||||||
|
|
||||||
CharSequence contentText = textEditor.getText();
|
CharSequence contentText = textEditor.getText();
|
||||||
|
|
|
@ -280,6 +280,19 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.isCtrlPressed() || event.isShiftPressed()) {
|
||||||
|
// FIXME: blackberry keyONE raises SHIFT key event even CTRL IS PRESSED
|
||||||
|
switch (keyCode) {
|
||||||
|
case KeyEvent.KEYCODE_N: {
|
||||||
|
// open compose activity by pressing SHIFT + N (or CTRL + N)
|
||||||
|
Intent composeIntent = new Intent(getApplicationContext(), ComposeActivity.class);
|
||||||
|
startActivity(composeIntent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue