mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	add logs for testing
This commit is contained in:
		
							parent
							
								
									40c94eef2a
								
							
						
					
					
						commit
						92660647c7
					
				
					 4 changed files with 17 additions and 1 deletions
				
			
		|  | @ -54,7 +54,9 @@ class DeleteHelper @Inject constructor( | ||||||
|         reason: String? |         reason: String? | ||||||
|     ): Single<Boolean>? { |     ): Single<Boolean>? { | ||||||
| 
 | 
 | ||||||
|  |         Timber.d("Making deletion for title: ${media?.displayTitle} with reason: $reason") | ||||||
|         if(context == null && media == null) { |         if(context == null && media == null) { | ||||||
|  |             Timber.e("context or media is null") | ||||||
|             return null |             return null | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -66,10 +68,13 @@ class DeleteHelper @Inject constructor( | ||||||
|         return reason?.let { |         return reason?.let { | ||||||
|             delete(media!!, it) |             delete(media!!, it) | ||||||
|                 .flatMapSingle { result -> |                 .flatMapSingle { result -> | ||||||
|  |                     Timber.d("Show deletiong notification") | ||||||
|                     Single.just(showDeletionNotification(context, media, result)) |                     Single.just(showDeletionNotification(context, media, result)) | ||||||
|                 } |                 } | ||||||
|                 .firstOrError() |                 .firstOrError() | ||||||
|                 .onErrorResumeNext { throwable -> |                 .onErrorResumeNext { throwable -> | ||||||
|  |                     Timber.e("Error while making deletion") | ||||||
|  |                     throwable.printStackTrace() | ||||||
|                     if (throwable is InvalidLoginTokenException) { |                     if (throwable is InvalidLoginTokenException) { | ||||||
|                         Single.error(throwable) |                         Single.error(throwable) | ||||||
|                     } else { |                     } else { | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ package fr.free.nrw.commons.delete | ||||||
| 
 | 
 | ||||||
| import android.annotation.SuppressLint | import android.annotation.SuppressLint | ||||||
| import android.content.Context | import android.content.Context | ||||||
|  | import android.util.Log | ||||||
| 
 | 
 | ||||||
| import fr.free.nrw.commons.utils.DateUtil | import fr.free.nrw.commons.utils.DateUtil | ||||||
| import java.util.Locale | import java.util.Locale | ||||||
|  | @ -39,6 +40,7 @@ class ReasonBuilder @Inject constructor( | ||||||
|         if (media == null || reason == null) { |         if (media == null || reason == null) { | ||||||
|             return Single.just("Not known") |             return Single.just("Not known") | ||||||
|         } |         } | ||||||
|  |         Timber.d("Fetching article number") | ||||||
|         return fetchArticleNumber(media, reason) |         return fetchArticleNumber(media, reason) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -56,9 +58,13 @@ class ReasonBuilder @Inject constructor( | ||||||
| 
 | 
 | ||||||
|     private fun fetchArticleNumber(media: Media, reason: String): Single<String> { |     private fun fetchArticleNumber(media: Media, reason: String): Single<String> { | ||||||
|         return if (checkAccount()) { |         return if (checkAccount()) { | ||||||
|  |             Timber.d("Fetching achievements for ${sessionManager.userName}") | ||||||
|             okHttpJsonApiClient |             okHttpJsonApiClient | ||||||
|                 .getAchievements(sessionManager.userName) |                 .getAchievements(sessionManager.userName) | ||||||
|                 .map { feedbackResponse -> appendArticlesUsed(feedbackResponse, media, reason) } |                 .map { feedbackResponse -> | ||||||
|  |                     Timber.d("Feedback Response: $feedbackResponse") | ||||||
|  |                     appendArticlesUsed(feedbackResponse, media, reason) | ||||||
|  |                 } | ||||||
|         } else { |         } else { | ||||||
|             Single.just("") |             Single.just("") | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -1695,6 +1695,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C | ||||||
|         val finalReason: String = reason |         val finalReason: String = reason | ||||||
|         val resultSingle: Single<Boolean> = reasonBuilder.getReason(media, reason) |         val resultSingle: Single<Boolean> = reasonBuilder.getReason(media, reason) | ||||||
|             .flatMap { |             .flatMap { | ||||||
|  |                 Timber.d("Reason builder returned: $it") | ||||||
|                 deleteHelper.makeDeletion( |                 deleteHelper.makeDeletion( | ||||||
|                     context, media, finalReason |                     context, media, finalReason | ||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
|  | @ -258,18 +258,21 @@ class OkHttpJsonApiClient @Inject constructor( | ||||||
|     fun getAchievements(userName: String?): Single<FeedbackResponse?> { |     fun getAchievements(userName: String?): Single<FeedbackResponse?> { | ||||||
|         val suffix = if (isBetaFlavour) "/feedback.py?labs=commonswiki" else "/feedback.py" |         val suffix = if (isBetaFlavour) "/feedback.py?labs=commonswiki" else "/feedback.py" | ||||||
|         val fetchAchievementUrlTemplate = wikiMediaToolforgeUrl.toString() + suffix |         val fetchAchievementUrlTemplate = wikiMediaToolforgeUrl.toString() + suffix | ||||||
|  |         Timber.d("Url : $fetchAchievementUrlTemplate and User Name : $userName") | ||||||
|         return Single.fromCallable<FeedbackResponse?>({ |         return Single.fromCallable<FeedbackResponse?>({ | ||||||
|             val url = String.format( |             val url = String.format( | ||||||
|                 Locale.ENGLISH, |                 Locale.ENGLISH, | ||||||
|                 fetchAchievementUrlTemplate, |                 fetchAchievementUrlTemplate, | ||||||
|                 userName |                 userName | ||||||
|             ) |             ) | ||||||
|  |             Timber.d("Formatted URL: $url") | ||||||
|             val urlBuilder: HttpUrl.Builder = url.toHttpUrlOrNull()!!.newBuilder() |             val urlBuilder: HttpUrl.Builder = url.toHttpUrlOrNull()!!.newBuilder() | ||||||
|                 .addQueryParameter("user", userName) |                 .addQueryParameter("user", userName) | ||||||
|             val request: Request = Request.Builder() |             val request: Request = Request.Builder() | ||||||
|                 .url(urlBuilder.toString()) |                 .url(urlBuilder.toString()) | ||||||
|                 .build() |                 .build() | ||||||
|             val response: Response = okHttpClient.newCall(request).execute() |             val response: Response = okHttpClient.newCall(request).execute() | ||||||
|  |             Timber.d("Response received: $response | Body: ${response.body} | IsSuccessful: ${response.isSuccessful}") | ||||||
|             if (response.body != null && response.isSuccessful) { |             if (response.body != null && response.isSuccessful) { | ||||||
|                 var json: String = response.body!!.string() |                 var json: String = response.body!!.string() | ||||||
|                 // Extract JSON from response |                 // Extract JSON from response | ||||||
|  | @ -281,6 +284,7 @@ class OkHttpJsonApiClient @Inject constructor( | ||||||
|                         FeedbackResponse::class.java |                         FeedbackResponse::class.java | ||||||
|                     ) |                     ) | ||||||
|                 } catch (e: Exception) { |                 } catch (e: Exception) { | ||||||
|  |                     e.printStackTrace() | ||||||
|                     return@fromCallable FeedbackResponse(0, 0, 0, FeaturedImages(0, 0), 0, "") |                     return@fromCallable FeedbackResponse(0, 0, 0, FeaturedImages(0, 0), 0, "") | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rohit Verma
						Rohit Verma