2023-03-28 11:22:17 +02:00
|
|
|
package juloo.keyboard2;
|
|
|
|
|
2024-02-10 17:33:42 +01:00
|
|
|
import android.annotation.TargetApi;
|
2023-03-28 11:22:17 +02:00
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.Intent;
|
2023-12-31 13:18:15 +01:00
|
|
|
import android.media.AudioManager;
|
|
|
|
import android.media.MediaPlayer;
|
|
|
|
import android.net.Uri;
|
2023-04-10 13:15:59 +02:00
|
|
|
import android.os.Build.VERSION;
|
2023-03-28 11:22:17 +02:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.provider.Settings;
|
2023-04-02 13:28:10 +02:00
|
|
|
import android.view.KeyEvent;
|
2024-05-05 11:22:34 +02:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
2023-03-28 11:22:17 +02:00
|
|
|
import android.view.View;
|
2023-08-24 00:53:31 +02:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2023-04-02 13:28:10 +02:00
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.TextView;
|
2023-12-31 13:18:15 +01:00
|
|
|
import android.widget.VideoView;
|
2023-03-28 11:22:17 +02:00
|
|
|
|
|
|
|
public class LauncherActivity extends Activity
|
|
|
|
{
|
2023-04-02 13:28:10 +02:00
|
|
|
/** Text is replaced when receiving key events. */
|
2023-12-31 13:18:15 +01:00
|
|
|
VideoView _intro_video;
|
2023-04-02 13:28:10 +02:00
|
|
|
TextView _tryhere_text;
|
|
|
|
EditText _tryhere_area;
|
|
|
|
|
2023-03-28 11:22:17 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.launcher_activity);
|
2023-12-31 13:18:15 +01:00
|
|
|
_intro_video = (VideoView)findViewById(R.id.launcher_intro_video);
|
2023-04-02 13:28:10 +02:00
|
|
|
_tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text);
|
|
|
|
_tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area);
|
2024-02-10 17:33:42 +01:00
|
|
|
if (VERSION.SDK_INT >= 28)
|
2023-04-10 13:15:59 +02:00
|
|
|
_tryhere_area.addOnUnhandledKeyEventListener(
|
|
|
|
this.new Tryhere_OnUnhandledKeyEventListener());
|
2023-12-31 13:18:15 +01:00
|
|
|
setup_intro_video(_intro_video);
|
2023-03-28 11:22:17 +02:00
|
|
|
}
|
2024-06-16 20:05:31 +02:00
|
|
|
|
2024-05-05 11:22:34 +02:00
|
|
|
@Override
|
2024-06-16 20:05:31 +02:00
|
|
|
public final boolean onCreateOptionsMenu(Menu menu)
|
|
|
|
{
|
2024-05-05 11:22:34 +02:00
|
|
|
getMenuInflater().inflate(R.menu.launcher_menu, menu);
|
|
|
|
return true;
|
|
|
|
}
|
2023-03-28 11:22:17 +02:00
|
|
|
|
2024-05-05 11:22:34 +02:00
|
|
|
@Override
|
2024-06-16 20:05:31 +02:00
|
|
|
public final boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
{
|
|
|
|
if (item.getItemId() == R.id.btnLaunchSettingsActivity)
|
|
|
|
{
|
2024-05-05 11:22:34 +02:00
|
|
|
Intent intent = new Intent(LauncherActivity.this, SettingsActivity.class);
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
2024-06-16 20:05:31 +02:00
|
|
|
|
2023-03-28 11:22:17 +02:00
|
|
|
public void launch_imesettings(View _btn)
|
|
|
|
{
|
|
|
|
startActivity(new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS));
|
|
|
|
}
|
2023-04-02 13:28:10 +02:00
|
|
|
|
2023-08-24 00:53:31 +02:00
|
|
|
public void launch_imepicker(View v)
|
|
|
|
{
|
|
|
|
InputMethodManager imm =
|
|
|
|
(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
|
|
|
|
imm.showInputMethodPicker();
|
|
|
|
}
|
|
|
|
|
2024-01-03 00:48:26 +01:00
|
|
|
static void setup_intro_video(final VideoView v)
|
2023-12-31 13:18:15 +01:00
|
|
|
{
|
|
|
|
if (VERSION.SDK_INT >= 26)
|
|
|
|
v.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE);
|
|
|
|
v.setVideoURI(Uri.parse("android.resource://" +
|
|
|
|
v.getContext().getPackageName() + "/" + R.raw.intro_video));
|
|
|
|
v.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
|
|
|
|
{
|
|
|
|
@Override
|
2024-01-03 00:48:26 +01:00
|
|
|
public void onPrepared(MediaPlayer mp)
|
|
|
|
{
|
2023-12-31 13:18:15 +01:00
|
|
|
mp.setLooping(true);
|
|
|
|
}
|
|
|
|
});
|
2024-01-03 00:48:26 +01:00
|
|
|
v.setOnErrorListener(new MediaPlayer.OnErrorListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra)
|
|
|
|
{
|
|
|
|
v.stopPlayback();
|
|
|
|
v.setVisibility(View.GONE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2023-12-31 13:18:15 +01:00
|
|
|
v.start();
|
|
|
|
}
|
|
|
|
|
2024-02-10 17:33:42 +01:00
|
|
|
@TargetApi(28)
|
2023-04-02 13:28:10 +02:00
|
|
|
final class Tryhere_OnUnhandledKeyEventListener implements View.OnUnhandledKeyEventListener
|
|
|
|
{
|
|
|
|
public boolean onUnhandledKeyEvent(View v, KeyEvent ev)
|
|
|
|
{
|
2023-06-03 10:00:16 +02:00
|
|
|
// Don't handle the back key
|
|
|
|
if (ev.getKeyCode() == KeyEvent.KEYCODE_BACK)
|
|
|
|
return false;
|
2023-04-02 13:28:10 +02:00
|
|
|
// Key release of modifiers would erase interesting data
|
|
|
|
if (KeyEvent.isModifierKey(ev.getKeyCode()))
|
|
|
|
return false;
|
|
|
|
StringBuilder s = new StringBuilder();
|
|
|
|
if (ev.isAltPressed()) s.append("Alt+");
|
|
|
|
if (ev.isShiftPressed()) s.append("Shift+");
|
|
|
|
if (ev.isCtrlPressed()) s.append("Ctrl+");
|
|
|
|
if (ev.isMetaPressed()) s.append("Meta+");
|
|
|
|
// s.append(ev.getDisplayLabel());
|
|
|
|
String kc = KeyEvent.keyCodeToString(ev.getKeyCode());
|
|
|
|
s.append(kc.replaceFirst("^KEYCODE_", ""));
|
|
|
|
_tryhere_text.setText(s.toString());
|
2024-06-16 20:05:31 +02:00
|
|
|
return false;
|
2023-04-02 13:28:10 +02:00
|
|
|
}
|
|
|
|
}
|
2023-03-28 11:22:17 +02:00
|
|
|
}
|