From 1c80a423b7607df08b30826138dfbf43380a9b3f Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 3 Nov 2016 15:25:38 +0300 Subject: [PATCH] Fix free version dialog --- OsmAnd/res/layout/free_version_banner.xml | 18 +++++------ .../ui/FreeVersionDialogFragment.java | 30 ++++++++++++------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/OsmAnd/res/layout/free_version_banner.xml b/OsmAnd/res/layout/free_version_banner.xml index 2db4931375..96f8b12100 100644 --- a/OsmAnd/res/layout/free_version_banner.xml +++ b/OsmAnd/res/layout/free_version_banner.xml @@ -90,14 +90,16 @@ + android:background="@color/dashboard_divider_dark" + android:visibility="visible"/> + android:orientation="horizontal" + android:visibility="gone"> + android:background="@color/dashboard_divider_dark" + android:visibility="gone"/> - - diff --git a/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java index 720fb69233..cb9f39db95 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java @@ -1,44 +1,52 @@ package net.osmand.plus.download.ui; +import android.annotation.SuppressLint; import android.app.Dialog; import android.os.Bundle; +import android.provider.Settings; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; + import net.osmand.plus.R; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity.FreeVersionDialog; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import net.osmand.plus.download.IndexItem; - -import java.util.ArrayList; -import java.util.List; +import net.osmand.util.Algorithms; public class FreeVersionDialogFragment extends DialogFragment { private FreeVersionDialog dialog; + @SuppressLint("HardwareIds") @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setNegativeButton(R.string.later, null); View view = getActivity().getLayoutInflater().inflate(R.layout.free_version_banner, null); + boolean hidePlus = false; + try { + String devId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID); + if (!Algorithms.isEmpty(devId)) { + hidePlus = devId.hashCode() % 20 == 8; + } + } catch (Exception e) { + // ignored + } + view.findViewById(R.id.osmLiveLayoutTopDivider).setVisibility(hidePlus ? View.GONE : View.VISIBLE); + view.findViewById(R.id.fullVersionLayout).setVisibility(hidePlus ? View.GONE : View.VISIBLE); builder.setView(view); dialog = new DownloadActivity.FreeVersionDialog(view, getDownloadActivity(), true); dialog.initFreeVersionBanner(); dialog.expandBanner(); return builder.create(); } - - + + DownloadActivity getDownloadActivity() { return (DownloadActivity) getActivity(); } - + } \ No newline at end of file