YAZEED ALRZOUQ
unknown
plain_text
3 years ago
7.5 kB
3
Indexable
package com.example.capacitiesconverter
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
buT.setOnClickListener{
var userIn=inNumber.text.toString().toLong()
if (userIn > 60000){
Toast.makeText(this,"Enter a reasonable capacity ! ", Toast.LENGTH_LONG).show()
}
else{
val MB=(1024*userIn)
val KB=(MB*1024)
val BS=(KB*1024)
val Bb=(BS*1024)
MBview.text="القيمة باميجا بايت"+MB.toString()
KBview.text="القيمة بالكيلو بايت "+KB.toString()
BSview.text="القيمة بالبايت "+BS.toString()
Bview.text="القيمة بالبت "+Bb.toString()
Toast.makeText(this,"DONE", Toast.LENGTH_LONG).show()
}
button4.setOnClickListener{
val openURL=Intent(android.content.Intent.ACTION_VIEW)
openURL.data=Uri.parse("https://www.unitconverters.net/data-storage-converter.html")
startActivity(openURL)
}
buExit.setOnClickListener{
val builder= AlertDialog.Builder(this)
builder.setTitle("تحذير")
builder.setMessage("هل ترغب بإغلاق البرنامج ؟ ")
builder.setPositiveButton("نعم",{ dialogInterface: DialogInterface, i: Int ->
finish()
})
builder.setNegativeButton("إلغاء",{ dialogInterface: DialogInterface, i: Int -> })
builder.show()
}
}
}
}
<?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:layout_gravity="center"
android:background="#CCFFFF"
tools:context=".MainActivity">
<EditText
android:id="@+id/inNumber"
android:layout_width="263dp"
android:layout_height="44dp"
android:ems="10"
android:foregroundGravity="center"
android:hint="أدخل قيمة بالجيجا بابت"
android:inputType="number"
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.023" />
<TextView
android:id="@+id/MBview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#EAE6A5"
android:gravity="right"
android:text="لحجم الإجمالي بالميجا : "
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/inNumber"
app:layout_constraintVertical_bias="0.065" />
<TextView
android:id="@+id/KBview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#EAE6A5"
android:gravity="right"
android:text="لحجم الإجمالي بالكيلو بايت :"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/MBview"
app:layout_constraintVertical_bias="0.074" />
<TextView
android:id="@+id/BSview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#EAE6A5"
android:gravity="right"
android:text="لحجم الإجمالي بالبايت : "
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/KBview"
app:layout_constraintVertical_bias="0.083" />
<TextView
android:id="@+id/Bview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#EAE6A5"
android:gravity="right"
android:text="لحجم الإجمالي بالبت : "
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/BSview"
app:layout_constraintVertical_bias="0.088" />
<Button
android:id="@+id/buT"
android:layout_width="413dp"
android:layout_height="42dp"
android:background="#000000"
android:backgroundTint="#000000"
android:text="أضغط هنا للتحويل"
android:textColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/Bview"
app:layout_constraintVertical_bias="0.562" />
<Button
android:id="@+id/buExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:background="#F91313"
android:backgroundTint="#F91313"
android:text="خروج"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buT"
app:layout_constraintVertical_bias="0.741" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#F91313"
android:backgroundTint="#F91313"
android:inputType="textUri"
android:text="للمزيد من انواع التحويل"
app:layout_constraintBottom_toTopOf="@+id/buExit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.511"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buT" />
</androidx.constraintlayout.widget.ConstraintLayout>Editor is loading...