Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29399749: Issue 5081 - Make libadblockplus-android users supply the application and applicationVersion parame… (Closed)
Patch Set: Created March 31, 2017, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 private volatile LogSystem logSystem; 72 private volatile LogSystem logSystem;
73 private volatile WebRequest webRequest; 73 private volatile WebRequest webRequest;
74 private volatile UpdateAvailableCallback updateAvailableCallback; 74 private volatile UpdateAvailableCallback updateAvailableCallback;
75 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; 75 private volatile UpdateCheckDoneCallback updateCheckDoneCallback;
76 private volatile FilterChangeCallback filterChangeCallback; 76 private volatile FilterChangeCallback filterChangeCallback;
77 private volatile ShowNotificationCallback showNotificationCallback; 77 private volatile ShowNotificationCallback showNotificationCallback;
78 private volatile boolean elemhideEnabled; 78 private volatile boolean elemhideEnabled;
79 private volatile boolean enabled = true; 79 private volatile boolean enabled = true;
80 private volatile List<String> whitelistedDomains; 80 private volatile List<String> whitelistedDomains;
81 81
82 public static AppInfo generateAppInfo(final Context context, boolean developme ntBuild) 82 public static AppInfo generateAppInfo(final Context context, boolean developme ntBuild,
83 String application, String applicationVe rsion)
83 { 84 {
84 String version = "0";
85 try
86 {
87 final PackageInfo info = context.getPackageManager().getPackageInfo(contex t.getPackageName(), 0);
88 version = info.versionName;
89 if (developmentBuild)
90 version += "." + info.versionCode;
anton 2017/03/31 13:30:27 addonVersion is generated, but we need hardcoded v
sergei 2017/03/31 13:49:09 I'm not sure that we should use a hard coded value
anton 2017/03/31 13:52:26 it's not clear from the task. i think the intentio
sergei 2017/03/31 14:01:52 I thought we control this version because it's our
anton 2017/03/31 14:05:27 no, it's app package, not library
91 }
92 catch (final NameNotFoundException e)
93 {
94 Log.e(TAG, "Failed to get the application version number", e);
95 }
96 final String sdkVersion = String.valueOf(VERSION.SDK_INT); 85 final String sdkVersion = String.valueOf(VERSION.SDK_INT);
97 final String locale = Locale.getDefault().toString().replace('_', '-'); 86 final String locale = Locale.getDefault().toString().replace('_', '-');
98 87
99 return AppInfo.builder() 88 AppInfo.Builder builder =
100 .setVersion(version) 89 AppInfo
90 .builder()
101 .setApplicationVersion(sdkVersion) 91 .setApplicationVersion(sdkVersion)
102 .setLocale(locale) 92 .setLocale(locale)
103 .setDevelopmentBuild(developmentBuild) 93 .setDevelopmentBuild(developmentBuild);
104 .build(); 94
95 if (application != null)
96 {
97 builder.setApplication(application);
98 }
99
100 if (applicationVersion != null)
101 {
102 builder.setApplicationVersion(applicationVersion);
103 }
104
105 return builder.build();
106 }
107
108 public static AppInfo generateAppInfo(final Context context, boolean developme ntBuild)
sergei 2017/03/31 13:49:09 So, currently application and applicationVersion a
anton 2017/03/31 13:52:26 there will be no compilation errors here
sergei 2017/03/31 14:01:52 Then I think it should be removed.
anton 2017/03/31 14:05:27 not clear what you've meant. if the user(app devel
sergei 2017/03/31 14:08:33 That was the idea to don't allow to use this metho
109 {
110 return generateAppInfo(context, developmentBuild, null, null);
105 } 111 }
106 112
107 /** 113 /**
108 * Builds Adblock engine 114 * Builds Adblock engine
109 */ 115 */
110 public static class Builder 116 public static class Builder
111 { 117 {
112 private Context context; 118 private Context context;
113 private Map<String, Integer> urlToResourceIdMap; 119 private Map<String, Integer> urlToResourceIdMap;
114 private AndroidWebRequestResourceWrapper.Storage resourceStorage; 120 private AndroidWebRequestResourceWrapper.Storage resourceStorage;
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 public void setWhitelistedDomains(List<String> domains) 727 public void setWhitelistedDomains(List<String> domains)
722 { 728 {
723 this.whitelistedDomains = domains; 729 this.whitelistedDomains = domains;
724 } 730 }
725 731
726 public List<String> getWhitelistedDomains() 732 public List<String> getWhitelistedDomains()
727 { 733 {
728 return whitelistedDomains; 734 return whitelistedDomains;
729 } 735 }
730 } 736 }
OLDNEW

Powered by Google App Engine
This is Rietveld