move WifiQrView and SendFDroidView to pure XML views
This puts the logic in the "Presenter": SwapWorkflowActivity
This commit is contained in:
		
							parent
							
								
									69ce8dbe8c
								
							
						
					
					
						commit
						014fb0b99d
					
				| @ -1,45 +0,0 @@ | ||||
| package org.fdroid.fdroid.views.swap; | ||||
| 
 | ||||
| import android.annotation.TargetApi; | ||||
| import android.content.Context; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import android.widget.Button; | ||||
| import org.fdroid.fdroid.R; | ||||
| import org.fdroid.fdroid.localrepo.SwapView; | ||||
| 
 | ||||
| public class SendFDroidView extends SwapView { | ||||
| 
 | ||||
|     private static final String TAG = "SendFDroidView"; | ||||
| 
 | ||||
|     public SendFDroidView(Context context) { | ||||
|         super(context); | ||||
|     } | ||||
| 
 | ||||
|     public SendFDroidView(Context context, AttributeSet attrs) { | ||||
|         super(context, attrs); | ||||
|     } | ||||
| 
 | ||||
|     public SendFDroidView(Context context, AttributeSet attrs, int defStyleAttr) { | ||||
|         super(context, attrs, defStyleAttr); | ||||
|     } | ||||
| 
 | ||||
|     @TargetApi(21) | ||||
|     public SendFDroidView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||||
|         super(context, attrs, defStyleAttr, defStyleRes); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     protected void onFinishInflate() { | ||||
|         super.onFinishInflate(); | ||||
| 
 | ||||
|         Button useBluetooth = (Button) findViewById(R.id.btn_use_bluetooth); | ||||
|         useBluetooth.setOnClickListener(new Button.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View v) { | ||||
|                 getActivity().showIntro(); | ||||
|                 getActivity().sendFDroidBluetooth(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| @ -36,6 +36,7 @@ import android.view.MenuInflater; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.Button; | ||||
| import android.widget.ImageView; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toast; | ||||
| @ -506,8 +507,12 @@ public class SwapWorkflowActivity extends AppCompatActivity { | ||||
| 
 | ||||
|         switch (currentView.getLayoutResId()) { | ||||
|             case R.layout.swap_send_fdroid: | ||||
|                 setUpFromWifi(); | ||||
|                 setUpUseBluetoothButton(); | ||||
|                 break; | ||||
|             case R.layout.swap_wifi_qr: | ||||
|                 setUpFromWifi(); | ||||
|                 setUpQrScannerButton(); | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
| @ -969,4 +974,29 @@ public class SwapWorkflowActivity extends AppCompatActivity { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void setUpUseBluetoothButton() { | ||||
|         Button useBluetooth = findViewById(R.id.btn_use_bluetooth); | ||||
|         if (useBluetooth != null) { | ||||
|             useBluetooth.setOnClickListener(new Button.OnClickListener() { | ||||
|                 @Override | ||||
|                 public void onClick(View v) { | ||||
|                     showIntro(); | ||||
|                     sendFDroidBluetooth(); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void setUpQrScannerButton() { | ||||
|         Button openQr = findViewById(R.id.btn_qr_scanner); | ||||
|         if (openQr != null) { | ||||
|             openQr.setOnClickListener(new Button.OnClickListener() { | ||||
|                 @Override | ||||
|                 public void onClick(View v) { | ||||
|                     initiateQrScan(); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,44 +0,0 @@ | ||||
| package org.fdroid.fdroid.views.swap; | ||||
| 
 | ||||
| import android.annotation.TargetApi; | ||||
| import android.content.Context; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import android.widget.Button; | ||||
| import org.fdroid.fdroid.R; | ||||
| import org.fdroid.fdroid.localrepo.SwapView; | ||||
| 
 | ||||
| public class WifiQrView extends SwapView { | ||||
| 
 | ||||
|     private static final String TAG = "WifiQrView"; | ||||
| 
 | ||||
|     public WifiQrView(Context context) { | ||||
|         super(context); | ||||
|     } | ||||
| 
 | ||||
|     public WifiQrView(Context context, AttributeSet attrs) { | ||||
|         super(context, attrs); | ||||
|     } | ||||
| 
 | ||||
|     public WifiQrView(Context context, AttributeSet attrs, int defStyleAttr) { | ||||
|         super(context, attrs, defStyleAttr); | ||||
|     } | ||||
| 
 | ||||
|     @TargetApi(21) | ||||
|     public WifiQrView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||||
|         super(context, attrs, defStyleAttr, defStyleRes); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     protected void onFinishInflate() { | ||||
|         super.onFinishInflate(); | ||||
| 
 | ||||
|         Button openQr = (Button) findViewById(R.id.btn_qr_scanner); | ||||
|         openQr.setOnClickListener(new Button.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View v) { | ||||
|                 getActivity().initiateQrScan(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| 
 | ||||
| <org.fdroid.fdroid.views.swap.SendFDroidView | ||||
| <org.fdroid.fdroid.localrepo.SwapView | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:swap="http://schemas.android.com/apk/res-auto" | ||||
| @ -50,4 +50,4 @@ | ||||
| 
 | ||||
|     </LinearLayout> | ||||
|     </ScrollView> | ||||
| </org.fdroid.fdroid.views.swap.SendFDroidView> | ||||
| </org.fdroid.fdroid.localrepo.SwapView> | ||||
| @ -1,6 +1,6 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| 
 | ||||
| <org.fdroid.fdroid.views.swap.WifiQrView | ||||
| <org.fdroid.fdroid.localrepo.SwapView | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:swap="http://schemas.android.com/apk/res-auto" | ||||
| @ -57,4 +57,4 @@ | ||||
| 
 | ||||
|     </LinearLayout> | ||||
|     </ScrollView> | ||||
| </org.fdroid.fdroid.views.swap.WifiQrView> | ||||
| </org.fdroid.fdroid.localrepo.SwapView> | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Hans-Christoph Steiner
						Hans-Christoph Steiner