Merge pull request #4152 from osmandapp/splash_screen

Splash screen
This commit is contained in:
vshcherb 2017-07-20 17:29:37 +02:00 committed by GitHub
commit 63bd1e74d2
9 changed files with 77 additions and 11 deletions

View file

@ -0,0 +1,10 @@
<?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/map_background_color_light"/>
<item android:top="@dimen/splash_screen_logo_top">
<bitmap
android:gravity="center_horizontal|top"
android:src="@drawable/ic_logo_splash_osmand"/>
</item>
</layer-list>

View file

@ -0,0 +1,10 @@
<?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/map_background_color_light"/>
<item android:top="@dimen/splash_screen_logo_top">
<bitmap
android:gravity="center_horizontal|top"
android:src="@drawable/ic_logo_splash_osmand"/>
</item>
</layer-list>

View file

@ -0,0 +1,10 @@
<?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/map_background_color_light"/>
<item android:top="@dimen/splash_screen_logo_top">
<bitmap
android:gravity="center_horizontal|top"
android:src="@drawable/ic_logo_splash_osmand_plus"/>
</item>
</layer-list>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/map_background_color_light"/>
</shape>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/map_background_color_light"/>
</shape>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/map_background_color_light"/>
</shape>

View file

@ -18,11 +18,12 @@ import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.inapp.InAppHelper;
public class SecondSplashScreenFragment extends Fragment {
public static final String TAG = "SecondSplashScreenFragment";
public static boolean SHOW = true;
private static final int SECOND_SPLASH_TIME_OUT = 5000;
private static final int SECOND_SPLASH_TIME_OUT = 8000;
private boolean started = false;
private FragmentActivity activity;
private OsmandApplication app;
@ -95,9 +96,19 @@ public class SecondSplashScreenFragment extends Fragment {
logoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
ImageView text = new ImageView(activity);
if (Version.isFreeVersion(app)) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand));
if ((InAppHelper.isSubscribedToLiveUpdates() && InAppHelper.isFullVersionPurchased()) || InAppHelper.isSubscribedToLiveUpdates()) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_osmlive));
} else if (InAppHelper.isFullVersionPurchased()) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_inapp));
} else {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand));
}
} else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus));
if (InAppHelper.isSubscribedToLiveUpdates()) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus_osmlive));
} else {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus));
}
}
RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
textLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
@ -142,18 +153,14 @@ public class SecondSplashScreenFragment extends Fragment {
}
if (!started) {
started = true;
SecondSplashScreenFragment.SHOW = false;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (activity instanceof MapActivity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != activity.getRequestedOrientation()) {
activity.setRequestedOrientation(app.getSettings().MAP_SCREEN_ORIENTATION.get());
// can't return from this method we are not sure if activity will be recreated or not
}
if (activity instanceof MapActivity && !((MapActivity) activity).isActivityDestroyed()) {
((MapActivity)activity).dismissSecondSplashScreen();
}
activity.getSupportFragmentManager().beginTransaction().remove(SecondSplashScreenFragment.this).commitAllowingStateLoss();
}
}, SECOND_SPLASH_TIME_OUT);
}

View file

@ -189,6 +189,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private boolean mIsDestroyed = false;
private InAppHelper inAppHelper;
private SecondSplashScreenFragment secondSplashScreenFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
@ -692,7 +694,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
FirstUsageWelcomeFragment.SHOW = false;
if (SecondSplashScreenFragment.SHOW) {
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, new SecondSplashScreenFragment(), SecondSplashScreenFragment.TAG).commitAllowingStateLoss();
secondSplashScreenFragment = new SecondSplashScreenFragment();
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, secondSplashScreenFragment, SecondSplashScreenFragment.TAG).commitAllowingStateLoss();
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
@ -700,7 +703,16 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
// can't return from this method we are not sure if activity will be recreated or not
}
}
}
public void dismissSecondSplashScreen() {
SecondSplashScreenFragment.SHOW = false;
getSupportFragmentManager().beginTransaction().remove(secondSplashScreenFragment).commitAllowingStateLoss();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
setRequestedOrientation(app.getSettings().MAP_SCREEN_ORIENTATION.get());
// can't return from this method we are not sure if activity will be recreated or not
}
}
@Override

View file

@ -29,6 +29,7 @@ import android.view.WindowManager;
import android.widget.Toast;
import net.osmand.PlatformUtil;
import net.osmand.SecondSplashScreenFragment;
import net.osmand.access.AccessibilityActionsProvider;
import net.osmand.core.android.MapRendererView;
import net.osmand.data.LatLon;
@ -662,6 +663,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
}
if (activity instanceof MapActivity && !((MapActivity) activity).isActivityDestroyed() &&
((MapActivity) activity).getSupportFragmentManager().findFragmentByTag(SecondSplashScreenFragment.TAG) != null) {
((MapActivity) activity).dismissSecondSplashScreen();
}
for (int i = 0; i < layers.size(); i++) {
try {
OsmandMapLayer layer = layers.get(i);