Fix adding variables
This commit is contained in:
parent
465e424488
commit
b00ecf9306
1 changed files with 32 additions and 17 deletions
|
@ -6,12 +6,14 @@ import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -22,6 +24,12 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
public static boolean SHOW = true;
|
public static boolean SHOW = true;
|
||||||
private static final int SECOND_SPLASH_TIME_OUT = 5000;
|
private static final int SECOND_SPLASH_TIME_OUT = 5000;
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
private FragmentActivity activity;
|
||||||
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
public OsmandApplication getMyApplication() {
|
||||||
|
return ((OsmandApplication) activity.getApplication());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasNavBar() {
|
private boolean hasNavBar() {
|
||||||
int id = getResources().getIdentifier("config_showNavigationBar", "bool", "android");
|
int id = getResources().getIdentifier("config_showNavigationBar", "bool", "android");
|
||||||
|
@ -69,25 +77,26 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
RelativeLayout view = new RelativeLayout(getActivity());
|
activity = getActivity();
|
||||||
|
app = getMyApplication();
|
||||||
|
|
||||||
|
RelativeLayout view = new RelativeLayout(activity);
|
||||||
view.setOnClickListener(null);
|
view.setOnClickListener(null);
|
||||||
view.setBackgroundColor(getResources().getColor(R.color.map_background_color_light));
|
view.setBackgroundColor(getResources().getColor(R.color.map_background_color_light));
|
||||||
|
|
||||||
ImageView logo = new ImageView(getContext());
|
ImageView logo = new ImageView(getContext());
|
||||||
if (Version.isFreeVersion(((MapActivity) getActivity()).getMyApplication())) {
|
if (Version.isFreeVersion(app)) {
|
||||||
logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand));
|
logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand));
|
||||||
} else if ((Version.isPaidVersion(((MapActivity) getActivity()).getMyApplication())) ||
|
} else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) {
|
||||||
(Version.isDeveloperVersion(((MapActivity) getActivity()).getMyApplication()))) {
|
|
||||||
logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand_plus));
|
logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand_plus));
|
||||||
}
|
}
|
||||||
RelativeLayout.LayoutParams logoLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
RelativeLayout.LayoutParams logoLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
logoLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
logoLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
||||||
logoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
logoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
||||||
ImageView text = new ImageView(getActivity());
|
ImageView text = new ImageView(activity);
|
||||||
if (Version.isFreeVersion(((MapActivity) getActivity()).getMyApplication())) {
|
if (Version.isFreeVersion(app)) {
|
||||||
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand));
|
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand));
|
||||||
} else if ((Version.isPaidVersion(((MapActivity) getActivity()).getMyApplication())) ||
|
} else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) {
|
||||||
(Version.isDeveloperVersion(((MapActivity) getActivity()).getMyApplication()))) {
|
|
||||||
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus));
|
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus));
|
||||||
}
|
}
|
||||||
RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
@ -102,10 +111,10 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
int textPaddingLeft = 0;
|
int textPaddingLeft = 0;
|
||||||
int textPaddingRight = 0;
|
int textPaddingRight = 0;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
|
||||||
if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
if (AndroidUiHelper.getScreenOrientation(activity) == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
||||||
logoPaddingLeft = getNavigationBarWidth();
|
logoPaddingLeft = getNavigationBarWidth();
|
||||||
textPaddingLeft = getNavigationBarWidth();
|
textPaddingLeft = getNavigationBarWidth();
|
||||||
} else if (AndroidUiHelper.getScreenOrientation(getActivity()) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
} else if (AndroidUiHelper.getScreenOrientation(activity) == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
||||||
logoPaddingRight = getNavigationBarWidth();
|
logoPaddingRight = getNavigationBarWidth();
|
||||||
textPaddingRight = getNavigationBarWidth();
|
textPaddingRight = getNavigationBarWidth();
|
||||||
}
|
}
|
||||||
|
@ -128,19 +137,23 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
((MapActivity)getActivity()).disableDrawer();
|
if (activity instanceof MapActivity) {
|
||||||
|
((MapActivity) activity).disableDrawer();
|
||||||
|
}
|
||||||
if (!started) {
|
if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
((MapActivity)getActivity()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
if (activity instanceof MapActivity) {
|
||||||
if (((MapActivity)getActivity()).getMyApplication().getSettings().MAP_SCREEN_ORIENTATION.get() != getActivity().getRequestedOrientation()) {
|
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
getActivity().setRequestedOrientation(((MapActivity)getActivity()).getMyApplication().getSettings().MAP_SCREEN_ORIENTATION.get());
|
if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != activity.getRequestedOrientation()) {
|
||||||
// can't return from this method we are not sure if activity will be recreated or not
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
((MapActivity)getActivity()).getSupportFragmentManager().beginTransaction().remove(SecondSplashScreenFragment.this).commitAllowingStateLoss();
|
activity.getSupportFragmentManager().beginTransaction().remove(SecondSplashScreenFragment.this).commitAllowingStateLoss();
|
||||||
}
|
}
|
||||||
}, SECOND_SPLASH_TIME_OUT);
|
}, SECOND_SPLASH_TIME_OUT);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +162,8 @@ public class SecondSplashScreenFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
((MapActivity)getActivity()).enableDrawer();
|
if (activity instanceof MapActivity) {
|
||||||
|
((MapActivity) activity).enableDrawer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue