Posts

Showing posts with the label Sketchware

Use Intent to open links and apps in sketchware

1) On a sketchware project add a button. 2) In that button click event add a ADD SOURCE DIRECTLY BLOCK. 3) paste the below code:- Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("market://developer?id=<developer name>")); startActivity(i); 4) Thank you. Enjoy app making...

Make a layout with rounded corners in sketchware

Image
1) Create a new sketchware project. 2) Drag and drop a Linear layout with id linear1 . 3) Add a widget that you want make a rounded corners inside Linear Layout linear1 . It may be EditText or Button or TextView or ImageView, etc. 5) Add a new more block round with View view , string color  ,string stroke_c and a number radius . 6) Paste the below code to the more block :- android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); gd.setColor(Color.parseColor(_color)); gd.setCornerRadius((float)_radius); gd.setStroke(2, Color.parseColor(_stroke_c)); _view.setBackground(gd); 7) In onCreate event add the more block with your view, colour, stroke colour and radius. Thank you...

Make an advanced text editor in sketchware

Image
PLEASE SUBSCRIBE Click here to subscribe... Code :- Collections.sort(string_files, String.CASE_INSENSITIVE_ORDER); Collections.sort(newVv, String.CASE_INSENSITIVE_ORDER); Collections.sort(hiddenOnes, String.CASE_INSENSITIVE_ORDER); Thank you

Toast a message with a custom view in sketchware

1) Create a new Sketchware Project. 2) Add a new Custom view with name custom . 3) Add a more block customToast with a String text . 4) In that Moreblock add a ASD block and copy the below code:- LayoutInflater inflater = getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.custom, null); TextView textview = (TextView) toastLayout.findViewById(R.id.textview1); textview.setText(_text); LinearLayout linear = (LinearLayout) toastLayout.findViewById(R.id.linear1); Toast toast = new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(toastLayout); toast.show(); 5) Go to the custom view then add a Linear Layout linear1 and a TextView textview1 inside it. 6) By using this moreblock customToast you can show custom toast. Thank You... In order to make the custom toast rounded replace the above code with this code:- LayoutInflater inflater = getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.custom, nu

Menu with icon in actionbar in sketchware

Image
1) Create a sketchware project. 2) Add a more block extra. 3) In that more block  extra  do as below:- 4) Code used in First ASD block is:- } @Override public boolean onCreateOptionsMenu (Menu menu){ menu.add(0,0,0,"Settings").setIcon(R.drawable.settings) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(0,1,1,"Profile"); menu.add(0,2,2,"About"); menu.add(0,3,3,"Rate now"); return true; 5) Code used in Second ASD block is:- } @Override public boolean onOptionsItemSelected(MenuItem item){ switch (item.getItemId()){ case 0: _settings(); break; case 1: _profile(); break; case 2: _about(); break; case 3:  _rate(); break; } return super.onOptionsItemSelected(item); 6) Since I added 4 menus there is only 4 cases. 7) Then add a image with name settings. 8) Then add 4 more blocks. In here I am created  settings ,  profile ,  about ,  rate  . That,s all. Save and run project...

Add menu in actionbar in Sketchware

Image
1) Create a sketchware project. 2) Add a more block extra . 3) In that more block extra do as below:- 4) Code used in First ASD block is:- } @Override public boolean onCreateOptionsMenu (Menu menu){ menu.add(0,0,0,"Settings"); menu.add(0,1,1,"Profile"); menu.add(0,2,2,"About"); menu.add(0,3,3,"Rate now"); return true; 5) Code used in Second ASD block is:- } @Override public boolean onOptionsItemSelected(MenuItem item){ switch (item.getItemId()){ case 0: _settings(); break; case 1: _profile(); break; case 2: _about(); break; case 3:  _rate(); break; } return super.onOptionsItemSelected(item); 6) Since I added 4 menus there is only 4 cases. 7) Then add 4 more blocks. In here I am created settings , profile , about , rate . That,s all. Save and run project...

Share any file from External Storage in sketchware

Image
1) Create a new sketchware project. 2) Add a Button with id button1 . 3) Add a FilePicker with name g and with file type */* . 4) In button1 onClick event do as below:- 5) Add a string variable with name myFilePath :- 6) In on FilePicked event to get file path add a listString str . Set String myFilePath to get at 0 at List String : filePath Then Do as below:- 7) Code used in the ASD block is:- Intent intentShareFile = new Intent(Intent.ACTION_SEND); intentShareFile.setType("application/*"); intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+myFilePath)); startActivity(Intent.createChooser(intentShareFile, "Share File")); That's all. Save and run project...

Swipe Refresh Listview in Chat app

Image
1) Create a new sketchware project. 2) Drag and Drop Linear Layout with id linear1 and height match_parent . 3) Drag Drop ListView with id wb inside that Linear Layout linear1 . 4) Create a new custom xml layout. Add a TextView with id textview1 . 5) Enable AppCompat and Design Library and also Firebase Library. 6) In ListView add custom view as your Custom View. 7) Add a Firebase Component with name as your choice and a ListMap map . 8)In wb  BindCustomView add as your choice. 9)In on Create event do as below:- First ASD code is:- final android.support.v4.widget.SwipeRefreshLayout sr = new android.support.v4.widget.SwipeRefreshLayout(this); sr.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(sr); linear1.removeView(wb); linear1.post(new Runnable() { @Override public void run() { sr.addView(wb); } });  sr.setOnRe

Swipe Refresh WebView In sketchware

Image
1) Create a new sketchware project. 2) Drag and Drop a Linear Layout with id linear1 and height match_parent . 3) Drag and Drop a WebView with id wb inside that Linear Layout linear1 . 4) Enable the AppCompat and Design Library. 5) In Oncreate event do as below:- 6) Code used in ASD block is :- final android.support.v4.widget.SwipeRefreshLayout sr = new android.support.v4.widget.SwipeRefreshLayout(this); sr.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(sr); wb.getSettings().setJavaScriptEnabled(true); linear1.removeView(wb); linear1.post(new Runnable() { @Override public void run() {sr.addView(wb); } }); wb.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { sr.setRefreshing(false); }}); sr.setOnRefreshListener( new android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener() { @Ove

How to zip files in Sketchware

Image
1) Create a new Sketchware project. 2) Add two Buttons with id button1 and button2 and a EditText with id edittext1 Then change the text of button1 and button2 to  Zip files and folders and Unzip files . Then add a file picker component and three string variables source , destination and path . Then Create a more block zip with two strings source and destination . And add another more block Unzip with one string path . 3) In button1 (To Zip folder)   on click event do as below:- 4) In button2 (To Unzip File) on click event do as below:- 5) In onfilepicked event do as below :- 6) In more more zip paste the below code:- try { java.util.zip.ZipOutputStream os = new java.util.zip.ZipOutputStream(new java.io.FileOutputStream(_destination)); zip(os, _source, null); os.close(); } catch(java.io.IOException e) {} } private void zip(java.util.zip.ZipOutputStream os, String filePath, String name) throws java.io.IOException { java.io.File file = new java.io.File(fi

How to add an introduction in sketchware

Image
Watch the below video and follow instructions. Code used in this video is:- linear1.setOnTouchListener(new View.OnTouchListener() {@Override public boolean onTouch(View p1, MotionEvent p2){ switch(p2.getAction()) { case MotionEvent.ACTION_DOWN: f = p2.getX();break; case MotionEvent.ACTION_UP: t = p2.getX();if (((f - t) < -250)) {_SlideLeft();} if (((t - f) < -250)) {_SlideRight();}break;}return true;}});

How to Share an image from imageview to any app.

1) Create a new sketchware project or use an existing project. 2) For sharing images from imageview1 , set a button as button1 to initiate sharing. 3) In button1 onClick event add a ASD block and paste the below code:- Bitmap bm = ((android.graphics.drawable.BitmapDrawable) imageview1.getDrawable()).getBitmap(); try { java.io.File file = new java.io.File(getExternalCacheDir() + "/image.jpg"); java.io.OutputStream out = new java.io.FileOutputStream(file); bm.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (Exception e) { showMessage(e.toString()); } Intent iten = new Intent(android.content.Intent.ACTION_SEND); iten.setType("*/*"); iten.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new java.io.File(getExternalCacheDir() + "/image.jpg"))); startActivity(Intent.createChooser(iten, "Send image")); If the above code crashes consider adding WRITE EXTERNAL STORAGE by adding a more block as nothing and a bl

How to get Subscriber Count in Sketchware.

Image
1) First Create a New Sketchware project. 2) Then add EditText as edittext1 , Button as button1 , TextView as textview5, textview2, textview3, textview4 . Add two string variables as g and h . Add two map variables as map and map1 . Add a List Map Variable as mapy. textview5 for Channel Name, textview2 for Subscribers, textview3 for Views, textview4 for Videos. Then add a Request Network Component with name cha . 3)Add a more block named ytch with strings id and key. Then add some blocks as a video below The first link used is   https://www.googleapis.com/youtube/v3/channels?part=snippet%2Cstatistics&id=   and the second link is    https://www.youtube.com/channel/ and last code is    &key=  4) Then add a button1 on Click event and do as below: Your Api Key must be replaced with your API Key. If you don't know how to get the API key you can watch the below video and don't forgot to enable youtube APIs 5) Then in cha onR

PDF - Convert linear view to pdf document in Sketchware.

Image
1) Create a New project. 2) Add EditText as id= " edittext1 ", a Button as id =" button "  with text" Save " and a Linear Layout as id =" linear1 ". 3) In that Linear Add an another EditText as id=" edittext2 ".Set linear1 background colour WHITE. 4) Then Create a String variable as path . 5) On button1 click event add add source directly block with code:- try{ android.graphics.pdf.PdfDocument document = new android.graphics.pdf.PdfDocument(); android.graphics.pdf.PdfDocument.PageInfo pageInfo = new android.graphics.pdf.PdfDocument.PageInfo.Builder(linear1.getWidth(), linear1.getHeight(), 1).create(); android.graphics.pdf.PdfDocument.Page page = document.startPage(pageInfo); Canvas canvas = page.getCanvas(); Paint paint = new Paint(); canvas.drawPaint(paint); linear1.draw(canvas); document.finishPage(page);  6) Then Set the string path to as shown below. 7) Add write string block to enable STORAGE permission. 8

How to make a Flashlight App in Sketchware App

Image
1) Create a New project in Sketchware. 2) In view area add a LinearLayout as linear1  and set it's layout to center horizontal and center vertical. Then add Imageview as imageview1 . Set it's width and height to 100dp and scale type to FIT_XY. Then on image manager add two images ic_flash_on_black and ic_flash_off_black . Set imageview1 to  ic_flash_off_black . 3) In library manager switch on AppCompat and Design. 4) Add a Camera component. 5) Add two Boolean Variables as flashLightStatus and hasCameraFlash . 6) Add two more blocks as flashLightOn and flashLightOff . 7) In OnCreate event add an add source directly block with code: hasCameraFlash = getPackageManager(). hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); 8) In More block flashLightOn add a add source directly block with code: android.hardware.camera2.CameraManager cameraManager = (android.hardware.camera2.CameraManager) getSystemService(Context.CAMERA_SERVICE); try { S

How to Check Latest Version in sketchware with Firebase Database

Image
1) Create a new project in Sketchware. 2) Add Firebase library in the library. Make sure the rules in your Firebase database are read and write true. 3) Add Firebase Database component as version:version 4) Add String variables as package_name, your_version, latest_version and Add map variable as map 5) Then OnCreate event set string package_name to your app package. In this tutorial I am using sketchware.check.version 6) Then below set string block add two add source directly block. First code is try { android.content.pm.PackageInfo pinfo = getPackageManager().getPackageInfo( package_name, android.content.pm.PackageManager.GET_ACTIVITIES); your_version = pinfo.versionName; } catch (Exception e){ showMessage(e.toString()); } Second code is DatabaseReference rootRef = _firebase.getReference(); rootRef.child("version").addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { if (snap