mirror of
				https://github.com/SimpleMobileTools/Simple-Draw.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	Use RadioGroup instead Spinner to select extension
This commit is contained in:
		| @@ -19,8 +19,8 @@ import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.widget.EditText; | ||||
| import android.widget.ImageView; | ||||
| import android.widget.RadioGroup; | ||||
| import android.widget.SeekBar; | ||||
| import android.widget.Spinner; | ||||
| import android.widget.Toast; | ||||
|  | ||||
| import com.simplemobiletools.draw.Config; | ||||
| @@ -52,7 +52,7 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange | ||||
|     @BindView(R.id.stroke_width_bar) SeekBar mStrokeWidthBar; | ||||
|  | ||||
|     private String curFileName; | ||||
|     private int curExtensionIndex; | ||||
|     private int curExtensionId; | ||||
|  | ||||
|     private int color; | ||||
|     private float strokeWidth; | ||||
| @@ -167,8 +167,10 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange | ||||
|         final EditText fileNameET = (EditText) saveFileView.findViewById(R.id.file_name); | ||||
|         fileNameET.setText(curFileName); | ||||
|  | ||||
|         final Spinner fileExtensionS = (Spinner) saveFileView.findViewById(R.id.file_extension); | ||||
|         fileExtensionS.setSelection(curExtensionIndex); | ||||
|         final RadioGroup fileExtensionRG = (RadioGroup) saveFileView.findViewById(R.id.extension_radio_group); | ||||
|         if (curExtensionId != 0) { | ||||
|             fileExtensionRG.check(curExtensionId); | ||||
|         } | ||||
|         builder.setView(saveFileView); | ||||
|  | ||||
|         builder.setPositiveButton(R.string.ok, null); | ||||
| @@ -180,11 +182,17 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange | ||||
|             @Override | ||||
|             public void onClick(View v) { | ||||
|                 final String fileName = fileNameET.getText().toString().trim(); | ||||
|                 final String extension = (String) fileExtensionS.getSelectedItem(); | ||||
|                 if (!fileName.isEmpty()) { | ||||
|                     final String extension; | ||||
|                     switch (fileExtensionRG.getCheckedRadioButtonId()) { | ||||
|                         default: | ||||
|                         case R.id.extension_radio_png: extension = ".png"; break; | ||||
|                         case R.id.extension_radio_svg: extension = ".svg"; break; | ||||
|                     } | ||||
|  | ||||
|                     if (saveFile(fileName, extension)) { | ||||
|                         curFileName = fileName; | ||||
|                         curExtensionIndex = fileExtensionS.getSelectedItemPosition(); | ||||
|                         curExtensionId = fileExtensionRG.getCheckedRadioButtonId(); | ||||
|  | ||||
|                         Utils.showToast(getApplicationContext(), R.string.saving_ok); | ||||
|                         alertDialog.dismiss(); | ||||
|   | ||||
| @@ -17,18 +17,26 @@ | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_below="@+id/file_name_label" | ||||
|         android:layout_marginBottom="@dimen/activity_margin" | ||||
|         android:layout_toLeftOf="@+id/file_extension" | ||||
|         android:singleLine="true"/> | ||||
|  | ||||
|     <Spinner | ||||
|         android:id="@+id/file_extension" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="match_parent" | ||||
|         android:layout_alignBottom="@+id/file_name" | ||||
|         android:layout_alignParentRight="true" | ||||
|         android:layout_alignTop="@+id/file_name" | ||||
|         android:layout_below="@+id/file_name_label" | ||||
|         android:gravity="center_vertical" | ||||
|         android:entries="@array/save_formats"/> | ||||
|     <RadioGroup | ||||
|         android:id="@+id/extension_radio_group" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_below="@+id/file_name" | ||||
|         android:checkedButton="@+id/extension_radio_png"> | ||||
|  | ||||
|         <RadioButton | ||||
|             android:id="@+id/extension_radio_png" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:text=".png"/> | ||||
|  | ||||
|         <RadioButton | ||||
|             android:id="@+id/extension_radio_svg" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:text=".svg"/> | ||||
|     </RadioGroup> | ||||
|  | ||||
| </RelativeLayout> | ||||
|   | ||||
| @@ -12,10 +12,6 @@ | ||||
|     <string name="no_permissions">Could not save the file without accessing the external storage</string> | ||||
|     <string name="ok">OK</string> | ||||
|     <string name="cancel">Cancel</string> | ||||
|     <string-array name="save_formats" translatable="false"> | ||||
|         <item>.png</item> | ||||
|         <item>.svg</item> | ||||
|     </string-array> | ||||
|  | ||||
|     <!-- Settings --> | ||||
|     <string name="settings">Settings</string> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user