Merge branch 'RetroMusicPlayer:dev' into 1216-add-option-to-clear-history
This commit is contained in:
commit
55dd275e9d
11 changed files with 204 additions and 24 deletions
|
@ -182,6 +182,15 @@
|
||||||
android:value=".activities.MainActivity" />
|
android:value=".activities.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activities.ErrorActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="cat.ereza.customactivityoncrash.RESTART" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name=".misc.GenericFileProvider"
|
android:name=".misc.GenericFileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
|
|
|
@ -16,9 +16,11 @@ package code.name.monkey.retromusic
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import cat.ereza.customactivityoncrash.config.CaocConfig
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.Constants.PRO_VERSION_PRODUCT_ID
|
import code.name.monkey.retromusic.Constants.PRO_VERSION_PRODUCT_ID
|
||||||
|
import code.name.monkey.retromusic.activities.ErrorActivity
|
||||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||||
import code.name.monkey.retromusic.helper.WallpaperAccentManager
|
import code.name.monkey.retromusic.helper.WallpaperAccentManager
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
|
@ -69,6 +71,9 @@ class App : Application() {
|
||||||
|
|
||||||
override fun onBillingInitialized() {}
|
override fun onBillingInitialized() {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// setting Error activity
|
||||||
|
CaocConfig.Builder.create().errorActivity(ErrorActivity::class.java).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTerminate() {
|
override fun onTerminate() {
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.ImageView
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.util.FileUtils.createFile
|
||||||
|
import code.name.monkey.retromusic.util.Share.shareFile
|
||||||
|
import java.text.DateFormat
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ErrorActivity : AppCompatActivity() {
|
||||||
|
private val dayFormat: DateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
|
private val ReportPrefix = "bug_report-"
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.customactivityoncrash_default_error_activity)
|
||||||
|
|
||||||
|
val restartButton =
|
||||||
|
findViewById<Button>(R.id.customactivityoncrash_error_activity_restart_button)
|
||||||
|
|
||||||
|
val config = CustomActivityOnCrash.getConfigFromIntent(intent)
|
||||||
|
if (config == null) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app)
|
||||||
|
restartButton.setOnClickListener {
|
||||||
|
CustomActivityOnCrash.restartApplication(
|
||||||
|
this@ErrorActivity,
|
||||||
|
config
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val moreInfoButton =
|
||||||
|
findViewById<Button>(R.id.customactivityoncrash_error_activity_more_info_button)
|
||||||
|
|
||||||
|
moreInfoButton.setOnClickListener { //We retrieve all the error data and show it
|
||||||
|
AlertDialog.Builder(this@ErrorActivity)
|
||||||
|
.setTitle(R.string.customactivityoncrash_error_activity_error_details_title)
|
||||||
|
.setMessage(
|
||||||
|
CustomActivityOnCrash.getAllErrorDetailsFromIntent(
|
||||||
|
this@ErrorActivity,
|
||||||
|
intent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setPositiveButton(
|
||||||
|
R.string.customactivityoncrash_error_activity_error_details_close,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
.setNeutralButton(
|
||||||
|
R.string.customactivityoncrash_error_activity_error_details_share
|
||||||
|
) { dialog, which ->
|
||||||
|
|
||||||
|
val bugReport = createFile(
|
||||||
|
context = this,
|
||||||
|
"Bug Report",
|
||||||
|
"$ReportPrefix${dayFormat.format(Date())}",
|
||||||
|
CustomActivityOnCrash.getAllErrorDetailsFromIntent(
|
||||||
|
this@ErrorActivity,
|
||||||
|
intent
|
||||||
|
), ".txt"
|
||||||
|
)
|
||||||
|
shareFile(this, bugReport)
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
val errorActivityDrawableId = config.errorDrawable
|
||||||
|
val errorImageView =
|
||||||
|
findViewById<ImageView>(R.id.customactivityoncrash_error_activity_image)
|
||||||
|
if (errorActivityDrawableId != null) {
|
||||||
|
errorImageView.setImageResource(
|
||||||
|
errorActivityDrawableId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -109,4 +109,9 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
private fun hasAudioPermission(): Boolean {
|
private fun hasAudioPermission(): Boolean {
|
||||||
return Settings.System.canWrite(this)
|
return Settings.System.canWrite(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
super.onBackPressed()
|
||||||
|
finishAffinity()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@ package code.name.monkey.retromusic.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.util.Log
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
|
||||||
object FileUtils {
|
object FileUtils {
|
||||||
fun copyFileToUri(context: Context, fromFile: File, toUri: Uri) {
|
fun copyFileToUri(context: Context, fromFile: File, toUri: Uri) {
|
||||||
|
@ -13,4 +16,45 @@ object FileUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a new file in storage in app specific directory.
|
||||||
|
*
|
||||||
|
* @return the file
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
fun createFile(context: Context, directoryName: String, fileName: String, body: String, fileType: String): File {
|
||||||
|
val root = createDirectory(context, directoryName)
|
||||||
|
val filePath = "$root/$fileName$fileType"
|
||||||
|
val file = File(filePath)
|
||||||
|
|
||||||
|
// create file if not exist
|
||||||
|
if (!file.exists()) {
|
||||||
|
try {
|
||||||
|
// create a new file and write text in it.
|
||||||
|
file.createNewFile()
|
||||||
|
file.writeText(body)
|
||||||
|
Log.d(FileUtils::class.java.name, "File has been created and saved")
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.d(FileUtils::class.java.name, e.message.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a new directory in storage in app specific directory.
|
||||||
|
*
|
||||||
|
* @return the file
|
||||||
|
*/
|
||||||
|
private fun createDirectory(context: Context, directoryName: String): File {
|
||||||
|
val file = File(
|
||||||
|
context.getExternalFilesDir(directoryName)
|
||||||
|
.toString()
|
||||||
|
)
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdir()
|
||||||
|
}
|
||||||
|
return file
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,8 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 2020-02-02.
|
* Created by hemanths on 2020-02-02.
|
||||||
|
@ -30,4 +32,16 @@ object Share {
|
||||||
feedIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
feedIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
ActivityCompat.startActivity(context, feedIntent, null)
|
ActivityCompat.startActivity(context, feedIntent, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun shareFile(context: Context, file: File) {
|
||||||
|
val attachmentUri = FileProvider.getUriForFile(
|
||||||
|
context,
|
||||||
|
context.applicationContext.packageName,
|
||||||
|
file
|
||||||
|
)
|
||||||
|
val sharingIntent = Intent(Intent.ACTION_SEND)
|
||||||
|
sharingIntent.type = "text/*"
|
||||||
|
sharingIntent.putExtra(Intent.EXTRA_STREAM, attachmentUri)
|
||||||
|
context.startActivity(Intent.createChooser(sharingIntent, "send bug report"))
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -29,13 +29,25 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/appNameText" />
|
app:layout_constraintTop_toBottomOf="@id/appNameText" />
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.PermissionItem
|
<ScrollView
|
||||||
android:id="@+id/storagePermission"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:fillViewport="true"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/finish"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/divider"
|
app:layout_constraintTop_toBottomOf="@+id/divider">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="@integer/permission_orientation">
|
||||||
|
|
||||||
|
<code.name.monkey.retromusic.views.PermissionItem
|
||||||
|
android:id="@+id/storagePermission"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="@integer/permission_layout_weight"
|
||||||
app:permissionButtonTitle="Grant access"
|
app:permissionButtonTitle="Grant access"
|
||||||
app:permissionIcon="@drawable/ic_sd_storage"
|
app:permissionIcon="@drawable/ic_sd_storage"
|
||||||
app:permissionTitle="@string/permission_title"
|
app:permissionTitle="@string/permission_title"
|
||||||
|
@ -44,18 +56,19 @@
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.PermissionItem
|
<code.name.monkey.retromusic.views.PermissionItem
|
||||||
android:id="@+id/audioPermission"
|
android:id="@+id/audioPermission"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_weight="@integer/permission_layout_weight"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/storagePermission"
|
|
||||||
app:permissionButtonTitle="Grant access"
|
app:permissionButtonTitle="Grant access"
|
||||||
app:permissionIcon="@drawable/ic_phonelink_ring"
|
app:permissionIcon="@drawable/ic_phonelink_ring"
|
||||||
app:permissionTitle="@string/ringtone_title"
|
app:permissionTitle="@string/ringtone_title"
|
||||||
app:permissionTitleNumber="2"
|
app:permissionTitleNumber="2"
|
||||||
app:permissionTitleSubTitle="@string/ringtone_summary"
|
app:permissionTitleSubTitle="@string/ringtone_summary"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/finish"
|
android:id="@+id/finish"
|
||||||
|
|
5
app/src/main/res/values-land/integers.xml
Normal file
5
app/src/main/res/values-land/integers.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="permission_orientation">0</integer>
|
||||||
|
<integer name="permission_layout_weight">1</integer>
|
||||||
|
</resources>
|
|
@ -8,4 +8,6 @@
|
||||||
|
|
||||||
<integer name="max_columns">6</integer>
|
<integer name="max_columns">6</integer>
|
||||||
<integer name="max_columns_land">8</integer>
|
<integer name="max_columns_land">8</integer>
|
||||||
|
<integer name="permission_orientation">1</integer>
|
||||||
|
<integer name="permission_layout_weight">1</integer>
|
||||||
</resources>
|
</resources>
|
|
@ -10,4 +10,6 @@
|
||||||
<integer name="max_columns_land">6</integer>
|
<integer name="max_columns_land">6</integer>
|
||||||
|
|
||||||
<integer name="anim_duration_medium">200</integer>
|
<integer name="anim_duration_medium">200</integer>
|
||||||
|
<integer name="permission_orientation">1</integer>
|
||||||
|
<integer name="permission_layout_weight">0</integer>
|
||||||
</resources>
|
</resources>
|
|
@ -543,4 +543,5 @@
|
||||||
<string name="you_have_to_select_at_least_one_category">You have to select at least one category.</string>
|
<string name="you_have_to_select_at_least_one_category">You have to select at least one category.</string>
|
||||||
<string name="you_will_be_forwarded_to_the_issue_tracker_website">You will be forwarded to the issue tracker website.</string>
|
<string name="you_will_be_forwarded_to_the_issue_tracker_website">You will be forwarded to the issue tracker website.</string>
|
||||||
<string name="your_account_data_is_only_used_for_authentication">Your account data is only used for authentication.</string>
|
<string name="your_account_data_is_only_used_for_authentication">Your account data is only used for authentication.</string>
|
||||||
|
<string name="customactivityoncrash_error_activity_error_details_share">Share Crash Report</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue