Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update README. #2

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4e7d7ac
various improvements
lesclaz Apr 6, 2024
f3442bb
Merge pull request #2 from suitetecsa/fixes
Apr 7, 2024
38f3537
update README and version lib
Apr 7, 2024
be9a0c3
Create LICENSE
Apr 10, 2024
1641de0
Add renovate.json
renovate[bot] May 2, 2024
2bc5abf
Merge pull request #3 from m4gen/renovate/configure
May 4, 2024
c6929e3
Update actions/checkout action to v4.1.4
renovate[bot] May 4, 2024
af2593c
Merge pull request #4 from m4gen/renovate/actions-checkout-4.x
May 4, 2024
0bfd286
Update dependency io.reactivex.rxjava3:rxjava to v3.1.8
renovate[bot] May 4, 2024
6c8b4fb
Update dependency com.squareup.okhttp3:mockwebserver to v4.12.0
renovate[bot] May 4, 2024
091f855
Update dependency com.squareup.retrofit2:adapter-rxjava3 to v2.11.0
renovate[bot] May 4, 2024
e62ee2b
Update dependency com.squareup.retrofit2:converter-gson to v2.11.0
renovate[bot] May 4, 2024
517c844
Merge pull request #5 from m4gen/renovate/io.reactivex.rxjava3-rxjava…
May 4, 2024
3063ead
Merge pull request #7 from m4gen/renovate/okhttp-monorepo
May 4, 2024
6d2a4e3
Merge pull request #8 from m4gen/renovate/com.squareup.retrofit2-adap…
May 4, 2024
08c803a
Merge pull request #9 from m4gen/renovate/com.squareup.retrofit2-conv…
May 4, 2024
fa2129c
Update dependency com.squareup.retrofit2:retrofit to v2.11.0
renovate[bot] May 4, 2024
33c5374
Merge pull request #10 from m4gen/renovate/com.squareup.retrofit2-ret…
May 4, 2024
1945e55
Update dependency com.google.android.material:material to v1.12.0
renovate[bot] May 4, 2024
b4c3096
Merge pull request #11 from m4gen/renovate/com.google.android.materia…
May 20, 2024
780569d
update README.md
alessandrxdev Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/app-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/app-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
task: [ lint ]
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Setup Java
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/app-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
java: [ 17 ]
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradlew-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

52 changes: 28 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ Una libreria para comprobar nuevas actualizaciones de aplicaciones en Apklis, as
La librería fue creada basándose en la original creada para Kotlin
[ApklisUpdate](https://github.com/Z17-CU/apklisupdate)

<p align="center">

Ejemplo
<img src="./preview/screen.png" width="60%">

</p>


### Agregar
1. Agregar en la raiz de su proyecto
Expand All @@ -27,36 +20,41 @@ repositories {

2. Agregar en su `build.gradle`
```groovy
implementation 'com.github.m4gen:apklisapi:1.0.0-alpha3'
implementation 'com.github.alessandrxdev:apklisapi:1.0.0-alpha4'
```

### Uso
📝 Comprobar si existe una nueva versión en Apklis debe usar `ApklisUpdate`
📝 **Comprobar si existe una nueva versión**

```java
ApklisUpdate api = new ApklisUpdate(this);
api.checkLastUpdate(PACKAGE_NAME, new UpdateCallback() {
@Override
public void onLastUpdate(LastRelease info) {
/* En caso de existir una nueva version LastRelease
* arroja la información de esa nueva versión
*/

private Disposable updateSubscription;

ApklisUpdate api = new ApklisUpdate.Builder().build();
updateSubscription = api.hasAppUpdate(this, new UpdateCallback() {
@Override
public void onLastUpdate(LastRelease info) {
/* En caso de existir una nueva version LastRelease
* arroja la información de esa nueva versión
*/
}
@Override
public void onError(Exception e) {
// error
@Override
public void onError(Exception e) {
Log.e(TAG, e.getMessage);
}
});
```

Desde `LastRelease` podrá extraer información como:

`info.versionName(); // String`
`info.versionCode(); // int`
`info.appSize(); // int`
`info.appChangelog(); // String`
- Versión Name: `getVersionName();`
- Versión Code: `getVersionCode();`
- Tamaño de la apk: `getSize();`
- Registro de cambios: `getChangelog();`

existe más información que puede extrar usando LastRelease.

💳 Comprobar compra de la aplicación
💳 **Comprobar compra de la aplicación**

```java
ApklisPay paid = new ApklisPay(this, this.getPackageName());
Expand Down Expand Up @@ -90,6 +88,12 @@ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
}
}
```
#### Ejemplo
<p align="center">

<img src="./preview/screen.png" width="60%">

</p>

### Contacto

Expand Down
22 changes: 10 additions & 12 deletions apklis-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,18 @@ dependencies {


implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.android.material:material:1.11.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")

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.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("io.reactivex.rxjava3:rxjava:3.1.8")
implementation("io.reactivex.rxjava3:rxandroid:3.0.2")
implementation("com.squareup.retrofit2:adapter-rxjava3:2.11.0")

implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")

testImplementation("junit:junit:4.13.2")
testImplementation("com.squareup.okhttp3:mockwebserver:4.9.1")
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

Expand All @@ -76,7 +74,7 @@ publishing {
register<MavenPublication>("release") {
groupId = "com.github.m4gen"
artifactId = "apklisapi"
version = "1.0.0-alpha3"
version = "1.0.0-alpha4"

afterEvaluate {
from(components["release"])
Expand All @@ -89,4 +87,4 @@ publishing {
url = uri("https://jitpack.io")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import com.arr.apklislib.update.model.PackageResponse;

import io.reactivex.Single;
import io.reactivex.rxjava3.core.Single;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Query;

public interface APKLisService {
@Headers({"User-Agent: ApplifyCU/1.0.0", "Content-Type: application/json"})
@GET("/application/")
public Single<PackageResponse> getPackageResponse(@Query("package_name") String packageName);
@GET("application/")
Single<PackageResponse> getPackageResponse(@Query("package_name") String packageName);
}
28 changes: 12 additions & 16 deletions apklis-api/src/main/java/com/arr/apklislib/update/ApklisUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import com.arr.apklislib.update.callback.UpdateCallback;
import com.arr.apklislib.update.model.LastRelease;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class ApklisUpdate {
Expand All @@ -23,8 +24,8 @@ public class ApklisUpdate {
this.service = service;
}

public void checkLastUpdate(String package_name, final UpdateCallback callback) {
service.getPackageResponse(package_name)
public Disposable checkLastUpdate(String package_name, final UpdateCallback callback) {
return service.getPackageResponse(package_name)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(response -> {
Expand All @@ -33,13 +34,11 @@ public void checkLastUpdate(String package_name, final UpdateCallback callback)
} else {
callback.onLastUpdate(response.getResults().get(0).getLastRelease());
}
}, throwable -> {
callback.onError((Exception) throwable);
}).dispose();
}, throwable -> callback.onError((Exception) throwable));
}

public void hasAppUpdate(@NonNull Context context, UpdateCallback callback) {
service.getPackageResponse(context.getPackageName())
public Disposable hasAppUpdate(@NonNull Context context, UpdateCallback callback) {
return service.getPackageResponse(context.getPackageName())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(response -> {
Expand All @@ -51,9 +50,7 @@ public void hasAppUpdate(@NonNull Context context, UpdateCallback callback) {
callback.onLastUpdate(lastRelease);
}
}
}, throwable -> {
callback.onError((Exception) throwable);
}).dispose();
}, throwable -> callback.onError((Exception) throwable));
}

private int getCurrentVersionCode(@NonNull Context context) {
Expand All @@ -64,7 +61,6 @@ private int getCurrentVersionCode(@NonNull Context context) {
.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "getCurrentVersionCode: " + e.getMessage(), e);
;
}
return 0;
}
Expand All @@ -79,11 +75,11 @@ public Builder setService(APKLisService service) {

public ApklisUpdate build() {
if (service == null) {
String API_URL = "https://api.apklis.cu/v2";
String API_URL = "https://api.apklis.cu/v2/";
service = new Retrofit.Builder()
.baseUrl(API_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build()
.create(APKLisService.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import okio.BufferedSource;
import okio.Okio;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

@RunWith(JUnit4.class)
Expand All @@ -37,7 +37,7 @@ public void setUp() throws IOException {
service = new Retrofit.Builder()
.baseUrl(mockWebServer.url("/"))
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build().create(APKLisService.class);
}

Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ dependencies {


implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

implementation(project(":apklis-api"))
implementation("io.reactivex.rxjava3:rxjava:3.1.8")
}
19 changes: 15 additions & 4 deletions app/src/main/java/com/arr/example/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package com.arr.example;

import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

import com.arr.apklislib.payments.ApklisPay;
import com.arr.apklislib.ui.ApklisUpdateDialog;
import com.arr.apklislib.update.ApklisUpdate;
import com.arr.apklislib.update.callback.UpdateCallback;
import com.arr.apklislib.update.model.LastRelease;
import com.arr.example.databinding.ActivityMainBinding;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import io.reactivex.rxjava3.disposables.Disposable;

public class MainActivity extends AppCompatActivity {

private ActivityMainBinding binding;
private Disposable updateSubscription;
private static final String TAG = "MainActivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -29,7 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(binding.getRoot());

ApklisUpdate api = new ApklisUpdate.Builder().build();
api.hasAppUpdate(
updateSubscription = api.hasAppUpdate(
this,
new UpdateCallback() {
@Override
Expand All @@ -40,10 +45,13 @@ public void onLastUpdate(LastRelease info) {
.setVersion(info.getVersionName())
.setChangelog(changelog.toString())
.show();

}

@Override
public void onError(Exception e) {}
public void onError(Exception e) {
Log.e(TAG, "onError: Not Found", e);
}
});


Expand All @@ -60,6 +68,9 @@ public void onError(Exception e) {}
protected void onDestroy() {
super.onDestroy();
this.binding = null;
if (updateSubscription != null && !updateSubscription.isDisposed()) {
updateSubscription.dispose();
}
}

private Spanned formatHtmlString(String htmlString) {
Expand Down
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}