use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class InstallConfirmActivity method onCreate.
@Override
protected void onCreate(Bundle icicle) {
FDroidApp fdroidApp = (FDroidApp) getApplication();
fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
super.onCreate(icicle);
intent = getIntent();
Uri uri = intent.getData();
Apk apk = ApkProvider.Helper.findByUri(this, uri, Schema.ApkTable.Cols.ALL);
app = AppProvider.Helper.findSpecificApp(getContentResolver(), apk.packageName, apk.repoId, Schema.AppMetadataTable.Cols.ALL);
appDiff = new AppDiff(this, apk);
setContentView(R.layout.install_start);
// increase dialog to full width
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
installConfirm = findViewById(R.id.install_confirm_panel);
installConfirm.setVisibility(View.INVISIBLE);
startInstallConfirm();
}
use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class UninstallDialogActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
final Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
PackageManager pm = getPackageManager();
ApplicationInfo appInfo;
try {
// noinspection WrongConstant (lint is actually wrong here!)
appInfo = pm.getApplicationInfo(apk.packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("Failed to get ApplicationInfo for uninstalling");
}
final boolean isSystem = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
final boolean isUpdate = (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
if (isSystem && !isUpdate) {
// Cannot remove system apps unless we're uninstalling updates
throw new RuntimeException("Cannot remove system apps unless we're uninstalling updates");
}
int messageId;
if (isUpdate) {
messageId = R.string.uninstall_update_confirm;
} else {
messageId = R.string.uninstall_confirm;
}
// hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
final AlertDialog.Builder builder = new AlertDialog.Builder(theme);
builder.setTitle(appInfo.loadLabel(pm));
builder.setIcon(appInfo.loadIcon(pm));
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent data = new Intent();
data.putExtra(Installer.EXTRA_APK, apk);
setResult(AppCompatActivity.RESULT_OK, intent);
finish();
}
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setResult(AppCompatActivity.RESULT_CANCELED);
finish();
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
setResult(AppCompatActivity.RESULT_CANCELED);
finish();
}
});
builder.setMessage(messageId);
builder.create().show();
}
use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class AppDetailsActivity method installApk.
@Override
public void installApk() {
Apk apkToInstall = ApkProvider.Helper.findSuggestedApk(this, app);
installApk(apkToInstall);
}
use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class AppDetailsRecyclerViewAdapter method getSuggestedApk.
private Apk getSuggestedApk() {
Apk curApk = null;
String appropriateSig = app.getMostAppropriateSignature();
for (int i = 0; i < versions.size(); i++) {
final Apk apk = versions.get(i);
if (apk.versionCode == app.autoInstallVersionCode && TextUtils.equals(apk.sig, appropriateSig)) {
curApk = apk;
break;
}
}
return curApk;
}
use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.
the class AppDetailsRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
int viewType = getItemViewType(position);
switch(viewType) {
case VIEWTYPE_HEADER:
HeaderViewHolder header = (HeaderViewHolder) holder;
headerView = header;
header.bindModel();
break;
// These don't have any specific requirements, they all get their state from the outer class.
case VIEWTYPE_SCREENSHOTS:
case VIEWTYPE_DONATE:
case VIEWTYPE_LINKS:
case VIEWTYPE_PERMISSIONS:
case VIEWTYPE_VERSIONS:
case VIEWTYPE_NO_VERSIONS:
((AppDetailsViewHolder) holder).bindModel();
break;
case VIEWTYPE_VERSION:
final Apk apk = (Apk) items.get(position);
((VersionViewHolder) holder).bindModel(apk);
break;
}
}
Aggregations