-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2471737
Showing
63 changed files
with
1,863 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'kotlin-android-extensions' | ||
} | ||
|
||
android { | ||
namespace 'com.azamovhud.dialoggit' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
minSdk 24 | ||
targetSdk 33 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'androidx.appcompat:appcompat:1.6.0' | ||
implementation 'com.google.android.material:material:1.8.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
|
||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
DialogGit/src/androidTest/java/com/example/dialoggit/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.dialoggit | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.azamovhud.dialoggit.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
61 changes: 61 additions & 0 deletions
61
DialogGit/src/main/java/com/azamovhud/dialoggit/adapters/ColorAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.azamovhud.dialoggit.adapters | ||
|
||
import android.graphics.Color | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.cardview.widget.CardView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.azamovhud.dialoggit.R | ||
|
||
class ColorAdapter(val list: List<Int>, val listener: OnItemClickListener) : | ||
RecyclerView.Adapter<ColorAdapter.ColorIV>() { | ||
|
||
var item: CardView? = null | ||
var lastPosition = 0 | ||
private val TAG = "ColorAdapter" | ||
|
||
inner class ColorIV(itemView: View) : RecyclerView.ViewHolder(itemView.rootView) { | ||
fun onBind(color: Int, position: Int) { | ||
Log.d(TAG, "onBind: $position") | ||
|
||
val cardView = itemView.findViewById<CardView>(R.id.card_view) | ||
val backCard = itemView.findViewById<CardView>(R.id.back_card) | ||
cardView.setCardBackgroundColor(color) | ||
|
||
itemView.setOnClickListener { | ||
listener.OnItemClicked(color) | ||
if (item != null) { | ||
if (lastPosition != position) { | ||
item!!.setCardBackgroundColor(Color.BLACK) | ||
item = backCard | ||
lastPosition = position | ||
backCard.setCardBackgroundColor(Color.WHITE) | ||
} else backCard.setCardBackgroundColor(Color.WHITE) | ||
} else { | ||
item = backCard | ||
lastPosition = position | ||
backCard.setCardBackgroundColor(Color.WHITE) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ColorIV { | ||
return ColorIV( | ||
LayoutInflater.from(parent.context) | ||
.inflate(R.layout.color_rv_item, parent, false) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ColorIV, position: Int) { | ||
holder.onBind(list[position], position) | ||
} | ||
|
||
override fun getItemCount(): Int = list.size | ||
|
||
interface OnItemClickListener { | ||
fun OnItemClicked(color: Int) | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
DialogGit/src/main/java/com/azamovhud/dialoggit/classes/BasicDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.azamovhud.dialoggit.classes | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.content.DialogInterface | ||
import android.os.Bundle | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatDialog | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import com.azamovhud.dialoggit.R | ||
import kotlinx.android.synthetic.main.basic_dialog.* | ||
|
||
class BasicDialog(context: Context) : AppCompatDialogFragment() { | ||
var basicDialogListeners: BasicDialogListeners? = null | ||
|
||
var dialogTitle: String? = null | ||
var mainText: String? = null | ||
var okBtnText: String? = null | ||
var cancelBtn: String? = null | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
val builder = AlertDialog.Builder(requireActivity()) | ||
val layoutInflater = activity?.layoutInflater | ||
|
||
val view = layoutInflater?.inflate(R.layout.basic_dialog, null)!! | ||
builder.setView(view) | ||
val titleTv: TextView = view.findViewById(R.id.title_tv) | ||
val mainTextTV: TextView = view.findViewById(R.id.message_tv) | ||
val okBtnTV: TextView = view.findViewById(R.id.positive_btn) | ||
val cancelBtnTV: TextView = view.findViewById(R.id.negative_btn) | ||
|
||
titleTv.text = dialogTitle | ||
mainTextTV.text = mainText | ||
okBtnTV.text = okBtnText | ||
cancelBtnTV.text = cancelBtn | ||
|
||
okBtnTV.setOnClickListener { | ||
dismiss() | ||
basicDialogListeners?.okButtonClicked() | ||
} | ||
|
||
cancelBtnTV.setOnClickListener { | ||
dismiss() | ||
basicDialogListeners?.cancelButtonClicked() | ||
} | ||
|
||
return builder.create() | ||
} | ||
|
||
fun createDialog(title:String, mainTxt:String, okBtnTxt:String, cancelBtnTxt:String){ | ||
this.dialogTitle = title | ||
this.mainText = mainTxt | ||
this.cancelBtn = okBtnTxt | ||
this.okBtnText = cancelBtnTxt | ||
|
||
} | ||
fun setOnButtonClickListener(listener:BasicDialogListeners){ | ||
this.basicDialogListeners = listener | ||
} | ||
|
||
interface BasicDialogListeners { | ||
fun okButtonClicked() | ||
fun cancelButtonClicked() | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
DialogGit/src/main/java/com/azamovhud/dialoggit/classes/CheckBoxDIalog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.azamovhud.dialoggit.classes | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import android.widget.CheckBox | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import androidx.core.view.forEach | ||
import com.azamovhud.dialoggit.R | ||
|
||
class CheckBoxDialog(val list: List<String>, val title: String) : AppCompatDialogFragment() { | ||
|
||
var listener: OnChooseClickListener? = null | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
val builder = AlertDialog.Builder(requireContext()) | ||
val inflater = activity?.layoutInflater!! | ||
|
||
val view = inflater.inflate(R.layout.check_box_dialog, null) | ||
val linear = view.findViewById<LinearLayout>(R.id.linear) | ||
|
||
for (i in list) { | ||
val params = LinearLayout.LayoutParams( | ||
LinearLayout.LayoutParams.WRAP_CONTENT, | ||
LinearLayout.LayoutParams.WRAP_CONTENT | ||
) | ||
params.setMargins(0, 24, 0, 0) | ||
|
||
val checkBox = CheckBox(activity) | ||
checkBox.tag = i | ||
checkBox.text = i | ||
checkBox.layoutParams = params | ||
linear.addView(checkBox) | ||
} | ||
builder.setView(view) | ||
val titleTV = view.findViewById<TextView>(R.id.title_tv) | ||
val chooseTV = view.findViewById<TextView>(R.id.choose_tv) | ||
chooseTV.setOnClickListener { | ||
val list = arrayListOf<String>() | ||
linear.forEach { | ||
val checkBox = it as CheckBox | ||
if (checkBox.isChecked) { | ||
list.add(checkBox.text.toString()) | ||
} | ||
} | ||
listener?.chooseClick(list) | ||
dismiss() | ||
} | ||
|
||
titleTV.text = title | ||
|
||
return builder.create() | ||
} | ||
|
||
fun setOnChooseClickListener(listener: OnChooseClickListener) { | ||
this.listener = listener | ||
} | ||
|
||
interface OnChooseClickListener { | ||
fun chooseClick(chosenList: List<String>) | ||
} | ||
|
||
} |
Oops, something went wrong.