Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
110 changes: 1 addition & 109 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add below dependency to your app's build.gradle file.
<pre>
<code>
dependencies {
compile 'com.github.Turkcell:TurkcellUpdater_android_sdk:1.2.4'
implementation 'com.github.Turkcell:TurkcellUpdater_android_sdk:1.3.0'
}
</code>
</pre>
Expand Down Expand Up @@ -61,82 +61,6 @@ This documents describes usage and structure configuration files used by Turkcel
</code>
</pre>

<h4>Updating an Android application to a new version served as APK file</h4>
<pre>
<code>
{
"packageName": "com.example.app1",
"updates": [
{
"descriptions": {
"tr": {
"message": "Yeni versiyon yayınlanmıştır",
"positive_button": "Güncelle",
"negative_button": "İptal"
},
"*": {
"message": "New version available",
"positive_button": "Update",
"negative_button": "Cancel"
}
},
"targetVersionCode": 1,
"targetPackageUrl": "http://example.com/app1-v10.apk"
}
]
}
</code>
</pre>

<h4>Updating an Android application depending on where current application is installed from</h4>
<pre>
<code>
{
"packageName": "com.example.app1",
"updates": [
{
"filters": {
"appInstallerPackageName": "com.android.vending"
},
"descriptions": {
"tr": {
"message": "Yeni versiyon yayınlanmıştır",
"positive_button": "Güncelle",
"negative_button": "İptal"
},
"*": {
"message": "New version available",
"positive_button": "Update",
"negative_button": "Cancel"
}
},
"targetVersionCode": 1,
"targetGooglePlay": true
},
{
"filters": {
"appInstallerPackageName": "!com.android.vending"
},
"descriptions": {
"tr": {
"message": "Yeni versiyon yayınlanmıştır",
"positive_button": "Güncelle",
"negative_button": "İptal"
},
"*": {
"message": "New version available",
"positive_button": "Update",
"negative_button": "Cancel"
}
},
"targetVersionCode": 1,
"targetPackageUrl": "http://example.com/app1-v10.apk"
}
]
}
</code>
</pre>

<h4>Forcing an Android application to update</h4>
<pre>
<code>
Expand Down Expand Up @@ -356,27 +280,6 @@ Type: Object
{
"packageName": "com.example.app1",
"updates": [
{
"descriptions": {
"tr": {
"message": "Yeni versiyon yayinlandi",
"whatIsNew": "Bazi hatalar duzeltildi",
"warnings": "Yeni versiyon ek izinler gerektiriyor",
"positive_button": "Tamam"
},
"*": {
"message": "New version available",
"whatIsNew": "Minor bug fixes",
"warnings": "New version requires additional privileges",
"positive_button": "Ok"
}
},
"targetVersionCode": 10,
"targetPackageUrl": "http://example.com/app1-v10.apk",
"forceUpdate": false
}
],
"messages": [
{
"descriptions": {
"tr": {
Expand Down Expand Up @@ -475,16 +378,6 @@ For iOS : If device language is English but the application language is Turkish
<td>1</td>
</tr>

<tr>
<td>targetPackageUrl</td>
<td>String</td>
<td>null</td>
<td>Android</td>
<td>URL of APK package of new version.</td>
<td>See <a href="#updateEntryNote2">Note #2</a></td>
<td>1</td>
</tr>

<tr>
<td>forceUpdate</td>
<td>Boolean</td>
Expand Down Expand Up @@ -524,7 +417,6 @@ For iOS : iTunes or Corporate Repository URL of the application.</td>
<li><code>forceExit</code> is <code>true</code></li>
<li><code>targetGooglePlay</code> is <code>true</code></li>
<li><code>targetWebsiteUrl</code> is not <code>null</code> or empty</li>
<li><code>targetPackageUrl</code> is not <code>null</code> or empty</li>
</ul>
</li>
</ol>
Expand Down
10 changes: 7 additions & 3 deletions TurkcellUpdaterSampleApp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

allprojects {
repositories {
jcenter()
google()
mavenLocal()
mavenCentral()
}
}
3 changes: 3 additions & 0 deletions TurkcellUpdaterSampleApp/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Wed Jun 03 09:45:52 EEST 2015
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=3128
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Thu May 09 19:36:05 MSK 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
4 changes: 4 additions & 0 deletions TurkcellUpdaterSampleApp/jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jdk:
- openjdk17
install:
- ./gradlew :turkcellUpdater:publishToMavenLocal
35 changes: 31 additions & 4 deletions TurkcellUpdaterSampleApp/turkcellUpdater/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
compileSdk 34

defaultConfig {
minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 34
useLibrary 'org.apache.http.legacy'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
namespace 'tr.com.turkcellteknoloji.turkcellupdater'
publishing {
singleVariant('release') {
withSourcesJar()
}
}
}

// gradle task: publishToMavenLocal
project.afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

// values used for local maven repo, jitpack uses github release:
groupId 'com.github.Turkcell'
artifactId 'TurkcellUpdater_android_sdk'
version '1.3.0'
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tr.com.turkcellteknoloji.turkcellupdater"
android:versionCode="5"
android:versionName="1.2.4" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />

<application>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -160,133 +160,7 @@ public void applyUpdate(Context context, Update update, final UpdateListener lis
openGooglePlayPage(context, update.targetPackageName, listener);
} else if (update.targetWebsiteUrl != null) {
openWebPage(context, update.targetWebsiteUrl, listener);
} else if (update.targetPackageUrl != null) {
try {
final DownloadRequest dr = new DownloadRequest();
dr.setUri(update.targetPackageUrl.toURI());
dr.setExpectedContentType("application/vnd.android.package-archive");
dr.setDownloadHandler(new DownloadHandlerAdapter(context, listener));
HttpClient client = Utilities.createClient("Turkcell Updater/1.0 ", false);
dr.executeAsync(client);
} catch (Exception e) {
if (listener == null) {
Log.e("Update failed", e);
} else {
listener.onUpdateFailed(e);
}
}
}
}

private final class DownloadHandlerAdapter implements DownloadHandler {

private final UpdateListener listener;
private final Context context;

private DownloadHandlerAdapter(Context context, UpdateListener listener) {
this.listener = listener;
this.context = context;
}

@Override
public void onSuccess(byte[] result) {
try {
installPackage(context, result, listener);
} catch (Exception e) {
if (listener != null) {
listener.onUpdateFailed(e);
}
}
}

@Override
public void onProgress(Integer percent) {
if (listener != null) {
if (percent != null) {
percent *= DOWNLOAD_PROGRESS_PERCENT;
percent /= 100;
}
listener.onUpdateProgress(percent);
}
}

@Override
public void onFail(Exception ex) {
if (listener == null) {
Log.e("Update failed", ex);
} else {
listener.onUpdateFailed(ex);
}
}

@Override
public void onCancelled() {
if (listener != null) {
listener.onUpdateCancelled();
}
}
}

private void installPackage(final Context context, final byte[] apkContents, final UpdateListener listener) {
final AsyncTask<Void, Void, File> task = new AsyncTask<Void, Void, File>() {
volatile Exception exception;

@SuppressLint("WorldReadableFiles")
@Override
protected File doInBackground(Void... params) {
try {
if (Utilities.isNullOrEmpty(apkContents)) {
throw new NullPointerException("apkContents");
}
String tempFileName = "nextversion.apk";
File tempFile = context.getFileStreamPath(tempFileName);
if (tempFile.exists()) {
tempFile.delete();
}
FileOutputStream fout = context.openFileOutput(tempFileName, Context.MODE_WORLD_READABLE);
try {
fout.write(apkContents);
fout.flush();
} finally {
try {
fout.close();
} catch (Exception e) {
// omit
}
}
return tempFile;
} catch (Exception e) {
exception = e;
Log.e("Couldn't save apk", e);
return null;
}
}

@Override
protected void onPostExecute(File result) {
if (exception == null) {
try {
Uri data = Uri.fromFile(result);
String type = "application/vnd.android.package-archive";
Intent promptInstall = new Intent(Intent.ACTION_VIEW);
promptInstall.setDataAndType(data, type);
context.startActivity(promptInstall);
if (listener != null) {
listener.onUpdateCompleted();
}
return;
} catch (Exception e) {
exception = e;
}
}
if (listener == null) {
Log.e("Update failed", exception);
} else {
listener.onUpdateFailed(exception);
}
}
};
task.execute();
}

private void openGooglePlayPage(Context context, String packageName, final UpdateListener listener) {
Expand Down
Loading