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;
|
2024-11-18 00:13:08 +01:00
|
|
|
import android.graphics.drawable.Animatable;
|
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;
|
2024-11-18 00:13:08 +01:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Message;
|
2023-03-28 11:22:17 +02:00
|
|
|
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;
|
2024-11-18 00:13:08 +01:00
|
|
|
import android.widget.ImageView;
|
2023-04-02 13:28:10 +02:00
|
|
|
import android.widget.TextView;
|
2024-11-18 00:13:08 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2023-03-28 11:22:17 +02:00
|
|
|
|
2024-11-18 00:13:08 +01:00
|
|
|
public class LauncherActivity extends Activity implements Handler.Callback
|
2023-03-28 11:22:17 +02:00
|
|
|
{
|
2023-04-02 13:28:10 +02:00
|
|
|
/** Text is replaced when receiving key events. */
|
|
|
|
TextView _tryhere_text;
|
|
|
|
EditText _tryhere_area;
|
2024-11-18 00:13:08 +01:00
|
|
|
/** Periodically restart the animations. */
|
|
|
|
List<Animatable> _animations;
|
|
|
|
Handler _handler;
|
2023-04-02 13:28:10 +02:00
|
|
|
|
2023-03-28 11:22:17 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.launcher_activity);
|
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());
|
2024-11-18 00:13:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStart()
|
|
|
|
{
|
|
|
|
super.onStart();
|
|
|
|
_animations = new ArrayList<Animatable>();
|
|
|
|
_animations.add(find_anim(R.id.launcher_anim_swipe));
|
|
|
|
_handler = new Handler(getMainLooper(), this);
|
|
|
|
_handler.sendEmptyMessageDelayed(0, 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean handleMessage(Message _msg)
|
|
|
|
{
|
|
|
|
for (Animatable anim : _animations)
|
|
|
|
anim.start();
|
|
|
|
_handler.sendEmptyMessageDelayed(0, 3000);
|
|
|
|
return true;
|
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-11-18 00:13:08 +01:00
|
|
|
Animatable find_anim(int id)
|
2023-12-31 13:18:15 +01:00
|
|
|
{
|
2024-11-18 00:13:08 +01:00
|
|
|
ImageView img = (ImageView)findViewById(id);
|
|
|
|
return (Animatable)img.getDrawable();
|
2023-12-31 13:18:15 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|