Skip to content

Commit ca9f6f5

Browse files
JBrown526Prince-kushwahaneslihanturan
authored
Fixes commons-app#4437 - Changed indentation on files with 2 spaces to 4 spaces (commons-app#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 (commons-app#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 (commons-app#4399) * * fix:Number of Contributions not updated * Add javadocs * minor changes * made minor changes * String was nonsense and untranslatible, fixed (commons-app#4466) * Ability to show captions and descriptions in all entered languages (commons-app#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>
1 parent b202f55 commit ca9f6f5

36 files changed

+3120
-3061
lines changed

.idea/codeStyles/Project.xml

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+97-88
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)