@@ -97,22 +97,21 @@ public void handleMessage(Message message) {
9797 private ProgressDialog mApkGenerationDialog ;
9898
9999
100- public void openBottomSheet (View v ) {
101-
102- View view = getLayoutInflater ().inflate (R .layout .bottom_sheet_view , null );
103- TextView txtSaveApk = (TextView )view .findViewById ( R .id .txt_save_apk );
104- TextView txtSaveProject = (TextView )view .findViewById ( R .id .txt_save_project );
105- TextView txtShareApk = (TextView )view .findViewById ( R .id .txt_share_apk );
106- final TextView txtShareProject = (TextView )view .findViewById ( R .id .txt_share_project );
107-
108- final Dialog mBottomSheetDialog = new Dialog (TemplateEditor .this ,
100+ public void openBottomSheet (View v ) {
101+
102+ View view = getLayoutInflater ().inflate (R .layout .bottom_sheet_view , null );
103+ TextView txtSaveApk = (TextView ) view .findViewById (R .id .txt_save_apk );
104+ TextView txtSaveProject = (TextView ) view .findViewById (R .id .txt_save_project );
105+ TextView txtShareApk = (TextView ) view .findViewById (R .id .txt_share_apk );
106+ final TextView txtShareProject = (TextView ) view .findViewById (R .id .txt_share_project );
107+ final Dialog mBottomSheetDialog = new Dialog (TemplateEditor .this ,
109108 R .style .MaterialDialogSheet );
110- mBottomSheetDialog .setContentView (view );
111- mBottomSheetDialog .setCancelable (true );
112- mBottomSheetDialog .getWindow ().setLayout (LinearLayout .LayoutParams .MATCH_PARENT ,
109+ mBottomSheetDialog .setContentView (view );
110+ mBottomSheetDialog .setCancelable (true );
111+ mBottomSheetDialog .getWindow ().setLayout (LinearLayout .LayoutParams .MATCH_PARENT ,
113112 LinearLayout .LayoutParams .WRAP_CONTENT );
114- mBottomSheetDialog .getWindow ().setGravity (Gravity .BOTTOM );
115- mBottomSheetDialog .show ();
113+ mBottomSheetDialog .getWindow ().setGravity (Gravity .BOTTOM );
114+ mBottomSheetDialog .show ();
116115
117116
118117 //save project
@@ -164,7 +163,7 @@ private void saveApk() {
164163 String aliasName = getString (R .string .alias_name );
165164 String aliaspassword = getString (R .string .alias_password );
166165 KeyStoreDetails keyStoreDetails = new KeyStoreDetails (keyPassword , aliasName , aliaspassword );
167- if (saveProject ().equals ("File already exists" )){
166+ if (saveProject ().equals ("File already exists" )) {
168167 return ;
169168 }
170169 SignerThread signer = new SignerThread (getApplicationContext (), selectedTemplate .getApkFilePath (), saveProject (), keyStoreDetails , selectedTemplate .getAssetsFilePath (), selectedTemplate .getAssetsFileName (TemplateEditor .this ));
@@ -527,9 +526,7 @@ private void setUpTemplateEditor() {
527526
528527 } catch (InstantiationException e ) {
529528 e .printStackTrace ();
530- }
531- catch ( IllegalAccessException e )
532- {
529+ } catch (IllegalAccessException e ) {
533530 e .printStackTrace ();
534531 }
535532 }
@@ -590,16 +587,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
590587 switch (id ) {
591588 case R .id .action_delete :
592589 final int restorePosition = selectedPosition ;
593- final Object object = selectedTemplate .deleteItem (TemplateEditor .this ,selectedPosition );
590+ final Object object = selectedTemplate .deleteItem (TemplateEditor .this , selectedPosition );
594591 selectedPosition = -1 ;
595592 restoreSelectedView ();
596593 Snackbar .make (findViewById (R .id .relative_layout ),
597- R .string .snackbar_deleted_message ,Snackbar .LENGTH_LONG )
594+ R .string .snackbar_deleted_message , Snackbar .LENGTH_LONG )
598595 .setAction (R .string .snackbar_undo , new View .OnClickListener () {
599596 @ Override
600597 public void onClick (View v ) {
601- selectedTemplate .restoreItem (TemplateEditor .this ,restorePosition ,object );
602- Snackbar .make (v ,R .string .snackbar_restored_message ,Snackbar .LENGTH_LONG ).show ();
598+ selectedTemplate .restoreItem (TemplateEditor .this , restorePosition , object );
599+ Snackbar .make (v , R .string .snackbar_restored_message , Snackbar .LENGTH_LONG ).show ();
603600 }
604601 }).show ();
605602 break ;
@@ -686,10 +683,10 @@ private String saveProject() {
686683 EditText authorEditText = (EditText ) findViewById (R .id .author_name );
687684 titleEditText = (EditText ) findViewById (R .id .template_title );
688685 assert findViewById (R .id .author_name ) != null ;
689- assert ( findViewById (R .id .author_name )) != null ;
686+ assert (findViewById (R .id .author_name )) != null ;
690687 String author = ((EditText ) findViewById (R .id .author_name )).getText ().toString ();
691688 assert findViewById (R .id .template_title ) != null ;
692- assert ( findViewById (R .id .template_title )) != null ;
689+ assert (findViewById (R .id .template_title )) != null ;
693690 String title = ((EditText ) findViewById (R .id .template_title )).getText ().toString ();
694691 if ("" .equals (author )) {
695692 assert authorEditText != null ;
@@ -739,6 +736,12 @@ private String saveProject() {
739736 Toast .makeText (this , "Unable to perform action: Add Meta Details" , Toast .LENGTH_SHORT ).show ();
740737 return null ;
741738 }
739+
740+ if (templateId == 7 && selectedTemplate .getItems (doc ).size () == 2 ) {
741+ Toast .makeText (this , "Please enter atleast 2 items" , Toast .LENGTH_SHORT ).show ();
742+ return null ;
743+ }
744+
742745 for (Element item : selectedTemplate .getItems (doc )) {
743746 dataElement .appendChild (item );
744747 }
@@ -751,13 +754,12 @@ private String saveProject() {
751754 saveFileName = saveFileName .replaceAll (" " , "-" );
752755
753756
754- boolean isSaved = FileUtils .saveXmlFile (toolkit .getSavedDir (), saveFileName , doc );
755- if (isSaved ) {
757+ boolean isSaved = FileUtils .saveXmlFile (toolkit .getSavedDir (), saveFileName , doc );
758+ if (isSaved ) {
756759 oldFileName = toolkit .getSavedDir () + saveFileName ;
757760 Toast .makeText (this , "Project Successfully Saved!" , Toast .LENGTH_SHORT ).show ();
758761 return oldFileName ;
759- }
760- else {
762+ } else {
761763 titleEditText .setError ("File Already exists" );
762764 return "File already exists" ;
763765 }
@@ -786,9 +788,9 @@ public void onBackPressed() {
786788 */
787789 private String saveDraft () {
788790
789- assert ( findViewById (R .id .author_name )) != null ;
791+ assert (findViewById (R .id .author_name )) != null ;
790792 String author = ((EditText ) findViewById (R .id .author_name )).getText ().toString ();
791- assert ( findViewById (R .id .template_title )) != null ;
793+ assert (findViewById (R .id .template_title )) != null ;
792794 String title = ((EditText ) findViewById (R .id .template_title )).getText ().toString ();
793795
794796
@@ -818,6 +820,7 @@ private String saveDraft() {
818820 doc .appendChild (rootElement );
819821 Element dataElement = doc .createElement ("data" );
820822 rootElement .appendChild (dataElement );
823+
821824 if (selectedTemplate .getItems (doc ).size () == 0 ) {
822825 Toast .makeText (this , "Unable to perform action: No Data" , Toast .LENGTH_SHORT ).show ();
823826 return null ;
@@ -826,6 +829,10 @@ private String saveDraft() {
826829 Toast .makeText (this , "Unable to perform action: No Meta Details" , Toast .LENGTH_SHORT ).show ();
827830 return null ;
828831 }
832+ if (templateId == 7 && selectedTemplate .getItems (doc ).size () == 2 ) {
833+ Toast .makeText (this , "Please enter atleast 2 items" , Toast .LENGTH_SHORT ).show ();
834+ return null ;
835+ }
829836 for (Element item : selectedTemplate .getItems (doc )) {
830837 dataElement .appendChild (item );
831838 }
@@ -876,9 +883,7 @@ private void startSimulator() {
876883 if (message == null || message .equals ("" )) {
877884 Toast .makeText (this , "Build unsuccessful" , Toast .LENGTH_SHORT ).show ();
878885 return ;
879- }
880- else if ("File already exists" .equals (message ))
881- {
886+ } else if ("File already exists" .equals (message )) {
882887 titleEditText .setError ("Template Already exists" );
883888 return ;
884889 }
0 commit comments