Skip to content

Commit

Permalink
Reduced android app size
Browse files Browse the repository at this point in the history
  • Loading branch information
jiriKuba committed Oct 1, 2017
1 parent 6aef9f6 commit b117e78
Show file tree
Hide file tree
Showing 24 changed files with 110 additions and 78 deletions.
13 changes: 7 additions & 6 deletions Bitcoin.Curses/Bitcoin.Curses.Droid/Bitcoin.Curses.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidLinkMode>Full</AndroidLinkMode>
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
<BundleAssemblies>false</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<Debugger>.Net (Xamarin)</Debugger>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
<EnableProguard>False</EnableProguard>
<AndroidEnableMultiDex>false</AndroidEnableMultiDex>
<EnableProguard>true</EnableProguard>
<AndroidLinkSkip />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -55,10 +56,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AndroidLinkMode>Full</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<BundleAssemblies>false</BundleAssemblies>
<AndroidCreatePackagePerAbi>True</AndroidCreatePackagePerAbi>
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
<Debugger>.Net (Xamarin)</Debugger>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
Expand Down Expand Up @@ -186,7 +187,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Effects\UnderlineEffect.cs" />
<Compile Include="Helpers\Settings.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Renders\RoundButtonRenderer.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
Expand All @@ -196,6 +196,7 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<ProguardConfiguration Include="proguard.cfg" />
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
Expand Down
44 changes: 0 additions & 44 deletions Bitcoin.Curses/Bitcoin.Curses.Droid/Helpers/Settings.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.kuba.bitcoinexchangerate" android:versionCode="8" android:versionName="1.0.0">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.kuba.bitcoinexchangerate" android:versionCode="9" android:versionName="1.0.1">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
Expand Down
42 changes: 42 additions & 0 deletions Bitcoin.Curses/Bitcoin.Curses.Droid/proguard.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This is Xamarin-specific (and enhanced) configuration.

-dontobfuscate

-keep class mono.MonoRuntimeProvider { *; <init>(...); }
-keep class mono.MonoPackageManager { *; <init>(...); }
-keep class mono.MonoPackageManager_Resources { *; <init>(...); }
-keep class mono.android.** { *; <init>(...); }
-keep class mono.java.** { *; <init>(...); }
-keep class mono.javax.** { *; <init>(...); }
-keep class opentk.platform.android.AndroidGameView { *; <init>(...); }
-keep class opentk.GameViewBase { *; <init>(...); }
-keep class opentk_1_0.platform.android.AndroidGameView { *; <init>(...); }
-keep class opentk_1_0.GameViewBase { *; <init>(...); }

-keep class android.runtime.** { <init>(***); }
-keep class assembly_mono_android.android.runtime.** { <init>(***); }
# hash for android.runtime and assembly_mono_android.android.runtime.
-keep class md52ce486a14f4bcd95899665e9d932190b.** { *; <init>(...); }
-keepclassmembers class md52ce486a14f4bcd95899665e9d932190b.** { *; <init>(...); }

# Android's template misses fluent setters...
-keepclassmembers class * extends android.view.View {
*** set*(***);
}

# also misses those inflated custom layout stuff from xml...
-keepclassmembers class * extends android.view.View {
<init>(android.content.Context,android.util.AttributeSet);
<init>(android.content.Context,android.util.AttributeSet,int);
}

-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class com.microsoft.windowsazure.messaging.** { *; }
-dontwarn com.microsoft.windowsazure.messaging.**
-keep class com.google.firebase.** { *; }
-dontwarn com.google.firebase.**
-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.**
-keep class android.support.v4.widget.Space { *; }
-dontwarn android.support.v4.widget.Space
14 changes: 14 additions & 0 deletions Bitcoin.Curses/Bitcoin.Curses/Attributes/PreserveAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Android.Runtime
{
public sealed class PreserveAttribute : System.Attribute
{
public bool AllMembers;
public bool Conditional;
}
}
1 change: 1 addition & 0 deletions Bitcoin.Curses/Bitcoin.Curses/Bitcoin.Curses.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Attributes\PreserveAttribute.cs" />
<Compile Include="BuyPricePage.xaml.cs">
<DependentUpon>BuyPricePage.xaml</DependentUpon>
</Compile>
Expand Down
53 changes: 27 additions & 26 deletions Bitcoin.Curses/Bitcoin.Curses/Helpers/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,38 @@

namespace Bitcoin.Curses.Helpers
{
/// <summary>
/// This is the Settings static class that can be used in your Core solution or in any
/// of your client applications. All settings are laid out the same exact way with getters
/// and setters.
/// </summary>
public static class Settings
{
private static ISettings AppSettings
/// <summary>
/// This is the Settings static class that can be used in your Core solution or in any
/// of your client applications. All settings are laid out the same exact way with getters
/// and setters.
/// </summary>
[Android.Runtime.Preserve(AllMembers = true)]
public static class Settings
{
get { return CrossSettings.Current; }
}
private static ISettings AppSettings
{
get { return CrossSettings.Current; }
}

//#region Setting Constants
//#region Setting Constants

//private const string SettingsKey = "settings_key";
//private static readonly string SettingsDefault = string.Empty;
//private const string SettingsKey = "settings_key";
//private static readonly string SettingsDefault = string.Empty;

//#endregion
//#endregion


//public static string GeneralSettings
//{
// get
// {
// return AppSettings.GetValueOrDefault<string>(SettingsKey, SettingsDefault);
// }
// set
// {
// AppSettings.AddOrUpdateValue<string>(SettingsKey, value);
// }
//}
//public static string GeneralSettings
//{
// get
// {
// return AppSettings.GetValueOrDefault<string>(SettingsKey, SettingsDefault);
// }
// set
// {
// AppSettings.AddOrUpdateValue<string>(SettingsKey, value);
// }
//}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Bitcoin.Curses.Models
{
[Android.Runtime.Preserve(AllMembers = true)]
public class BitcoinExchangeRate
{
//json format: "USD" : {"15m" : 478.68, "last" : 478.68, "buy" : 478.55, "sell" : 478.68, "symbol" : "$"},
Expand Down
1 change: 1 addition & 0 deletions Bitcoin.Curses/Bitcoin.Curses/Models/ExchangeRate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Bitcoin.Curses.Models
{
[Android.Runtime.Preserve(AllMembers = true)]
public class ExchangeRate
{
//{ "base": "USD", "date": "2017-02-21", "rates": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Bitcoin.Curses.Models
{
[Android.Runtime.Preserve(AllMembers = true)]
public class ExchangeRateHistory
{
//{"bpi":{"2017-05-13":1759.9613},"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index. BPI value data returned as USD.","time":{"updated":"May 14, 2017 00:03:00 UTC","updatedISO":"2017-05-14T00:03:00+00:00"}}
Expand Down
1 change: 1 addition & 0 deletions Bitcoin.Curses/Bitcoin.Curses/Models/ExchangeRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Bitcoin.Curses.Models
{
[Android.Runtime.Preserve(AllMembers = true)]
public class ExchangeRates
{
public IDictionary<string, BitcoinExchangeRate> ExchangeRateList { get; private set; }
Expand Down
3 changes: 2 additions & 1 deletion Bitcoin.Curses/Bitcoin.Curses/Models/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Bitcoin.Curses.Models
{
class MainModel
[Android.Runtime.Preserve(AllMembers = true)]
public class MainModel
{
public ExchangeRates ExchangeRates { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Bitcoin.Curses.Models
{
[Android.Runtime.Preserve(AllMembers = true)]
public class SpotUSDExchangeRate
{
//{"time":{"updated":"Aug 3, 2017 16:24:00 UTC","updatedISO":"2017-08-03T16:24:00+00:00","updateduk":"Aug 3, 2017 at 17:24 BST"},"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org","bpi":{"USD":{"code":"USD","rate":"2,783.8138","description":"United States Dollar","rate_float":2783.8138}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Bitcoin.Curses.Models
{
[Android.Runtime.Preserve(AllMembers = true)]
public class SpotUSDExchangeRateValue
{
[JsonProperty(PropertyName = "code")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Bitcoin.Curses.Services
{
[Android.Runtime.Preserve(AllMembers = true)]
public class BitcoinDataService : IBitcoinDataService
{
private const string USD_RATE_KEY = "USD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Bitcoin.Curses.Services
{
[Android.Runtime.Preserve(AllMembers = true)]
public class CurrencyNavigateService : ICurrencyNavigateService
{
private readonly MainViewModel _mainViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Bitcoin.Curses.Services
{
[Android.Runtime.Preserve(AllMembers = true)]
public class CustomCurrencySymbolService : ICustomCurrencySymbolService
{
public void AddCustomCurrencySymbolToModel(IDictionary<string, BitcoinExchangeRate> models)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Bitcoin.Curses.Services
{
[Android.Runtime.Preserve(AllMembers = true)]
public class DataProvideService : IDataProvideService
{
//http://www.coindesk.com/api/ maybe better api
Expand Down
1 change: 1 addition & 0 deletions Bitcoin.Curses/Bitcoin.Curses/Services/NetworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Bitcoin.Curses.Services
{
[Android.Runtime.Preserve(AllMembers = true)]
public class NetworkService : INetworkService
{
private const string CheckUrl = "http://google.com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Bitcoin.Curses.Services
{
[Android.Runtime.Preserve(AllMembers = true)]
public class RateSettingsApplyService : IRateSettingsApplyService
{
public void SetExchangeRateVisibleOnLiveTile(string exchangeRateKey, bool isVisible)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Bitcoin.Curses.ViewModel
{
[Android.Runtime.Preserve(AllMembers = true)]
public class ExchangeRateViewModel : ViewModelBase
{
private BitcoinExchangeRate _exchangeRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Bitcoin.Curses.ViewModel
{
[Android.Runtime.Preserve(AllMembers = true)]
public class ExchangeRatesViewModel : ViewModelBase
{
public ObservableCollection<ExchangeRateViewModel> ExchangeRateList { get; private set; }
Expand Down
1 change: 1 addition & 0 deletions Bitcoin.Curses/Bitcoin.Curses/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Bitcoin.Curses.ViewModel
{
[Android.Runtime.Preserve(AllMembers = true)]
public class MainViewModel : ViewModelBase
{
private readonly IBitcoinDataService _bitcoinDataService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Bitcoin.Curses.ViewModel
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
/// </summary>
[Android.Runtime.Preserve(AllMembers = true)]
internal class ViewModelLocator
{
/// <summary>
Expand Down

0 comments on commit b117e78

Please sign in to comment.