Skip to content

Commit 7336881

Browse files
4D17Y4translatewikiobsidian-zeroaq45654amire80
authored
[GSoC] Master rebase. (#4505)
* Localisation updates from https://translatewiki.net. * Fixes #4357 After switching to different account, contributions screen shows pictures of previous account (#4421) * Update UploadMediaDetailFragment.java * Update LoginActivity.java Clear CompositeDisposable after logging in successfully. It may help solve the problem of saving the contribution to the previous account * Revert "Update UploadMediaDetailFragment.java" This reverts commit b1b4257. Co-authored-by: Obsidian_zero <1198474846@qq.com> * Remove unnecessary whitespace from a message (#4439) * Merge v3.0.1 into master (#4446) * Versioning and changelog for v3.0.0 (#4152) * Versioning for v3.0.0 * Update changelog.md * Handled migration 8-9-10 in BookmarksLocationDao (#4154) * #Fixes #4141 - Handled migrations for BookmarkLocationsDao from 8-9-10 * #Fixes #4141 - Handled migrations for BookmarkLocationsDao from 8-9-10 * Fixes #4179 (#4180) * Handled null pointer exception in MainActivity->ContributionsFragment#backButtonClicked() * Updated >ContributionsFragment#backButtonClicked() to handle back press properly * Fixes #4179 (#4181) * Handled possible null check on MediaDetails in BookmarkListRootFragment#backPressed() * Cherrypick for hotfix3.1 (#4205) * Fixes #4159 On Explore Tab, All Available Options on toolbar in media detail view are only targeting the first media in the list. Fixes #4159 On Explore Tab, All Available Options on toolbar in media detail view are only targeting the first media in the list. * fixed bug: App crashes on viewing review in Review Fragment #4132 (#4146) * fixed bug:app crashes on viewing review in Review Fragment #4135 * Fixed the issue with back button in contribution tab. (#4177) Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> * Fixed the issue with back navigation button on toolbar in explore tab. (#4175) * Fix (#4148) Issues on theme change * fixed themeChange crashes * fixed comments * Overlooked the title bar Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com> Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> Co-authored-by: Aditya-Srivastav <54016427+4D17Y4@users.noreply.github.com> * Fixes #4173 (#4396) * Fix #4147 Pre-fill desc in Nearby uploads with Wikidata item's label + description (#4390) * Update query to fetch descriptions * Make description added to NearbyResultItem * Make string operations to display description and label in a combined way * Fix reviews, remove long description from list and swap label and description texts * Fix repeated information issue * Fix double information issue * fix style issues * Remove douplicated information * Changes made (#4354) * Remove nonexistent method * Fix #4283 IllegalStateException (#4440) * Fix #4283 IllegalStateException * Fix flickering issue * Versioning for v3.0.1 * Update changelog.md Co-authored-by: Ashish <ashishkumar468@gmail.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com> Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com> Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> Co-authored-by: Aditya-Srivastav <54016427+4D17Y4@users.noreply.github.com> Co-authored-by: Madhur Gupta <30932899+madhurgupta10@users.noreply.github.com> Co-authored-by: Vinayak Aggarwal <56196007+vinayak0505@users.noreply.github.com> * Localisation updates from https://translatewiki.net. * Added a feature for editing coordinates (#4418) * not * Place Picker added * Pick location and API call linked * minor warnings resolved * Code conventions followed * issue fixed * Wikitext edited properly * minor modification * Location Picker added * Bottom sheet removed * Location picker fully implemented * credit added * credit added * issues fixed * issues fixed * minor issue fixed * Some build issues occured merging release v3.0 are fixed. One paranthesis issue is solved, a method about UploadService is removed, since we don't use it anymore. (#4451) * Localisation updates from https://translatewiki.net. * Fixes 4344 - Duplicate Uploads (#4442) * Fixes 4344 - Update the retention policy of the Work Manager to ExistingWorkPolicy.APPEND_OR_REPLACE- which would append the new work to the end of existing one. This helps remove the while loop in UploadWorker which was meant to handle the cases where a new worker would be created for retries. The while loop seemed to have race conditions uploading duplicate entries. * Update states to IN_PROGRESS before uploads are processed * Fixes #3694 Pre-select places as depictions (#4452) * WikidataEditService: stop automatically adding WikidataPlace as a depiction When the user initiates the upload process from Nearby and also manually adds the place as a depiction, the depiction is added twice. Since this behavior is invisible to the user, it is being removed in preparation for auto-selecting the place as a depiction on the DepictsFragment screen. * DepictsFragment: auto-select place as a depiction Pass the Place reference from UploadActivity to DepictsFragment and select the corresponding DepictedItem. Using the place id, retrieve the corresponding Entity to create and select a DepictedItem. * UploadRepository: use Place from UploadItem to obtain a DepictedItem Instead of passing a Place object from UploadActivity to DepictsFragment and then passing the Place object up the chain to obtain and select a DepictedItem, retrieve the Place object directly within UploadRepository * DepictsFragment: select Place depiction when fragment becomes visible * UploadDepictsAdapter: make adapter aware of selection state Update selection state when recycled list items are automatically selected, preventing automatically selected items from appearing as unselected until they are forced to re-bind (i.e. after scrolling) * DepictsFragment: pre-select place depictions for all UploadItems If several images are selected and set to different places, pre-select all place depictions to reinforce the intended upload workflow philosophy (i.e. all images in a set are intended to be from/of the same place). See discussion in #3694 * DepictsFragment: scroll to the top every time list is updated * Typo fixes (#4461) * Fixed typo on class documentation of TextUtils * corrected comma placement in documentation * Fixed typos in comments * fix-issue-4424 (#4445) Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> * fix edit categories ui (#4414) Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> * Fix doom version issue (#4463) * Update db version * DBOpenHelper version update * fix :Back Pressed Event not work in Explore tab when user not login (#4404) * fix :Back Pressed Event not work in Explore tab * minor changes * fix :Upload count or number of contribution does not get updated when media is successful uploaded (#4399) * * fix:Number of Contributions not updated * Add javadocs * minor changes * made minor changes * String was nonsense and untranslatible, fixed (#4466) * Ability to show captions and descriptions in all entered languages (#4355) * implement Ability to show captions and descriptions in all entered languages *Add Javadoc * handle Back event of fragment(mediaDetailFragment) * fix minor bugs * add internationalization * revert previous changes * fix visibility bug * resolve conflict * Fixes #4437 - Changed indentation on files with 2 spaces to 4 spaces (#4462) * Edited Project.xml to make indent size 4 * Changed files with 2 space indentation to use 4 space indentation * Edited Project.xml to make indent size 4 * changed files with 2 space indent to 4 space indent * fix :Back Pressed Event not work in Explore tab when user not login (#4404) * fix :Back Pressed Event not work in Explore tab * minor changes * fix :Upload count or number of contribution does not get updated when media is successful uploaded (#4399) * * fix:Number of Contributions not updated * Add javadocs * minor changes * made minor changes * String was nonsense and untranslatible, fixed (#4466) * Ability to show captions and descriptions in all entered languages (#4355) * implement Ability to show captions and descriptions in all entered languages *Add Javadoc * handle Back event of fragment(mediaDetailFragment) * fix minor bugs * add internationalization * revert previous changes * fix visibility bug * resolve conflict Co-authored-by: Prince kushwaha <65972015+Prince-kushwaha@users.noreply.github.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com> * Use more understandable strings (#4470) * Fix #3792 Missing Column Issue (#4468) * Fix Missing Column Issue * Fix tests * Add UploadCategoriesFragment Unit Tests (#4473) * Panorama (#4467) * panoramic images fixed * made requested changes * Minor refactoring Co-authored-by: Aditya Srivastava <iamaditya2009@gmail.com> * Localisation updates from https://translatewiki.net. * Main activity title is sometimes "Contributions", sometimes "Commons" (#4472) Fixes #4438 Replace == with equals() in onRestoreInstanceState * Localisation updates from https://translatewiki.net. * caption and description copyable (#4481) * Removed next button in quiz (#4382) * issues resolved * modification done * warning fixed * issues resolved * Button added * don't know function added * Button added * modification done * modification done * Localisation updates from https://translatewiki.net. * Added option to show and modify location while uploading (#4475) * initial commit * Everything done * minor modification * minor modification * Issues fixed * minor modifications * issue fixed * Issues fixed * Tutorial removed from log out state (#4479) * tutorial removed from log out state * Issue removed * Update changelog.md * Versioning for v3.0.2 * Fix #4482 (#4484) * Fix crash when image resolution is very high (#4483) * Localisation updates from https://translatewiki.net. * Add Contributions Fragment Unit Tests (#4490) * Fix Tests Errors (#4491) * Add UploadMediaDetailFragment Unit Tests (#4492) * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Initialised xmls, made folder and image item. * xmls done * xmls completed * removed unwanted attribute * Created models, adapters and view models (#4441) * created models, adapters and view models * Added Image Fragment * back button linked * Documentation and refractor * spaces * Butterknife annotation * DiffUtil * Added Examples * Extended Custom selector From Base Activity * made view model injectable * [GSOC] Added Image Fetch (#4449) * Added basic Fetch * added permission request * Folder count rectified * Loaded thumbnail * disabled overlay * Added sha1 function * Documented the code * [GSoC] Image Selection (#4457) * Localisation updates from https://translatewiki.net. * Fixes #4357 After switching to different account, contributions screen shows pictures of previous account (#4421) * Update UploadMediaDetailFragment.java * Update LoginActivity.java Clear CompositeDisposable after logging in successfully. It may help solve the problem of saving the contribution to the previous account * Revert "Update UploadMediaDetailFragment.java" This reverts commit b1b4257. Co-authored-by: Obsidian_zero <1198474846@qq.com> * Remove unnecessary whitespace from a message (#4439) * Merge v3.0.1 into master (#4446) * Versioning and changelog for v3.0.0 (#4152) * Versioning for v3.0.0 * Update changelog.md * Handled migration 8-9-10 in BookmarksLocationDao (#4154) * #Fixes #4141 - Handled migrations for BookmarkLocationsDao from 8-9-10 * #Fixes #4141 - Handled migrations for BookmarkLocationsDao from 8-9-10 * Fixes #4179 (#4180) * Handled null pointer exception in MainActivity->ContributionsFragment#backButtonClicked() * Updated >ContributionsFragment#backButtonClicked() to handle back press properly * Fixes #4179 (#4181) * Handled possible null check on MediaDetails in BookmarkListRootFragment#backPressed() * Cherrypick for hotfix3.1 (#4205) * Fixes #4159 On Explore Tab, All Available Options on toolbar in media detail view are only targeting the first media in the list. Fixes #4159 On Explore Tab, All Available Options on toolbar in media detail view are only targeting the first media in the list. * fixed bug: App crashes on viewing review in Review Fragment #4132 (#4146) * fixed bug:app crashes on viewing review in Review Fragment #4135 * Fixed the issue with back button in contribution tab. (#4177) Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> * Fixed the issue with back navigation button on toolbar in explore tab. (#4175) * Fix (#4148) Issues on theme change * fixed themeChange crashes * fixed comments * Overlooked the title bar Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com> Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> Co-authored-by: Aditya-Srivastav <54016427+4D17Y4@users.noreply.github.com> * Fixes #4173 (#4396) * Fix #4147 Pre-fill desc in Nearby uploads with Wikidata item's label + description (#4390) * Update query to fetch descriptions * Make description added to NearbyResultItem * Make string operations to display description and label in a combined way * Fix reviews, remove long description from list and swap label and description texts * Fix repeated information issue * Fix double information issue * fix style issues * Remove douplicated information * Changes made (#4354) * Remove nonexistent method * Fix #4283 IllegalStateException (#4440) * Fix #4283 IllegalStateException * Fix flickering issue * Versioning for v3.0.1 * Update changelog.md Co-authored-by: Ashish <ashishkumar468@gmail.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com> Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com> Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> Co-authored-by: Aditya-Srivastav <54016427+4D17Y4@users.noreply.github.com> Co-authored-by: Madhur Gupta <30932899+madhurgupta10@users.noreply.github.com> Co-authored-by: Vinayak Aggarwal <56196007+vinayak0505@users.noreply.github.com> * Localisation updates from https://translatewiki.net. * Added basic Fetch * added permission request * Folder count rectified * Loaded thumbnail * disabled overlay * Added sha1 function * Documented the code * Added a feature for editing coordinates (#4418) * not * Place Picker added * Pick location and API call linked * minor warnings resolved * Code conventions followed * issue fixed * Wikitext edited properly * minor modification * Location Picker added * Bottom sheet removed * Location picker fully implemented * credit added * credit added * issues fixed * issues fixed * minor issue fixed * Some build issues occured merging release v3.0 are fixed. One paranthesis issue is solved, a method about UploadService is removed, since we don't use it anymore. (#4451) * Localisation updates from https://translatewiki.net. * Fixes 4344 - Duplicate Uploads (#4442) * Fixes 4344 - Update the retention policy of the Work Manager to ExistingWorkPolicy.APPEND_OR_REPLACE- which would append the new work to the end of existing one. This helps remove the while loop in UploadWorker which was meant to handle the cases where a new worker would be created for retries. The while loop seemed to have race conditions uploading duplicate entries. * Update states to IN_PROGRESS before uploads are processed * Image selection added * Forwarded activity result to upload wizard * Initialised xmls, made folder and image item. * xmls done * xmls completed * removed unwanted attribute * Created models, adapters and view models (#4441) * created models, adapters and view models * Added Image Fragment * back button linked * Documentation and refractor * spaces * Butterknife annotation * DiffUtil * Added Examples * Extended Custom selector From Base Activity * made view model injectable * Added basic Fetch * added permission request * Folder count rectified * Loaded thumbnail * disabled overlay * Added sha1 function * Documented the code * Image selection added * Forwarded activity result to upload wizard * [GSOC] Added Image Fetch (#4449) * Added basic Fetch * added permission request * Folder count rectified * Loaded thumbnail * disabled overlay * Added sha1 function * Documented the code * fixed merge errors * Documented the remaining function Co-authored-by: translatewiki.net <l10n-bot@translatewiki.net> Co-authored-by: obsidian-zero <63155026+obsidian-zero@users.noreply.github.com> Co-authored-by: Obsidian_zero <1198474846@qq.com> Co-authored-by: Amir E. Aharoni <amir.aharoni@mail.huji.ac.il> Co-authored-by: Josephine Lim <josephinelim86@gmail.com> Co-authored-by: Ashish <ashishkumar468@gmail.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com> Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com> Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> Co-authored-by: Madhur Gupta <30932899+madhurgupta10@users.noreply.github.com> Co-authored-by: Vinayak Aggarwal <56196007+vinayak0505@users.noreply.github.com> Co-authored-by: Ayan Sarkar <71203077+Ayan-10@users.noreply.github.com> * [GSoC] Show uploaded images differently. (#4464) * uploaded images shown differently * Loaded images before query * Handled exceptions, Made ImageLoader injectable, Document and clean code * [GSoC] Added Uploaded status table in room database. (#4476) * added Uploaded status table in room database * Added unique property, minor refractoring * Database intigrated * Database integrated * Handled result null exception * Exceptions handled and refractored * Introduced constants * moved to sealed class * No database insert on network error * queried original image * documented the code * Updated uploaded status on upload success * Image Helper test (#4485) * [GSoC] Adapter Tests (#4488) * Added FolderAdapterTest * Image Adapter Test * merge fix * rebase fix Co-authored-by: translatewiki.net <l10n-bot@translatewiki.net> Co-authored-by: obsidian-zero <63155026+obsidian-zero@users.noreply.github.com> Co-authored-by: Obsidian_zero <1198474846@qq.com> Co-authored-by: Amir E. Aharoni <amir.aharoni@mail.huji.ac.il> Co-authored-by: Josephine Lim <josephinelim86@gmail.com> Co-authored-by: Ashish <ashishkumar468@gmail.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com> Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com> Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com> Co-authored-by: Madhur Gupta <30932899+madhurgupta10@users.noreply.github.com> Co-authored-by: Vinayak Aggarwal <56196007+vinayak0505@users.noreply.github.com> Co-authored-by: Ayan Sarkar <71203077+Ayan-10@users.noreply.github.com> Co-authored-by: Brigham Byerly <6891883+byerlyb20@users.noreply.github.com> Co-authored-by: Jamie Brown <jamiejbrown521@gmail.com> Co-authored-by: Prince kushwaha <65972015+Prince-kushwaha@users.noreply.github.com> Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com> Co-authored-by: Ashar <asharalikhan200@gmail.com>
1 parent 93dae58 commit 7336881

File tree

112 files changed

+5611
-3352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+5611
-3352
lines changed

.idea/codeStyles/Project.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Wikimedia Commons for Android
22

3+
## v3.0.2
4+
- Fixed crash when uploading high res image
5+
- Fixed crash when viewing images in Explore
6+
37
## v3.0.1
48
- Pre-fill desc in Nearby uploads with Wikidata item's label + description
59
- Improved ACRA crash reporting

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ android {
154154
defaultConfig {
155155
//applicationId 'fr.free.nrw.commons'
156156

157-
versionCode 1016
158-
versionName '3.0.1'
157+
versionCode 1021
158+
versionName '3.0.2'
159159
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
160160

161161
minSdkVersion 19

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<activity android:name=".WelcomeActivity" />
5858

5959
<activity
60+
android:hardwareAccelerated="false"
6061
android:name=".upload.UploadActivity"
6162
android:configChanges="orientation|screenSize|keyboard"
6263
android:icon="@mipmap/ic_launcher"

app/src/main/java/fr/free/nrw/commons/CommonsApplication.java

Lines changed: 97 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,39 @@
6363
import timber.log.Timber;
6464

6565
@AcraCore(
66-
buildConfigClass = BuildConfig.class,
67-
resReportSendSuccessToast = R.string.crash_dialog_ok_toast,
68-
reportFormat = StringFormat.KEY_VALUE_LIST,
69-
reportContent = {USER_COMMENT, APP_VERSION_CODE, APP_VERSION_NAME, ANDROID_VERSION, PHONE_MODEL, STACK_TRACE}
66+
buildConfigClass = BuildConfig.class,
67+
resReportSendSuccessToast = R.string.crash_dialog_ok_toast,
68+
reportFormat = StringFormat.KEY_VALUE_LIST,
69+
reportContent = {USER_COMMENT, APP_VERSION_CODE, APP_VERSION_NAME, ANDROID_VERSION, PHONE_MODEL,
70+
STACK_TRACE}
7071
)
7172

7273
@AcraMailSender(
73-
mailTo = "commons-app-android-private@googlegroups.com",
74-
reportAsFile = false
74+
mailTo = "commons-app-android-private@googlegroups.com",
75+
reportAsFile = false
7576
)
7677

7778
@AcraDialog(
78-
resTheme = R.style.Theme_AppCompat_Dialog,
79-
resText = R.string.crash_dialog_text,
80-
resTitle = R.string.crash_dialog_title,
81-
resCommentPrompt = R.string.crash_dialog_comment_prompt
79+
resTheme = R.style.Theme_AppCompat_Dialog,
80+
resText = R.string.crash_dialog_text,
81+
resTitle = R.string.crash_dialog_title,
82+
resCommentPrompt = R.string.crash_dialog_comment_prompt
8283
)
8384

8485
public class CommonsApplication extends MultiDexApplication {
8586

86-
public static final String IS_LIMITED_CONNECTION_MODE_ENABLED = "is_limited_connection_mode_enabled";
87-
@Inject
88-
SessionManager sessionManager;
89-
@Inject
90-
DBOpenHelper dbOpenHelper;
87+
public static final String IS_LIMITED_CONNECTION_MODE_ENABLED = "is_limited_connection_mode_enabled";
88+
@Inject
89+
SessionManager sessionManager;
90+
@Inject
91+
DBOpenHelper dbOpenHelper;
9192

92-
@Inject
93-
@Named("default_preferences")
94-
JsonKvStore defaultPrefs;
93+
@Inject
94+
@Named("default_preferences")
95+
JsonKvStore defaultPrefs;
9596

96-
@Inject
97-
CustomOkHttpNetworkFetcher customOkHttpNetworkFetcher;
97+
@Inject
98+
CustomOkHttpNetworkFetcher customOkHttpNetworkFetcher;
9899

99100
/**
100101
* Constants begin
@@ -118,23 +119,26 @@ public class CommonsApplication extends MultiDexApplication {
118119
private RefWatcher refWatcher;
119120

120121
private static CommonsApplication INSTANCE;
122+
121123
public static CommonsApplication getInstance() {
122124
return INSTANCE;
123125
}
124126

125127
private AppLanguageLookUpTable languageLookUpTable;
128+
126129
public AppLanguageLookUpTable getLanguageLookUpTable() {
127130
return languageLookUpTable;
128131
}
129132

130-
@Inject ContributionDao contributionDao;
133+
@Inject
134+
ContributionDao contributionDao;
131135

132-
/**
133-
* In memory list of contributios whose uploads ahve been paused by the user
134-
*/
135-
public static Map<String, Boolean> pauseUploads = new HashMap<>();
136+
/**
137+
* In memory list of contributios whose uploads ahve been paused by the user
138+
*/
139+
public static Map<String, Boolean> pauseUploads = new HashMap<>();
136140

137-
/**
141+
/**
138142
* Used to declare and initialize various components and dependencies
139143
*/
140144
@Override
@@ -146,15 +150,14 @@ public void onCreate() {
146150
Mapbox.getInstance(this, getString(R.string.mapbox_commons_app_token));
147151

148152
ApplicationlessInjection
149-
.getInstance(this)
150-
.getCommonsApplicationComponent()
151-
.inject(this);
153+
.getInstance(this)
154+
.getCommonsApplicationComponent()
155+
.inject(this);
152156

153157
AppAdapter.set(new CommonsAppAdapter(sessionManager, defaultPrefs));
154158

155159
initTimber();
156160

157-
158161
if (!defaultPrefs.getBoolean("has_user_manually_removed_location")) {
159162
Set<String> defaultExifTagsSet = defaultPrefs.getStringSet(Prefs.MANAGED_EXIF_TAGS);
160163
if (null == defaultExifTagsSet) {
@@ -166,9 +169,9 @@ public void onCreate() {
166169

167170
// Set DownsampleEnabled to True to downsample the image in case it's heavy
168171
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
169-
.setNetworkFetcher(customOkHttpNetworkFetcher)
170-
.setDownsampleEnabled(true)
171-
.build();
172+
.setNetworkFetcher(customOkHttpNetworkFetcher)
173+
.setDownsampleEnabled(true)
174+
.build();
172175
try {
173176
Fresco.initialize(this, config);
174177
} catch (Exception e) {
@@ -192,77 +195,80 @@ public void onCreate() {
192195
}
193196

194197
/**
195-
* Plants debug and file logging tree.
196-
* Timber lets you plant your own logging trees.
197-
*
198+
* Plants debug and file logging tree. Timber lets you plant your own logging trees.
198199
*/
199200
private void initTimber() {
200-
boolean isBeta = ConfigUtils.isBetaFlavour();
201-
String logFileName =
202-
isBeta ? "CommonsBetaAppLogs" : "CommonsAppLogs";
203-
String logDirectory = LogUtils.getLogDirectory();
204-
//Delete stale logs if they have exceeded the specified size
205-
deleteStaleLogs(logFileName, logDirectory);
206-
207-
FileLoggingTree tree = new FileLoggingTree(
208-
Log.VERBOSE,
209-
logFileName,
210-
logDirectory,
211-
1000,
212-
getFileLoggingThreadPool());
213-
214-
Timber.plant(tree);
215-
Timber.plant(new Timber.DebugTree());
201+
boolean isBeta = ConfigUtils.isBetaFlavour();
202+
String logFileName =
203+
isBeta ? "CommonsBetaAppLogs" : "CommonsAppLogs";
204+
String logDirectory = LogUtils.getLogDirectory();
205+
//Delete stale logs if they have exceeded the specified size
206+
deleteStaleLogs(logFileName, logDirectory);
207+
208+
FileLoggingTree tree = new FileLoggingTree(
209+
Log.VERBOSE,
210+
logFileName,
211+
logDirectory,
212+
1000,
213+
getFileLoggingThreadPool());
214+
215+
Timber.plant(tree);
216+
Timber.plant(new Timber.DebugTree());
216217
}
217218

218-
/**
219-
* Deletes the logs zip file at the specified directory and file locations specified in the
220-
* params
221-
*
222-
* @param logFileName
223-
* @param logDirectory
224-
*/
225-
private void deleteStaleLogs(String logFileName, String logDirectory) {
226-
try {
227-
File file = new File(logDirectory + "/zip/" + logFileName + ".zip");
228-
if (file.exists() && file.getTotalSpace() > 1000000) {// In Kbs
229-
file.delete();
230-
}
231-
} catch (Exception e) {
232-
Timber.e(e);
219+
/**
220+
* Deletes the logs zip file at the specified directory and file locations specified in the
221+
* params
222+
*
223+
* @param logFileName
224+
* @param logDirectory
225+
*/
226+
private void deleteStaleLogs(String logFileName, String logDirectory) {
227+
try {
228+
File file = new File(logDirectory + "/zip/" + logFileName + ".zip");
229+
if (file.exists() && file.getTotalSpace() > 1000000) {// In Kbs
230+
file.delete();
231+
}
232+
} catch (Exception e) {
233+
Timber.e(e);
234+
}
233235
}
234-
}
235236

236237
public static boolean isRoboUnitTest() {
237238
return "robolectric".equals(Build.FINGERPRINT);
238239
}
239240

240241
private ThreadPoolService getFileLoggingThreadPool() {
241242
return new ThreadPoolService.Builder("file-logging-thread")
242-
.setPriority(Process.THREAD_PRIORITY_LOWEST)
243-
.setPoolSize(1)
244-
.setExceptionHandler(new BackgroundPoolExceptionHandler())
245-
.build();
243+
.setPriority(Process.THREAD_PRIORITY_LOWEST)
244+
.setPoolSize(1)
245+
.setExceptionHandler(new BackgroundPoolExceptionHandler())
246+
.build();
246247
}
247248

248249
public static void createNotificationChannel(@NonNull Context context) {
249250
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
250-
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
251-
NotificationChannel channel = manager.getNotificationChannel(NOTIFICATION_CHANNEL_ID_ALL);
251+
NotificationManager manager = (NotificationManager) context
252+
.getSystemService(Context.NOTIFICATION_SERVICE);
253+
NotificationChannel channel = manager
254+
.getNotificationChannel(NOTIFICATION_CHANNEL_ID_ALL);
252255
if (channel == null) {
253256
channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID_ALL,
254-
context.getString(R.string.notifications_channel_name_all), NotificationManager.IMPORTANCE_DEFAULT);
257+
context.getString(R.string.notifications_channel_name_all),
258+
NotificationManager.IMPORTANCE_DEFAULT);
255259
manager.createNotificationChannel(channel);
256260
}
257261
}
258262
}
259263

260264
public String getUserAgent() {
261-
return "Commons/" + ConfigUtils.getVersionNameWithSha(this) + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE;
265+
return "Commons/" + ConfigUtils.getVersionNameWithSha(this)
266+
+ " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE;
262267
}
263268

264269
/**
265270
* Helps in setting up LeakCanary library
271+
*
266272
* @return instance of LeakCanary
267273
*/
268274
protected RefWatcher setupLeakCanary() {
@@ -272,7 +278,7 @@ protected RefWatcher setupLeakCanary() {
272278
return LeakCanary.install(this);
273279
}
274280

275-
/**
281+
/**
276282
* Provides a way to get member refWatcher
277283
*
278284
* @param context Application context
@@ -285,7 +291,8 @@ public static RefWatcher getRefWatcher(Context context) {
285291

286292
/**
287293
* clears data of current application
288-
* @param context Application context
294+
*
295+
* @param context Application context
289296
* @param logoutListener Implementation of interface LogoutListener
290297
*/
291298
@SuppressLint("CheckResult")
@@ -302,13 +309,13 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
302309
}
303310

304311
sessionManager.logout()
305-
.andThen(Completable.fromAction(() ->{
306-
Timber.d("All accounts have been removed");
307-
clearImageCache();
308-
//TODO: fix preference manager
309-
defaultPrefs.clearAll();
310-
defaultPrefs.putBoolean("firstrun", false);
311-
updateAllDatabases();
312+
.andThen(Completable.fromAction(() -> {
313+
Timber.d("All accounts have been removed");
314+
clearImageCache();
315+
//TODO: fix preference manager
316+
defaultPrefs.clearAll();
317+
defaultPrefs.putBoolean("firstrun", false);
318+
updateAllDatabases();
312319
}
313320
))
314321
.subscribeOn(Schedulers.io())
@@ -332,12 +339,13 @@ private void updateAllDatabases() {
332339
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
333340

334341
CategoryDao.Table.onDelete(db);
335-
dbOpenHelper.deleteTable(db,CONTRIBUTIONS_TABLE);//Delete the contributions table in the existing db on older versions
342+
dbOpenHelper.deleteTable(db,
343+
CONTRIBUTIONS_TABLE);//Delete the contributions table in the existing db on older versions
336344

337345
try {
338-
contributionDao.deleteAll();
346+
contributionDao.deleteAll();
339347
} catch (SQLiteException e) {
340-
Timber.e(e);
348+
Timber.e(e);
341349
}
342350
BookmarkPicturesDao.Table.onDelete(db);
343351
BookmarkLocationsDao.Table.onDelete(db);
@@ -348,6 +356,7 @@ private void updateAllDatabases() {
348356
* Interface used to get log-out events
349357
*/
350358
public interface LogoutListener {
359+
351360
void onLogoutComplete();
352361
}
353362
}

0 commit comments

Comments
 (0)