|
|
|
@ -11,6 +11,7 @@ import androidx.appcompat.app.AlertDialog |
|
|
|
import androidx.appcompat.widget.AppCompatTextView |
|
|
|
import androidx.appcompat.widget.AppCompatTextView |
|
|
|
import androidx.browser.customtabs.CustomTabsIntent |
|
|
|
import androidx.browser.customtabs.CustomTabsIntent |
|
|
|
import androidx.core.content.ContextCompat |
|
|
|
import androidx.core.content.ContextCompat |
|
|
|
|
|
|
|
import androidx.core.content.FileProvider |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import net.pokeranalytics.android.BuildConfig |
|
|
|
import net.pokeranalytics.android.BuildConfig |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
@ -19,6 +20,11 @@ import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import net.pokeranalytics.android.util.DeviceUtils |
|
|
|
import net.pokeranalytics.android.util.DeviceUtils |
|
|
|
import net.pokeranalytics.android.util.URL |
|
|
|
import net.pokeranalytics.android.util.URL |
|
|
|
|
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sizes |
|
|
|
// Sizes |
|
|
|
@ -63,20 +69,33 @@ fun PokerAnalyticsActivity.openPlayStorePage() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Open email for "Contact us" |
|
|
|
// Open email for "Contact us" |
|
|
|
fun PokerAnalyticsActivity.openContactMail(subjectStringRes: Int) { |
|
|
|
fun PokerAnalyticsActivity.openContactMail(subjectStringRes: Int, filePath: String?= null) { |
|
|
|
val info = "v${BuildConfig.VERSION_NAME}(${BuildConfig.VERSION_CODE}), Android ${android.os.Build.VERSION.SDK_INT}, ${DeviceUtils.getDeviceName()}" |
|
|
|
val info = "v${BuildConfig.VERSION_NAME}(${BuildConfig.VERSION_CODE}), Android ${android.os.Build.VERSION.SDK_INT}, ${DeviceUtils.getDeviceName()}" |
|
|
|
val intent = Intent(Intent.ACTION_SENDTO) |
|
|
|
|
|
|
|
intent.data = Uri.parse("mailto:${URL.SUPPORT_EMAIL.value}") |
|
|
|
val emailIntent = Intent(Intent.ACTION_SEND) |
|
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, getString(subjectStringRes)) |
|
|
|
|
|
|
|
intent.putExtra(Intent.EXTRA_EMAIL, URL.SUPPORT_EMAIL.value) |
|
|
|
filePath?.let { |
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, "\n\n$info") |
|
|
|
val databaseFile = File(it) |
|
|
|
startActivity(Intent.createChooser(intent, getString(R.string.contact))) |
|
|
|
val contentUri = FileProvider.getUriForFile(this, "net.pokeranalytics.android.fileprovider", databaseFile) |
|
|
|
|
|
|
|
if (contentUri != null) { |
|
|
|
|
|
|
|
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) |
|
|
|
|
|
|
|
emailIntent.setDataAndType(contentUri, contentResolver.getType(contentUri)) |
|
|
|
|
|
|
|
emailIntent.putExtra(Intent.EXTRA_STREAM, contentUri) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emailIntent.type = "message/rfc822" |
|
|
|
|
|
|
|
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(subjectStringRes)) |
|
|
|
|
|
|
|
emailIntent.putExtra(Intent.EXTRA_TEXT, "\n\n$info") |
|
|
|
|
|
|
|
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(URL.SUPPORT_EMAIL.value)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startActivity(Intent.createChooser(emailIntent, getString(R.string.contact))) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Open custom tab |
|
|
|
// Open custom tab |
|
|
|
fun PokerAnalyticsActivity.openUrl(url: String) { |
|
|
|
fun PokerAnalyticsActivity.openUrl(url: String) { |
|
|
|
val builder: CustomTabsIntent.Builder = CustomTabsIntent.Builder() |
|
|
|
val builder: CustomTabsIntent.Builder = CustomTabsIntent.Builder() |
|
|
|
builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary)) |
|
|
|
builder.setToolbarColor(ContextCompat.getColor(this, net.pokeranalytics.android.R.color.colorPrimary)) |
|
|
|
val customTabsIntent = builder.build() |
|
|
|
val customTabsIntent = builder.build() |
|
|
|
customTabsIntent.launchUrl(this, Uri.parse(url)) |
|
|
|
customTabsIntent.launchUrl(this, Uri.parse(url)) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -102,7 +121,7 @@ fun showAlertDialog(context: Context, title: Int? = null, message: Int? = null) |
|
|
|
message?.let { |
|
|
|
message?.let { |
|
|
|
builder.setMessage(message) |
|
|
|
builder.setMessage(message) |
|
|
|
} |
|
|
|
} |
|
|
|
builder.setPositiveButton(R.string.ok, null) |
|
|
|
builder.setPositiveButton(net.pokeranalytics.android.R.string.ok, null) |
|
|
|
builder.show() |
|
|
|
builder.show() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|