From 2378ad627be1fbc7574031156a3df54891029435 Mon Sep 17 00:00:00 2001 From: Chris Duarte Date: Tue, 17 Oct 2017 08:44:41 -0700 Subject: [PATCH] Swith android to use layout file for splash (#952) --- android/app/build.gradle | 1 + .../com/mattermost/rnbeta/MainActivity.java | 61 ++----------------- .../app/src/main/res/layout/launch_screen.xml | 19 ++++++ android/app/src/main/res/values/colors.xml | 4 ++ android/app/src/main/res/values/styles.xml | 4 +- app/mattermost.js | 5 +- app/screens/load_team/load_team.js | 3 +- app/screens/root/root.js | 6 +- 8 files changed, 40 insertions(+), 63 deletions(-) create mode 100644 android/app/src/main/res/layout/launch_screen.xml create mode 100644 android/app/src/main/res/values/colors.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index 4975b74f0..461a93c74 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -154,6 +154,7 @@ android { dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:25.0.1" + compile 'com.android.support:percent:25.3.1' compile "com.facebook.react:react-native:+" // From node_modules compile project(':react-native-navigation') compile project(':react-native-image-picker') diff --git a/android/app/src/main/java/com/mattermost/rnbeta/MainActivity.java b/android/app/src/main/java/com/mattermost/rnbeta/MainActivity.java index 994260489..844857672 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/MainActivity.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/MainActivity.java @@ -2,62 +2,9 @@ package com.mattermost.rnbeta; import com.reactnativenavigation.controllers.SplashActivity; -import java.lang.ref.WeakReference; - -import android.content.Context; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.graphics.Color; -import android.widget.TextView; -import android.view.ViewGroup.LayoutParams; -import android.view.Gravity; -import android.util.TypedValue; - public class MainActivity extends SplashActivity { - - private static ImageView imageView; - private static WeakReference wr_activity; - protected static MainActivity getActivity() { - return wr_activity.get(); - } - - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - // @Override - // protected String getMainComponentName() { - // return "Mattermost"; - // } - - @Override - public LinearLayout createSplashLayout() { - wr_activity = new WeakReference<>(this); - LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); - Context context = getActivity(); - final int drawableId = getImageId(); - - NotificationsLifecycleFacade.getInstance().LoadManagedConfig(getActivity()); - - imageView = new ImageView(context); - imageView.setImageResource(drawableId); - - imageView.setLayoutParams(layoutParams); - imageView.setScaleType(ImageView.ScaleType.CENTER); - - LinearLayout view = new LinearLayout(this); - view.setBackgroundColor(Color.parseColor("#FFFFFF")); - view.setGravity(Gravity.CENTER); - view.addView(imageView); - - return view; - } - - private static int getImageId() { - int drawableId = getActivity().getResources().getIdentifier("splash", "drawable", getActivity().getClass().getPackage().getName()); - if (drawableId == 0) { - drawableId = getActivity().getResources().getIdentifier("splash", "drawable", getActivity().getPackageName()); - } - return drawableId; - } + @Override + public int getSplashLayout() { + return R.layout.launch_screen; + } } diff --git a/android/app/src/main/res/layout/launch_screen.xml b/android/app/src/main/res/layout/launch_screen.xml new file mode 100644 index 000000000..8e2032943 --- /dev/null +++ b/android/app/src/main/res/layout/launch_screen.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 000000000..7dcc846ad --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 778e66aaa..548f3e7fa 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -3,7 +3,9 @@ diff --git a/app/mattermost.js b/app/mattermost.js index 9a2c5e2ac..52aaba15f 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -544,7 +544,7 @@ export default class Mattermost { launchApp = () => { this.handleManagedConfig().then((shouldStart) => { if (shouldStart) { - this.startApp(); + this.startApp('fade'); } }); }; @@ -576,7 +576,8 @@ export default class Mattermost { navigatorStyle: { navBarHidden: true, statusBarHidden: false, - statusBarHideWithNavBar: false + statusBarHideWithNavBar: false, + screenBackgroundColor: 'transparent' } }, passProps: { diff --git a/app/screens/load_team/load_team.js b/app/screens/load_team/load_team.js index 6be5491c3..f0546dfbf 100644 --- a/app/screens/load_team/load_team.js +++ b/app/screens/load_team/load_team.js @@ -67,7 +67,8 @@ export default class LoadTeam extends PureComponent { actions.initialize(); navigator.resetTo({ screen: 'Channel', - animated: false, + animated: true, + animationType: 'fade', navigatorStyle: { navBarHidden: true, statusBarHidden: false, diff --git a/app/screens/root/root.js b/app/screens/root/root.js index aa740d71d..60d1965be 100644 --- a/app/screens/root/root.js +++ b/app/screens/root/root.js @@ -39,7 +39,8 @@ export default class Root extends Component { navigator.resetTo({ screen: 'LoadTeam', title: '', - animated: false, + animated: true, + animationType: 'fade', backButtonTitle: '', navigatorStyle: { statusBarHidden: false, @@ -57,7 +58,8 @@ export default class Root extends Component { navigator.resetTo({ screen: 'SelectServer', - animated: false, + animated: true, + animationType: 'fade', navigatorStyle: { navBarHidden: true, navBarBackgroundColor: 'black',