@@ -97,22 +97,21 @@ public void handleMessage(Message message) {
97
97
private ProgressDialog mApkGenerationDialog ;
98
98
99
99
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 ,
109
108
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 ,
113
112
LinearLayout .LayoutParams .WRAP_CONTENT );
114
- mBottomSheetDialog .getWindow ().setGravity (Gravity .BOTTOM );
115
- mBottomSheetDialog .show ();
113
+ mBottomSheetDialog .getWindow ().setGravity (Gravity .BOTTOM );
114
+ mBottomSheetDialog .show ();
116
115
117
116
118
117
//save project
@@ -164,7 +163,7 @@ private void saveApk() {
164
163
String aliasName = getString (R .string .alias_name );
165
164
String aliaspassword = getString (R .string .alias_password );
166
165
KeyStoreDetails keyStoreDetails = new KeyStoreDetails (keyPassword , aliasName , aliaspassword );
167
- if (saveProject ().equals ("File already exists" )){
166
+ if (saveProject ().equals ("File already exists" )) {
168
167
return ;
169
168
}
170
169
SignerThread signer = new SignerThread (getApplicationContext (), selectedTemplate .getApkFilePath (), saveProject (), keyStoreDetails , selectedTemplate .getAssetsFilePath (), selectedTemplate .getAssetsFileName (TemplateEditor .this ));
@@ -535,9 +534,7 @@ private void setUpTemplateEditor() {
535
534
536
535
} catch (InstantiationException e ) {
537
536
e .printStackTrace ();
538
- }
539
- catch ( IllegalAccessException e )
540
- {
537
+ } catch (IllegalAccessException e ) {
541
538
e .printStackTrace ();
542
539
}
543
540
}
@@ -598,16 +595,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
598
595
switch (id ) {
599
596
case R .id .action_delete :
600
597
final int restorePosition = selectedPosition ;
601
- final Object object = selectedTemplate .deleteItem (TemplateEditor .this ,selectedPosition );
598
+ final Object object = selectedTemplate .deleteItem (TemplateEditor .this , selectedPosition );
602
599
selectedPosition = -1 ;
603
600
restoreSelectedView ();
604
601
Snackbar .make (findViewById (R .id .relative_layout ),
605
- R .string .snackbar_deleted_message ,Snackbar .LENGTH_LONG )
602
+ R .string .snackbar_deleted_message , Snackbar .LENGTH_LONG )
606
603
.setAction (R .string .snackbar_undo , new View .OnClickListener () {
607
604
@ Override
608
605
public void onClick (View v ) {
609
- selectedTemplate .restoreItem (TemplateEditor .this ,restorePosition ,object );
610
- Snackbar .make (v ,R .string .snackbar_restored_message ,Snackbar .LENGTH_LONG ).show ();
606
+ selectedTemplate .restoreItem (TemplateEditor .this , restorePosition , object );
607
+ Snackbar .make (v , R .string .snackbar_restored_message , Snackbar .LENGTH_LONG ).show ();
611
608
}
612
609
}).show ();
613
610
break ;
@@ -694,10 +691,10 @@ private String saveProject() {
694
691
EditText authorEditText = (EditText ) findViewById (R .id .author_name );
695
692
titleEditText = (EditText ) findViewById (R .id .template_title );
696
693
assert findViewById (R .id .author_name ) != null ;
697
- assert ( findViewById (R .id .author_name )) != null ;
694
+ assert (findViewById (R .id .author_name )) != null ;
698
695
String author = ((EditText ) findViewById (R .id .author_name )).getText ().toString ();
699
696
assert findViewById (R .id .template_title ) != null ;
700
- assert ( findViewById (R .id .template_title )) != null ;
697
+ assert (findViewById (R .id .template_title )) != null ;
701
698
String title = ((EditText ) findViewById (R .id .template_title )).getText ().toString ();
702
699
if ("" .equals (author )) {
703
700
assert authorEditText != null ;
@@ -747,6 +744,12 @@ private String saveProject() {
747
744
Toast .makeText (this , "Unable to perform action: Add Meta Details" , Toast .LENGTH_SHORT ).show ();
748
745
return null ;
749
746
}
747
+
748
+ if (templateId == 7 && selectedTemplate .getItems (doc ).size () == 2 ) {
749
+ Toast .makeText (this , "Please enter atleast 2 items" , Toast .LENGTH_SHORT ).show ();
750
+ return null ;
751
+ }
752
+
750
753
for (Element item : selectedTemplate .getItems (doc )) {
751
754
dataElement .appendChild (item );
752
755
}
@@ -759,13 +762,12 @@ private String saveProject() {
759
762
saveFileName = saveFileName .replaceAll (" " , "-" );
760
763
761
764
762
- boolean isSaved = FileUtils .saveXmlFile (toolkit .getSavedDir (), saveFileName , doc );
763
- if (isSaved ) {
765
+ boolean isSaved = FileUtils .saveXmlFile (toolkit .getSavedDir (), saveFileName , doc );
766
+ if (isSaved ) {
764
767
oldFileName = toolkit .getSavedDir () + saveFileName ;
765
768
Toast .makeText (this , "Project Successfully Saved!" , Toast .LENGTH_SHORT ).show ();
766
769
return oldFileName ;
767
- }
768
- else {
770
+ } else {
769
771
titleEditText .setError ("File Already exists" );
770
772
return "File already exists" ;
771
773
}
@@ -794,9 +796,9 @@ public void onBackPressed() {
794
796
*/
795
797
private String saveDraft () {
796
798
797
- assert ( findViewById (R .id .author_name )) != null ;
799
+ assert (findViewById (R .id .author_name )) != null ;
798
800
String author = ((EditText ) findViewById (R .id .author_name )).getText ().toString ();
799
- assert ( findViewById (R .id .template_title )) != null ;
801
+ assert (findViewById (R .id .template_title )) != null ;
800
802
String title = ((EditText ) findViewById (R .id .template_title )).getText ().toString ();
801
803
802
804
@@ -826,6 +828,7 @@ private String saveDraft() {
826
828
doc .appendChild (rootElement );
827
829
Element dataElement = doc .createElement ("data" );
828
830
rootElement .appendChild (dataElement );
831
+
829
832
if (selectedTemplate .getItems (doc ).size () == 0 ) {
830
833
Toast .makeText (this , "Unable to perform action: No Data" , Toast .LENGTH_SHORT ).show ();
831
834
return null ;
@@ -834,6 +837,10 @@ private String saveDraft() {
834
837
Toast .makeText (this , "Unable to perform action: No Meta Details" , Toast .LENGTH_SHORT ).show ();
835
838
return null ;
836
839
}
840
+ if (templateId == 7 && selectedTemplate .getItems (doc ).size () == 2 ) {
841
+ Toast .makeText (this , "Please enter atleast 2 items" , Toast .LENGTH_SHORT ).show ();
842
+ return null ;
843
+ }
837
844
for (Element item : selectedTemplate .getItems (doc )) {
838
845
dataElement .appendChild (item );
839
846
}
@@ -884,9 +891,7 @@ private void startSimulator() {
884
891
if (message == null || message .equals ("" )) {
885
892
Toast .makeText (this , "Build unsuccessful" , Toast .LENGTH_SHORT ).show ();
886
893
return ;
887
- }
888
- else if ("File already exists" .equals (message ))
889
- {
894
+ } else if ("File already exists" .equals (message )) {
890
895
titleEditText .setError ("Template Already exists" );
891
896
return ;
892
897
}
0 commit comments