faisal alhatlan

 avatar
unknown
plain_text
2 years ago
9.8 kB
1
Indexable
package com.example.myapplication1
import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import kotlinx.android.synthetic.main.activity_main.*
import android.content.Intent
import android.net.Uri
import kotlinx.android.synthetic.main.activity_main.view.*

class MainActivity : AppCompatActivity() {



    @SuppressLint("SuspiciousIndentation")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

      button.setOnClickListener {
            var y=editTextNumber.text.toString()
       /*     var a=editTextNumber2.text.toString()
            var b=editTextNumber3.text.toString()
            var c=editTextNumber4.text.toString()*/

          var result=0.0
            if (y.toDouble() >6000)
            {
                var Al=AlertDialog.Builder(this)
                Al.setTitle("Warning")
                Al.setMessage("enter a reasnable capacity!!")
                Al.setPositiveButton("OK"){DialogInterface,which-> Toast.makeText(this,"DONE",Toast.LENGTH_SHORT).show() }
                Al.setNeutralButton("Cancel") {DialogInterface, which-> Toast.makeText(this,"OK",Toast.LENGTH_SHORT).show()}
                val alertDialog: AlertDialog = Al.create()
                alertDialog.show()

            }
            else
            {
                result=y.toDouble()*1024
                var kb=y.toDouble()*1024*1024
                var byt=y.toDouble()*1024*1024*1024
                var bt=y.toDouble()*1024*1024*1024*1024
                textView.text=result.toString()
                textView2.text=kb.toString()
                textView3.text=result.toString()
                textView4.text=kb.toString()
                textView5.text=byt.toString()
                textView6.text=bt.toString()



                /*editTextNumber3.textView.text=byt.toString()
                editTextNumber4.textView.text=bt.toString()*/


                val t= Toast.makeText(this,"الانتهاء من عملية التحويل",Toast.LENGTH_SHORT)
                t.show()
                //  t.setGravity(Gravity.START,200,200)
            }
        }

       button2.setOnClickListener {
           var Al=AlertDialog.Builder(this)
           Al.setTitle("تحذير")
           Al.setMessage("!هل تود الخروج من البرنامج!")
           Al.setPositiveButton("نعم"){DialogInterface,which-> Toast.makeText(this,"DONE",Toast.LENGTH_SHORT).show() }
           Al.setNeutralButton("لا") {DialogInterface, which-> Toast.makeText(this,"OK",Toast.LENGTH_SHORT).show()}
           val alertDialog: AlertDialog = Al.create()
           alertDialog.show()
           showToast1()

        }

        googleBtn.setOnClickListener {
            val openURL = Intent(android.content.Intent.ACTION_VIEW)
            openURL.data = Uri.parse("https://www.unitconverters.net/")
            startActivity(openURL)
        }

        fun showToast() {

            Toast.makeText(this, "الانتهاء من عملية التحويل", Toast.LENGTH_SHORT).show()

    }


    }

    private fun convertterfahr(t: Int): Double {
        var x=(t-32)/1.8
        return x

    }

    private fun showToast1(): Any {
        return Toast.makeText(this, "enter a reasonable tempreture", Toast.LENGTH_SHORT).show()

    }

    private fun tointger(textView: TextView?) {


    }

    @SuppressLint("SuspiciousIndentation")
    fun converttocelcius(y: Int): Double {
          var z=(y*1.8)+32
            return z

        }


    private fun showToast() {
        Toast.makeText(this, "الانتهاء من عملية التحويل", Toast.LENGTH_SHORT).show()
    }

}

private fun Nothing?.setOnClickListener(function: () -> Unit) {


}

private fun Nothing?.setText(get: String)
{
    TODO("Not yet implemented")
}








<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#CCFFFF"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/textView6"
        android:layout_width="314dp"
        android:layout_height="31dp"
        android:background="#FFEB3B"
        android:text="الحجم الاجمالي بالبت"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.556"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.58" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="314dp"
        android:layout_height="31dp"
        android:background="#FFEB3B"
        android:text="الحجم الاجمالي بالبايت"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="314dp"
        android:layout_height="31dp"
        android:background="#FFEB3B"
        android:text="الحجم الاجمالي بالكيلو بايت"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.556"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.404" />

    <Button
        android:id="@+id/googleBtn"
        android:layout_width="182dp"
        android:layout_height="35dp"
        android:text="المزيد من انواع التحويل"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.721"
        tools:ignore="MissingConstraints" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#0F26A8"
        android:text="Capacities Converter"
        android:textSize="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.053"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.053" />

    <Button
        android:id="@+id/button"
        android:layout_width="312dp"
        android:layout_height="42dp"
        android:background="#090909"
        android:text="اضغط هنا للتحويل"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.807" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FA473A"
        android:clickable="false"
        android:text="خروج"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.897" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="28dp"
        tools:layout_editor_absoluteY="148dp" />

    <EditText
        android:id="@+id/editTextNumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="580dp"
        android:backgroundTint="#EFE5E5"
        android:ems="10"
        android:inputType="number"
        android:text="ادخل قيمة بالجيجا بايت"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="314dp"
        android:layout_height="31dp"
        android:background="#FFEB3B"
        android:text="الحجم الاجمالي بالميجا"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.556"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.304" />

</androidx.constraintlayout.widget.ConstraintLayout>

Editor is loading...