mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Made locale non dependent on phone OS settings, but choosable on app settings (#4366)
* setLocale added * localization added * test complete * resolved conflicts * issues resolved * minor issues fixed * Made methods concise * Issues fixed
This commit is contained in:
		
							parent
							
								
									9562fd1f2c
								
							
						
					
					
						commit
						1408fe5e53
					
				
					 6 changed files with 139 additions and 40 deletions
				
			
		|  | @ -1,7 +1,9 @@ | |||
| package fr.free.nrw.commons.contributions; | ||||
| 
 | ||||
| import android.app.Activity; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.SharedPreferences; | ||||
| import android.os.Build.VERSION; | ||||
| import android.os.Build.VERSION_CODES; | ||||
| import android.os.Bundle; | ||||
|  | @ -37,6 +39,7 @@ import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.NearbyParentFra | |||
| import fr.free.nrw.commons.notification.NotificationActivity; | ||||
| import fr.free.nrw.commons.notification.NotificationController; | ||||
| import fr.free.nrw.commons.quiz.QuizChecker; | ||||
| import fr.free.nrw.commons.settings.SettingsFragment; | ||||
| import fr.free.nrw.commons.theme.BaseActivity; | ||||
| import fr.free.nrw.commons.upload.worker.UploadWorker; | ||||
| import fr.free.nrw.commons.utils.ViewUtilWrapper; | ||||
|  | @ -107,6 +110,7 @@ public class MainActivity  extends BaseActivity | |||
|     @Override | ||||
|     public void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         loadLocale(); | ||||
|         setContentView(R.layout.main); | ||||
|         ButterKnife.bind(this); | ||||
|         setSupportActionBar(toolbar); | ||||
|  | @ -365,4 +369,14 @@ public class MainActivity  extends BaseActivity | |||
|         BOOKMARK, | ||||
|         MORE | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Load default language in onCreate from SharedPreferences | ||||
|      */ | ||||
|     private void loadLocale(){ | ||||
|         final SharedPreferences preferences = getSharedPreferences("Settings", Activity.MODE_PRIVATE); | ||||
|         final String language = preferences.getString("language", ""); | ||||
|         final SettingsFragment settingsFragment = new SettingsFragment(); | ||||
|         settingsFragment.setLocale(this, language); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ayan Sarkar
						Ayan Sarkar