Skip to content

Commit

Permalink
Add an introduction video in the launcher activity
Browse files Browse the repository at this point in the history
A video is more intuitive than a written description and doesn't need
translations.
  • Loading branch information
Julow committed Dec 31, 2023
1 parent 4a5a125 commit 49a6a30
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
21 changes: 12 additions & 9 deletions res/layout/launcher_activity.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<TextView style="@style/paragraph" android:text="@string/launcher_description"/>
<Button style="@style/paragraph" android:text="@string/launcher_button_imesettings" android:onClick="launch_imesettings" android:layout_width="wrap_content"/>
<Button style="@style/paragraph" android:text="@string/launcher_button_imepicker" android:onClick="launch_imepicker" android:layout_width="wrap_content"/>
<TextView style="@style/paragraph" android:text="@string/launcher_sourcecode"/>
<TextView style="@style/paragraph" android:text="https://github.com/Julow/Unexpected-Keyboard" android:autoLink="web" android:linksClickable="true"/>
<TextView android:id="@+id/launcher_tryhere_text" style="@style/paragraph" android:text="@string/launcher_tryhere"/>
<EditText android:id="@+id/launcher_tryhere_area" style="@style/paragraph" android:inputType="text"/>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true">
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<TextView style="@style/paragraph" android:text="@string/launcher_description"/>
<Button style="@style/paragraph" android:text="@string/launcher_button_imesettings" android:onClick="launch_imesettings" android:layout_width="wrap_content"/>
<Button style="@style/paragraph" android:text="@string/launcher_button_imepicker" android:onClick="launch_imepicker" android:layout_width="wrap_content"/>
<VideoView android:id="@+id/launcher_intro_video" android:layout_width="240dp" android:layout_height="wrap_content" android:layout_gravity="center"/>
<TextView android:id="@+id/launcher_tryhere_text" style="@style/paragraph" android:text="@string/launcher_tryhere"/>
<EditText android:id="@+id/launcher_tryhere_area" style="@style/paragraph" android:inputType="text"/>
<TextView style="@style/paragraph" android:text="@string/launcher_sourcecode"/>
<TextView style="@style/paragraph" android:text="https://github.com/Julow/Unexpected-Keyboard" android:autoLink="web" android:linksClickable="true"/>
</LinearLayout>
</ScrollView>
Binary file added res/raw/intro_video.mp4
Binary file not shown.
23 changes: 23 additions & 0 deletions srcs/juloo.keyboard2/LauncherActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.app.Activity;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.provider.Settings;
Expand All @@ -10,10 +13,12 @@
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.VideoView;

public class LauncherActivity extends Activity
{
/** Text is replaced when receiving key events. */
VideoView _intro_video;
TextView _tryhere_text;
EditText _tryhere_area;

Expand All @@ -22,11 +27,13 @@ public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.launcher_activity);
_intro_video = (VideoView)findViewById(R.id.launcher_intro_video);
_tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text);
_tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area);
if (VERSION.SDK_INT > 28)
_tryhere_area.addOnUnhandledKeyEventListener(
this.new Tryhere_OnUnhandledKeyEventListener());
setup_intro_video(_intro_video);
}

public void launch_imesettings(View _btn)
Expand All @@ -41,6 +48,22 @@ public void launch_imepicker(View v)
imm.showInputMethodPicker();
}

static void setup_intro_video(VideoView v)
{
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
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
v.start();
}

final class Tryhere_OnUnhandledKeyEventListener implements View.OnUnhandledKeyEventListener
{
public boolean onUnhandledKeyEvent(View v, KeyEvent ev)
Expand Down

0 comments on commit 49a6a30

Please sign in to comment.