forked from Skycoder42/QtAutoUpdater
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1365ab5
commit 8cf0b1d
Showing
8 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 81 additions & 1 deletion
82
src/jar/src/de/skycoder42/qtautoupdater/core/plugin/qplaystore/UpdateHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,88 @@ | ||
package de.skycoder42.qtautoupdater.core.plugin.qplaystore; | ||
|
||
import android.content.Context; | ||
import android.content.IntentSender.SendIntentException; | ||
|
||
import android.app.Activity; | ||
|
||
import com.google.android.play.core.tasks.OnCompleteListener; | ||
import com.google.android.play.core.tasks.OnSuccessListener; | ||
import com.google.android.play.core.tasks.Task; | ||
|
||
import com.google.android.play.core.appupdate.AppUpdateInfo; | ||
import com.google.android.play.core.appupdate.AppUpdateManager; | ||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory; | ||
|
||
class UpdateHelper | ||
import com.google.android.play.core.install.InstallStateUpdatedListener; | ||
import com.google.android.play.core.install.InstallState; | ||
|
||
import com.google.android.play.core.install.model.UpdateAvailability; | ||
import com.google.android.play.core.install.model.AppUpdateType; | ||
import com.google.android.play.core.install.model.InstallStatus; | ||
|
||
class UpdateHelper implements InstallStateUpdatedListener | ||
{ | ||
private AppUpdateManager _manager; | ||
|
||
private native void reportCheckResult(AppUpdateInfo info); | ||
@Override | ||
public native void onStateUpdate(InstallState state); | ||
|
||
public UpdateHelper(AppUpdateManager manager) { | ||
_manager = manager; | ||
} | ||
|
||
public void startUpdateCheck() { | ||
_manager.getAppUpdateInfo().addOnCompleteListener(new OnCompleteListener<AppUpdateInfo>() { | ||
@Override | ||
public void onComplete(Task<AppUpdateInfo> task) { | ||
if (task.isSuccessful()) | ||
reportCheckResult(task.getResult()); | ||
else | ||
reportCheckResult(null); | ||
} | ||
}); | ||
} | ||
|
||
public void resumeStalledUpdate(final int requestCode, final Activity activity) { | ||
_manager.getAppUpdateInfo().addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { | ||
@Override | ||
public void onSuccess(AppUpdateInfo info) { | ||
if (info.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) | ||
triggerUpdate(requestCode, activity, info); | ||
} | ||
}); | ||
} | ||
|
||
public boolean triggerUpdate(int requestCode, Activity activity, AppUpdateInfo info) { | ||
try { | ||
_manager.startUpdateFlowForResult(info, | ||
AppUpdateType.IMMEDIATE, | ||
activity, | ||
requestCode); | ||
return true; | ||
} catch(SendIntentException e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
|
||
public boolean startUpdate(int requestCode, Activity activity, AppUpdateInfo info) { | ||
try { | ||
_manager.registerListener(this); | ||
_manager.startUpdateFlowForResult(info, | ||
AppUpdateType.FLEXIBLE, | ||
activity, | ||
requestCode); | ||
return true; | ||
} catch(SendIntentException e) { | ||
_manager.unregisterListener(this); | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
|
||
public void completeUpdate() { | ||
_manager.completeUpdate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters