[android] using different metadata for different application market's bundles.

This commit is contained in:
rachytski 2012-07-04 20:28:34 -07:00 committed by Alex Zolotarev
parent 585ed5affe
commit 172fa5ab4a
11 changed files with 454 additions and 131 deletions

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MapsWithMeLite" default="help">
<property name="mwm.tools.dir" value="../../tools"/>
<property name="mwm.data.dir" value="../../../data"/>
<property name="renderscript.opt.level" value="O0"/>
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
@ -66,7 +70,7 @@
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MapsWithMe" default="help">
<target name="-exclude-text-drules">
<exec executable="rm">
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-include-text-drules">
<exec executable="ln">
<arg value="-s"/>
<arg value="${mwm.data.dir}/drules_proto.txt"/>
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-set-production-mode" depends="android_rules.-set-mode-check">
<property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-production-unsigned.apk" />
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-production.apk" />
<property name="build.is.mode.set" value="true" />
<!-- record the current build target -->
<property name="build.target" value="release" />
<property name="build.is.instrumented" value="false" />
<!-- production mode is only valid if the manifest does not explicitly
set debuggable to true. default is false. -->
<xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
output="build.is.packaging.debug" default="false"/>
<!-- signing mode: production -->
<property name="build.is.signing.debug" value="false" />
<if condition="${build.is.packaging.debug}">
<then>
<echo>*************************************************</echo>
<echo>**** Android Manifest has debuggable=true ****</echo>
<echo>** Doing DEBUG packaging with PRODUCTION keys ***</echo>
<echo>*************************************************</echo>
</then>
<else>
<!-- property only set in release mode.
Useful for if/unless attributes in target node
when using Ant before 1.8 -->
<property name="build.is.mode.release" value="true"/>
</else>
</if>
</target>
<target name="production" depends="-exclude-text-drules, -set-production-mode,
android_rules.-release-obfuscation-check, android_rules.-package, android_rules.-release-prompt-for-password, android_rules.-release-nosign"
if="has.keystore" description="Production target - almost the same as release, but with real word config.">
<!-- only create apk if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not create apk..." >
<sequential>
<property name="out.unaligned.file" location="${out.absolute.dir}/${ant.project.name}-production-unaligned.apk" />
<!-- Signs the APK -->
<echo>Signing final apk...</echo>
<signjar
jar="${out.packaged.file}"
signedjar="${out.unaligned.file}"
keystore="${key.store}"
storepass="${key.store.password}"
alias="${key.alias}"
keypass="${key.alias.password}"
verbose="${verbose}" />
<!-- Zip aligns the APK -->
<zipalign-helper in.package="${out.unaligned.file}"
out.package="${out.final.file}" />
<echo>Release Package: ${out.final.file}</echo>
</sequential>
</do-only-if-not-library>
<record-build-info />
</target>
<target name="release" depends="-include-text-drules, android_rules.release">
</target>
<target name="debug" depends="-include-text-drules, android_rules.debug">
</target>
<target name="-include-amazon-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_amazon.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="amazon-production" depends="-include-amazon-appinfo, production"/>
<target name="amazon-release" depends="-include-amazon-appinfo, release"/>
<target name="amazon-debug" depends="-include-amazon-appinfo, debug"/>
<target name="-include-google-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_google.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="google-production" depends="-include-google-appinfo, production"/>
<target name="google-release" depends="-include-google-appinfo, release"/>
<target name="google-debug" depends="-include-google-appinfo, debug"/>
<target name="-include-samsung-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_samsung.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="samsung-production" depends="-include-samsung-appinfo, production"/>
<target name="samsung-release" depends="-include-samsung-appinfo, release"/>
<target name="samsung-debug" depends="-include-samsung-appinfo, debug"/>
</project>

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MapsWithMePro" default="help">
<property name="mwm.tools.dir" value="../../tools"/>
<property name="mwm.data.dir" value="../../../data"/>
<property name="renderscript.opt.level" value="O0"/>
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MapsWithMe" default="help">
<target name="-exclude-text-drules">
<exec executable="rm">
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-include-text-drules">
<exec executable="ln">
<arg value="-s"/>
<arg value="${mwm.data.dir}/drules_proto.txt"/>
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-set-production-mode" depends="android_rules.-set-mode-check">
<property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-production-unsigned.apk" />
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-production.apk" />
<property name="build.is.mode.set" value="true" />
<!-- record the current build target -->
<property name="build.target" value="release" />
<property name="build.is.instrumented" value="false" />
<!-- production mode is only valid if the manifest does not explicitly
set debuggable to true. default is false. -->
<xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
output="build.is.packaging.debug" default="false"/>
<!-- signing mode: production -->
<property name="build.is.signing.debug" value="false" />
<if condition="${build.is.packaging.debug}">
<then>
<echo>*************************************************</echo>
<echo>**** Android Manifest has debuggable=true ****</echo>
<echo>** Doing DEBUG packaging with PRODUCTION keys ***</echo>
<echo>*************************************************</echo>
</then>
<else>
<!-- property only set in release mode.
Useful for if/unless attributes in target node
when using Ant before 1.8 -->
<property name="build.is.mode.release" value="true"/>
</else>
</if>
</target>
<target name="production" depends="-exclude-text-drules, -set-production-mode,
android_rules.-release-obfuscation-check, android_rules.-package, android_rules.-release-prompt-for-password, android_rules.-release-nosign"
if="has.keystore" description="Production target - almost the same as release, but with real word config.">
<!-- only create apk if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not create apk..." >
<sequential>
<property name="out.unaligned.file" location="${out.absolute.dir}/${ant.project.name}-production-unaligned.apk" />
<!-- Signs the APK -->
<echo>Signing final apk...</echo>
<signjar
jar="${out.packaged.file}"
signedjar="${out.unaligned.file}"
keystore="${key.store}"
storepass="${key.store.password}"
alias="${key.alias}"
keypass="${key.alias.password}"
verbose="${verbose}" />
<!-- Zip aligns the APK -->
<zipalign-helper in.package="${out.unaligned.file}"
out.package="${out.final.file}" />
<echo>Release Package: ${out.final.file}</echo>
</sequential>
</do-only-if-not-library>
<record-build-info />
</target>
<target name="release" depends="-include-text-drules, android_rules.release">
</target>
<target name="debug" depends="-include-text-drules, android_rules.debug">
</target>
<target name="-include-amazon-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_amazon.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="amazon-production" depends="-include-amazon-appinfo, production"/>
<target name="amazon-release" depends="-include-amazon-appinfo, release"/>
<target name="amazon-debug" depends="-include-amazon-appinfo, debug"/>
<target name="-include-google-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_google.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="google-production" depends="-include-google-appinfo, production"/>
<target name="google-release" depends="-include-google-appinfo, release"/>
<target name="google-debug" depends="-include-google-appinfo, debug"/>
<target name="-include-samsung-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_samsung.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="samsung-production" depends="-include-samsung-appinfo, production"/>
<target name="samsung-release" depends="-include-samsung-appinfo, release"/>
<target name="samsung-debug" depends="-include-samsung-appinfo, debug"/>
</project>

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MapsWithMe" default="production">
<property name="mwm.tools.dir" value="../tools"/>
<property name="mwm.data.dir" value="../../data"/>
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
@ -50,6 +53,8 @@
unless="ndk.dir"
/>
<import file="custom_rules.xml" optional="true" />
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
@ -57,128 +62,6 @@
<exec executable="${ndk.dir}/ndk-build" failonerror="true"/>
</target>
-->
<target name="clean" depends="android_rules.clean">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
<target name="-exclude-text-drules">
<exec executable="rm">
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-include-text-drules">
<exec executable="ln">
<arg value="-s"/>
<arg value="../../data/drules_proto.txt"/>
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-ndk-production">
<exec executable="bash" failonerror="true">
<arg value="../tools/autobuild/android.sh"/>
<arg value="production"/>
</exec>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="NDK_DEBUG=0"/>
<arg value="PRODUCTION=1"/>
<arg value="V=1"/>
</exec>
</target>
<target name="-set-production-mode" depends="android_rules.-set-mode-check">
<property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-production-unsigned.apk" />
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-production.apk" />
<property name="build.is.mode.set" value="true" />
<!-- record the current build target -->
<property name="build.target" value="release" />
<property name="build.is.instrumented" value="false" />
<!-- production mode is only valid if the manifest does not explicitly
set debuggable to true. default is false. -->
<xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
output="build.is.packaging.debug" default="false"/>
<!-- signing mode: production -->
<property name="build.is.signing.debug" value="false" />
<if condition="${build.is.packaging.debug}">
<then>
<echo>*************************************************</echo>
<echo>**** Android Manifest has debuggable=true ****</echo>
<echo>** Doing DEBUG packaging with PRODUCTION keys ***</echo>
<echo>*************************************************</echo>
</then>
<else>
<!-- property only set in release mode.
Useful for if/unless attributes in target node
when using Ant before 1.8 -->
<property name="build.is.mode.release" value="true"/>
</else>
</if>
</target>
<target name="production" depends="-exclude-text-drules, -ndk-production, -set-production-mode,
android_rules.-release-obfuscation-check, android_rules.-package, android_rules.-release-prompt-for-password, android_rules.-release-nosign"
if="has.keystore" description="Production target - almost the same as release, but with real word config.">
<!-- only create apk if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not create apk..." >
<sequential>
<property name="out.unaligned.file" location="${out.absolute.dir}/${ant.project.name}-production-unaligned.apk" />
<!-- Signs the APK -->
<echo>Signing final apk...</echo>
<signjar
jar="${out.packaged.file}"
signedjar="${out.unaligned.file}"
keystore="${key.store}"
storepass="${key.store.password}"
alias="${key.alias}"
keypass="${key.alias.password}"
verbose="${verbose}" />
<!-- Zip aligns the APK -->
<zipalign-helper in.package="${out.unaligned.file}"
out.package="${out.final.file}" />
<echo>Release Package: ${out.final.file}</echo>
</sequential>
</do-only-if-not-library>
<record-build-info />
</target>
<target name="-ndk-release">
<exec executable="bash" failonerror="true">
<arg value="../tools/autobuild/android.sh"/>
<arg value="release"/>
</exec>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="NDK_DEBUG=0"/>
<arg value="V=1"/>
</exec>
</target>
<target name="release" depends="-include-text-drules, -ndk-release, android_rules.release">
</target>
<target name="-ndk-debug">
<exec executable="bash" failonerror="true">
<arg value="../tools/autobuild/android.sh"/>
<arg value="debug"/>
</exec>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="NDK_DEBUG=1"/>
<arg value="V=1"/>
</exec>
</target>
<target name="debug" depends="-include-text-drules, -ndk-debug, android_rules.debug">
</target>
<!--
<target name="-pre-compile">
</target>

161
android/custom_rules.xml Normal file
View file

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MapsWithMe" default="help">
<target name="clean" depends="android_rules.clean">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
<target name="-exclude-text-drules">
<exec executable="rm">
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-include-text-drules">
<exec executable="ln">
<arg value="-s"/>
<arg value="${mwm.data.dir}/drules_proto.txt"/>
<arg value="${asset.absolute.dir}/drules_proto.txt"/>
</exec>
</target>
<target name="-ndk-production">
<exec executable="bash" failonerror="true">
<arg value="${mwm.tools.dir}/autobuild/android.sh"/>
<arg value="production"/>
</exec>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="NDK_DEBUG=0"/>
<arg value="PRODUCTION=1"/>
<arg value="V=1"/>
</exec>
</target>
<target name="-set-production-mode" depends="android_rules.-set-mode-check">
<property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-production-unsigned.apk" />
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-production.apk" />
<property name="build.is.mode.set" value="true" />
<!-- record the current build target -->
<property name="build.target" value="release" />
<property name="build.is.instrumented" value="false" />
<!-- production mode is only valid if the manifest does not explicitly
set debuggable to true. default is false. -->
<xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
output="build.is.packaging.debug" default="false"/>
<!-- signing mode: production -->
<property name="build.is.signing.debug" value="false" />
<if condition="${build.is.packaging.debug}">
<then>
<echo>*************************************************</echo>
<echo>**** Android Manifest has debuggable=true ****</echo>
<echo>** Doing DEBUG packaging with PRODUCTION keys ***</echo>
<echo>*************************************************</echo>
</then>
<else>
<!-- property only set in release mode.
Useful for if/unless attributes in target node
when using Ant before 1.8 -->
<property name="build.is.mode.release" value="true"/>
</else>
</if>
</target>
<target name="production" depends="-exclude-text-drules, -ndk-production, -set-production-mode,
android_rules.-release-obfuscation-check, android_rules.-package, android_rules.-release-prompt-for-password, android_rules.-release-nosign"
if="has.keystore" description="Production target - almost the same as release, but with real word config.">
<!-- only create apk if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not create apk..." >
<sequential>
<property name="out.unaligned.file" location="${out.absolute.dir}/${ant.project.name}-production-unaligned.apk" />
<!-- Signs the APK -->
<echo>Signing final apk...</echo>
<signjar
jar="${out.packaged.file}"
signedjar="${out.unaligned.file}"
keystore="${key.store}"
storepass="${key.store.password}"
alias="${key.alias}"
keypass="${key.alias.password}"
verbose="${verbose}" />
<!-- Zip aligns the APK -->
<zipalign-helper in.package="${out.unaligned.file}"
out.package="${out.final.file}" />
<echo>Release Package: ${out.final.file}</echo>
</sequential>
</do-only-if-not-library>
<record-build-info />
</target>
<target name="-ndk-release">
<exec executable="bash" failonerror="true">
<arg value="${mwm.tools.dir}/autobuild/android.sh"/>
<arg value="release"/>
</exec>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="NDK_DEBUG=0"/>
<arg value="V=1"/>
</exec>
</target>
<target name="release" depends="-include-text-drules, -ndk-release, android_rules.release">
</target>
<target name="-ndk-debug">
<exec executable="bash" failonerror="true">
<arg value="${mwm.tools.dir}/autobuild/android.sh"/>
<arg value="debug"/>
</exec>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="NDK_DEBUG=1"/>
<arg value="V=1"/>
</exec>
</target>
<target name="debug" depends="-include-text-drules, -ndk-debug, android_rules.debug">
</target>
<target name="-include-amazon-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_amazon.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="amazon-production" depends="-include-amazon-appinfo, production"/>
<target name="amazon-release" depends="-include-amazon-appinfo, release"/>
<target name="amazon-debug" depends="-include-amazon-appinfo, debug"/>
<target name="-include-google-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_google.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="google-production" depends="-include-google-appinfo, production"/>
<target name="google-release" depends="-include-google-appinfo, release"/>
<target name="google-debug" depends="-include-google-appinfo, debug"/>
<target name="-include-samsung-appinfo">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${mwm.data.dir}/app_info_samsung.txt"/>
<arg value="${asset.absolute.dir}/app_info.txt"/>
</exec>
</target>
<target name="samsung-production" depends="-include-samsung-appinfo, production"/>
<target name="samsung-release" depends="-include-samsung-appinfo, release"/>
<target name="samsung-debug" depends="-include-samsung-appinfo, debug"/>
</project>

View file

@ -189,12 +189,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
findViewById(R.id.map_button_search).setVisibility(View.VISIBLE);
}
else
{
if (android.os.Build.MODEL.equals("Kindle Fire"))
nativeCheckForProVersion("http://redbutton.mapswithme.com/enable_search_banner_amazon_appstore");
else
nativeCheckForProVersion("http://redbutton.mapswithme.com/enable_search_banner_google_play");
}
nativeCheckForProVersion(mApplication.getProVersionCheckURL());
}
/// Invoked from native code - asynchronous server check.

View file

@ -1,22 +1,48 @@
package com.mapswithme.maps;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.os.Environment;
import android.util.Log;
import com.mapswithme.maps.location.LocationService;
public class MWMApplication extends android.app.Application
{
private final static String TAG = "MWMApplication";
private LocationService mLocationService = null;
private boolean mIsProVersion = false;
private String mProVersionCheckURL;
@Override
public void onCreate()
{
super.onCreate();
AssetManager assets = getAssets();
try
{
InputStream stream = assets.open("app_info.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
mIsProVersion = getPackageName().endsWith(".pro");
mProVersionCheckURL = reader.readLine();
Log.i(TAG, "PROCHECKURL: " + mProVersionCheckURL);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
final String extStoragePath = getDataStoragePath();
final String extTmpPath = getExtAppDirectoryPath("caches");
// Create folders if they don't exist
@ -64,7 +90,12 @@ public class MWMApplication extends android.app.Application
public boolean isProVersion()
{
return true;
return mIsProVersion;
}
public String getProVersionCheckURL()
{
return mProVersionCheckURL;
}
private String getTmpPath()

1
data/app_info_amazon.txt Normal file
View file

@ -0,0 +1 @@
http://redbutton.mapswithme.com/enable_search_banner_amazon

1
data/app_info_google.txt Normal file
View file

@ -0,0 +1 @@
http://redbutton.mapswithme.com/enable_search_banner_google

View file

@ -0,0 +1 @@
http://redbutton.mapswithme.com/enable_search_banner_samsung