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

Delta Between Two Patch Sets: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java

Issue 29375826: Issue 4903 - Allow to specify file system root (Closed)
Left Patch Set: Created Feb. 16, 2017, 11:41 a.m.
Right Patch Set: removed init(), added doc Created March 17, 2017, 7:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 public AdblockSettingsStorage getStorage() 84 public AdblockSettingsStorage getStorage()
85 { 85 {
86 return storage; 86 return storage;
87 } 87 }
88 88
89 /** 89 /**
90 * Init with context 90 * Init with context
91 * @param context application context 91 * @param context application context
92 * @param basePath file system root to store files 92 * @param basePath file system root to store files
93 *
94 * Adblock Plus library will download subscription files and s tore them on
95 * the path passed. The path should exist and the directory co ntent should not be
96 * cleared out occasionally. Using `context.getCacheDir().getA bsolutePath()` is not
97 * recommended because it can be cleared by the system.
93 * @param developmentBuild debug or release? 98 * @param developmentBuild debug or release?
94 * @param preferenceName Shared Preferences name 99 * @param preferenceName Shared Preferences name
95 */ 100 */
96 public void init(Context context, String basePath, boolean developmentBuild, S tring preferenceName) 101 public void init(Context context, String basePath, boolean developmentBuild, S tring preferenceName)
97 { 102 {
98 this.context = context.getApplicationContext(); 103 this.context = context.getApplicationContext();
99 this.basePath = basePath; 104 this.basePath = basePath;
100 this.developmentBuild = developmentBuild; 105 this.developmentBuild = developmentBuild;
101 this.preferenceName = preferenceName; 106 this.preferenceName = preferenceName;
102 }
103
104 /**
105 * Init with context
106 * @param context application context
107 * @param developmentBuild debug or release?
108 * @param preferenceName Shared Preferences name
109 */
110 public void init(Context context, boolean developmentBuild, String preferenceN ame)
anton 2017/02/16 11:43:44 for back compatibility. do we need it?
sergei 2017/03/13 08:49:23 Could it be marked as deprecated and I think we sh
anton 2017/03/13 09:16:32 It could be marked with @Deprecated java annotatio
111 {
112 init(context, context.getCacheDir().getAbsolutePath(), developmentBuild, pre ferenceName);
anton 2017/02/16 11:47:15 for back compatibility it's better to getCacheDir(
anton 2017/02/16 11:49:24 getDataDir is available starting api 24 only. prob
113 } 107 }
114 108
115 private void createAdblock() 109 private void createAdblock()
116 { 110 {
117 Log.d(TAG, "Creating adblock engine ..."); 111 Log.d(TAG, "Creating adblock engine ...");
118 112
119 // read and apply current settings 113 // read and apply current settings
120 SharedPreferences prefs = context.getSharedPreferences(preferenceName, Conte xt.MODE_PRIVATE); 114 SharedPreferences prefs = context.getSharedPreferences(preferenceName, Conte xt.MODE_PRIVATE);
121 storage = new SharedPrefsStorage(prefs); 115 storage = new SharedPrefsStorage(prefs);
122 116
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 */ 220 */
227 public synchronized void release() 221 public synchronized void release()
228 { 222 {
229 if (referenceCounter.decrementAndGet() == 0) 223 if (referenceCounter.decrementAndGet() == 0)
230 { 224 {
231 waitForReady(); 225 waitForReady();
232 disposeAdblock(); 226 disposeAdblock();
233 } 227 }
234 } 228 }
235 } 229 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld