Posts

How to Create Custom Notifications with Listeners

MoreBlock Code:  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = "Channel name 1"; String description = "Notification channel"; int importance = NotificationManager.IMPORTANCE_DEFAULT; NotificationChannel channel = new NotificationChannel("id 1", name, importance); channel.setDescription(description); NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } OnButtonClicked: RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.cview); Intent intent = new Intent(MainActivity.this, TwoActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0); Intent intent1 = new Intent(MainActivity.this, ThreeActivity.class); intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIn

How to Create Material Ripple Effect in Sketchware

On MoreBlock: } public static class MaterialRippleLayout extends FrameLayout {     private static final int     DEFAULT_DURATION        = 350;     private static final int     DEFAULT_FADE_DURATION   = 75;     private static final float   DEFAULT_DIAMETER_DP     = 35;     private static final float   DEFAULT_ALPHA           = 0.2f;     private static final int     DEFAULT_COLOR           = Color.BLACK;     private static final int     DEFAULT_BACKGROUND      = Color.TRANSPARENT;     private static final boolean DEFAULT_HOVER           = true;     private static final boolean DEFAULT_DELAY_CLICK     = true;     private static final boolean DEFAULT_PERSISTENT      = false;     private static final boolean DEFAULT_SEARCH_ADAPTER  = false;     private static final boolean DEFAULT_RIPPLE_OVERLAY  = false;     private static final int     DEFAULT_ROUNDED_CORNERS = 0;     private static final int  FADE_EXTRA_DELAY = 50;     private static final long HOVER_DURATION   = 2500;     private final

How to Create BottomApp Bar in Sketchware

Image
//OnCreate bap = new com.google.android.material.bottomappbar.BottomAppBar(this); bap.getContext().setTheme(R.style.AppTheme_AppBarOverlay | R.style.AppTheme_PopupOverlay); bap.setBackgroundTint(getColorStateList(R.color.colorPrimary)); bap.setFabAlignmentMode(com.google.android.material.bottomappbar.BottomAppBar.FAB_ALIGNMENT_MODE_END); bap.setElevation(16); androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams lp = new androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams(androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams.FILL_PARENT, 130); lp.gravity = Gravity.BOTTOM; bap.setLayoutParams(lp); bap.setId(View.generateViewId()); ((ViewGroup)_fab.getParent()).addView(bap); ((androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams)_fab.getLayoutParams()).setAnchorId(bap.getId()); bap.setFabCradleMargin(15); } private com.google.android.material.bottomappbar.BottomAppBar bap; private void doNothing() { //CheckBox onclick  bap.setFabAlignmentMod

Create Rating Bar in Dialog in Sketchware

Image
//1st ASD Block: final AlertDialog cpDialog = new AlertDialog.Builder(MainActivity.this).create(); View convertView = (View) getLayoutInflater().inflate(R.layout.color_picker_layout, null); cpDialog.setView(convertView); cpDialog.show(); //2nd ASD Block: final Button rate = (Button)convertView.findViewById(R.id.button1); rate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View a) { //your blocks here //3rd ASD Block: cpDialog.dismiss(); } }); //4th ASD Block: final Button cancel = (Button)convertView.findViewById(R.id.button2); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View a) { //Your Blocks here //5th ASD Block: cpDialog.dismiss(); } }); //6th ASD Block: final LinearLayout colorLayout = (LinearLayout) convertView.findViewById(R.id.linear2); //7th ASD Block: rb = new RatingBar(this); rb.setNumStars(5); rb.setStepSize(0.5f); rb.setRating(0.0f); colorLayout.addView(rb); rb.setOnRatingBarChangeListener(new RatingBa

How to Make Right Drawer in Sketchware

Image
_toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View _v) { _drawer.openDrawer(Gravity.RIGHT); } }); LinearLayout _nav_view = (LinearLayout) findViewById(R.id._nav_view); androidx.drawerlayout.widget.DrawerLayout .LayoutParams lp = new androidx.drawerlayout.widget.DrawerLayout .LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); lp.gravity=Gravity.RIGHT; _nav_view.setLayoutParams(lp);

How to Create Bottom Navigation Bar in Androidx in Sketchware

Image
//1st ASD Block com.google.android.material.bottomnavigation.BottomNavigationView  btm= new com.google.android.material.bottomnavigation.BottomNavigationView (MainActivity.this); btm.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linear1.addView(btm); linear1.setElevation(16); Menu menu = btm.getMenu(); final int A = 0; final int B = 1; final int C = 2; final int D = 3; final int E = 4;     menu.add(Menu.NONE, A, Menu.NONE, "Home").setIcon(R.drawable.ic_home_grey); menu.add(Menu.NONE, B, Menu.NONE, "Money").setIcon(R.drawable.ic_money_grey); menu.add(Menu.NONE, C, Menu.NONE, "Favorites").setIcon(R.drawable.ic_favorites_grey); menu.add(Menu.NONE, D, Menu.NONE, "Profile").setIcon(R.drawable.ic_person_grey); menu.add(Menu.NONE, E, Menu.NONE, "Report").setIcon(R.drawable.ic_report_grey); //2nd ASD Block btm.setOnNavigationItemSelectedListener(new  com.google.android.ma

How to make Drawer under StatusBar in Sketchware

Image
//On MoreBlock  } public static class StatusBarUtil { private StatusBarUtil(){ } private static final int FAKE_STATUS_BAR_VIEW_ID = View.generateViewId(); private static final int FAKE_TRANSLUCENT_VIEW_ID = View.generateViewId(); public static final int DEFAULT_STATUS_BAR_ALPHA = 48; private static final int TAG_KEY_HAVE_SET_OFFSET = -123; public static void setColor(Activity activity, int color) { setColor(activity, color, DEFAULT_STATUS_BAR_ALPHA); } public static void setColor(Activity activity, int color, int statusBarAlpha) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha)); } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { activity.getWindow().ad