CB-12626: Updated Android plugin
This closes #125 Prefer a slightly slower, but bulletproof, way to check for the splashscreen instead of relying on the Cordova preferences. This fixes the splash screen on several phones.
This commit is contained in:
parent
833dc7f783
commit
50a55883d3
@ -77,6 +77,18 @@ public class SplashScreen extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getSplashId() {
|
||||||
|
int drawableId = 0;
|
||||||
|
String splashResource = preferences.getString("SplashScreen", "screen");
|
||||||
|
if (splashResource != null) {
|
||||||
|
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName());
|
||||||
|
if (drawableId == 0) {
|
||||||
|
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return drawableId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void pluginInitialize() {
|
protected void pluginInitialize() {
|
||||||
if (HAS_BUILT_IN_SPLASH_SCREEN) {
|
if (HAS_BUILT_IN_SPLASH_SCREEN) {
|
||||||
@ -90,17 +102,7 @@ public class SplashScreen extends CordovaPlugin {
|
|||||||
getView().setVisibility(View.INVISIBLE);
|
getView().setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
int drawableId = getSplashId();
|
||||||
if (drawableId == 0) {
|
|
||||||
String splashResource = preferences.getString("SplashScreen", "screen");
|
|
||||||
if (splashResource != null) {
|
|
||||||
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName());
|
|
||||||
if (drawableId == 0) {
|
|
||||||
drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName());
|
|
||||||
}
|
|
||||||
//preferences.set("SplashDrawableId", drawableId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save initial orientation.
|
// Save initial orientation.
|
||||||
orientation = cordova.getActivity().getResources().getConfiguration().orientation;
|
orientation = cordova.getActivity().getResources().getConfiguration().orientation;
|
||||||
@ -205,7 +207,7 @@ public class SplashScreen extends CordovaPlugin {
|
|||||||
|
|
||||||
// Splash drawable may change with orientation, so reload it.
|
// Splash drawable may change with orientation, so reload it.
|
||||||
if (splashImageView != null) {
|
if (splashImageView != null) {
|
||||||
int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
int drawableId = getSplashId();
|
||||||
if (drawableId != 0) {
|
if (drawableId != 0) {
|
||||||
splashImageView.setImageDrawable(cordova.getActivity().getResources().getDrawable(drawableId));
|
splashImageView.setImageDrawable(cordova.getActivity().getResources().getDrawable(drawableId));
|
||||||
}
|
}
|
||||||
@ -263,7 +265,7 @@ public class SplashScreen extends CordovaPlugin {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void showSplashScreen(final boolean hideAfterDelay) {
|
private void showSplashScreen(final boolean hideAfterDelay) {
|
||||||
final int splashscreenTime = preferences.getInteger("SplashScreenDelay", DEFAULT_SPLASHSCREEN_DURATION);
|
final int splashscreenTime = preferences.getInteger("SplashScreenDelay", DEFAULT_SPLASHSCREEN_DURATION);
|
||||||
final int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
final int drawableId = getSplashId();
|
||||||
|
|
||||||
final int fadeSplashScreenDuration = getFadeDuration();
|
final int fadeSplashScreenDuration = getFadeDuration();
|
||||||
final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration);
|
final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user