mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	fix: resolve crash when submitting feedback without internet access
This commit is contained in:
		
							parent
							
								
									64fd10d00e
								
							
						
					
					
						commit
						5c91f6db9d
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		|  | @ -5,6 +5,7 @@ import android.annotation.SuppressLint | |||
| import android.content.ActivityNotFoundException | ||||
| import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.net.ConnectivityManager | ||||
| import android.net.Uri | ||||
| import android.os.Bundle | ||||
| import android.view.LayoutInflater | ||||
|  | @ -170,6 +171,11 @@ class MoreBottomSheetFragment : BottomSheetDialogFragment() { | |||
|     fun uploadFeedback(feedback: Feedback) { | ||||
|         val feedbackContentCreator = FeedbackContentCreator(requireContext(), feedback) | ||||
| 
 | ||||
|         if (!isNetworkAvailable(requireContext())) { | ||||
|             Toast.makeText(requireContext(), R.string.error_feedback, Toast.LENGTH_LONG).show() | ||||
|             return | ||||
|         } | ||||
| 
 | ||||
|         val single = pageEditClient.createNewSection( | ||||
|             "Commons:Mobile_app/Feedback", | ||||
|             feedbackContentCreator.getSectionTitle(), | ||||
|  | @ -192,6 +198,15 @@ class MoreBottomSheetFragment : BottomSheetDialogFragment() { | |||
|             } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * This method is to check whether internet connection is available or not | ||||
|      */ | ||||
|     fun isNetworkAvailable(context: Context): Boolean { | ||||
|         val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | ||||
|         val activeNetwork = connectivityManager.activeNetworkInfo | ||||
|         return activeNetwork != null && activeNetwork.isConnected | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * This method shows the alert dialog when a user wants to send feedback about the app. | ||||
|      */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 angrezichatterbox
						angrezichatterbox