AppPreferences.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Chris Narkiewicz
  5. * Copyright (C) 2019 Chris Narkiewicz, EZ Aquarii
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. package com.nextcloud.client.preferences;
  21. import com.owncloud.android.datamodel.OCFile;
  22. import com.owncloud.android.utils.FileSortOrder;
  23. import com.nmc.android.app_review.AppReviewShownModel;
  24. import androidx.annotation.Nullable;
  25. /**
  26. * This interface provides single point of entry for access to all application
  27. * preferences and allows clients to subscribe for specific configuration
  28. * changes.
  29. */
  30. public interface AppPreferences {
  31. /**
  32. * Preferences listener. Callbacks should be invoked on main thread.
  33. *
  34. * Maintainers should extend this interface with callbacks for specific
  35. * events.
  36. */
  37. interface Listener {
  38. default void onDarkThemeModeChanged(DarkMode mode) {
  39. /* default empty implementation */
  40. };
  41. }
  42. /**
  43. * Registers preferences listener. It no-ops if listener
  44. * is already registered.
  45. *
  46. * @param listener application preferences listener
  47. */
  48. void addListener(@Nullable Listener listener);
  49. /**
  50. * Unregister listener. It no-ops if listener is not registered.
  51. *
  52. * @param listener application preferences listener
  53. */
  54. void removeListener(@Nullable Listener listener);
  55. void setKeysReInitEnabled();
  56. boolean isKeysReInitEnabled();
  57. void setPushToken(String pushToken);
  58. String getPushToken();
  59. boolean instantPictureUploadEnabled();
  60. boolean instantVideoUploadEnabled();
  61. boolean isShowHiddenFilesEnabled();
  62. void setShowHiddenFilesEnabled(boolean enabled);
  63. /**
  64. * Gets the selected file extension position the user selected to do the
  65. * last upload of a url file shared from other app.
  66. *
  67. * @return selectedPos the selected file extension position.
  68. */
  69. int getUploadUrlFileExtensionUrlSelectedPos();
  70. /**
  71. * Saves the selected file extension position the user selected to do the
  72. * last upload of a url file shared from other app.
  73. *
  74. * @param selectedPos the selected file extension position.
  75. */
  76. void setUploadUrlFileExtensionUrlSelectedPos(int selectedPos);
  77. /**
  78. * Gets the selected map file extension position the user selected to
  79. * do the last upload of a url file shared from other app.
  80. *
  81. * @return selectedPos the selected file extension position.
  82. */
  83. int getUploadMapFileExtensionUrlSelectedPos();
  84. /**
  85. * Saves the selected map file extension position the user selected to
  86. * do the last upload of a url file shared from other app.
  87. *
  88. * @param selectedPos the selected file extension position.
  89. */
  90. void setUploadMapFileExtensionUrlSelectedPos(int selectedPos);
  91. /**
  92. * Gets the last local path where the user selected to do an upload from.
  93. *
  94. * @return path Absolute path to a folder, as previously stored by
  95. * {@link #setUploadFromLocalLastPath(String)}, or empty String if never saved before.
  96. */
  97. String getUploadFromLocalLastPath();
  98. /**
  99. * Saves the path where the user selected to do the last local upload of a file from.
  100. *
  101. * @param path Absolute path to a folder.
  102. */
  103. void setUploadFromLocalLastPath(String path);
  104. /**
  105. * Gets the path where the user selected to do the last upload of a file shared from other app.
  106. *
  107. * @return path Absolute path to a folder, as previously stored by {@link #setLastUploadPath(String)},
  108. * or empty String if never saved before.
  109. */
  110. String getLastUploadPath();
  111. /**
  112. * Get preferred folder display type.
  113. *
  114. * @param folder Folder
  115. * @return preference value, default is
  116. * {@link com.owncloud.android.ui.fragment.OCFileListFragment#FOLDER_LAYOUT_LIST}
  117. */
  118. String getFolderLayout(OCFile folder);
  119. /**
  120. * Set preferred folder display type.
  121. *
  122. * @param folder Folder which layout is being set or null for root folder
  123. * @param layoutName preference value
  124. */
  125. void setFolderLayout(@Nullable OCFile folder, String layoutName);
  126. /**
  127. * Saves the path where the user selected to do the last upload of a file shared from other app.
  128. *
  129. * @param path Absolute path to a folder.
  130. */
  131. void setLastUploadPath(String path);
  132. String getLockPreference();
  133. void setLockPreference(String lockPreference);
  134. /**
  135. * Set pass code composed of 4 digits (as strings).
  136. *
  137. * @todo This must be refactored further to use a passcode stype
  138. * @param d1 1st digit
  139. * @param d2 2nd digit
  140. * @param d3 3rd digit
  141. * @param d4 4th digit
  142. */
  143. void setPassCode(String d1, String d2, String d3, String d4);
  144. /**
  145. * Get 4-digit passcode as array of strings. Strings may be null.
  146. *
  147. * @return 4 strings with digits or nulls
  148. */
  149. String[] getPassCode();
  150. /**
  151. * Gets the unlock via fingerprint preference configured by the user.
  152. *
  153. * @implNote this is always false
  154. * @return useFingerprint is unlock with fingerprint enabled
  155. */
  156. boolean isFingerprintUnlockEnabled();
  157. /**
  158. * Gets the auto upload paths flag last set.
  159. *
  160. * @return ascending order the legacy cleaning flag, default is false
  161. */
  162. boolean isAutoUploadPathsUpdateEnabled();
  163. /**
  164. * Saves the legacy cleaning flag which the user has set last.
  165. *
  166. * @param pathUpdate flag if it is a auto upload path update
  167. */
  168. void setAutoUploadPathsUpdateEnabled(boolean pathUpdate);
  169. /**
  170. * Gets the auto upload split out flag last set.
  171. *
  172. * @return ascending order the legacy cleaning flag, default is false
  173. */
  174. boolean isAutoUploadSplitEntriesEnabled();
  175. /**
  176. * Saves the flag for split entries magic
  177. *
  178. * @param splitOut flag if it is a auto upload path update
  179. */
  180. void setAutoUploadSplitEntriesEnabled(boolean splitOut);
  181. boolean isAutoUploadInitialized();
  182. void setAutoUploadInit(boolean autoUploadInit);
  183. /**
  184. * Get preferred folder sort order.
  185. *
  186. * @param folder Folder whoch order is being retrieved or null for root folder
  187. * @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
  188. */
  189. FileSortOrder getSortOrderByFolder(@Nullable OCFile folder);
  190. /**
  191. * Set preferred folder sort order.
  192. *
  193. * @param folder Folder which sort order is changed; if null, root folder is assumed
  194. * @param sortOrder the sort order of a folder
  195. */
  196. void setSortOrder(@Nullable OCFile folder, FileSortOrder sortOrder);
  197. /**
  198. * Set preferred folder sort order.
  199. *
  200. * @param sortOrder the sort order
  201. */
  202. void setSortOrder(FileSortOrder.Type type, FileSortOrder sortOrder);
  203. /**
  204. * Get preferred folder sort order.
  205. *
  206. * @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
  207. */
  208. FileSortOrder getSortOrderByType(FileSortOrder.Type type, FileSortOrder defaultOrder);
  209. FileSortOrder getSortOrderByType(FileSortOrder.Type type);
  210. /**
  211. * Gets the legacy cleaning flag last set.
  212. *
  213. * @return ascending order the legacy cleaning flag, default is false
  214. */
  215. boolean isLegacyClean();
  216. /**
  217. * Saves the legacy cleaning flag which the user has set last.
  218. *
  219. * @param legacyClean flag if it is a legacy cleaning
  220. */
  221. void setLegacyClean(boolean legacyClean);
  222. boolean isKeysMigrationEnabled();
  223. void setKeysMigrationEnabled(boolean enabled);
  224. boolean isStoragePathFixEnabled();
  225. void setStoragePathFixEnabled(boolean enabled);
  226. boolean isShowDetailedTimestampEnabled();
  227. void setShowDetailedTimestampEnabled(boolean showDetailedTimestamp);
  228. boolean isShowMediaScanNotifications();
  229. void setShowMediaScanNotifications(boolean showMediaScanNotification);
  230. /**
  231. * Gets the uploader behavior which the user has set last.
  232. *
  233. * @return uploader behavior the uploader behavior
  234. */
  235. int getUploaderBehaviour();
  236. /**
  237. * Changes dark theme mode
  238. *
  239. * This is reactive property. Listeners will be invoked if registered.
  240. *
  241. * @param mode dark mode setting: on, off, system
  242. */
  243. void setDarkThemeMode(DarkMode mode);
  244. /**
  245. * @return dark mode setting: on, off, system
  246. */
  247. DarkMode getDarkThemeMode();
  248. /**
  249. * Saves the uploader behavior which the user has set last.
  250. *
  251. * @param uploaderBehaviour the uploader behavior
  252. */
  253. void setUploaderBehaviour(int uploaderBehaviour);
  254. float getGridColumns();
  255. void setGridColumns(float gridColumns);
  256. long getLockTimestamp();
  257. void setLockTimestamp(long timestamp);
  258. /**
  259. * Gets the last seen version code right before updating.
  260. *
  261. * @return grid columns grid columns
  262. */
  263. int getLastSeenVersionCode();
  264. /**
  265. * Saves the version code as the last seen version code.
  266. *
  267. * @param versionCode the app's version code
  268. */
  269. void setLastSeenVersionCode(int versionCode);
  270. void removeLegacyPreferences();
  271. /**
  272. * Clears all user preferences.
  273. *
  274. * @implNote this clears only shared preferences, not preferences kept in account manager
  275. */
  276. void clear();
  277. String getStoragePath(String defaultPath);
  278. void setStoragePath(String path);
  279. void setStoragePathValid();
  280. boolean isStoragePathValid();
  281. void removeKeysMigrationPreference();
  282. String getCurrentAccountName();
  283. void setCurrentAccountName(String accountName);
  284. /**
  285. * Gets status of migration to user id, default false
  286. *
  287. * @return true: migration done: every account has userId, false: pending accounts without userId
  288. */
  289. boolean isUserIdMigrated();
  290. void setMigratedUserId(boolean value);
  291. void setPhotoSearchTimestamp(long timestamp);
  292. long getPhotoSearchTimestamp();
  293. boolean isPowerCheckDisabled();
  294. void setPowerCheckDisabled(boolean value);
  295. void increasePinWrongAttempts();
  296. void resetPinWrongAttempts();
  297. int pinBruteForceDelay();
  298. String getUidPid();
  299. void setUidPid(String uidPid);
  300. long getCalendarLastBackup();
  301. void setCalendarLastBackup(long timestamp);
  302. void setPdfZoomTipShownCount(int count);
  303. int getPdfZoomTipShownCount();
  304. boolean isStoragePermissionRequested();
  305. void setStoragePermissionRequested(boolean value);
  306. void setHideVideoClicked(boolean isHideVideoClicked);
  307. boolean getHideVideoClicked();
  308. }