madshellnpm 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ package com.example.checkbox
2
+
3
+ import androidx.appcompat.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.widget.Button
6
+ import android.widget.CheckBox
7
+ import android.widget.Toast
8
+
9
+ class MainActivity : AppCompatActivity() {
10
+
11
+ lateinit var pizza: CheckBox
12
+ lateinit var coffee: CheckBox
13
+ lateinit var burger: CheckBox
14
+ lateinit var button: Button
15
+
16
+ override fun onCreate(savedInstanceState: Bundle?) {
17
+ super.onCreate(savedInstanceState)
18
+ setContentView(R.layout.activity_main)
19
+
20
+ pizza = findViewById(R.id.checkBox1)
21
+ coffee = findViewById(R.id.checkBox2)
22
+ burger = findViewById(R.id.checkBox3)
23
+ button = findViewById(R.id.button)
24
+
25
+ button.setOnClickListener {
26
+
27
+ var totalAmount: Int = 0
28
+ val result = StringBuilder()
29
+
30
+ result.append("Selected Items")
31
+
32
+ if (pizza.isChecked) {
33
+ result.append("\nPizza 100Rs")
34
+ totalAmount += 100
35
+ }
36
+
37
+ if (coffee.isChecked) {
38
+ result.append("\nCoffee 50Rs")
39
+ totalAmount += 50
40
+ }
41
+
42
+ if (burger.isChecked) {
43
+ result.append("\nBurger 120Rs")
44
+ totalAmount += 120
45
+ }
46
+
47
+ result.append("\nTotal: $totalAmount Rs")
48
+
49
+ Toast.makeText(
50
+ applicationContext,
51
+ result.toString(),
52
+ Toast.LENGTH_SHORT
53
+ ).show()
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,67 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <RelativeLayout
4
+ xmlns:android="http://schemas.android.com/apk/res/android"
5
+ xmlns:app="http://schemas.android.com/apk/res-auto"
6
+ xmlns:tools="http://schemas.android.com/tools"
7
+ android:layout_width="match_parent"
8
+ android:layout_height="match_parent"
9
+ android:padding="16dp"
10
+ tools:context=".MainActivity">
11
+
12
+ <TextView
13
+ android:layout_width="wrap_content"
14
+ android:layout_height="wrap_content"
15
+ android:layout_centerHorizontal="true"
16
+ android:layout_marginTop="50dp"
17
+ android:text="MAD LAB CHECK BOX EXAMPLE"
18
+ android:textAlignment="center"
19
+ android:textColor="@android:color/holo_green_dark"
20
+ android:textSize="32sp"
21
+ android:textStyle="bold" />
22
+
23
+ <TextView
24
+ android:layout_width="match_parent"
25
+ android:layout_height="wrap_content"
26
+ android:layout_above="@id/checkBox1"
27
+ android:layout_marginBottom="50dp"
28
+ android:text="Select your products!!"
29
+ android:textAlignment="center"
30
+ android:textColor="@android:color/background_dark"
31
+ android:textSize="24sp"
32
+ android:textStyle="bold|italic" />
33
+
34
+ <CheckBox
35
+ android:id="@+id/checkBox1"
36
+ android:layout_width="wrap_content"
37
+ android:layout_height="wrap_content"
38
+ android:layout_centerInParent="true"
39
+ android:text="Pizza" />
40
+
41
+ <CheckBox
42
+ android:id="@+id/checkBox2"
43
+ android:layout_width="wrap_content"
44
+ android:layout_height="wrap_content"
45
+ android:layout_below="@id/checkBox1"
46
+ android:layout_centerInParent="true"
47
+ android:layout_marginTop="10dp"
48
+ android:text="Coffee" />
49
+
50
+ <CheckBox
51
+ android:id="@+id/checkBox3"
52
+ android:layout_width="wrap_content"
53
+ android:layout_height="wrap_content"
54
+ android:layout_below="@id/checkBox2"
55
+ android:layout_centerInParent="true"
56
+ android:layout_marginTop="10dp"
57
+ android:text="Burger" />
58
+
59
+ <Button
60
+ android:id="@+id/button"
61
+ android:layout_width="match_parent"
62
+ android:layout_height="wrap_content"
63
+ android:layout_below="@id/checkBox3"
64
+ android:layout_marginTop="10dp"
65
+ android:text="Complete purchase" />
66
+
67
+ </RelativeLayout>
package/cli.js CHANGED
@@ -20,7 +20,8 @@ const topics = [
20
20
  "sharedpreferences",
21
21
  "spinner",
22
22
  "toggle_button",
23
- "alertdialog"
23
+ "alertdialog",
24
+ "fragments"
24
25
  ];
25
26
 
26
27
  export async function showMenu() {
package/package.json CHANGED
@@ -1,23 +1,17 @@
1
1
  {
2
2
  "name": "madshellnpm",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "MAD Lab Android Code Generator",
5
5
  "main": "index.js",
6
-
7
6
  "bin": {
8
- "madlab": "./index.js",
9
- "madbms": "./index.js",
10
- "madshell": "./index.js",
7
+ "madlabnpm": "./index.js",
11
8
  "madshellnpm": "./index.js",
12
- "madlabnpm": "./index.js"
9
+ "madbms": "./index.js"
13
10
  },
14
-
15
11
  "type": "module",
16
-
17
12
  "scripts": {
18
13
  "postinstall": "node postinstall.js"
19
14
  },
20
-
21
15
  "keywords": [
22
16
  "android",
23
17
  "kotlin",
@@ -25,14 +19,12 @@
25
19
  "generator",
26
20
  "bmsce"
27
21
  ],
28
-
29
22
  "author": "KBH",
30
23
  "license": "MIT",
31
-
32
24
  "dependencies": {
33
25
  "chalk": "^5.3.0",
34
26
  "figlet": "^1.7.0",
35
27
  "fs-extra": "^11.2.0",
36
28
  "inquirer": "^9.2.15"
37
29
  }
38
- }
30
+ }
@@ -0,0 +1,37 @@
1
+ package com.example.fragment
2
+
3
+ import androidx.appcompat.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import androidx.fragment.app.Fragment
6
+ import androidx.fragment.app.FragmentManager
7
+ import com.example.fragment.databinding.ActivityMainBinding
8
+
9
+ class MainActivity : AppCompatActivity() {
10
+
11
+ private lateinit var fragmentManager: FragmentManager
12
+ private lateinit var binding: ActivityMainBinding
13
+
14
+ override fun onCreate(savedInstanceState: Bundle?) {
15
+ super.onCreate(savedInstanceState)
16
+
17
+ binding = ActivityMainBinding.inflate(layoutInflater)
18
+ setContentView(binding.root)
19
+
20
+ binding.bf1.setOnClickListener {
21
+ goToFragment(Fragment1())
22
+ }
23
+
24
+ binding.bf2.setOnClickListener {
25
+ goToFragment(Fragment2())
26
+ }
27
+ }
28
+
29
+ private fun goToFragment(fragment: Fragment) {
30
+
31
+ fragmentManager = supportFragmentManager
32
+
33
+ fragmentManager.beginTransaction()
34
+ .replace(R.id.fragmentContainer, fragment)
35
+ .commit()
36
+ }
37
+ }
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <androidx.constraintlayout.widget.ConstraintLayout
4
+ xmlns:android="http://schemas.android.com/apk/res/android"
5
+ xmlns:app="http://schemas.android.com/apk/res-auto"
6
+ xmlns:tools="http://schemas.android.com/tools"
7
+ android:layout_width="match_parent"
8
+ android:layout_height="match_parent"
9
+ tools:context=".MainActivity">
10
+
11
+ <androidx.fragment.app.FragmentContainerView
12
+ android:id="@+id/fragmentContainer"
13
+ android:layout_width="412dp"
14
+ android:layout_height="576dp"
15
+ app:layout_constraintEnd_toEndOf="parent"
16
+ app:layout_constraintTop_toTopOf="parent" />
17
+
18
+ <Button
19
+ android:id="@+id/bf1"
20
+ android:layout_width="wrap_content"
21
+ android:layout_height="wrap_content"
22
+ android:layout_marginEnd="64dp"
23
+ android:layout_marginBottom="88dp"
24
+ android:text="Fragment1"
25
+ android:backgroundTint="@color/blue"
26
+ app:layout_constraintBottom_toBottomOf="parent"
27
+ app:layout_constraintEnd_toStartOf="@+id/bf2" />
28
+
29
+ <Button
30
+ android:id="@+id/bf2"
31
+ android:layout_width="wrap_content"
32
+ android:layout_height="wrap_content"
33
+ android:layout_marginEnd="44dp"
34
+ android:layout_marginBottom="88dp"
35
+ android:text="Fragment2"
36
+ android:backgroundTint="@color/yellow"
37
+ app:layout_constraintBottom_toBottomOf="parent"
38
+ app:layout_constraintEnd_toEndOf="parent" />
39
+
40
+ </androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,21 @@
1
+ To use androidx, make these changes in the gradle files:
2
+
3
+ Build.gradle: (replace dependencies with this)
4
+
5
+ dependencies {
6
+
7
+ implementation 'androidx.appcompat:appcompat:1.6.1'
8
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
9
+
10
+ testImplementation 'junit:junit:4.13.2'
11
+
12
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
13
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
14
+ }
15
+
16
+
17
+ gradle properties:
18
+ android.useAndroidX=true
19
+ android.enableJetifier=true
20
+
21
+ (Add these two in addition it at the end)
@@ -0,0 +1,19 @@
1
+ package com.example.fragment
2
+
3
+ import android.os.Bundle
4
+ import androidx.fragment.app.Fragment
5
+ import android.view.LayoutInflater
6
+ import android.view.View
7
+ import android.view.ViewGroup
8
+
9
+ class Fragment1 : Fragment() {
10
+
11
+ override fun onCreateView(
12
+ inflater: LayoutInflater,
13
+ container: ViewGroup?,
14
+ savedInstanceState: Bundle?
15
+ ): View? {
16
+
17
+ return inflater.inflate(R.layout.fragment_1, container, false)
18
+ }
19
+ }
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context=".Fragment1">
8
+
9
+ <TextView
10
+ android:layout_width="match_parent"
11
+ android:layout_height="match_parent"
12
+ android:text="Fragment1"
13
+ android:background="@color/blue"
14
+ android:textColor="@color/white"
15
+ android:textSize="30sp"
16
+ android:gravity="center" />
17
+
18
+ </FrameLayout>
@@ -0,0 +1,19 @@
1
+ package com.example.fragment
2
+
3
+ import android.os.Bundle
4
+ import androidx.fragment.app.Fragment
5
+ import android.view.LayoutInflater
6
+ import android.view.View
7
+ import android.view.ViewGroup
8
+
9
+ class Fragment2 : Fragment() {
10
+
11
+ override fun onCreateView(
12
+ inflater: LayoutInflater,
13
+ container: ViewGroup?,
14
+ savedInstanceState: Bundle?
15
+ ): View? {
16
+
17
+ return inflater.inflate(R.layout.fragment_2, container, false)
18
+ }
19
+ }
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:layout_width="match_parent"
6
+ android:layout_height="match_parent"
7
+ tools:context=".Fragment2">
8
+
9
+ <TextView
10
+ android:layout_width="match_parent"
11
+ android:layout_height="match_parent"
12
+ android:text="Fragment2"
13
+ android:background="@color/yellow"
14
+ android:textColor="@color/white"
15
+ android:textSize="30sp"
16
+ android:gravity="center" />
17
+
18
+ </FrameLayout>