mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Injected API, Session Manager
This commit is contained in:
		
							parent
							
								
									6c38b58a29
								
							
						
					
					
						commit
						4b0f1f6a09
					
				
					 3 changed files with 36 additions and 0 deletions
				
			
		|  | @ -3,12 +3,44 @@ package fr.free.nrw.commons.delete; | |||
| import android.support.v7.app.AppCompatActivity; | ||||
| import android.os.Bundle; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import fr.free.nrw.commons.R; | ||||
| import fr.free.nrw.commons.auth.SessionManager; | ||||
| import fr.free.nrw.commons.di.ApplicationlessInjection; | ||||
| import fr.free.nrw.commons.mwapi.MediaWikiApi; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| public class DeleteActivity extends AppCompatActivity { | ||||
| 
 | ||||
|     @Inject MediaWikiApi mwApi; | ||||
|     @Inject SessionManager sessionManager; | ||||
| 
 | ||||
|     @Override | ||||
|     public void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
| 
 | ||||
|         ApplicationlessInjection | ||||
|                 .getInstance(this.getApplicationContext()) | ||||
|                 .getCommonsApplicationComponent() | ||||
|                 .inject(this); | ||||
| 
 | ||||
|         setContentView(R.layout.activity_delete); | ||||
| 
 | ||||
|         String authCookie = sessionManager.getAuthCookie(); | ||||
|         Timber.d(authCookie); | ||||
| 
 | ||||
|         mwApi.setAuthCookie(authCookie); | ||||
|         String editToken = "noooooooo"; | ||||
| 
 | ||||
|         try { | ||||
|             editToken = mwApi.getEditToken(); | ||||
|         } catch (Exception e) { | ||||
|             Timber.d(e.getMessage()); | ||||
|         } | ||||
|         Timber.d(editToken); | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -10,6 +10,7 @@ import fr.free.nrw.commons.CommonsApplication; | |||
| import fr.free.nrw.commons.MediaWikiImageView; | ||||
| import fr.free.nrw.commons.auth.LoginActivity; | ||||
| import fr.free.nrw.commons.contributions.ContributionsSyncAdapter; | ||||
| import fr.free.nrw.commons.delete.DeleteActivity; | ||||
| import fr.free.nrw.commons.modifications.ModificationsSyncAdapter; | ||||
| import fr.free.nrw.commons.settings.SettingsFragment; | ||||
| 
 | ||||
|  | @ -34,6 +35,8 @@ public interface CommonsApplicationComponent extends AndroidInjector<Application | |||
| 
 | ||||
|     void inject(LoginActivity activity); | ||||
| 
 | ||||
|     void inject(DeleteActivity activity); | ||||
| 
 | ||||
|     void inject(SettingsFragment fragment); | ||||
| 
 | ||||
|     @Override | ||||
|  |  | |||
|  | @ -297,6 +297,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment { | |||
|         } | ||||
|         if (delete.getVisibility()!=View.GONE){ | ||||
|             delete.setOnClickListener(v -> { | ||||
|                 Timber.d("clicked delete"); | ||||
|                 Bundle bundle = new Bundle(); | ||||
|                 bundle.putParcelable("media",media); | ||||
|                 Intent deleteIntent = new Intent(getActivity(), DeleteActivity.class); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Suchit Kar
						Suchit Kar