@@ -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 ));
@@ -527,9 +526,7 @@ private void setUpTemplateEditor() {
527
526
528
527
} catch (InstantiationException e ) {
529
528
e .printStackTrace ();
530
- }
531
- catch ( IllegalAccessException e )
532
- {
529
+ } catch (IllegalAccessException e ) {
533
530
e .printStackTrace ();
534
531
}
535
532
}
@@ -590,16 +587,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
590
587
switch (id ) {
591
588
case R .id .action_delete :
592
589
final int restorePosition = selectedPosition ;
593
- final Object object = selectedTemplate .deleteItem (TemplateEditor .this ,selectedPosition );
590
+ final Object object = selectedTemplate .deleteItem (TemplateEditor .this , selectedPosition );
594
591
selectedPosition = -1 ;
595
592
restoreSelectedView ();
596
593
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 )
598
595
.setAction (R .string .snackbar_undo , new View .OnClickListener () {
599
596
@ Override
600
597
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 ();
603
600
}
604
601
}).show ();
605
602
break ;
@@ -686,10 +683,10 @@ private String saveProject() {
686
683
EditText authorEditText = (EditText ) findViewById (R .id .author_name );
687
684
titleEditText = (EditText ) findViewById (R .id .template_title );
688
685
assert findViewById (R .id .author_name ) != null ;
689
- assert ( findViewById (R .id .author_name )) != null ;
686
+ assert (findViewById (R .id .author_name )) != null ;
690
687
String author = ((EditText ) findViewById (R .id .author_name )).getText ().toString ();
691
688
assert findViewById (R .id .template_title ) != null ;
692
- assert ( findViewById (R .id .template_title )) != null ;
689
+ assert (findViewById (R .id .template_title )) != null ;
693
690
String title = ((EditText ) findViewById (R .id .template_title )).getText ().toString ();
694
691
if ("" .equals (author )) {
695
692
assert authorEditText != null ;
@@ -739,6 +736,12 @@ private String saveProject() {
739
736
Toast .makeText (this , "Unable to perform action: Add Meta Details" , Toast .LENGTH_SHORT ).show ();
740
737
return null ;
741
738
}
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
+
742
745
for (Element item : selectedTemplate .getItems (doc )) {
743
746
dataElement .appendChild (item );
744
747
}
@@ -751,13 +754,12 @@ private String saveProject() {
751
754
saveFileName = saveFileName .replaceAll (" " , "-" );
752
755
753
756
754
- boolean isSaved = FileUtils .saveXmlFile (toolkit .getSavedDir (), saveFileName , doc );
755
- if (isSaved ) {
757
+ boolean isSaved = FileUtils .saveXmlFile (toolkit .getSavedDir (), saveFileName , doc );
758
+ if (isSaved ) {
756
759
oldFileName = toolkit .getSavedDir () + saveFileName ;
757
760
Toast .makeText (this , "Project Successfully Saved!" , Toast .LENGTH_SHORT ).show ();
758
761
return oldFileName ;
759
- }
760
- else {
762
+ } else {
761
763
titleEditText .setError ("File Already exists" );
762
764
return "File already exists" ;
763
765
}
@@ -786,9 +788,9 @@ public void onBackPressed() {
786
788
*/
787
789
private String saveDraft () {
788
790
789
- assert ( findViewById (R .id .author_name )) != null ;
791
+ assert (findViewById (R .id .author_name )) != null ;
790
792
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 ;
792
794
String title = ((EditText ) findViewById (R .id .template_title )).getText ().toString ();
793
795
794
796
@@ -818,6 +820,7 @@ private String saveDraft() {
818
820
doc .appendChild (rootElement );
819
821
Element dataElement = doc .createElement ("data" );
820
822
rootElement .appendChild (dataElement );
823
+
821
824
if (selectedTemplate .getItems (doc ).size () == 0 ) {
822
825
Toast .makeText (this , "Unable to perform action: No Data" , Toast .LENGTH_SHORT ).show ();
823
826
return null ;
@@ -826,6 +829,10 @@ private String saveDraft() {
826
829
Toast .makeText (this , "Unable to perform action: No Meta Details" , Toast .LENGTH_SHORT ).show ();
827
830
return null ;
828
831
}
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
+ }
829
836
for (Element item : selectedTemplate .getItems (doc )) {
830
837
dataElement .appendChild (item );
831
838
}
@@ -876,9 +883,7 @@ private void startSimulator() {
876
883
if (message == null || message .equals ("" )) {
877
884
Toast .makeText (this , "Build unsuccessful" , Toast .LENGTH_SHORT ).show ();
878
885
return ;
879
- }
880
- else if ("File already exists" .equals (message ))
881
- {
886
+ } else if ("File already exists" .equals (message )) {
882
887
titleEditText .setError ("Template Already exists" );
883
888
return ;
884
889
}
0 commit comments