use of io.virtualapp.home.models.AppData in project VirtualApp by asLody.
the class HomeActivity method deleteApp.
private void deleteApp(int position) {
AppData data = mLaunchpadAdapter.getList().get(position);
new AlertDialog.Builder(this).setTitle("Delete app").setMessage("Do you want to delete " + data.getName() + "?").setPositiveButton(android.R.string.yes, (dialog, which) -> {
mPresenter.deleteApp(data);
}).setNegativeButton(android.R.string.no, null).show();
}
use of io.virtualapp.home.models.AppData in project VirtualApp by asLody.
the class HomeActivity method addAppToLauncher.
@Override
public void addAppToLauncher(AppData model) {
List<AppData> dataList = mLaunchpadAdapter.getList();
boolean replaced = false;
for (int i = 0; i < dataList.size(); i++) {
AppData data = dataList.get(i);
if (data instanceof EmptyAppData) {
mLaunchpadAdapter.replace(i, model);
replaced = true;
break;
}
}
if (!replaced) {
mLaunchpadAdapter.add(model);
mLauncherView.smoothScrollToPosition(mLaunchpadAdapter.getItemCount() - 1);
}
}
use of io.virtualapp.home.models.AppData in project VirtualApp by asLody.
the class HomePresenterImpl method addApp.
@Override
public void addApp(AppInfoLite info) {
class AddResult {
private PackageAppData appData;
private int userId;
}
AddResult addResult = new AddResult();
VUiKit.defer().when(() -> {
InstalledAppInfo installedAppInfo = VirtualCore.get().getInstalledAppInfo(info.packageName, 0);
if (installedAppInfo != null) {
int[] userIds = installedAppInfo.getInstalledUsers();
int nextUserId = userIds.length;
addResult.userId = nextUserId;
if (VUserManager.get().getUserInfo(nextUserId) == null) {
String nextUserName = "Space " + nextUserId + 1;
VUserInfo newUserInfo = VUserManager.get().createUser(nextUserName, VUserInfo.FLAG_ADMIN);
if (newUserInfo == null) {
throw new IllegalStateException();
}
}
boolean success = VirtualCore.get().installPackageAsUser(nextUserId, info.packageName);
if (!success) {
throw new IllegalStateException();
}
} else {
InstallResult res = mRepo.addVirtualApp(info);
if (!res.isSuccess) {
throw new IllegalStateException();
}
}
}).then((res) -> {
addResult.appData = PackageAppDataStorage.get().acquire(info.packageName);
}).done(res -> {
if (addResult.userId == 0) {
PackageAppData data = addResult.appData;
data.isLoading = true;
mView.addAppToLauncher(data);
handleOptApp(data);
} else {
MultiplePackageAppData data = new MultiplePackageAppData(addResult.appData, addResult.userId);
data.isLoading = true;
mView.addAppToLauncher(data);
handleMultipleApp(data);
}
});
}
use of io.virtualapp.home.models.AppData in project VirtualApp by asLody.
the class AppRepository method getVirtualApps.
@Override
public Promise<List<AppData>, Throwable, Void> getVirtualApps() {
return VUiKit.defer().when(() -> {
List<InstalledAppInfo> infos = VirtualCore.get().getInstalledApps(0);
List<AppData> models = new ArrayList<AppData>();
for (InstalledAppInfo info : infos) {
if (VirtualCore.get().getLaunchIntent(info.packageName, 0) == null) {
continue;
}
PackageAppData data = new PackageAppData(mContext, info);
models.add(data);
int[] userIds = info.getInstalledUsers();
for (int userId : userIds) {
if (userId != 0) {
models.add(new MultiplePackageAppData(data, userId));
}
}
}
return models;
});
}
use of io.virtualapp.home.models.AppData in project VirtualApp by asLody.
the class LaunchpadAdapter method moveItem.
public void moveItem(int pos, int targetPos) {
AppData model = mList.remove(pos);
mList.add(targetPos, model);
notifyItemMoved(pos, targetPos);
}
Aggregations