Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Expensify/App into arosiclair-airsh…
Browse files Browse the repository at this point in the history
…ip-15
  • Loading branch information
arosiclair committed Apr 7, 2023
2 parents 5405f30 + d889c0f commit fd0afba
Show file tree
Hide file tree
Showing 87 changed files with 757 additions and 535 deletions.
3 changes: 3 additions & 0 deletions __mocks__/react-native-localize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const mockRNLocalize = require('react-native-localize/mock');

module.exports = mockRNLocalize;
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001029500
versionName "1.2.95-0"
versionCode 1001029604
versionName "1.2.96-4"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

if (isNewArchitectureEnabled()) {
Expand Down
9 changes: 1 addition & 8 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:resizeableActivity="false"
android:theme="@style/AppTheme"
android:theme="@style/BootTheme"
tools:replace="android:supportsRtl">

<activity
Expand All @@ -26,13 +26,6 @@
android:launchMode="singleTask"
android:exported="true"
android:windowSoftInputMode="adjustResize">
</activity>

<activity
android:name=".bootsplash.BootSplashActivity"
android:theme="@style/BootTheme"
android:exported="true"
android:launchMode="singleTask">

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ protected boolean isConcurrentRootEnabled() {

@Override
protected void onCreate(Bundle savedInstanceState) {
BootSplash.init(this);
super.onCreate(null);
if (getResources().getBoolean(R.bool.portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
BootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated bootsplash.xml drawable over our MainActivity
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.expensify.chat.bootsplash;

import android.app.Activity;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class BootSplash {

public static void init(final @DrawableRes int drawableResId, @NonNull final Activity activity) {
BootSplashModule.init(drawableResId, activity);
public static void init(@Nullable final Activity activity) {
BootSplashModule.init(activity);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.expensify.chat.bootsplash;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import androidx.annotation.NonNull;
import com.expensify.chat.R;

public class BootSplashDialog extends Dialog {

public BootSplashDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
setCancelable(false);
setCanceledOnTouchOutside(false);
}

@Override
public void onBackPressed() {
// Prevent default behavior
}

@Override
protected void onCreate(Bundle savedInstanceState) {
final Window window = this.getWindow();

if (window != null) {
window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
window.setWindowAnimations(R.style.Theme_SplashScreen_Dialog);
}

super.onCreate(savedInstanceState);
}
}
Original file line number Diff line number Diff line change
@@ -1,66 +1,97 @@
package com.expensify.chat.bootsplash;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.content.DialogInterface;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import androidx.annotation.DrawableRes;
import android.view.ViewTreeObserver;
import android.window.SplashScreen;
import android.window.SplashScreenView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.expensify.chat.R;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
import java.util.Timer;
import java.util.TimerTask;

@ReactModule(name = BootSplashModule.MODULE_NAME)
@ReactModule(name = BootSplashModule.NAME)
public class BootSplashModule extends ReactContextBaseJavaModule {

public static final String MODULE_NAME = "BootSplash";
private static int mDrawableResId = -1;
private static boolean mSplashVisible = false;
public static final String NAME = "BootSplash";
private static boolean mShouldKeepOnScreen = true;

@Nullable
private static BootSplashDialog mDialog = null;

public BootSplashModule(ReactApplicationContext reactContext) {
super(reactContext);
}

@Override
public String getName() {
return MODULE_NAME;
return NAME;
}

protected static void init(final @DrawableRes int drawableResId, final Activity activity) {
UiThreadUtil.runOnUiThread(new Runnable() {
protected static void init(@Nullable final Activity activity) {
if (activity == null) {
FLog.w(ReactConstants.TAG, NAME + ": Ignored initialization, current activity is null.");
return;
}

activity.setTheme(R.style.AppTheme);

// Keep the splash screen on-screen until Dialog is shown
final View contentView = activity.findViewById(android.R.id.content);

contentView
.getViewTreeObserver()
.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public void run() {
if (activity == null
|| activity.isFinishing()
|| activity.findViewById(R.id.bootsplash_layout_id) != null) {
return;
public boolean onPreDraw() {
if (mShouldKeepOnScreen) {
return false;
}

mDrawableResId = drawableResId;
mSplashVisible = true;

LinearLayout layout = new LinearLayout(activity);
layout.setId(R.id.bootsplash_layout_id);
layout.setLayoutTransition(null);
layout.setOrientation(LinearLayout.VERTICAL);
contentView
.getViewTreeObserver()
.removeOnPreDrawListener(this);

View view = new View(activity);
view.setBackgroundResource(mDrawableResId);
return true;
}
});

LayoutParams params = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// This is not called on Android 12 when activity is started using Android studio / notifications
activity
.getSplashScreen()
.setOnExitAnimationListener(new SplashScreen.OnExitAnimationListener() {
@Override
public void onSplashScreenExit(@NonNull SplashScreenView view) {
view.remove(); // Remove it without animation
}
});
}

mDialog = new BootSplashDialog(activity, R.style.BootTheme);

mDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
mShouldKeepOnScreen = false;
}
});

layout.addView(view, params);
activity.addContentView(layout, params);
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
mDialog.show();
}
});
}
Expand All @@ -79,9 +110,6 @@ public void run() {

@ReactMethod
public void hide() {
if (mDrawableResId == -1)
return;

UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
Expand All @@ -92,37 +120,22 @@ public void run() {
return;
}

final LinearLayout layout = activity.findViewById(R.id.bootsplash_layout_id);
if (mDialog != null) {
mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mDialog = null;
}
});

// check if splash screen is already hidden
if (layout == null)
return;

final ViewGroup parent = (ViewGroup) layout.getParent();

layout
.animate()
.setDuration(250)
.alpha(0.0f)
.setInterpolator(new AccelerateInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);

if (parent != null)
parent.removeView(layout);

mDrawableResId = -1;
mSplashVisible = false;
}
}).start();
mDialog.dismiss();
}
}
});
}

@ReactMethod
public void getVisibilityStatus(final Promise promise) {
promise.resolve(mSplashVisible ? "visible" : "hidden");
promise.resolve(mDialog != null ? "visible" : "hidden");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -14,7 +13,7 @@ public class BootSplashPackage implements ReactPackage {
@NonNull
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new BootSplashModule(reactContext));
return Collections.singletonList(new BootSplashModule(reactContext));
}

@NonNull
Expand Down
7 changes: 7 additions & 0 deletions android/app/src/main/res/anim/fade_out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/accelerate_quad"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="250" />
8 changes: 5 additions & 3 deletions android/app/src/main/res/drawable/bootsplash.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:drawable="@color/bootsplash_background" />
<item android:gravity="fill">
<color android:color="?attr/windowSplashScreenBackground" />
</item>

<item>
<bitmap android:src="@mipmap/bootsplash_logo" android:gravity="center" />
<item android:gravity="fill">
<bitmap android:src="?windowSplashScreenAnimatedIcon" android:gravity="center" />
</item>
</layer-list>
Binary file modified android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/bootsplash_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/bootsplash_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/bootsplash_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions android/app/src/main/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<resources>

<style name="Theme.SplashScreen" parent="Theme.SplashScreen.Common">
<item name="android:windowSplashScreenAnimatedIcon">?windowSplashScreenAnimatedIcon</item>
<item name="android:windowSplashScreenBackground">?windowSplashScreenBackground</item>
</style>

</resources>
4 changes: 4 additions & 0 deletions android/app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<attr name="windowSplashScreenAnimatedIcon" format="reference" />
<attr name="windowSplashScreenBackground" format="color" />
</resources>
3 changes: 0 additions & 3 deletions android/app/src/main/res/values/ids.xml

This file was deleted.

Loading

0 comments on commit fd0afba

Please sign in to comment.