Merge pull request #4848 from Zverik/banners2

[banners] Fix android build, remove default icon
This commit is contained in:
Aleksandr Zatsepin 2016-12-01 16:22:56 +03:00 committed by GitHub
commit 961d4749e3
5 changed files with 26 additions and 16 deletions

1
android/assets/banners.txt Symbolic link
View file

@ -0,0 +1 @@
../../data/banners.txt

View file

@ -47,7 +47,7 @@ jobject CreateMapObject(JNIEnv * env, int mapObjectType, string const & title,
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
"String;Lcom/mapswithme/maps/bookmarks/data/Banner;)V");
jobject jbanner;
jobject jbanner = nullptr;
if (hasBanner)
jbanner = CreateBanner(env, bannerTitleId, bannerMessageId, bannerIconId, bannerUrl);
@ -69,7 +69,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
static jmethodID const ctorId = jni::GetConstructorID(
env, g_bookmarkClazz, "(IILjava/lang/String;Lcom/mapswithme/maps/bookmarks/data/Banner;)V");
jobject jbanner;
jobject jbanner = nullptr;
if (info.HasBanner())
jbanner = CreateBanner(env, info.GetBannerTitleId(), info.GetBannerMessageId(),
info.GetBannerIconId(), info.GetBannerUrl());

View file

@ -2,6 +2,7 @@ cd ..
rm -rf assets/
mkdir assets
cp ../data/banners.txt assets/
cp ../data/categories.txt assets/
cp ../data/classificator.txt assets/
cp ../data/colors.txt assets/

View file

@ -51,13 +51,9 @@ string Banner::GetProperty(string const & name) const
return {};
}
Banner::Banner(string const & id) : m_id(id)
Banner::Banner(string const & id)
: m_id(id), m_messageBase("banner" + id), m_activeAfter(time(nullptr)), m_activeBefore(kEternity)
{
m_messageBase = "banner_" + id;
m_iconName = m_messageBase + ".png";
m_defaultUrl = "";
m_activeAfter = time(nullptr);
m_activeBefore = kEternity;
}
bool Banner::IsActive() const
@ -216,9 +212,17 @@ Banner const & BannerSet::GetBannerForFeature(FeatureType const & ft) const
void BannerSet::LoadBanners()
{
auto reader = GetPlatform().GetReader(BANNERS_FILE);
ReaderStreamBuf buffer(move(reader));
istream s(&buffer);
ReadBanners(s);
try
{
auto reader = GetPlatform().GetReader(BANNERS_FILE);
ReaderStreamBuf buffer(move(reader));
istream s(&buffer);
ReadBanners(s);
}
catch (FileAbsentException const &)
{
LOG(LWARNING, ("No", BANNERS_FILE, "found"));
return;
}
}
} // namespace banner

View file

@ -169,25 +169,29 @@ string Info::GetApproximatePricing() const
string Info::GetBannerTitleId() const
{
CHECK(!m_banner.IsEmpty(), ());
if (m_banner.IsEmpty())
return {};
return m_banner.GetMessageBase() + "_title";
}
string Info::GetBannerMessageId() const
{
CHECK(!m_banner.IsEmpty(), ());
if (m_banner.IsEmpty())
return {};
return m_banner.GetMessageBase() + "_message";
}
string Info::GetBannerIconId() const
{
CHECK(!m_banner.IsEmpty(), ());
if (m_banner.IsEmpty())
return {};
return m_banner.GetIconName();
}
string Info::GetBannerUrl() const
{
CHECK(!m_banner.IsEmpty(), ());
if (m_banner.IsEmpty())
return {};
return m_banner.GetFormattedUrl(m_metadata.Get(feature::Metadata::FMD_BANNER_URL));
}