remove welcome video, use the image instead

that video is not worth 300 kB
This commit is contained in:
Helium314 2024-01-31 16:28:43 +01:00
parent 7b649eeb12
commit 0c868ab22a
5 changed files with 7 additions and 79 deletions

View file

@ -8,21 +8,17 @@ package org.dslul.openboard.inputmethod.latin.setup;
import static android.util.TypedValue.COMPLEX_UNIT_DIP; import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import android.content.ContentResolver;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.provider.Settings; import android.provider.Settings;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.VideoView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
@ -37,27 +33,20 @@ import org.dslul.openboard.inputmethod.latin.settings.SettingsActivity;
import org.dslul.openboard.inputmethod.latin.utils.ActivityThemeUtils; import org.dslul.openboard.inputmethod.latin.utils.ActivityThemeUtils;
import org.dslul.openboard.inputmethod.latin.utils.JniUtils; import org.dslul.openboard.inputmethod.latin.utils.JniUtils;
import org.dslul.openboard.inputmethod.latin.utils.LeakGuardHandlerWrapper; import org.dslul.openboard.inputmethod.latin.utils.LeakGuardHandlerWrapper;
import org.dslul.openboard.inputmethod.latin.utils.Log;
import org.dslul.openboard.inputmethod.latin.utils.UncachedInputMethodManagerUtils; import org.dslul.openboard.inputmethod.latin.utils.UncachedInputMethodManagerUtils;
import java.util.ArrayList; import java.util.ArrayList;
// TODO: Use Fragment to implement welcome screen and setup steps. // TODO: Use Fragment to implement welcome screen and setup steps.
public final class SetupWizardActivity extends AppCompatActivity implements View.OnClickListener { public final class SetupWizardActivity extends AppCompatActivity implements View.OnClickListener {
static final String TAG = SetupWizardActivity.class.getSimpleName();
// For debugging purpose. // For debugging purpose.
private static final boolean FORCE_TO_SHOW_WELCOME_SCREEN = false; private static final boolean FORCE_TO_SHOW_WELCOME_SCREEN = false;
private static final boolean ENABLE_WELCOME_VIDEO = true;
private InputMethodManager mImm; private InputMethodManager mImm;
private View mSetupWizard; private View mSetupWizard;
private View mWelcomeScreen; private View mWelcomeScreen;
private View mSetupScreen; private View mSetupScreen;
private Uri mWelcomeVideoUri;
private VideoView mWelcomeVideoView;
private ImageView mWelcomeImageView;
private View mActionStart; private View mActionStart;
private TextView mActionNext; private TextView mActionNext;
private TextView mStep1Bullet; private TextView mStep1Bullet;
@ -187,26 +176,6 @@ public final class SetupWizardActivity extends AppCompatActivity implements View
}); });
mSetupStepGroup.addStep(step3); mSetupStepGroup.addStep(step3);
mWelcomeVideoUri = new Uri.Builder()
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getPackageName())
.path(Integer.toString(R.raw.setup_welcome_video))
.build();
final VideoView welcomeVideoView = findViewById(R.id.setup_welcome_video);
welcomeVideoView.setOnPreparedListener(mp -> {
// Now VideoView has been laid-out and ready to play, remove background of it to
// reveal the video.
welcomeVideoView.setBackgroundResource(0);
mp.setLooping(true);
});
welcomeVideoView.setOnErrorListener((mp, what, extra) -> {
Log.e(TAG, "Playing welcome video causes error: what=" + what + " extra=" + extra);
hideWelcomeVideoAndShowWelcomeImage();
return true;
});
mWelcomeVideoView = welcomeVideoView;
mWelcomeImageView = findViewById(R.id.setup_welcome_image);
mActionStart = findViewById(R.id.setup_start_label); mActionStart = findViewById(R.id.setup_start_label);
mActionStart.setOnClickListener(this); mActionStart.setOnClickListener(this);
@ -359,29 +328,6 @@ public final class SetupWizardActivity extends AppCompatActivity implements View
super.onBackPressed(); super.onBackPressed();
} }
void hideWelcomeVideoAndShowWelcomeImage() {
mWelcomeVideoView.setVisibility(View.GONE);
mWelcomeImageView.setImageResource(R.drawable.setup_welcome_image);
mWelcomeImageView.setVisibility(View.VISIBLE);
}
private void showAndStartWelcomeVideo() {
mWelcomeVideoView.setVisibility(View.VISIBLE);
mWelcomeVideoView.setVideoURI(mWelcomeVideoUri);
mWelcomeVideoView.start();
}
private void hideAndStopWelcomeVideo() {
mWelcomeVideoView.stopPlayback();
mWelcomeVideoView.setVisibility(View.GONE);
}
@Override
protected void onPause() {
hideAndStopWelcomeVideo();
super.onPause();
}
@Override @Override
public void onWindowFocusChanged(final boolean hasFocus) { public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus); super.onWindowFocusChanged(hasFocus);
@ -398,14 +344,8 @@ public final class SetupWizardActivity extends AppCompatActivity implements View
mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE); mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE); mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);
if (welcomeScreen) { if (welcomeScreen) {
if (ENABLE_WELCOME_VIDEO) {
showAndStartWelcomeVideo();
} else {
hideWelcomeVideoAndShowWelcomeImage();
}
return; return;
} }
hideAndStopWelcomeVideo();
final boolean isStepActionAlreadyDone = mStepNumber < determineSetupStepNumber(); final boolean isStepActionAlreadyDone = mStepNumber < determineSetupStepNumber();
mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone); mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone);
mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE); mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);

View file

@ -22,6 +22,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="@integer/setup_body_weight_in_screen" android:layout_weight="@integer/setup_body_weight_in_screen"
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/setup_welcome_video" /> <include layout="@layout/setup_welcome_image" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -16,28 +16,16 @@
android:layout_weight="@integer/setup_welcome_video_end_padding_weight_in_screen" android:layout_weight="@integer/setup_welcome_video_end_padding_weight_in_screen"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" /> android:layout_height="0dp" />
<LinearLayout <ImageView
android:id="@+id/setup_welcome_image"
android:layout_weight="@integer/setup_welcome_video_weight_in_screen" android:layout_weight="@integer/setup_welcome_video_weight_in_screen"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="1dp" android:padding="1dp"
android:background="@color/setup_welcome_video_margin_color" > android:background="@color/setup_welcome_video_margin_color"
<VideoView android:adjustViewBounds="true"
android:id="@+id/setup_welcome_video" android:src="@drawable/setup_welcome_image" />
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/setup_background"
android:contentDescription="@string/setup_welcome_additional_description"/>
<ImageView
android:id="@+id/setup_welcome_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="gone"
android:contentDescription="@string/setup_welcome_additional_description"/>
</LinearLayout>
<View <View
android:layout_weight="@integer/setup_welcome_video_end_padding_weight_in_screen" android:layout_weight="@integer/setup_welcome_video_end_padding_weight_in_screen"
android:layout_width="0dp" android:layout_width="0dp"

View file

@ -11,5 +11,5 @@
android:orientation="vertical" android:orientation="vertical"
android:gravity="center"> android:gravity="center">
<include layout="@layout/setup_welcome_title" /> <include layout="@layout/setup_welcome_title" />
<include layout="@layout/setup_welcome_video" /> <include layout="@layout/setup_welcome_image" />
</LinearLayout> </LinearLayout>