Compare commits
46 Commits
master
...
feature/pl
| Author | SHA1 | Date |
|---|---|---|
|
|
cd6d5ab2ae | 6 years ago |
|
|
26cd102e46 | 6 years ago |
|
|
73b72deeb9 | 6 years ago |
|
|
d9c07bf291 | 6 years ago |
|
|
ea8bad6acc | 6 years ago |
|
|
c734898241 | 6 years ago |
|
|
75a2248469 | 6 years ago |
|
|
dcc6be514a | 6 years ago |
|
|
eef60124ed | 6 years ago |
|
|
1aef1c9745 | 6 years ago |
|
|
28699f594f | 6 years ago |
|
|
f1b47a6e51 | 6 years ago |
|
|
3843ab4185 | 6 years ago |
|
|
75b4097851 | 6 years ago |
|
|
071a39c241 | 6 years ago |
|
|
dff498ffa5 | 6 years ago |
|
|
d90aaa72bc | 6 years ago |
|
|
9ad428152c | 6 years ago |
|
|
54b6457fc9 | 6 years ago |
|
|
48868992a4 | 6 years ago |
|
|
358c65f9aa | 6 years ago |
|
|
5dfb008261 | 6 years ago |
|
|
3fa447e26c | 6 years ago |
|
|
599c29989a | 6 years ago |
|
|
2ca63b3a1a | 6 years ago |
|
|
2751850a92 | 6 years ago |
|
|
7abf6fd268 | 6 years ago |
|
|
7474b33a7e | 6 years ago |
|
|
7653ea86ce | 6 years ago |
|
|
c025f35d43 | 6 years ago |
|
|
e8f83ba08b | 6 years ago |
|
|
8835a7d4d6 | 6 years ago |
|
|
5882fd8cd6 | 6 years ago |
|
|
63d6c9b5b9 | 6 years ago |
|
|
20494c7849 | 6 years ago |
|
|
5689b8dfe4 | 6 years ago |
|
|
a2e9b8309c | 6 years ago |
|
|
ac2000ea8c | 6 years ago |
|
|
86a2f3bb1b | 6 years ago |
|
|
fa5e098b31 | 6 years ago |
|
|
45bdd93b78 | 7 years ago |
|
|
f1423257b1 | 7 years ago |
|
|
047a08c2a0 | 7 years ago |
|
|
b1064100a6 | 7 years ago |
|
|
c2f79015bc | 7 years ago |
|
|
75248ffdec | 7 years ago |
@ -0,0 +1,83 @@ |
|||||||
|
package net.pokeranalytics.android.model.realm |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import androidx.fragment.app.Fragment |
||||||
|
import io.realm.Realm |
||||||
|
import io.realm.RealmObject |
||||||
|
import io.realm.annotations.Ignore |
||||||
|
import io.realm.annotations.PrimaryKey |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.exceptions.ModelException |
||||||
|
import net.pokeranalytics.android.model.interfaces.DeleteValidityStatus |
||||||
|
import net.pokeranalytics.android.model.interfaces.Identifiable |
||||||
|
import net.pokeranalytics.android.model.interfaces.Manageable |
||||||
|
import net.pokeranalytics.android.model.interfaces.SaveValidityStatus |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragment |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragmentType |
||||||
|
import net.pokeranalytics.android.ui.view.RowEditableDataSource |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
import net.pokeranalytics.android.util.NULL_TEXT |
||||||
|
import java.util.* |
||||||
|
|
||||||
|
open class Comment : RealmObject(), Manageable, RowRepresentable { |
||||||
|
|
||||||
|
@PrimaryKey |
||||||
|
override var id = UUID.randomUUID().toString() |
||||||
|
var content: String = "" |
||||||
|
var date: Date = Date() |
||||||
|
|
||||||
|
@Ignore |
||||||
|
override val realmObjectClass: Class<out Identifiable> = Comment::class.java |
||||||
|
|
||||||
|
@Ignore |
||||||
|
override val viewType: Int = RowViewType.CONTENT.ordinal |
||||||
|
|
||||||
|
@Ignore |
||||||
|
override val inputFragmentType: InputFragmentType = InputFragmentType.EDIT_TEXT_MULTI_LINES |
||||||
|
|
||||||
|
@Ignore |
||||||
|
override val valueCanBeClearedWhenEditing: Boolean = false |
||||||
|
|
||||||
|
override fun localizedTitle(context: Context): String { |
||||||
|
return context.getString(R.string.comment) |
||||||
|
} |
||||||
|
|
||||||
|
override fun getDisplayName(context: Context): String { |
||||||
|
return if (content.isNotEmpty()) content else NULL_TEXT |
||||||
|
} |
||||||
|
|
||||||
|
override fun startEditing(dataSource: Any?, parent: Fragment?) { |
||||||
|
if (parent == null) return |
||||||
|
if (parent !is RowRepresentableDelegate) return |
||||||
|
val data = RowEditableDataSource() |
||||||
|
data.append(this.content, R.string.value) |
||||||
|
InputFragment.buildAndShow(this, parent, data, isDeletable = true) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
||||||
|
this.content = value as String? ?: "" |
||||||
|
} |
||||||
|
|
||||||
|
override fun isValidForSave(): Boolean { |
||||||
|
return true |
||||||
|
} |
||||||
|
|
||||||
|
override fun alreadyExists(realm: Realm): Boolean { |
||||||
|
return realm.where(this::class.java).notEqualTo("id", this.id).findAll().isNotEmpty() |
||||||
|
} |
||||||
|
|
||||||
|
override fun getFailedSaveMessage(status: SaveValidityStatus): Int { |
||||||
|
throw ModelException("${this::class.java} getFailedSaveMessage for $status not handled") |
||||||
|
} |
||||||
|
|
||||||
|
override fun isValidForDelete(realm: Realm): Boolean { |
||||||
|
return true |
||||||
|
} |
||||||
|
|
||||||
|
override fun getFailedDeleteMessage(status: DeleteValidityStatus): Int { |
||||||
|
return R.string.cf_entry_delete_popup_message |
||||||
|
} |
||||||
|
} |
||||||
@ -1,15 +1,175 @@ |
|||||||
package net.pokeranalytics.android.model.realm |
package net.pokeranalytics.android.model.realm |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import io.realm.Realm |
||||||
|
import io.realm.RealmList |
||||||
import io.realm.RealmObject |
import io.realm.RealmObject |
||||||
|
import io.realm.annotations.Ignore |
||||||
import io.realm.annotations.PrimaryKey |
import io.realm.annotations.PrimaryKey |
||||||
|
import io.realm.kotlin.where |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.interfaces.* |
||||||
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.PlayerRow |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRow |
||||||
|
import net.pokeranalytics.android.util.NULL_TEXT |
||||||
|
import net.pokeranalytics.android.util.extensions.isSameDay |
||||||
|
import net.pokeranalytics.android.util.extensions.mediumDate |
||||||
import java.util.* |
import java.util.* |
||||||
|
|
||||||
open class Player : RealmObject() { |
open class Player : RealmObject(), NameManageable, Deletable, StaticRowRepresentableDataSource, RowRepresentable { |
||||||
|
|
||||||
@PrimaryKey |
@PrimaryKey |
||||||
var id = UUID.randomUUID().toString() |
override var id = UUID.randomUUID().toString() |
||||||
|
|
||||||
// The name of the player |
// The name of the player |
||||||
var name: String = "" |
override var name: String = "" |
||||||
|
|
||||||
|
// New fields |
||||||
|
var summary: String = "" |
||||||
|
var color: Int? = null |
||||||
|
var picture: String? = null |
||||||
|
var comments: RealmList<Comment> = RealmList() |
||||||
|
|
||||||
|
@Ignore |
||||||
|
override val realmObjectClass: Class<out Identifiable> = Player::class.java |
||||||
|
|
||||||
|
@Ignore |
||||||
|
override val viewType: Int = RowViewType.ROW_PLAYER.ordinal |
||||||
|
|
||||||
|
@Ignore |
||||||
|
private var rowRepresentation: List<RowRepresentable> = mutableListOf() |
||||||
|
|
||||||
|
@Ignore |
||||||
|
private var commentsToDelete: ArrayList<Comment> = ArrayList() |
||||||
|
|
||||||
|
|
||||||
|
override fun isValidForDelete(realm: Realm): Boolean { |
||||||
|
//TODO |
||||||
|
return true |
||||||
|
} |
||||||
|
|
||||||
|
override fun getFailedSaveMessage(status: SaveValidityStatus): Int { |
||||||
|
return when(status) { |
||||||
|
SaveValidityStatus.ALREADY_EXISTS -> R.string.duplicate_user_error |
||||||
|
else -> super.getFailedSaveMessage(status) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun getFailedDeleteMessage(status: DeleteValidityStatus): Int { |
||||||
|
//TODO |
||||||
|
return R.string.relationship_error |
||||||
|
} |
||||||
|
|
||||||
|
override fun adapterRows(): List<RowRepresentable>? { |
||||||
|
return rowRepresentation |
||||||
|
} |
||||||
|
|
||||||
|
override fun getDisplayName(context: Context): String { |
||||||
|
return this.name |
||||||
|
} |
||||||
|
|
||||||
|
override fun stringForRow(row: RowRepresentable): String { |
||||||
|
return when (row) { |
||||||
|
PlayerRow.NAME -> if (this.name.isNotEmpty()) this.name else NULL_TEXT |
||||||
|
else -> return super.stringForRow(row) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
||||||
|
when (row) { |
||||||
|
PlayerRow.NAME -> this.name = value as String? ?: "" |
||||||
|
PlayerRow.SUMMARY -> this.summary = value as String? ?: "" |
||||||
|
PlayerRow.IMAGE -> this.picture = value as String? ?: "" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Update the row representation |
||||||
|
*/ |
||||||
|
private fun updatedRowRepresentationForCurrentState(): List<RowRepresentable> { |
||||||
|
val rows = ArrayList<RowRepresentable>() |
||||||
|
rows.add(PlayerRow.IMAGE) |
||||||
|
rows.add(PlayerRow.NAME) |
||||||
|
rows.add(PlayerRow.SUMMARY) |
||||||
|
|
||||||
|
if (comments.size > 0) { |
||||||
|
rows.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, R.string.comments)) |
||||||
|
|
||||||
|
val currentCommentCalendar = Calendar.getInstance() |
||||||
|
val currentDateCalendar = Calendar.getInstance() |
||||||
|
|
||||||
|
val commentsToDisplay = ArrayList<Comment>() |
||||||
|
commentsToDisplay.addAll(comments) |
||||||
|
commentsToDisplay.sortByDescending { it.date } |
||||||
|
|
||||||
|
commentsToDisplay.forEachIndexed { index, comment -> |
||||||
|
currentCommentCalendar.time = comment.date |
||||||
|
|
||||||
|
if (!currentCommentCalendar.isSameDay(currentDateCalendar) || index == 0) { |
||||||
|
currentDateCalendar.time = currentCommentCalendar.time |
||||||
|
rows.add(CustomizableRowRepresentable(RowViewType.HEADER_SUBTITLE, title = currentDateCalendar.time.mediumDate())) |
||||||
|
} |
||||||
|
|
||||||
|
rows.add(comment) |
||||||
|
} |
||||||
|
|
||||||
|
rows.add(SeparatorRow()) |
||||||
|
} |
||||||
|
|
||||||
|
return rows |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return if the player has a picture |
||||||
|
*/ |
||||||
|
fun hasPicture(): Boolean { |
||||||
|
return picture != null && picture?.isNotEmpty() == true |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update row representation |
||||||
|
*/ |
||||||
|
fun updateRowRepresentation() { |
||||||
|
this.rowRepresentation = this.updatedRowRepresentationForCurrentState() |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Add an entry |
||||||
|
*/ |
||||||
|
fun addComment(): Comment { |
||||||
|
val entry = Comment() |
||||||
|
this.comments.add(entry) |
||||||
|
updateRowRepresentation() |
||||||
|
return entry |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Delete an entry |
||||||
|
*/ |
||||||
|
fun deleteComment(comment: Comment) { |
||||||
|
commentsToDelete.add(comment) |
||||||
|
this.comments.remove(comment) |
||||||
|
updateRowRepresentation() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Clean up deleted entries |
||||||
|
*/ |
||||||
|
fun cleanupComments() { // called when saving the custom field |
||||||
|
val realm = Realm.getDefaultInstance() |
||||||
|
realm.executeTransaction { |
||||||
|
this.commentsToDelete.forEach { // entries are out of realm |
||||||
|
realm.where<Comment>().equalTo("id", it.id).findFirst()?.deleteFromRealm() |
||||||
|
} |
||||||
|
} |
||||||
|
realm.close() |
||||||
|
this.commentsToDelete.clear() |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
@ -0,0 +1,77 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity |
||||||
|
|
||||||
|
import android.app.Activity |
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.os.Bundle |
||||||
|
import android.view.View |
||||||
|
import androidx.fragment.app.Fragment |
||||||
|
import kotlinx.android.synthetic.main.activity_color_picker.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||||
|
|
||||||
|
class ColorPickerActivity : PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
|
||||||
|
const val INTENT_COLOR = "INTENT_COLOR" |
||||||
|
|
||||||
|
fun newInstance(context: Context) { |
||||||
|
val intent = Intent(context, ColorPickerActivity::class.java) |
||||||
|
context.startActivity(intent) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new instance for result |
||||||
|
*/ |
||||||
|
fun newInstanceForResult(fragment: Fragment, requestCode: Int) { |
||||||
|
val intent = Intent(fragment.requireContext(), ColorPickerActivity::class.java) |
||||||
|
fragment.startActivityForResult(intent, requestCode) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
setContentView(R.layout.activity_color_picker) |
||||||
|
|
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
color1.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color2.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color3.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color4.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color5.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color6.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color7.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color8.setOnClickListener { manageSelectedColor(it) } |
||||||
|
color9.setOnClickListener { manageSelectedColor(it) } |
||||||
|
} |
||||||
|
|
||||||
|
private fun manageSelectedColor(view: View) { |
||||||
|
|
||||||
|
val color = when(view) { |
||||||
|
color1 -> getColor(R.color.player_color_1) |
||||||
|
color2 -> getColor(R.color.player_color_2) |
||||||
|
color3 -> getColor(R.color.player_color_3) |
||||||
|
color4 -> getColor(R.color.player_color_4) |
||||||
|
color5 -> getColor(R.color.player_color_5) |
||||||
|
color6 -> getColor(R.color.player_color_6) |
||||||
|
color7 -> getColor(R.color.player_color_7) |
||||||
|
color8 -> getColor(R.color.player_color_8) |
||||||
|
color9 -> getColor(R.color.player_color_9) |
||||||
|
else -> getColor(R.color.player_color_1) |
||||||
|
} |
||||||
|
|
||||||
|
val intent = Intent() |
||||||
|
intent.putExtra(INTENT_COLOR, color) |
||||||
|
setResult(Activity.RESULT_OK, intent) |
||||||
|
finish() |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,33 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.activity |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import android.content.Intent |
|
||||||
import android.os.Bundle |
|
||||||
import androidx.fragment.app.Fragment |
|
||||||
import net.pokeranalytics.android.R |
|
||||||
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
||||||
|
|
||||||
class ComparisonChartActivity : PokerAnalyticsActivity() { |
|
||||||
|
|
||||||
companion object { |
|
||||||
fun newInstance(context: Context) { |
|
||||||
val intent = Intent(context, ComparisonChartActivity::class.java) |
|
||||||
context.startActivity(intent) |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Create a new instance for result |
|
||||||
*/ |
|
||||||
fun newInstanceForResult(fragment: Fragment, requestCode: Int) { |
|
||||||
val intent = Intent(fragment.requireContext(), ComparisonChartActivity::class.java) |
|
||||||
fragment.startActivityForResult(intent, requestCode) |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) { |
|
||||||
super.onCreate(savedInstanceState) |
|
||||||
setContentView(R.layout.activity_comparison_chart) |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,268 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity.components |
||||||
|
|
||||||
|
import android.Manifest |
||||||
|
import android.app.Activity |
||||||
|
import android.content.Intent |
||||||
|
import android.content.pm.PackageManager |
||||||
|
import android.graphics.Bitmap |
||||||
|
import android.provider.MediaStore |
||||||
|
import androidx.core.app.ActivityCompat |
||||||
|
import androidx.core.content.ContextCompat |
||||||
|
import androidx.core.content.FileProvider |
||||||
|
import kotlinx.coroutines.Dispatchers |
||||||
|
import kotlinx.coroutines.GlobalScope |
||||||
|
import kotlinx.coroutines.launch |
||||||
|
import net.pokeranalytics.android.util.ImageUtils |
||||||
|
import timber.log.Timber |
||||||
|
import java.io.File |
||||||
|
import java.io.IOException |
||||||
|
import java.util.* |
||||||
|
|
||||||
|
|
||||||
|
open class MediaActivity : PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
const val SELECTED_CHOICE_TAKE_PICTURE = 10 |
||||||
|
const val SELECTED_CHOICE_SELECT_PICTURE = 11 |
||||||
|
const val REQUEST_CODE_TAKE_PICTURE = 100 |
||||||
|
const val REQUEST_CODE_SELECT_PICTURE = 101 |
||||||
|
const val PERMISSION_REQUEST_EXTERNAL_STORAGE = 201 |
||||||
|
const val PERMISSION_REQUEST_CAMERA = 202 |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Data |
||||||
|
private var tempFile: File? = null |
||||||
|
private var mCurrentPhotoPath: String? = null |
||||||
|
private var selectedChoice = -1 |
||||||
|
private var multiplePictures = false |
||||||
|
|
||||||
|
override fun onDestroy() { |
||||||
|
super.onDestroy() |
||||||
|
if (tempFile != null) { |
||||||
|
tempFile!!.delete() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
||||||
|
super.onActivityResult(requestCode, resultCode, data) |
||||||
|
|
||||||
|
if (resultCode == Activity.RESULT_OK) { |
||||||
|
if (requestCode == REQUEST_CODE_SELECT_PICTURE || requestCode == REQUEST_CODE_TAKE_PICTURE) { |
||||||
|
|
||||||
|
val filesList = ArrayList<File>() |
||||||
|
|
||||||
|
GlobalScope.launch { |
||||||
|
|
||||||
|
if (tempFile != null) { |
||||||
|
tempFile?.let { |
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
filesList.add(it) |
||||||
|
getPictures(filesList) |
||||||
|
} |
||||||
|
} |
||||||
|
} else if (data?.clipData != null) { |
||||||
|
data?.clipData?.let { clipData -> |
||||||
|
try { |
||||||
|
|
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
isLoadingNewPictures() |
||||||
|
} |
||||||
|
|
||||||
|
for (i in 0 until clipData.itemCount) { |
||||||
|
val item = clipData.getItemAt(i) |
||||||
|
val uri = item.uri |
||||||
|
val inputStream = contentResolver.openInputStream(uri) |
||||||
|
val photoFile = ImageUtils.createTempImageFile(this@MediaActivity) |
||||||
|
ImageUtils.copyInputStreamToFile(inputStream!!, photoFile) |
||||||
|
filesList.add(photoFile) |
||||||
|
} |
||||||
|
|
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
getPictures(filesList) |
||||||
|
} |
||||||
|
|
||||||
|
} catch (e: Exception) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
} |
||||||
|
} else if (data?.data != null) { |
||||||
|
data?.data?.let { uri -> |
||||||
|
try { |
||||||
|
|
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
isLoadingNewPictures() |
||||||
|
} |
||||||
|
|
||||||
|
val inputStream = contentResolver.openInputStream(uri) |
||||||
|
val photoFile = ImageUtils.createTempImageFile(this@MediaActivity) |
||||||
|
ImageUtils.copyInputStreamToFile(inputStream!!, photoFile) |
||||||
|
filesList.add(photoFile) |
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
getPictures(filesList) |
||||||
|
} |
||||||
|
|
||||||
|
} catch (e: Exception) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { |
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults) |
||||||
|
|
||||||
|
if (grantResults.isNotEmpty()) { |
||||||
|
for (result in grantResults) { |
||||||
|
if (result != PackageManager.PERMISSION_GRANTED) { |
||||||
|
//Toast.makeText(this, getString(R.string.photo_library_add_usage_description), Toast.LENGTH_SHORT).show() |
||||||
|
selectedChoice = -1 |
||||||
|
return |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
when (selectedChoice) { |
||||||
|
SELECTED_CHOICE_TAKE_PICTURE -> { |
||||||
|
openImageCaptureIntent(multiplePictures) |
||||||
|
} |
||||||
|
SELECTED_CHOICE_SELECT_PICTURE -> { |
||||||
|
openImageGalleryIntent(multiplePictures) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
selectedChoice = -1 |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Open the Camera Intent |
||||||
|
*/ |
||||||
|
fun openImageCaptureIntent(multiplePictures: Boolean) { |
||||||
|
|
||||||
|
tempFile = null |
||||||
|
|
||||||
|
this.mCurrentPhotoPath = null |
||||||
|
this.multiplePictures = multiplePictures |
||||||
|
|
||||||
|
// Test if we have the permission |
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { |
||||||
|
selectedChoice = SELECTED_CHOICE_TAKE_PICTURE |
||||||
|
askForStoragePermission() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) |
||||||
|
// Ensure that there's a camera activity to handle the intent |
||||||
|
if (takePictureIntent.resolveActivity(packageManager) != null) { |
||||||
|
// Create the File where the photo should go |
||||||
|
try { |
||||||
|
tempFile = ImageUtils.createImageFile(this) |
||||||
|
mCurrentPhotoPath = "file:" + tempFile?.absolutePath |
||||||
|
} catch (ex: IOException) { |
||||||
|
// Error occurred while creating the File |
||||||
|
} |
||||||
|
|
||||||
|
// Continue only if the File was successfully created |
||||||
|
if (tempFile != null) { |
||||||
|
Timber.d("tempFile: ${tempFile?.absolutePath}") |
||||||
|
val photoURI = FileProvider.getUriForFile( |
||||||
|
this, |
||||||
|
applicationContext.packageName + ".fileprovider", tempFile!! |
||||||
|
) |
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI) |
||||||
|
startActivityForResult(takePictureIntent, REQUEST_CODE_TAKE_PICTURE) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Open the gallery intent |
||||||
|
*/ |
||||||
|
fun openImageGalleryIntent(multiplePictures: Boolean) { |
||||||
|
|
||||||
|
tempFile = null |
||||||
|
|
||||||
|
this.multiplePictures = multiplePictures |
||||||
|
|
||||||
|
// Test if we have the permission |
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { |
||||||
|
selectedChoice = SELECTED_CHOICE_SELECT_PICTURE |
||||||
|
askForStoragePermission() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
this.multiplePictures = multiplePictures |
||||||
|
|
||||||
|
val galleryIntent = Intent() |
||||||
|
galleryIntent.type = "image/*" |
||||||
|
galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiplePictures) |
||||||
|
galleryIntent.action = Intent.ACTION_GET_CONTENT |
||||||
|
startActivityForResult(galleryIntent, REQUEST_CODE_SELECT_PICTURE) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Ask for the external storage permission |
||||||
|
*/ |
||||||
|
private fun askForStoragePermission() { |
||||||
|
// Here, thisActivity is the current activity |
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { |
||||||
|
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), |
||||||
|
PERMISSION_REQUEST_EXTERNAL_STORAGE) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Ask for the acmera permission |
||||||
|
*/ |
||||||
|
private fun askForCameraPermission() { |
||||||
|
// Here, thisActivity is the current activity |
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { |
||||||
|
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), |
||||||
|
PERMISSION_REQUEST_CAMERA) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Ask for camera and storage permission |
||||||
|
*/ |
||||||
|
private fun askForCameraAndStoragePermissions() { |
||||||
|
|
||||||
|
val permissions = ArrayList<String>() |
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { |
||||||
|
permissions.add(Manifest.permission.CAMERA) |
||||||
|
} |
||||||
|
|
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { |
||||||
|
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE) |
||||||
|
} |
||||||
|
|
||||||
|
if (permissions.size > 0) { |
||||||
|
ActivityCompat.requestPermissions(this, permissions.toArray(arrayOfNulls<String>(permissions.size)), PERMISSION_REQUEST_CAMERA) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Called when a bitmap is return |
||||||
|
* |
||||||
|
* @param bitmap the bitmap returned |
||||||
|
*/ |
||||||
|
open fun getBitmapImage(file: File?, bitmap: Bitmap?) {} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Called when the user is adding new photos |
||||||
|
*/ |
||||||
|
open fun isLoadingNewPictures() {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Called when the user has selected photos |
||||||
|
*/ |
||||||
|
open fun getPictures(files: ArrayList<File>) {} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -1,115 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.fragment |
|
||||||
|
|
||||||
import android.os.Bundle |
|
||||||
import android.view.* |
|
||||||
import kotlinx.android.synthetic.main.fragment_comparison_chart.* |
|
||||||
import net.pokeranalytics.android.R |
|
||||||
import net.pokeranalytics.android.ui.activity.BankrollActivity |
|
||||||
import net.pokeranalytics.android.ui.activity.SettingsActivity |
|
||||||
import net.pokeranalytics.android.ui.adapter.ComparisonChartPagerAdapter |
|
||||||
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
||||||
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
||||||
import net.pokeranalytics.android.ui.extensions.toast |
|
||||||
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
||||||
import net.pokeranalytics.android.ui.view.rowrepresentable.MoreTabRow |
|
||||||
|
|
||||||
class ComparisonChartFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate { |
|
||||||
|
|
||||||
companion object { |
|
||||||
|
|
||||||
/** |
|
||||||
* Create new instance |
|
||||||
*/ |
|
||||||
fun newInstance(): ComparisonChartFragment { |
|
||||||
val fragment = ComparisonChartFragment() |
|
||||||
val bundle = Bundle() |
|
||||||
fragment.arguments = bundle |
|
||||||
return fragment |
|
||||||
} |
|
||||||
|
|
||||||
val rowRepresentation: List<RowRepresentable> by lazy { |
|
||||||
val rows = ArrayList<RowRepresentable>() |
|
||||||
rows.addAll(MoreTabRow.values()) |
|
||||||
rows |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private lateinit var viewPagerAdapter: ComparisonChartPagerAdapter |
|
||||||
private var comparisonChartMenu: Menu? = null |
|
||||||
|
|
||||||
|
|
||||||
// Life Cycle |
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
||||||
return inflater.inflate(R.layout.fragment_comparison_chart, container, false) |
|
||||||
} |
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
||||||
super.onViewCreated(view, savedInstanceState) |
|
||||||
initData() |
|
||||||
initUI() |
|
||||||
} |
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { |
|
||||||
menu?.clear() |
|
||||||
inflater?.inflate(R.menu.toolbar_comparison_chart, menu) |
|
||||||
this.comparisonChartMenu = menu |
|
||||||
super.onCreateOptionsMenu(menu, inflater) |
|
||||||
} |
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
|
||||||
when (item!!.itemId) { |
|
||||||
R.id.settings -> openChangeStatistics() |
|
||||||
} |
|
||||||
return true |
|
||||||
} |
|
||||||
|
|
||||||
// Rows |
|
||||||
override fun adapterRows(): List<RowRepresentable>? { |
|
||||||
return rowRepresentation |
|
||||||
} |
|
||||||
|
|
||||||
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
||||||
super.onRowSelected(position, row, fromAction) |
|
||||||
when(row) { |
|
||||||
MoreTabRow.BANKROLL -> BankrollActivity.newInstance(requireContext()) |
|
||||||
MoreTabRow.SETTINGS -> SettingsActivity.newInstance(requireContext()) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// Business |
|
||||||
|
|
||||||
/** |
|
||||||
* Init data |
|
||||||
*/ |
|
||||||
private fun initData() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init UI |
|
||||||
*/ |
|
||||||
private fun initUI() { |
|
||||||
|
|
||||||
setDisplayHomeAsUpEnabled(true) |
|
||||||
setToolbarTitle(getString(R.string.comparison_chart)) |
|
||||||
|
|
||||||
parentActivity?.let { |
|
||||||
viewPagerAdapter = ComparisonChartPagerAdapter(requireContext(), it.supportFragmentManager) |
|
||||||
viewPager.adapter = viewPagerAdapter |
|
||||||
viewPager.offscreenPageLimit = 2 |
|
||||||
tabs.setupWithViewPager(viewPager) |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Open change statistics |
|
||||||
*/ |
|
||||||
private fun openChangeStatistics() { |
|
||||||
//TODO |
|
||||||
toast("Open change statistics") |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,198 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.fragment |
|
||||||
|
|
||||||
import android.app.Activity |
|
||||||
import android.content.ActivityNotFoundException |
|
||||||
import android.content.Intent |
|
||||||
import android.net.Uri |
|
||||||
import android.os.Bundle |
|
||||||
import android.view.LayoutInflater |
|
||||||
import android.view.View |
|
||||||
import android.view.ViewGroup |
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager |
|
||||||
import io.realm.Realm |
|
||||||
import kotlinx.android.synthetic.main.fragment_settings.* |
|
||||||
import net.pokeranalytics.android.BuildConfig |
|
||||||
import net.pokeranalytics.android.R |
|
||||||
import net.pokeranalytics.android.model.realm.Currency |
|
||||||
import net.pokeranalytics.android.model.realm.Session |
|
||||||
import net.pokeranalytics.android.ui.activity.* |
|
||||||
import net.pokeranalytics.android.ui.activity.components.RequestCode |
|
||||||
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
||||||
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
||||||
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
||||||
import net.pokeranalytics.android.ui.extensions.openContactMail |
|
||||||
import net.pokeranalytics.android.ui.extensions.openPlayStorePage |
|
||||||
import net.pokeranalytics.android.ui.extensions.openUrl |
|
||||||
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
||||||
import net.pokeranalytics.android.ui.view.rowrepresentable.SettingRow |
|
||||||
import net.pokeranalytics.android.util.Preferences |
|
||||||
import net.pokeranalytics.android.util.URL |
|
||||||
import net.pokeranalytics.android.util.UserDefaults |
|
||||||
import net.pokeranalytics.android.util.billing.AppGuard |
|
||||||
import net.pokeranalytics.android.util.billing.IAPProducts |
|
||||||
import timber.log.Timber |
|
||||||
import java.util.* |
|
||||||
|
|
||||||
|
|
||||||
class SettingsFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, StaticRowRepresentableDataSource { |
|
||||||
|
|
||||||
|
|
||||||
companion object { |
|
||||||
|
|
||||||
/** |
|
||||||
* Create new instance |
|
||||||
*/ |
|
||||||
fun newInstance(): SettingsFragment { |
|
||||||
val fragment = SettingsFragment() |
|
||||||
val bundle = Bundle() |
|
||||||
fragment.arguments = bundle |
|
||||||
return fragment |
|
||||||
} |
|
||||||
|
|
||||||
val rowRepresentation: List<RowRepresentable> by lazy { |
|
||||||
val rows = ArrayList<RowRepresentable>() |
|
||||||
rows.addAll(SettingRow.getRows()) |
|
||||||
rows |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private lateinit var settingsAdapterRow: RowRepresentableAdapter |
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
||||||
return inflater.inflate(R.layout.fragment_settings, container, false) |
|
||||||
} |
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
||||||
super.onViewCreated(view, savedInstanceState) |
|
||||||
initData() |
|
||||||
initUI() |
|
||||||
} |
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
|
||||||
|
|
||||||
when (requestCode) { |
|
||||||
RequestCode.CURRENCY.value -> { |
|
||||||
if (resultCode == Activity.RESULT_OK) { |
|
||||||
data?.let { |
|
||||||
Preferences.setCurrencyCode(data.getStringExtra(CurrenciesFragment.INTENT_CURRENCY_CODE), requireContext()) |
|
||||||
val realm = Realm.getDefaultInstance() |
|
||||||
realm.executeTransaction { |
|
||||||
realm.where(Currency::class.java).isNull("code").or().equalTo("code", UserDefaults.currency.currencyCode).findAll().forEach { currency -> |
|
||||||
currency.rate = Currency.DEFAULT_RATE |
|
||||||
} |
|
||||||
|
|
||||||
realm.where(Session::class.java).isNull("bankroll.currency.code").findAll().forEach { session -> |
|
||||||
session.bankrollHasBeenUpdated() |
|
||||||
} |
|
||||||
} |
|
||||||
realm.close() |
|
||||||
settingsAdapterRow.refreshRow(SettingRow.CURRENCY) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
RequestCode.SUBSCRIPTION.value -> { |
|
||||||
settingsAdapterRow.refreshRow(SettingRow.SUBSCRIPTION) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override fun adapterRows(): List<RowRepresentable>? { |
|
||||||
return rowRepresentation |
|
||||||
} |
|
||||||
|
|
||||||
override fun stringForRow(row: RowRepresentable): String { |
|
||||||
return when (row) { |
|
||||||
SettingRow.SUBSCRIPTION -> AppGuard.subscriptionStatus(requireContext()) |
|
||||||
SettingRow.VERSION -> BuildConfig.VERSION_NAME + if (BuildConfig.DEBUG) " (${BuildConfig.VERSION_CODE}) DEBUG" else "" |
|
||||||
SettingRow.CURRENCY -> UserDefaults.currency.symbol |
|
||||||
else -> "" |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
||||||
when (row) { |
|
||||||
SettingRow.BANKROLL_REPORT -> BankrollActivity.newInstance(requireContext()) |
|
||||||
SettingRow.TOP_10 -> Top10Activity.newInstance(requireContext()) |
|
||||||
SettingRow.SUBSCRIPTION -> { |
|
||||||
if (!AppGuard.isProUser) { |
|
||||||
BillingActivity.newInstanceForResult(this, false) |
|
||||||
} else { |
|
||||||
this.openPlaystoreAccount() |
|
||||||
} |
|
||||||
} |
|
||||||
SettingRow.RATE_APP -> parentActivity?.openPlayStorePage() |
|
||||||
SettingRow.CONTACT_US -> parentActivity?.openContactMail(R.string.contact) |
|
||||||
SettingRow.BUG_REPORT -> parentActivity?.openContactMail(R.string.bug_report_subject, Realm.getDefaultInstance().path) |
|
||||||
SettingRow.CURRENCY -> CurrenciesActivity.newInstanceForResult(this@SettingsFragment, RequestCode.CURRENCY.value) |
|
||||||
SettingRow.FOLLOW_US -> { |
|
||||||
when (position) { |
|
||||||
0 -> parentActivity?.openUrl(URL.BLOG.value) |
|
||||||
1 -> parentActivity?.openUrl(URL.INSTAGRAM.value) |
|
||||||
2 -> parentActivity?.openUrl(URL.TWITTER.value) |
|
||||||
3 -> parentActivity?.openUrl(URL.FACEBOOK.value) |
|
||||||
} |
|
||||||
} |
|
||||||
SettingRow.PRIVACY_POLICY -> parentActivity?.openUrl(URL.PRIVACY_POLICY.value) |
|
||||||
SettingRow.TERMS_OF_USE -> parentActivity?.openUrl(URL.TERMS.value) |
|
||||||
SettingRow.GDPR -> openGDPRActivity() |
|
||||||
} |
|
||||||
|
|
||||||
row.relatedResultsRepresentable?.let { |
|
||||||
DataListActivity.newInstance(requireContext(), it.ordinal) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init UI |
|
||||||
*/ |
|
||||||
private fun initUI() { |
|
||||||
|
|
||||||
setToolbarTitle(getString(R.string.more)) |
|
||||||
|
|
||||||
setDisplayHomeAsUpEnabled(true) |
|
||||||
|
|
||||||
val viewManager = LinearLayoutManager(requireContext()) |
|
||||||
settingsAdapterRow = RowRepresentableAdapter( |
|
||||||
this, this |
|
||||||
) |
|
||||||
|
|
||||||
recyclerView.apply { |
|
||||||
setHasFixedSize(true) |
|
||||||
layoutManager = viewManager |
|
||||||
adapter = settingsAdapterRow |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init data |
|
||||||
*/ |
|
||||||
private fun initData() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Open GDPR Activity |
|
||||||
*/ |
|
||||||
private fun openGDPRActivity() { |
|
||||||
val intent = Intent(requireContext(), GDPRActivity::class.java) |
|
||||||
startActivity(intent) |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Open Google Play account |
|
||||||
*/ |
|
||||||
private fun openPlaystoreAccount() { |
|
||||||
|
|
||||||
val packageName = "net.pokeranalytics.android" |
|
||||||
val sku = IAPProducts.PRO.identifier |
|
||||||
|
|
||||||
try { |
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/account/subscriptions?sku=$sku&package=$packageName"))) |
|
||||||
} catch (e: ActivityNotFoundException) { |
|
||||||
Timber.d(e) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,50 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
|
||||||
|
|
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
||||||
|
|
||||||
enum class BottomSheetType { |
|
||||||
NONE, |
|
||||||
LIST, |
|
||||||
LIST_STATIC, |
|
||||||
LIST_GAME, |
|
||||||
DOUBLE_LIST, |
|
||||||
MULTI_SELECTION, |
|
||||||
GRID, |
|
||||||
EDIT_TEXT, |
|
||||||
EDIT_TEXT_MULTI_LINES, |
|
||||||
DOUBLE_EDIT_TEXT, |
|
||||||
NUMERIC_TEXT, |
|
||||||
SUM; |
|
||||||
|
|
||||||
fun newInstance(row: RowRepresentable): BottomSheetFragment { |
|
||||||
return when (this) { |
|
||||||
NONE -> BottomSheetFragment(row) |
|
||||||
LIST -> BottomSheetListFragment(row) |
|
||||||
LIST_STATIC -> BottomSheetStaticListFragment(row) |
|
||||||
LIST_GAME -> BottomSheetListGameFragment(row) |
|
||||||
DOUBLE_LIST -> BottomSheetListGameFragment(row) |
|
||||||
MULTI_SELECTION -> BottomSheetMultiSelectionFragment(row) |
|
||||||
GRID -> BottomSheetTableSizeGridFragment(row) |
|
||||||
EDIT_TEXT -> BottomSheetEditTextFragment(row) |
|
||||||
EDIT_TEXT_MULTI_LINES -> BottomSheetEditTextMultiLinesFragment(row) |
|
||||||
DOUBLE_EDIT_TEXT -> BottomSheetDoubleEditTextFragment(row) |
|
||||||
NUMERIC_TEXT -> BottomSheetNumericTextFragment(row) |
|
||||||
SUM -> BottomSheetSumFragment(row) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
val validationRequired: Boolean |
|
||||||
get() = when (this) { |
|
||||||
LIST, LIST_GAME, LIST_STATIC, GRID, DOUBLE_LIST -> false |
|
||||||
else -> true |
|
||||||
} |
|
||||||
|
|
||||||
val clearRequired: Boolean |
|
||||||
get() = true |
|
||||||
|
|
||||||
val addRequired: Boolean |
|
||||||
get() = when (this) { |
|
||||||
EDIT_TEXT, NUMERIC_TEXT, DOUBLE_EDIT_TEXT, EDIT_TEXT_MULTI_LINES, GRID, LIST_STATIC, SUM -> false |
|
||||||
else -> true |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,50 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment.components.input |
||||||
|
|
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
|
||||||
|
enum class InputFragmentType { |
||||||
|
NONE, |
||||||
|
LIST, |
||||||
|
LIST_STATIC, |
||||||
|
LIST_GAME, |
||||||
|
DOUBLE_LIST, |
||||||
|
MULTI_SELECTION, |
||||||
|
GRID, |
||||||
|
EDIT_TEXT, |
||||||
|
EDIT_TEXT_MULTI_LINES, |
||||||
|
DOUBLE_EDIT_TEXT, |
||||||
|
NUMERIC_TEXT, |
||||||
|
SUM; |
||||||
|
|
||||||
|
fun newInstance(row: RowRepresentable): InputFragment { |
||||||
|
return when (this) { |
||||||
|
NONE -> InputFragment(row) |
||||||
|
LIST -> InputListFragment(row) |
||||||
|
LIST_STATIC -> InputStaticListFragment(row) |
||||||
|
LIST_GAME -> InputListGameFragment(row) |
||||||
|
DOUBLE_LIST -> InputListGameFragment(row) |
||||||
|
MULTI_SELECTION -> InputMultiSelectionFragment(row) |
||||||
|
GRID -> InputTableSizeGridFragment(row) |
||||||
|
EDIT_TEXT -> InputEditTextFragment(row) |
||||||
|
EDIT_TEXT_MULTI_LINES -> InputEditTextMultiLinesFragment(row) |
||||||
|
DOUBLE_EDIT_TEXT -> InputDoubleEditTextFragment(row) |
||||||
|
NUMERIC_TEXT -> InputNumericTextFragment(row) |
||||||
|
SUM -> InputSumFragment(row) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
val validationRequired: Boolean |
||||||
|
get() = when (this) { |
||||||
|
LIST, LIST_GAME, LIST_STATIC, GRID, DOUBLE_LIST -> false |
||||||
|
else -> true |
||||||
|
} |
||||||
|
|
||||||
|
val clearRequired: Boolean |
||||||
|
get() = true |
||||||
|
|
||||||
|
val addRequired: Boolean |
||||||
|
get() = when (this) { |
||||||
|
EDIT_TEXT, NUMERIC_TEXT, DOUBLE_EDIT_TEXT, EDIT_TEXT_MULTI_LINES, GRID, LIST_STATIC, SUM -> false |
||||||
|
else -> true |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,205 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment.data |
||||||
|
|
||||||
|
import android.app.Activity.RESULT_OK |
||||||
|
import android.content.Intent |
||||||
|
import android.graphics.Color |
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import androidx.appcompat.app.AlertDialog |
||||||
|
import kotlinx.android.synthetic.main.fragment_player.* |
||||||
|
import kotlinx.coroutines.Dispatchers |
||||||
|
import kotlinx.coroutines.GlobalScope |
||||||
|
import kotlinx.coroutines.delay |
||||||
|
import kotlinx.coroutines.launch |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.Comment |
||||||
|
import net.pokeranalytics.android.model.realm.Player |
||||||
|
import net.pokeranalytics.android.ui.activity.ColorPickerActivity |
||||||
|
import net.pokeranalytics.android.ui.activity.components.MediaActivity |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
||||||
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
||||||
|
import net.pokeranalytics.android.ui.extensions.showAlertDialog |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.PlayerRow |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SimpleRow |
||||||
|
import net.pokeranalytics.android.util.NULL_TEXT |
||||||
|
import java.io.File |
||||||
|
|
||||||
|
/** |
||||||
|
* Player data fragment |
||||||
|
*/ |
||||||
|
class PlayerDataFragment : EditableDataFragment(), StaticRowRepresentableDataSource { |
||||||
|
|
||||||
|
companion object { |
||||||
|
const val REQUEST_CODE_PICK_COLOR = 1000 |
||||||
|
} |
||||||
|
|
||||||
|
private val player: Player |
||||||
|
get() { |
||||||
|
return this.item as Player |
||||||
|
} |
||||||
|
|
||||||
|
private var mediaActivity: MediaActivity? = null |
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
super.onCreateView(inflater, container, savedInstanceState) |
||||||
|
shouldOpenKeyboard = false |
||||||
|
return inflater.inflate(R.layout.fragment_player, container, false) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
||||||
|
super.onActivityResult(requestCode, resultCode, data) |
||||||
|
|
||||||
|
if (requestCode == REQUEST_CODE_PICK_COLOR && resultCode == RESULT_OK && data?.hasExtra(ColorPickerActivity.INTENT_COLOR) == true) { |
||||||
|
val color = data.getIntExtra(ColorPickerActivity.INTENT_COLOR, Color.TRANSPARENT) |
||||||
|
player.color = if (color != Color.TRANSPARENT) color else null |
||||||
|
rowRepresentableAdapter.refreshRow(PlayerRow.IMAGE) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
override fun getPhotos(files: ArrayList<File>) { |
||||||
|
super.getPhotos(files) |
||||||
|
files.firstOrNull()?.let { picture -> |
||||||
|
player.updateValue(picture.absolutePath, PlayerRow.IMAGE) |
||||||
|
rowRepresentableAdapter.refreshRow(PlayerRow.IMAGE) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun getDataSource(): RowRepresentableDataSource { |
||||||
|
return this |
||||||
|
} |
||||||
|
|
||||||
|
override fun adapterRows(): List<RowRepresentable>? { |
||||||
|
return player.adapterRows() |
||||||
|
} |
||||||
|
|
||||||
|
override fun viewTypeForPosition(position: Int): Int { |
||||||
|
return when (position) { |
||||||
|
0 -> RowViewType.ROW_PLAYER_IMAGE.ordinal |
||||||
|
else -> super.viewTypeForPosition(position) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun rowRepresentableForPosition(position: Int): RowRepresentable? { |
||||||
|
return when (position) { |
||||||
|
0 -> player |
||||||
|
else -> super.rowRepresentableForPosition(position) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun stringForRow(row: RowRepresentable): String { |
||||||
|
return when (row) { |
||||||
|
PlayerRow.NAME -> if (player.name.isNotEmpty()) player.name else NULL_TEXT |
||||||
|
PlayerRow.SUMMARY -> if (player.summary.isNotEmpty()) player.summary else NULL_TEXT |
||||||
|
else -> super.stringForRow(row) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
||||||
|
when (row) { |
||||||
|
PlayerRow.IMAGE -> openPictureDialog() |
||||||
|
else -> super.onRowSelected(position, row, fromAction) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
||||||
|
when (row) { |
||||||
|
is Comment -> { |
||||||
|
row.updateValue(value, row) |
||||||
|
player.updateRowRepresentation() |
||||||
|
rowRepresentableAdapter.notifyDataSetChanged() |
||||||
|
} |
||||||
|
else -> { |
||||||
|
super.onRowValueChanged(value, row) |
||||||
|
if (row == PlayerRow.NAME) { |
||||||
|
rowRepresentableAdapter.refreshRow(PlayerRow.IMAGE) |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowDeleted(row: RowRepresentable) { |
||||||
|
super.onRowDeleted(row) |
||||||
|
when (row) { |
||||||
|
is Comment -> { |
||||||
|
if (row.isValidForDelete(getRealm())) { |
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
delay(300) |
||||||
|
showAlertDialog(requireContext(), message = R.string.are_you_sure_you_want_to_delete, showCancelButton = true, positiveAction = { |
||||||
|
player.deleteComment(row) |
||||||
|
rowRepresentableAdapter.notifyDataSetChanged() |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
mediaActivity = parentActivity as MediaActivity? |
||||||
|
|
||||||
|
player.updateRowRepresentation() |
||||||
|
|
||||||
|
if (!deleteButtonShouldAppear) { |
||||||
|
onRowSelected(0, SimpleRow.NAME) |
||||||
|
} |
||||||
|
|
||||||
|
addComment.setOnClickListener { |
||||||
|
val comment = player.addComment() |
||||||
|
rowRepresentableAdapter.notifyDataSetChanged() |
||||||
|
onRowSelected(-1, comment) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Open picture dialog |
||||||
|
*/ |
||||||
|
private fun openPictureDialog() { |
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(requireContext()) |
||||||
|
|
||||||
|
val placesArray = ArrayList<CharSequence>() |
||||||
|
placesArray.add(getString(R.string.take_a_picture)) |
||||||
|
placesArray.add(getString(R.string.library)) |
||||||
|
placesArray.add(getString(R.string.select_a_color)) |
||||||
|
|
||||||
|
if (player.hasPicture()) { |
||||||
|
placesArray.add(getString(R.string.remove_picture)) |
||||||
|
} |
||||||
|
|
||||||
|
builder.setItems(placesArray.toTypedArray()) { _, which -> |
||||||
|
when (placesArray[which]) { |
||||||
|
getString(R.string.take_a_picture) -> mediaActivity?.openImageCaptureIntent(false) |
||||||
|
getString(R.string.library) -> mediaActivity?.openImageGalleryIntent(false) |
||||||
|
getString(R.string.select_a_color) -> { |
||||||
|
ColorPickerActivity.newInstanceForResult(this, REQUEST_CODE_PICK_COLOR) |
||||||
|
} |
||||||
|
getString(R.string.remove_picture) -> { |
||||||
|
player.updateValue(null, PlayerRow.IMAGE) |
||||||
|
rowRepresentableAdapter.refreshRow(PlayerRow.IMAGE) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
builder.show() |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
override fun onDataSaved() { |
||||||
|
super.onDataSaved() |
||||||
|
player.cleanupComments() |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,92 @@ |
|||||||
|
package net.pokeranalytics.android.ui.view |
||||||
|
|
||||||
|
import io.realm.RealmResults |
||||||
|
import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException |
||||||
|
import net.pokeranalytics.android.util.UserDefaults |
||||||
|
import java.util.* |
||||||
|
import kotlin.collections.ArrayList |
||||||
|
|
||||||
|
/** |
||||||
|
* An container class to describe the way an field of an object will be edited |
||||||
|
*/ |
||||||
|
|
||||||
|
enum class RowEditableDescriptorType { |
||||||
|
DATE, |
||||||
|
DATA, |
||||||
|
STATIC, |
||||||
|
DEFAULT |
||||||
|
} |
||||||
|
|
||||||
|
open class RowEditableDescriptor(var defaultValue: Any? = null, |
||||||
|
var hint: Int? = null, |
||||||
|
var inputType: Int? = null) |
||||||
|
|
||||||
|
class DateRowEditableDescriptor(date: Date? = null, |
||||||
|
val minimumDate: Date? = null, |
||||||
|
var onlyDate: Boolean = false, |
||||||
|
var onlyTime: Boolean = false): RowEditableDescriptor(defaultValue = date) { |
||||||
|
val date: Date? |
||||||
|
get() { |
||||||
|
return defaultValue as Date? |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class DataRowEditableDescriptor( |
||||||
|
defaultValue: Any? = null, |
||||||
|
hint: Int? = null, |
||||||
|
inputType: Int? = null, |
||||||
|
data: RealmResults<*>? = null): RowEditableDescriptor(defaultValue, hint, inputType) { |
||||||
|
|
||||||
|
var data: RealmResults<RowRepresentable>? = null |
||||||
|
|
||||||
|
init { |
||||||
|
if (data != null && data.count() > 0) { |
||||||
|
if (data.first() is RowRepresentable) { |
||||||
|
this.data = data as RealmResults<RowRepresentable>? |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class StaticDataRowEditableDescriptor( |
||||||
|
defaultValue: Any? = null, |
||||||
|
hint: Int? = null, |
||||||
|
inputType: Int? = null, |
||||||
|
var staticData: List<RowRepresentable>? = null): RowEditableDescriptor(defaultValue, hint, inputType) { |
||||||
|
} |
||||||
|
|
||||||
|
class RowEditableDataSource(customCurrency: Currency? = null) { |
||||||
|
var currency: Currency = UserDefaults.currency |
||||||
|
|
||||||
|
init { |
||||||
|
customCurrency?.let { currency = it } |
||||||
|
} |
||||||
|
|
||||||
|
var descriptors = ArrayList<RowEditableDescriptor>() |
||||||
|
|
||||||
|
fun append(defaultValue: Any? = null, hint: Int? = null, inputType: Int? = null, data: RealmResults<*>? = null, staticData: List<RowRepresentable>? = null) { |
||||||
|
when { |
||||||
|
data != null -> descriptors.add(DataRowEditableDescriptor(defaultValue, hint, inputType, data)) |
||||||
|
staticData != null -> descriptors.add(StaticDataRowEditableDescriptor(defaultValue, hint, inputType, staticData)) |
||||||
|
else -> descriptors.add(RowEditableDescriptor(defaultValue, hint, inputType)) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun appendDateDescriptor(date:Date?= null, |
||||||
|
minimumDate: Date? = null, |
||||||
|
onlyDate: Boolean = false, |
||||||
|
onlyTime: Boolean = false) { |
||||||
|
descriptors.add(DateRowEditableDescriptor(date, minimumDate, onlyDate, onlyTime)) |
||||||
|
} |
||||||
|
|
||||||
|
val descriptorType: RowEditableDescriptorType |
||||||
|
get() { |
||||||
|
return when (descriptors.firstOrNull()) { |
||||||
|
null -> throw RowRepresentableEditDescriptorException("RowEditableDescriptor inconsistency") |
||||||
|
is DateRowEditableDescriptor -> RowEditableDescriptorType.DATE |
||||||
|
is DataRowEditableDescriptor -> RowEditableDescriptorType.DATA |
||||||
|
is StaticDataRowEditableDescriptor -> RowEditableDescriptorType.STATIC |
||||||
|
else -> RowEditableDescriptorType.DEFAULT |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,14 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.view |
|
||||||
|
|
||||||
import io.realm.RealmResults |
|
||||||
|
|
||||||
/** |
|
||||||
* An container class to describe the way an field of an object will be edited |
|
||||||
*/ |
|
||||||
class RowRepresentableEditDescriptor( |
|
||||||
var defaultValue: Any? = null, |
|
||||||
var hint: Int? = null, |
|
||||||
var inputType: Int? = null, |
|
||||||
var data: RealmResults<RowRepresentable>? = null, |
|
||||||
var staticData: List<RowRepresentable>? = null |
|
||||||
) |
|
||||||
@ -1,34 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.view.rowrepresentable |
|
||||||
|
|
||||||
import net.pokeranalytics.android.R |
|
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
||||||
import net.pokeranalytics.android.ui.view.RowViewType |
|
||||||
|
|
||||||
/** |
|
||||||
* An enum managing the rows in the more tabs |
|
||||||
*/ |
|
||||||
enum class MoreTabRow : RowRepresentable { |
|
||||||
BANKROLL, |
|
||||||
TOP_10, |
|
||||||
SETTINGS; |
|
||||||
|
|
||||||
override val resId: Int? |
|
||||||
get() { |
|
||||||
return when(this) { |
|
||||||
BANKROLL -> R.string.bankroll |
|
||||||
TOP_10 -> R.string.top_10 |
|
||||||
SETTINGS -> R.string.services |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override val imageRes: Int? |
|
||||||
get() { |
|
||||||
return when(this) { |
|
||||||
BANKROLL -> R.drawable.ic_outline_lock |
|
||||||
TOP_10 -> R.drawable.ic_outline_star |
|
||||||
SETTINGS -> R.drawable.ic_outline_settings |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override val viewType: Int = RowViewType.TITLE_ICON_ARROW.ordinal |
|
||||||
} |
|
||||||
@ -0,0 +1,63 @@ |
|||||||
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
||||||
|
import net.pokeranalytics.android.model.realm.Player |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragment |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragmentType |
||||||
|
import net.pokeranalytics.android.ui.view.RowEditableDataSource |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
|
/** |
||||||
|
* An enum managing the player rows |
||||||
|
*/ |
||||||
|
enum class PlayerRow : RowRepresentable { |
||||||
|
IMAGE, |
||||||
|
NAME, |
||||||
|
SUMMARY; |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
IMAGE -> null |
||||||
|
NAME -> R.string.name |
||||||
|
SUMMARY -> R.string.summary |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
IMAGE -> RowViewType.ROW_PLAYER_IMAGE.ordinal |
||||||
|
NAME -> RowViewType.TITLE_SUBTITLE.ordinal |
||||||
|
SUMMARY -> RowViewType.TITLE_SUBTITLE.ordinal |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val inputFragmentType: InputFragmentType |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
IMAGE -> InputFragmentType.NONE |
||||||
|
NAME -> InputFragmentType.EDIT_TEXT |
||||||
|
SUMMARY -> InputFragmentType.EDIT_TEXT_MULTI_LINES |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun startEditing(dataSource: Any?, parent: Fragment?) { |
||||||
|
if (dataSource == null) return |
||||||
|
if (dataSource !is Player) return |
||||||
|
if (parent == null) return |
||||||
|
if (parent !is RowRepresentableDelegate) return |
||||||
|
val data = RowEditableDataSource() |
||||||
|
when (this) { |
||||||
|
NAME -> data.append(dataSource.name) |
||||||
|
SUMMARY -> data.append(dataSource.summary) |
||||||
|
else -> PokerAnalyticsException.InputFragmentException |
||||||
|
} |
||||||
|
InputFragment.buildAndShow(this, parent, data) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,16 +1,15 @@ |
|||||||
package net.pokeranalytics.android.ui.view.rowrepresentable |
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
import net.pokeranalytics.android.R |
import net.pokeranalytics.android.R |
||||||
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType |
import net.pokeranalytics.android.ui.fragment.components.input.InputFragmentType |
||||||
import net.pokeranalytics.android.ui.view.DefaultEditDataSource |
|
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
import net.pokeranalytics.android.ui.view.RowViewType |
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
|
|
||||||
enum class SimpleRow : RowRepresentable, DefaultEditDataSource { |
enum class SimpleRow : RowRepresentable { |
||||||
NAME; |
NAME; |
||||||
|
|
||||||
override val resId: Int? = R.string.name |
override val resId: Int? = R.string.name |
||||||
override val viewType: Int = RowViewType.TITLE_VALUE.ordinal |
override val viewType: Int = RowViewType.TITLE_VALUE.ordinal |
||||||
override val bottomSheetType: BottomSheetType = BottomSheetType.EDIT_TEXT |
override val inputFragmentType: InputFragmentType = InputFragmentType.EDIT_TEXT |
||||||
} |
} |
||||||
@ -1,6 +1,49 @@ |
|||||||
package net.pokeranalytics.android.ui.view.rowrepresentable |
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
import net.pokeranalytics.android.ui.view.DefaultEditDataSource |
import androidx.fragment.app.Fragment |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.TournamentFeature |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragment |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragmentType |
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowEditableDataSource |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
enum class TournamentFeatureRow : RowRepresentable, DefaultEditDataSource |
enum class TournamentFeatureRow : RowRepresentable { |
||||||
|
NAME; |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
NAME -> R.string.name |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
NAME -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val inputFragmentType: InputFragmentType |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
NAME -> InputFragmentType.EDIT_TEXT |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun startEditing(dataSource: Any?, parent: Fragment?) { |
||||||
|
if (dataSource == null) return |
||||||
|
if (dataSource !is TournamentFeature) return |
||||||
|
if (parent == null) return |
||||||
|
if (parent !is RowRepresentableDelegate) return |
||||||
|
val data = RowEditableDataSource() |
||||||
|
when (this) { |
||||||
|
NAME -> data.append(dataSource.name) |
||||||
|
} |
||||||
|
InputFragment.buildAndShow(this, parent, data) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|||||||
@ -1,6 +1,49 @@ |
|||||||
package net.pokeranalytics.android.ui.view.rowrepresentable |
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
import net.pokeranalytics.android.ui.view.DefaultEditDataSource |
import androidx.fragment.app.Fragment |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.TournamentName |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragment |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.input.InputFragmentType |
||||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowEditableDataSource |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
enum class TournamentNameRow : RowRepresentable, DefaultEditDataSource |
enum class TournamentNameRow : RowRepresentable { |
||||||
|
NAME; |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
NAME -> R.string.name |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
NAME -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val inputFragmentType: InputFragmentType |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
NAME -> InputFragmentType.EDIT_TEXT |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun startEditing(dataSource: Any?, parent: Fragment?) { |
||||||
|
if (dataSource == null) return |
||||||
|
if (dataSource !is TournamentName) return |
||||||
|
if (parent == null) return |
||||||
|
if (parent !is RowRepresentableDelegate) return |
||||||
|
val data = RowEditableDataSource() |
||||||
|
when (this) { |
||||||
|
NAME -> data.append(dataSource.name) |
||||||
|
} |
||||||
|
InputFragment.buildAndShow(this, parent, data) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,377 @@ |
|||||||
|
package net.pokeranalytics.android.util |
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity |
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.graphics.* |
||||||
|
import android.graphics.Paint.FILTER_BITMAP_FLAG |
||||||
|
import android.media.ExifInterface |
||||||
|
import android.net.Uri |
||||||
|
import android.os.Environment |
||||||
|
import androidx.core.content.ContextCompat |
||||||
|
import kotlinx.coroutines.Dispatchers |
||||||
|
import kotlinx.coroutines.GlobalScope |
||||||
|
import kotlinx.coroutines.launch |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import timber.log.Timber |
||||||
|
import java.io.File |
||||||
|
import java.io.FileOutputStream |
||||||
|
import java.io.IOException |
||||||
|
import java.io.InputStream |
||||||
|
import java.text.SimpleDateFormat |
||||||
|
import java.util.* |
||||||
|
|
||||||
|
|
||||||
|
object ImageUtils { |
||||||
|
|
||||||
|
/** |
||||||
|
* Rotate a bitmap if it's necessary (depending of the EXIF data) |
||||||
|
* Some devices don't rotate the picture but instead add the orientation |
||||||
|
* value in the EXIF data. |
||||||
|
* That's why we need sometimes to rotate by ourselves the bitmap |
||||||
|
* |
||||||
|
* @param src The file to check (for getting the Exif data) |
||||||
|
* @param bitmap The bitmap to modify (if necessary) |
||||||
|
* @return The bitmap in the correct orientation |
||||||
|
*/ |
||||||
|
fun rotateBitmap(src: String, bitmap: Bitmap, updateFile: Boolean): Bitmap { |
||||||
|
try { |
||||||
|
val orientation = getExifOrientation(src) |
||||||
|
|
||||||
|
if (orientation == ExifInterface.ORIENTATION_NORMAL) { |
||||||
|
return bitmap |
||||||
|
} |
||||||
|
|
||||||
|
val matrix = Matrix() |
||||||
|
when (orientation) { |
||||||
|
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.setScale(-1f, 1f) |
||||||
|
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.setRotate(180f) |
||||||
|
ExifInterface.ORIENTATION_FLIP_VERTICAL -> { |
||||||
|
matrix.setRotate(180f) |
||||||
|
matrix.postScale(-1f, 1f) |
||||||
|
} |
||||||
|
ExifInterface.ORIENTATION_TRANSPOSE -> { |
||||||
|
matrix.setRotate(90f) |
||||||
|
matrix.postScale(-1f, 1f) |
||||||
|
} |
||||||
|
ExifInterface.ORIENTATION_ROTATE_90 -> matrix.setRotate(90f) |
||||||
|
ExifInterface.ORIENTATION_TRANSVERSE -> { |
||||||
|
matrix.setRotate(-90f) |
||||||
|
matrix.postScale(-1f, 1f) |
||||||
|
} |
||||||
|
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.setRotate(-90f) |
||||||
|
else -> return bitmap |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
val oriented = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true) |
||||||
|
bitmap.recycle() |
||||||
|
if (updateFile) { |
||||||
|
updateFile(src, oriented) |
||||||
|
} |
||||||
|
return oriented |
||||||
|
} catch (e: OutOfMemoryError) { |
||||||
|
e.printStackTrace() |
||||||
|
return bitmap |
||||||
|
} |
||||||
|
|
||||||
|
} catch (e: IOException) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
|
||||||
|
return bitmap |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the Exif orientation value |
||||||
|
* |
||||||
|
* @param filePath The path of the file |
||||||
|
* @return the orientation value |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
@Throws(IOException::class) |
||||||
|
private fun getExifOrientation(filePath: String): Int { |
||||||
|
val exifInterface = ExifInterface(filePath) |
||||||
|
return exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Save a bitmap into a file (& apply 90% compression) |
||||||
|
* |
||||||
|
* @param filePath Path of the file |
||||||
|
* @param bitmap Bitmap to save |
||||||
|
*/ |
||||||
|
fun updateFile(filePath: String, bitmap: Bitmap) { |
||||||
|
var out: FileOutputStream? = null |
||||||
|
try { |
||||||
|
out = FileOutputStream(filePath) |
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out) |
||||||
|
} catch (e: Exception) { |
||||||
|
e.printStackTrace() |
||||||
|
} finally { |
||||||
|
try { |
||||||
|
out?.close() |
||||||
|
} catch (e: IOException) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Resize a file with the given maximum width or height (and keep the ratio!) |
||||||
|
* @param filePath String: File path |
||||||
|
* @param bitmap Bitmap: Image |
||||||
|
* @param maxWidth int: Max width |
||||||
|
* @param maxHeight int: Max height |
||||||
|
*/ |
||||||
|
fun resizeFile(filePath: String, bitmap: Bitmap, maxWidth: Int, maxHeight: Int) { |
||||||
|
var bitmap = bitmap |
||||||
|
|
||||||
|
val options = BitmapFactory.Options() |
||||||
|
options.inJustDecodeBounds = true |
||||||
|
BitmapFactory.decodeFile(filePath, options) |
||||||
|
val imageWidth = options.outWidth |
||||||
|
val imageHeight = options.outHeight |
||||||
|
|
||||||
|
var newWidth: Int |
||||||
|
var newHeight: Int |
||||||
|
|
||||||
|
if (imageWidth > imageHeight) { |
||||||
|
newWidth = maxWidth |
||||||
|
newHeight = imageHeight * maxWidth / imageWidth |
||||||
|
if (newHeight > maxHeight) { |
||||||
|
newHeight = maxHeight |
||||||
|
newWidth = imageWidth * maxHeight / imageHeight |
||||||
|
} |
||||||
|
} else { |
||||||
|
newHeight = maxHeight |
||||||
|
newWidth = imageWidth * maxHeight / imageHeight |
||||||
|
if (newWidth > maxWidth) { |
||||||
|
newWidth = maxWidth |
||||||
|
newHeight = imageHeight * maxWidth / imageWidth |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true) |
||||||
|
updateFile(filePath, bitmap) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a unique temp image file name |
||||||
|
* |
||||||
|
* @return |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
@Throws(IOException::class) |
||||||
|
fun createTempImageFile(context: Context): File { |
||||||
|
// Create an image file name |
||||||
|
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date()) |
||||||
|
val imageFileName = "JPEG_" + timeStamp + "_" |
||||||
|
val storageDir = context.cacheDir |
||||||
|
return File.createTempFile(imageFileName, ".jpg", storageDir) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a unique image file name |
||||||
|
* |
||||||
|
* @return |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
@Throws(IOException::class) |
||||||
|
fun createImageFile(context: Context): File { |
||||||
|
// Create an image file name |
||||||
|
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date()) |
||||||
|
val imageFileName = "JPEG_" + timeStamp + "_" |
||||||
|
|
||||||
|
val storage = ContextCompat.getExternalFilesDirs(context, Environment.DIRECTORY_PICTURES) |
||||||
|
val storageDir = if (storage.isNotEmpty()) storage.first() else Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) |
||||||
|
|
||||||
|
val appStorageDir = File(storageDir.path + "/" + context.getString(R.string.app_name)) |
||||||
|
if (!appStorageDir.exists()) { |
||||||
|
appStorageDir.mkdirs() |
||||||
|
} |
||||||
|
|
||||||
|
return File.createTempFile(imageFileName, ".jpg", appStorageDir) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Decode sample Bitmap |
||||||
|
* |
||||||
|
* @param filePath The bitmap file path |
||||||
|
* @param reqWidth Max width required |
||||||
|
* @param reqHeight Max height required |
||||||
|
* @return The sampled bitmap |
||||||
|
*/ |
||||||
|
fun decodeSampledBitmapFromFile(filePath: String, reqWidth: Int, reqHeight: Int): Bitmap { |
||||||
|
|
||||||
|
// First decode with inJustDecodeBounds=true to check dimensions |
||||||
|
val options = BitmapFactory.Options() |
||||||
|
options.inJustDecodeBounds = true |
||||||
|
BitmapFactory.decodeFile(filePath, options) |
||||||
|
|
||||||
|
// Calculate inSampleSize |
||||||
|
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight) |
||||||
|
|
||||||
|
// Decode bitmap with inSampleSize set |
||||||
|
options.inJustDecodeBounds = false |
||||||
|
return BitmapFactory.decodeFile(filePath, options) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Calculate the sample size |
||||||
|
*/ |
||||||
|
fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, |
||||||
|
reqHeight: Int): Int { |
||||||
|
// Raw height and width of image |
||||||
|
val height = options.outHeight |
||||||
|
val width = options.outWidth |
||||||
|
var inSampleSize = 1 |
||||||
|
|
||||||
|
if (height > reqHeight || width > reqWidth) { |
||||||
|
|
||||||
|
val halfHeight = height / 2 |
||||||
|
val halfWidth = width / 2 |
||||||
|
|
||||||
|
// Calculate the largest inSampleSize value that is a power of 2 and keeps both |
||||||
|
// height and width larger than the requested height and width. |
||||||
|
while (halfHeight / inSampleSize > reqHeight && halfWidth / inSampleSize > reqWidth) { |
||||||
|
inSampleSize *= 2 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return inSampleSize |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Copy an input stream inside a file |
||||||
|
* |
||||||
|
* @param in Input Stream |
||||||
|
* @param file Destination file |
||||||
|
*/ |
||||||
|
fun copyInputStreamToFile(inputStream: InputStream, file: File) { |
||||||
|
try { |
||||||
|
val out = FileOutputStream(file) |
||||||
|
val buf = ByteArray(4096) |
||||||
|
var len = 0 |
||||||
|
while ({ len = inputStream.read(buf); len }() > 0) { |
||||||
|
out.write(buf, 0, len) |
||||||
|
} |
||||||
|
|
||||||
|
out.close() |
||||||
|
inputStream.close() |
||||||
|
} catch (e: Exception) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update the gallery with the current file |
||||||
|
* |
||||||
|
* @param context Context |
||||||
|
* @param filePath The file to add |
||||||
|
*/ |
||||||
|
fun updateGallery(context: Context, filePath: String) { |
||||||
|
val mediaScanIntent = Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE) |
||||||
|
val f = File(filePath) |
||||||
|
val contentUri = Uri.fromFile(f) |
||||||
|
mediaScanIntent.data = contentUri |
||||||
|
context.sendBroadcast(mediaScanIntent) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Save the bitmap in a file |
||||||
|
*/ |
||||||
|
fun saveBitmapInFile(context: Context, bitmap: Bitmap, filename: String, action: (filePath: String) -> Unit) { |
||||||
|
|
||||||
|
GlobalScope.launch { |
||||||
|
|
||||||
|
val outputFile = File(context.filesDir, filename) |
||||||
|
|
||||||
|
var out: FileOutputStream? = null |
||||||
|
try { |
||||||
|
out = FileOutputStream(outputFile.absolutePath) |
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out) // bmp is your Bitmap instance |
||||||
|
} catch (e: Exception) { |
||||||
|
e.printStackTrace() |
||||||
|
} finally { |
||||||
|
try { |
||||||
|
if (out != null) { |
||||||
|
out.close() |
||||||
|
} |
||||||
|
} catch (e: IOException) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
GlobalScope.launch(Dispatchers.Main) { |
||||||
|
Timber.d("Save file here: ${outputFile.absolutePath}") |
||||||
|
action(outputFile.absolutePath) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Bitmap resizer |
||||||
|
*/ |
||||||
|
fun bitmapResizer(bitmap: Bitmap, newWidth: Int, newHeight: Int): Bitmap { |
||||||
|
val scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888) |
||||||
|
|
||||||
|
val ratioX = newWidth / bitmap.width.toFloat() |
||||||
|
val ratioY = newHeight / bitmap.height.toFloat() |
||||||
|
val middleX = newWidth / 2.0f |
||||||
|
val middleY = newHeight / 2.0f |
||||||
|
|
||||||
|
val scaleMatrix = Matrix() |
||||||
|
scaleMatrix.setScale(ratioX, ratioY, middleX, middleY) |
||||||
|
|
||||||
|
val canvas = Canvas(scaledBitmap) |
||||||
|
canvas.matrix = scaleMatrix |
||||||
|
canvas.drawBitmap(bitmap, middleX - bitmap.width / 2, middleY - bitmap.height / 2, Paint(FILTER_BITMAP_FLAG)) |
||||||
|
|
||||||
|
return scaledBitmap |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Export a bitmap |
||||||
|
*/ |
||||||
|
private fun exportFile(context: Activity, bitmap: Bitmap) { |
||||||
|
/* |
||||||
|
val outputFile = File.createTempFile("test_export", ".jpg", context.cacheDir) |
||||||
|
|
||||||
|
var out: FileOutputStream? = null |
||||||
|
try { |
||||||
|
out = FileOutputStream(outputFile.absolutePath) |
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out) |
||||||
|
} catch (e: Exception) { |
||||||
|
e.printStackTrace() |
||||||
|
} finally { |
||||||
|
try { |
||||||
|
if (out != null) { |
||||||
|
out.close() |
||||||
|
} |
||||||
|
} catch (e: IOException) { |
||||||
|
e.printStackTrace() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
val uri = FileProvider.getUriForFile(context, |
||||||
|
context.packageName + ".provider", outputFile) |
||||||
|
|
||||||
|
val shareIntent = ShareCompat.IntentBuilder.from(context) |
||||||
|
.setType("image/jpg") |
||||||
|
.setSubject(context.getString(R.string.share_file_name)) |
||||||
|
.setStream(uri) |
||||||
|
.setChooserTitle(context.getString(R.string.share_title)) |
||||||
|
.createChooserIntent() |
||||||
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) |
||||||
|
|
||||||
|
context.startActivity(shareIntent) |
||||||
|
*/ |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,36 +0,0 @@ |
|||||||
package net.pokeranalytics.android.util |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import java.util.* |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LocaleUtils { |
|
||||||
|
|
||||||
companion object { |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the current locale |
|
||||||
*/ |
|
||||||
fun getCurrentLocale(context: Context) : Locale { |
|
||||||
val defaultLocaleCode = Preferences.getString(Preferences.Keys.LOCALE_CODE, context) |
|
||||||
var locale = Locale.getDefault() |
|
||||||
if (defaultLocaleCode != null) { |
|
||||||
locale = Locale(defaultLocaleCode) |
|
||||||
Locale.setDefault(locale) |
|
||||||
} |
|
||||||
return locale |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
*/ |
|
||||||
fun setCurrentLocale(context: Context, language: String) { |
|
||||||
Preferences.setString(Preferences.Keys.LOCALE_CODE, language, context) |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,15 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_1" /> |
||||||
|
|
||||||
|
<stroke |
||||||
|
android:color="@color/gray" |
||||||
|
android:width="1dp" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_2" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_3" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_4" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_5" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_6" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_7" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_8" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="@color/player_color_9" /> |
||||||
|
|
||||||
|
<size |
||||||
|
android:width="48dp" |
||||||
|
android:height="48dp" /> |
||||||
|
|
||||||
|
</shape> |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue