Skip to content

Commit

Permalink
add privacy policy
Browse files Browse the repository at this point in the history
  • Loading branch information
leolin310148 committed Sep 7, 2017
1 parent ffae08d commit 0bf4e30
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 63 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ android {
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "me.leolin.isbadgeworking"
minSdkVersion 15
minSdkVersion 19
targetSdkVersion 25
versionCode 5
versionCode 6
versionName "${new Date().format("yyyyMMddHHmmss")}"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
126 changes: 65 additions & 61 deletions app/src/main/kotlin/me/leolin/isbadgeworking/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.Button
import android.widget.ListView
import android.widget.TextView
import android.widget.*
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import me.leolin.api.IsBadgeWorkingApi
import me.leolin.api.ReportBadgeWorkingRequest
import me.leolin.shortcutbadger.ShortcutBadger
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.find
import org.jetbrains.anko.indeterminateProgressDialog
import org.jetbrains.anko.toast
import org.jetbrains.anko.*
import retrofit2.Retrofit
import retrofit2.converter.jackson.JacksonConverterFactory
import java.util.*
Expand All @@ -33,21 +27,17 @@ class MainActivity : AppCompatActivity() {

val isBadgeWorkingApi by lazy {
Retrofit.Builder()
.baseUrl(if (Build.VERSION.SDK_INT >= 19) {
"https://api.leolin.me/is-badge-working/"
} else {
"http://api.leolin.me/is-badge-working/"
})
.addConverterFactory(JacksonConverterFactory.create(jacksonObjectMapper()))
.client(
OkHttpClient().newBuilder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY })
.build()
)
.build()
.create(IsBadgeWorkingApi::class.java)
.baseUrl("https://api.leolin.me/is-badge-working/")
.addConverterFactory(JacksonConverterFactory.create(jacksonObjectMapper()))
.client(
OkHttpClient().newBuilder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY })
.build()
)
.build()
.create(IsBadgeWorkingApi::class.java)
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -73,61 +63,75 @@ class MainActivity : AppCompatActivity() {
val packageInfo = packageManager.getPackageInfo(currentHomePackage, PackageManager.GET_ACTIVITIES)

val req = ReportBadgeWorkingRequest(
Build.SERIAL,
Build.MODEL,
Build.MANUFACTURER,
BuildConfig.SHORTCUTBADGER_VERSION,
Build.VERSION.RELEASE,
currentHomePackage,
packageInfo.versionName,
packageInfo.versionCode.toString(),
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE.toString(),
working
Build.SERIAL,
Build.MODEL,
Build.MANUFACTURER,
BuildConfig.SHORTCUTBADGER_VERSION,
Build.VERSION.RELEASE,
currentHomePackage,
packageInfo.versionName,
packageInfo.versionCode.toString(),
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE.toString(),
working
)

find<ListView>(R.id.listView).adapter = ListAdapter(
listOf(
DisplayData("Launcher", "${req.launcherPackage} \n${req.launcherVersionCode} / ${req.launcherVersionName}"),
DisplayData("Device", "${req.deviceBrand} / ${req.deviceModel}"),
DisplayData("Android", "${req.androidVersion}"),
DisplayData("ShortcutBadger", req.shortcutBadgerVersion),
DisplayData("This App", "${req.reportAppVersionCode} / ${req.reportAppVersionName}")
),
layoutInflater
listOf(
DisplayData("Launcher", "${req.launcherPackage} \n${req.launcherVersionCode} / ${req.launcherVersionName}"),
DisplayData("Device", "${req.deviceBrand} / ${req.deviceModel}"),
DisplayData("Android", "${req.androidVersion}"),
DisplayData("ShortcutBadger", req.shortcutBadgerVersion),
DisplayData("This App", "${req.reportAppVersionCode} / ${req.reportAppVersionName}")
),
layoutInflater
)


if (send) {
val dialog = indeterminateProgressDialog("Sending...") { show() }
doAsync {
try {
isBadgeWorkingApi.sendReport(req).execute().apply {
runOnUiThread {
dialog.dismiss()
if (code() == 200) {
toast("Thank you!")
} else {
toast("Hmm..something wrong, please try later.")
}
}
}
} catch(e: Exception) {
Log.e("err", e.message, e)
alert("""
Due to Google Play policy, we need your acceptation to let us collect device data.
The request payload below will be collect to IsBadgeWorking Server and will only be used for improving the open source project `ShortcutBadger`.
${jacksonObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(req)}
By clicking `Agree`, we will start to send the data above to IsBadgeWorking Server.
""".trimIndent(),
"Allowing us to collect privacy data") {
positiveButton("Agree", { doSend(req) })
negativeButton("Cancel", {})
}.show()
}
}

private fun doSend(req: ReportBadgeWorkingRequest) {
val dialog = indeterminateProgressDialog("Sending...") { show() }
doAsync {
try {
isBadgeWorkingApi.sendReport(req).execute().apply {
runOnUiThread {
dialog.dismiss()
toast("Hmm..something wrong, please try later.")
if (code() == 200) {
toast("Thank you!")
} else {
toast("Hmm..something wrong, please try later.")
}
}
}

} catch (e: Exception) {
Log.e("err", e.message, e)
runOnUiThread {
dialog.dismiss()
toast("Hmm..something wrong, please try later.")
}
}

}
}


data class DisplayData(
val label: String,
val value: String
val label: String,
val value: String
)

inner class ListAdapter(val displayDataList: List<DisplayData>, val layoutInflater: LayoutInflater) : BaseAdapter() {
Expand Down
9 changes: 9 additions & 0 deletions privacy-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
All apps provided by this developer, leolin310148, on Google Play are subject to the following privacy policy:

When you use the APP function, we will regard the nature of the service function, you provide the necessary APP system permissions, and within the scope of the specific purpose of handling and use of your personal information; this APP will not use personal data for other purposes . I will not automatically record any action on any server, including the IP address of the device you are using, the time of use, the browser you are using, browsing, and clicking on data records.

This APP's other third party APP's web link does not apply to the privacy policy of this site, you must refer to the privacy policy in the link site.

The APP will never provide, exchange, rent or sell any of your personal information to other individuals, groups, private enterprises or public authorities.

The privacy policy of this site will be amended at any time in accordance with the needs, the revised terms will be published on the website.

0 comments on commit 0bf4e30

Please sign in to comment.