mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 14:02:44 +00:00
remove welcome video, use the image instead
that video is not worth 300 kB
This commit is contained in:
parent
7b649eeb12
commit
0c868ab22a
5 changed files with 7 additions and 79 deletions
|
@ -8,21 +8,17 @@ package org.dslul.openboard.inputmethod.latin.setup;
|
|||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
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.JniUtils;
|
||||
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 java.util.ArrayList;
|
||||
|
||||
// TODO: Use Fragment to implement welcome screen and setup steps.
|
||||
public final class SetupWizardActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
static final String TAG = SetupWizardActivity.class.getSimpleName();
|
||||
|
||||
// For debugging purpose.
|
||||
private static final boolean FORCE_TO_SHOW_WELCOME_SCREEN = false;
|
||||
private static final boolean ENABLE_WELCOME_VIDEO = true;
|
||||
|
||||
private InputMethodManager mImm;
|
||||
|
||||
private View mSetupWizard;
|
||||
private View mWelcomeScreen;
|
||||
private View mSetupScreen;
|
||||
private Uri mWelcomeVideoUri;
|
||||
private VideoView mWelcomeVideoView;
|
||||
private ImageView mWelcomeImageView;
|
||||
private View mActionStart;
|
||||
private TextView mActionNext;
|
||||
private TextView mStep1Bullet;
|
||||
|
@ -187,26 +176,6 @@ public final class SetupWizardActivity extends AppCompatActivity implements View
|
|||
});
|
||||
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.setOnClickListener(this);
|
||||
|
||||
|
@ -359,29 +328,6 @@ public final class SetupWizardActivity extends AppCompatActivity implements View
|
|||
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
|
||||
public void onWindowFocusChanged(final boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
|
@ -398,14 +344,8 @@ public final class SetupWizardActivity extends AppCompatActivity implements View
|
|||
mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
|
||||
mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);
|
||||
if (welcomeScreen) {
|
||||
if (ENABLE_WELCOME_VIDEO) {
|
||||
showAndStartWelcomeVideo();
|
||||
} else {
|
||||
hideWelcomeVideoAndShowWelcomeImage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
hideAndStopWelcomeVideo();
|
||||
final boolean isStepActionAlreadyDone = mStepNumber < determineSetupStepNumber();
|
||||
mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone);
|
||||
mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_weight="@integer/setup_body_weight_in_screen"
|
||||
android:orientation="vertical">
|
||||
<include layout="@layout/setup_welcome_video" />
|
||||
<include layout="@layout/setup_welcome_image" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -16,28 +16,16 @@
|
|||
android:layout_weight="@integer/setup_welcome_video_end_padding_weight_in_screen"
|
||||
android:layout_width="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_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="1dp"
|
||||
android:background="@color/setup_welcome_video_margin_color" >
|
||||
<VideoView
|
||||
android:id="@+id/setup_welcome_video"
|
||||
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:background="@color/setup_welcome_video_margin_color"
|
||||
android:adjustViewBounds="true"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/setup_welcome_additional_description"/>
|
||||
</LinearLayout>
|
||||
android:src="@drawable/setup_welcome_image" />
|
||||
<View
|
||||
android:layout_weight="@integer/setup_welcome_video_end_padding_weight_in_screen"
|
||||
android:layout_width="0dp"
|
|
@ -11,5 +11,5 @@
|
|||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<include layout="@layout/setup_welcome_title" />
|
||||
<include layout="@layout/setup_welcome_video" />
|
||||
<include layout="@layout/setup_welcome_image" />
|
||||
</LinearLayout>
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue