Merge pull request #7274 from osmandapp/version_check_fix

Add Android API version checks
This commit is contained in:
Alexey 2019-07-17 13:26:42 +03:00 committed by GitHub
commit 22e23c8c01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -92,7 +93,11 @@ public class AppModeDialog {
LinearLayout container = ll.findViewById(R.id.app_modes_content); LinearLayout container = ll.findViewById(R.id.app_modes_content);
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() : 0; int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() : 0;
scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0); scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this); if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
ll.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
} }
}; };
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener); ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);

View file

@ -16,6 +16,7 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build;
import android.os.Build.VERSION; import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES; import android.os.Build.VERSION_CODES;
import android.os.Bundle; import android.os.Bundle;
@ -325,7 +326,9 @@ public class EditProfileFragment extends BaseOsmAndFragment {
popupWindow.setAnchorView(selectColorBtn); popupWindow.setAnchorView(selectColorBtn);
popupWindow.setContentWidth(AndroidUtils.dpToPx(activity, 200f)); popupWindow.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
popupWindow.setModal(true); popupWindow.setModal(true);
popupWindow.setDropDownGravity(Gravity.TOP | Gravity.RIGHT); if (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
popupWindow.setDropDownGravity(Gravity.TOP | Gravity.RIGHT);
}
popupWindow.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f)); popupWindow.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f)); popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
final ProfileColorAdapter profileColorAdapter = new ProfileColorAdapter(activity, mode.getIconColorInfo()); final ProfileColorAdapter profileColorAdapter = new ProfileColorAdapter(activity, mode.getIconColorInfo());

View file

@ -6,6 +6,7 @@ import android.content.DialogInterface.OnDismissListener;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.ColorRes; import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
@ -855,7 +856,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
LinearLayout container = ll.findViewById(R.id.app_modes_content); LinearLayout container = ll.findViewById(R.id.app_modes_content);
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() + rightTogglePadding : 0; int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() + rightTogglePadding : 0;
scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0); scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this); if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
ll.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
} }
}; };
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener); ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);