From ac7940a17a52724d9a246e330b5c3edba17e515c Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Mon, 30 Nov 2015 18:30:50 +0300 Subject: [PATCH] Review and rebase fixes --- .gitignore | 1 - android/jni/Android.mk | 2 +- android/jni/com/mapswithme/maps/Framework.cpp | 5 +- .../com/mapswithme/maps/MwmApplication.cpp | 1 + .../src/com/mapswithme/maps/MwmActivity.java | 19 +- .../com/mapswithme/maps/MwmApplication.java | 3 +- .../maps/routing/NavigationController.java | 5 +- .../mapswithme/maps/routing/SlotFrame.java | 2 +- .../FloatingSearchToolbarController.java | 1 + android/src/com/mapswithme/util/UiUtils.java | 188 ++++++------------ iphone/Maps/Maps.xcodeproj/project.pbxproj | 14 +- tools/autobuild/android.sh | 2 +- 12 files changed, 86 insertions(+), 157 deletions(-) diff --git a/.gitignore b/.gitignore index 6134a7c7e1..ebbf26dc2f 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,6 @@ bada/Maps/*.zip # data data/intermediate_data data/**/*.mwm -data/**/*.offsets !data/World.mwm !data/WorldCoasts.mwm # temporary files for downloader diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 8d39dec575..1291ef652b 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -13,7 +13,7 @@ endif # List all static libraries which are built using our own scripts in tools/android # #################################################################################### -MY_PREBUILT_LIBS_PATH := ../../../omim-android-drape-$(OMIM_CONFIG)-$(TARGET_ARCH_ABI)/out/$(OMIM_CONFIG) +MY_PREBUILT_LIBS_PATH := ../../../omim-android-$(OMIM_CONFIG)-$(TARGET_ARCH_ABI)/out/$(OMIM_CONFIG) # Avoid clean errors due to missing external static libs ifneq ($(MAKECMDGOALS),clean) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 539dbb6477..92ca2a8b39 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -1068,10 +1068,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeDisableFollowing(JNIEnv * env, jclass thiz) { - android::Platform::RunOnGuiThreadImpl([]() - { - (void)g_framework->NativeFramework()->DisableFollowMode(); - }); + frm()->DisableFollowMode(); } JNIEXPORT jobjectArray JNICALL diff --git a/android/jni/com/mapswithme/maps/MwmApplication.cpp b/android/jni/com/mapswithme/maps/MwmApplication.cpp index 5de9b805ed..0e7e73f689 100644 --- a/android/jni/com/mapswithme/maps/MwmApplication.cpp +++ b/android/jni/com/mapswithme/maps/MwmApplication.cpp @@ -12,6 +12,7 @@ extern "C" jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath, jstring flavorName, jstring buildType, jboolean isYota, jboolean isTablet) { + android::Platform::Instance().InitAppMethodRefs(thiz); android::Platform::Instance().Initialize( env, apkPath, storagePath, tmpPath, obbGooglePath, flavorName, buildType, isYota, isTablet); } diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index eb72211eae..6ee5e067d6 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -60,6 +60,7 @@ import com.mapswithme.maps.widget.menu.MainMenu; import com.mapswithme.maps.widget.placepage.BasePlacePageAnimationController; import com.mapswithme.maps.widget.placepage.PlacePageView; import com.mapswithme.maps.widget.placepage.PlacePageView.State; +import com.mapswithme.util.Animations; import com.mapswithme.util.BottomSheetHelper; import com.mapswithme.util.Config; import com.mapswithme.util.InputUtils; @@ -328,11 +329,9 @@ public class MwmActivity extends BaseMwmFragmentActivity mFrame = findViewById(R.id.map_fragment_container); mFadeView = (FadeView) findViewById(R.id.fade_view); - mFadeView.setListener(new FadeView.Listener() - { + mFadeView.setListener(new FadeView.Listener() { @Override - public void onTouch() - { + public void onTouch() { mMainMenu.close(true); } }); @@ -343,7 +342,7 @@ public class MwmActivity extends BaseMwmFragmentActivity mMapFragment = (MapFragment) MapFragment.instantiate(this, MapFragment.class.getName(), null); getSupportFragmentManager() .beginTransaction() - .replace(R.id.map_fragment_container, mMapFragment, FRAGMENT_TAG) + .replace(R.id.map_fragment_container, mMapFragment, MapFragment.FRAGMENT_TAG) .commit(); } mFrame.setOnTouchListener(this); @@ -407,11 +406,9 @@ public class MwmActivity extends BaseMwmFragmentActivity private void startLocationToPoint(String statisticsEvent, String alohaEvent, final @Nullable MapObject endPoint) { - closeMenu(statisticsEvent, alohaEvent, new Runnable() - { + closeMenu(statisticsEvent, alohaEvent, new Runnable() { @Override - public void run() - { + public void run() { RoutingController.get().prepare(endPoint); if (mPlacePage.isDocked() || !mPlacePage.isFloating()) @@ -719,7 +716,7 @@ public class MwmActivity extends BaseMwmFragmentActivity { super.onResume(); - mLocationStateModeListenerId = LocationState.INSTANCE.addLocationStateModeListener(this); + LocationState.INSTANCE.setMyPositionModeListener(this); invalidateLocationState(); mSearchController.refreshToolbar(); @@ -802,7 +799,7 @@ public class MwmActivity extends BaseMwmFragmentActivity @Override protected void onPause() { - LocationState.INSTANCE.removeLocationStateModeListener(mLocationStateModeListenerId); + LocationState.INSTANCE.removeMyPositionModeListener(); pauseLocation(); TtsPlayer.INSTANCE.stop(); LikesManager.INSTANCE.cancelDialogs(); diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java index 916a896498..9ab3e0ecaa 100644 --- a/android/src/com/mapswithme/maps/MwmApplication.java +++ b/android/src/com/mapswithme/maps/MwmApplication.java @@ -44,7 +44,6 @@ public class MwmApplication extends Application private boolean mAreCountersInitialized; private boolean mIsFrameworkInitialized; - private boolean mAreStatsInitialised; private Handler mMainLoopHandler; private Object mMainQueueToken = new Object(); @@ -196,6 +195,8 @@ public class MwmApplication extends Application private native void nativeInitPlatform(String apkPath, String storagePath, String tmpPath, String obbGooglePath, String flavorName, String buildType, boolean isYota, boolean isTablet); + private native void nativeInitFramework(); + private native void nativeAddLocalization(String name, String value); /** diff --git a/android/src/com/mapswithme/maps/routing/NavigationController.java b/android/src/com/mapswithme/maps/routing/NavigationController.java index fd000c341c..a9fcfc00f2 100644 --- a/android/src/com/mapswithme/maps/routing/NavigationController.java +++ b/android/src/com/mapswithme/maps/routing/NavigationController.java @@ -10,6 +10,7 @@ import com.mapswithme.maps.R; import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut; import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.widget.FlatProgressView; +import com.mapswithme.util.Animations; import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; import com.mapswithme.util.statistics.AlohaHelper; @@ -75,11 +76,11 @@ public class NavigationController if (info.vehicleNextTurnDirection.containsNextTurn()) { - UiUtils.appearSlidingDown(mNextTurnFrame, null); + Animations.appearSliding(mNextTurnFrame, Animations.TOP, null); info.vehicleNextTurnDirection.setNextTurnDrawable(mNextTurnImage); } else - UiUtils.disappearSlidingUp(mNextTurnFrame, null); + Animations.disappearSliding(mNextTurnFrame, Animations.BOTTOM, null); } private void updatePedestrian(RoutingInfo info) diff --git a/android/src/com/mapswithme/maps/routing/SlotFrame.java b/android/src/com/mapswithme/maps/routing/SlotFrame.java index 561b147af9..7273af7072 100644 --- a/android/src/com/mapswithme/maps/routing/SlotFrame.java +++ b/android/src/com/mapswithme/maps/routing/SlotFrame.java @@ -223,7 +223,7 @@ public class SlotFrame extends LinearLayout setClipToPadding(false); setClickable(true); - int padding = UiUtils.dp(8); + int padding = UiUtils.toPx(8); setPadding(padding, padding / 4, padding, padding); mSlotFrom = new Slot(this, R.id.from, 1); diff --git a/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java b/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java index e054ebdee2..44e8bea1ee 100644 --- a/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java +++ b/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java @@ -6,6 +6,7 @@ import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.api.ParsedMwmRequest; import com.mapswithme.maps.widget.SearchToolbarController; import com.mapswithme.util.Animations; +import com.mapswithme.util.UiUtils; public class FloatingSearchToolbarController extends SearchToolbarController { diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java index 8560c005b4..fac9afa552 100644 --- a/android/src/com/mapswithme/util/UiUtils.java +++ b/android/src/com/mapswithme/util/UiUtils.java @@ -62,19 +62,11 @@ public final class UiUtils void onViewMeasured(int width, int height); } - - public static void waitLayout(final View view, @NonNull final ViewTreeObserver.OnGlobalLayoutListener callback) - { - ViewTreeObserver observer = view.getViewTreeObserver(); - if (!observer.isAlive()) - throw new IllegalArgumentException("ViewTreeObserver is not alive"); - - observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() - { + public static void waitLayout(final View view, @NonNull final ViewTreeObserver.OnGlobalLayoutListener callback) { + view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @Override - public void onGlobalLayout() - { + public void onGlobalLayout() { // viewTreeObserver can be dead(isAlive() == false), we should get a new one here. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) view.getViewTreeObserver().removeGlobalOnLayoutListener(this); @@ -168,6 +160,21 @@ public final class UiUtils invisible(frame, id); } + public static boolean isHidden(View view) + { + return view.getVisibility() == View.GONE; + } + + public static boolean isInvisible(View view) + { + return view.getVisibility() == View.INVISIBLE; + } + + public static boolean isVisible(View view) + { + return view.getVisibility() == View.VISIBLE; + } + public static void visibleIf(boolean condition, View view) { view.setVisibility(condition ? View.VISIBLE : View.INVISIBLE); @@ -194,11 +201,6 @@ public final class UiUtils hide(views); } - public static boolean isVisible(View view) - { - return (view.getVisibility() == View.VISIBLE); - } - public static void setTextAndShow(TextView tv, CharSequence text) { tv.setText(text); @@ -221,34 +223,34 @@ public final class UiUtils public void run() { new AlertDialog.Builder(activity) - .setCancelable(false) - .setMessage(message) - .setPositiveButton(activity.getString(R.string.connection_settings), new DialogInterface.OnClickListener() - { - @Override - public void onClick(DialogInterface dlg, int which) - { - try + .setCancelable(false) + .setMessage(message) + .setPositiveButton(activity.getString(R.string.connection_settings), new DialogInterface.OnClickListener() { - activity.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); - } catch (final Exception ex) - { - ex.printStackTrace(); - } + @Override + public void onClick(DialogInterface dlg, int which) + { + try + { + activity.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); + } catch (final Exception ex) + { + ex.printStackTrace(); + } - dlg.dismiss(); - } - }) - .setNegativeButton(activity.getString(R.string.close), new DialogInterface.OnClickListener() - { - @Override - public void onClick(DialogInterface dlg, int which) - { - dlg.dismiss(); - } - }) - .create() - .show(); + dlg.dismiss(); + } + }) + .setNegativeButton(activity.getString(R.string.close), new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dlg, int which) + { + dlg.dismiss(); + } + }) + .create() + .show(); } }); } @@ -262,14 +264,13 @@ public final class UiUtils public static AlertDialog buildAlertDialog(Activity activity, int titleId) { return new AlertDialog.Builder(activity) - .setCancelable(false) - .setMessage(titleId) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() - { - @Override - public void onClick(DialogInterface dlg, int which) { dlg.dismiss(); } - }) - .create(); + .setCancelable(false) + .setMessage(titleId) + .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dlg, int which) { dlg.dismiss(); } + }) + .create(); } public static void showAlertDialog(Activity activity, int titleId) @@ -283,18 +284,18 @@ public final class UiUtils String rotation = activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "|" : "-"; switch (activity.getWindowManager().getDefaultDisplay().getRotation()) { - case Surface.ROTATION_0: - rotation += "0"; - break; - case Surface.ROTATION_90: - rotation += "90"; - break; - case Surface.ROTATION_180: - rotation += "180"; - break; - case Surface.ROTATION_270: - rotation += "270"; - break; + case Surface.ROTATION_0: + rotation += "0"; + break; + case Surface.ROTATION_90: + rotation += "90"; + break; + case Surface.ROTATION_180: + rotation += "180"; + break; + case Surface.ROTATION_270: + rotation += "270"; + break; } return rotation; } @@ -314,69 +315,6 @@ public final class UiUtils return isSmallTablet() || isBigTablet(); } - public static void appearSlidingDown(final View view, @Nullable final Runnable completionListener) - { - if (isVisible(view) || view.getAnimation() != null) - { - if (completionListener != null) - completionListener.run(); - return; - } - - show(view); - - Animation a = AnimationUtils.loadAnimation(view.getContext(), R.anim.slide_appear_down); - if (completionListener != null) - a.setAnimationListener(new UiUtils.SimpleAnimationListener() - { - @Override - public void onAnimationEnd(Animation animation) - { - completionListener.run(); - } - }); - - view.startAnimation(a); - } - - public static void disappearSlidingUp(final View view, @Nullable final Runnable completionListener) - { - if (!isVisible(view) || view.getAnimation() != null) - { - if (completionListener != null) - completionListener.run(); - return; - } - - Animation a = AnimationUtils.loadAnimation(view.getContext(), R.anim.slide_disappear_up); - a.setAnimationListener(new UiUtils.SimpleAnimationListener() - { - @Override - public void onAnimationEnd(Animation animation) - { - hide(view); - view.clearAnimation(); - - if (completionListener != null) - completionListener.run(); - } - }); - - view.startAnimation(a); - } - - public static void exchangeViewsAnimatedDown(final View toHide, final View toShow, @Nullable final Runnable completionListener) - { - disappearSlidingUp(toHide, new Runnable() - { - @Override - public void run() - { - appearSlidingDown(toShow, completionListener); - } - }); - } - public static int dimen(@DimenRes int id) { return MwmApplication.get().getResources().getDimensionPixelSize(id); diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 03257d491f..b4ad55507a 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -123,7 +123,7 @@ 34F45E8E1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F45E8D1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm */; }; 34F45E901B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F45E8F1B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib */; }; 34F8ADD91B97229A004184CC /* MWMSearchTableView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F8ADD81B97229A004184CC /* MWMSearchTableView.mm */; }; - 34FE4C451BCC013500066718 /* MWMMapWidgets.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34FE4C441BCC013500066718 /* MWMMapWidgets.mm */; settings = {ASSET_TAGS = (); }; }; + 34FE4C451BCC013500066718 /* MWMMapWidgets.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34FE4C441BCC013500066718 /* MWMMapWidgets.mm */; }; 45159BF91B0CA2D5009BFA85 /* resources-6plus in Resources */ = {isa = PBXBuildFile; fileRef = 45159BF81B0CA2D5009BFA85 /* resources-6plus */; }; 4519503A1B7A3E070085DA05 /* patterns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 451950391B7A3E070085DA05 /* patterns.txt */; }; 4519503B1B7A3E390085DA05 /* patterns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 451950391B7A3E070085DA05 /* patterns.txt */; }; @@ -621,12 +621,9 @@ B0DFE6311A1B78A200B6C35E /* LocalNotifications.plist in Resources */ = {isa = PBXBuildFile; fileRef = B0DFE62F1A1B78A200B6C35E /* LocalNotifications.plist */; }; B0FBFA271A515AFD0086819E /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = B0FBFA261A515AFD0086819E /* ViewController.mm */; }; B0FBFA2B1A515B4C0086819E /* TableViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = B0FBFA2A1A515B4C0086819E /* TableViewController.mm */; }; - BB3E6ED81C03229C007EF3F8 /* resources-hdpi in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED21C03229C007EF3F8 /* resources-hdpi */; settings = {ASSET_TAGS = (); }; }; - BB3E6ED91C03229C007EF3F8 /* resources-hdpi_clear in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED31C03229C007EF3F8 /* resources-hdpi_clear */; settings = {ASSET_TAGS = (); }; }; - BB3E6EDA1C03229C007EF3F8 /* resources-hdpi_dark in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED41C03229C007EF3F8 /* resources-hdpi_dark */; settings = {ASSET_TAGS = (); }; }; - BB3E6EDE1C0327F8007EF3F8 /* resources-hdpi in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED21C03229C007EF3F8 /* resources-hdpi */; settings = {ASSET_TAGS = (); }; }; - BB3E6EDF1C0327FB007EF3F8 /* resources-hdpi_clear in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED31C03229C007EF3F8 /* resources-hdpi_clear */; settings = {ASSET_TAGS = (); }; }; - BB3E6EE01C0327FE007EF3F8 /* resources-hdpi_dark in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED41C03229C007EF3F8 /* resources-hdpi_dark */; settings = {ASSET_TAGS = (); }; }; + BB3E6EDE1C0327F8007EF3F8 /* resources-hdpi in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED21C03229C007EF3F8 /* resources-hdpi */; }; + BB3E6EDF1C0327FB007EF3F8 /* resources-hdpi_clear in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED31C03229C007EF3F8 /* resources-hdpi_clear */; }; + BB3E6EE01C0327FE007EF3F8 /* resources-hdpi_dark in Resources */ = {isa = PBXBuildFile; fileRef = BB3E6ED41C03229C007EF3F8 /* resources-hdpi_dark */; }; CB252D6F16FF82C9001E41E9 /* Statistics.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB252D6C16FF82C8001E41E9 /* Statistics.mm */; }; ED48BBB517C267F5003E7E92 /* ColorPickerView.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED48BBB417C267F5003E7E92 /* ColorPickerView.mm */; }; ED48BBBA17C2B1E2003E7E92 /* CircleView.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED48BBB917C2B1E2003E7E92 /* CircleView.mm */; }; @@ -3115,7 +3112,6 @@ FA459EB414327AF700B5BB3C /* WorldCoasts.mwm in Resources */, FA85F633145DDDC20090E1A0 /* packed_polygons.bin in Resources */, F6ED13561B16439E0095C6DE /* MWMDirectionView.xib in Resources */, - BB3E6ED81C03229C007EF3F8 /* resources-hdpi in Resources */, 34D15BA91BD8F93C00C8BCBE /* AddSetTableViewCell.xib in Resources */, FA99CB73147089B100689A9A /* Localizable.strings in Resources */, 34CFFE8D1B7DE71C009D0C9F /* MWMSearchView.xib in Resources */, @@ -3132,8 +3128,6 @@ 3438CDF91B8616760051AA78 /* MWMSearchShowOnMapCell.xib in Resources */, 34BAB6EE1BB2DFCE00DB941B /* MWMBottomMenuCollectionViewPortraitCell.xib in Resources */, 349A358D1B53EABC009677EE /* MWMSearchDownloadMapRequest.xib in Resources */, - BB3E6EDA1C03229C007EF3F8 /* resources-hdpi_dark in Resources */, - BB3E6ED91C03229C007EF3F8 /* resources-hdpi_clear in Resources */, 4A23D15B1B8B4DD700D4EB6F /* drules_proto_clear.bin in Resources */, 341C2A5B1B720B8A00AD41A1 /* MWMAPIBarView.xib in Resources */, 34B82AC51B84608600180497 /* MWMSearchHistoryClearCell.xib in Resources */, diff --git a/tools/autobuild/android.sh b/tools/autobuild/android.sh index 2da5bb690d..b5a61c2157 100755 --- a/tools/autobuild/android.sh +++ b/tools/autobuild/android.sh @@ -16,7 +16,7 @@ source "$MY_PATH/ndk_helper.sh" MKSPEC="$MY_PATH/../mkspecs/android-clang" QMAKE_PARAMS="CONFIG+=${CONFIGURATION}" -SHADOW_DIR_BASE="$MY_PATH/../../../omim-android-drape" +SHADOW_DIR_BASE="$MY_PATH/../../../omim-android" # Try to read ndk root path from android/local.properties file export NDK_ROOT=$(GetNdkRoot) || ( echo "Can't read NDK root path from android/local.properties"; exit 1 )