Skip to content

Commit

Permalink
Update libraries an merge request
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian011494 committed May 7, 2020
1 parent c85a268 commit 5f9d3f0
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 40 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ implementation 'com.github.Z17-CU:apklisupdate:$VERSION'

override fun onNewUpdate(appUpdateInfo: AppUpdateInfo) {

//Start info alert dialog or do what you want.
ApklisUpdateDialog(
this@MainActivity,
appUpdateInfo,
ContextCompat.getColor(
this@MainActivity,
R.color.colorAccent)
).show()

//Start info fragment or do what you want.
supportFragmentManager.beginTransaction().add(
R.id.container, ApklisUpdateFragment.newInstance(
Expand Down
26 changes: 13 additions & 13 deletions apklisupdate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ group='com.github.adrian011494'


android {
compileSdkVersion 28
compileSdkVersion 29



defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
versionCode 2
versionName "1.1"

Expand Down Expand Up @@ -61,11 +61,11 @@ afterEvaluate {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'org.mockito:mockito-core:2.4.5'
testImplementation 'org.mockito:mockito-core:2.23.0'


implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
Expand All @@ -76,20 +76,20 @@ dependencies {
testImplementation 'org.amshove.kluent:kluent:1.14'

/**Retrofit**/
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:4.5.0'
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'

/** rx java **/
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.8.1'

implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.palette:palette:1.0.0'

//html
implementation 'org.sufficientlysecure:html-textview:3.6'
implementation 'org.sufficientlysecure:html-textview:3.9'
implementation 'com.squareup.picasso:picasso:2.71828'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cu.uci.apklisupdate.base
import cu.uci.apklisupdate.BuildConfig
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
Expand Down Expand Up @@ -33,12 +34,14 @@ abstract class RestClient<T>(
init {


val userAgentInterceptor = Interceptor { chain ->
val original = chain.request()
val requestBuilder = original.newBuilder()
.header("User-Agent", BuildConfig.APPLICATION_ID)
val request = requestBuilder.build()
return@Interceptor chain.proceed(request)
val userAgentInterceptor = object : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val original = chain.request()
val requestBuilder = original.newBuilder()
.header("User-Agent", BuildConfig.APPLICATION_ID)
val request = requestBuilder.build()
return chain.proceed(request)
}
}

mOkHttpClient = OkHttpClient().newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.google.android.material.button.MaterialButton
import com.squareup.picasso.Picasso
import cu.uci.apklisupdate.R
import cu.uci.apklisupdate.model.AppUpdateInfo
import kotlinx.android.synthetic.main.apklis_dialog_update.*
import org.sufficientlysecure.htmltextview.HtmlTextView

class ApklisUpdateDialog(
Expand All @@ -25,27 +26,26 @@ class ApklisUpdateDialog(
super.onCreate(savedInstanceState)
setContentView(R.layout.apklis_dialog_update)

findViewById<HtmlTextView>(R.id.changelog).setHtml("${context.getString(R.string.changelog)}\n${updateInfo.last_release.changelog}")
findViewById<TextView>(R.id.version).text = updateInfo.last_release.version_name
findViewById<TextView>(R.id.title).text = updateInfo.name
findViewById<MaterialButton>(R.id.fromApklis).setOnClickListener {
changelog.setHtml("${context.getString(R.string.changelog)}\n${updateInfo.last_release.changelog}")
version.text = updateInfo.last_release.version_name
title.text = updateInfo.name
fromApklis.setOnClickListener {
val i = Intent(Intent.ACTION_VIEW)
i.data =
Uri.parse("https://www.apklis.cu/es/application/${updateInfo.package_name}/latest")
context.startActivity(Intent.createChooser(i, context.getString(R.string.open_web)))
}

findViewById<MaterialButton>(R.id.download).setOnClickListener {
download.setOnClickListener {
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(updateInfo.last_release.apk_file)
context.startActivity(Intent.createChooser(i, context.getString(R.string.download)))
}

Picasso.get().load(updateInfo.last_release.icon).into(findViewById<AppCompatImageView>(R.id.logo))

findViewById<MaterialButton>(R.id.fromApklis).setTextColor(actionsColor)
findViewById<MaterialButton>(R.id.download).setTextColor(actionsColor)
Picasso.get().load(updateInfo.last_release.icon).into(logo)

fromApklis.setTextColor(actionsColor)
download.setTextColor(actionsColor)
}

}
16 changes: 10 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "cu.uci.ejemploapklis"
minSdkVersion 15
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -20,15 +20,19 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.palette:palette:1.0.0'
implementation project(':apklisupdate')
}
13 changes: 7 additions & 6 deletions app/src/main/java/cu/uci/ejemploapklis/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.core.content.ContextCompat
import cu.uci.apklisupdate.ApklisUpdate
import cu.uci.apklisupdate.UpdateCallback
import cu.uci.apklisupdate.model.AppUpdateInfo
import cu.uci.apklisupdate.view.ApklisUpdateDialog
import cu.uci.apklisupdate.view.ApklisUpdateFragment

class MainActivity : AppCompatActivity() {
Expand All @@ -30,12 +31,12 @@ class MainActivity : AppCompatActivity() {
).show()

//Start info fragment or do what you want.
//supportFragmentManager.beginTransaction().add(
// R.id.container, ApklisUpdateFragment.newInstance(
// updateInfo = appUpdateInfo,
// actionsColor = ContextCompat.getColor(this@MainActivity, R.color.colorAccent)
// )
//).commit()
supportFragmentManager.beginTransaction().add(
R.id.container, ApklisUpdateFragment.newInstance(
updateInfo = appUpdateInfo,
actionsColor = ContextCompat.getColor(this@MainActivity, R.color.colorAccent)
)
).commit()

}

Expand Down

0 comments on commit 5f9d3f0

Please sign in to comment.