Search in sources :

Example 41 with Apk

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();
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) Uri(android.net.Uri) Apk(org.fdroid.fdroid.data.Apk)

Example 42 with Apk

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) ContextThemeWrapper(android.view.ContextThemeWrapper) Apk(org.fdroid.fdroid.data.Apk)

Example 43 with Apk

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);
}
Also used : Apk(org.fdroid.fdroid.data.Apk)

Example 44 with Apk

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;
}
Also used : Apk(org.fdroid.fdroid.data.Apk) SuppressLint(android.annotation.SuppressLint)

Example 45 with Apk

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;
    }
}
Also used : Apk(org.fdroid.fdroid.data.Apk) SuppressLint(android.annotation.SuppressLint)

Aggregations

Apk (org.fdroid.fdroid.data.Apk)63 Test (org.junit.Test)17 Uri (android.net.Uri)16 File (java.io.File)12 Intent (android.content.Intent)11 App (org.fdroid.fdroid.data.App)10 Repo (org.fdroid.fdroid.data.Repo)10 ArrayList (java.util.ArrayList)8 PendingIntent (android.app.PendingIntent)7 Context (android.content.Context)7 PackageInfo (android.content.pm.PackageInfo)7 FileCompatTest (org.fdroid.fdroid.compat.FileCompatTest)7 BroadcastReceiver (android.content.BroadcastReceiver)6 PackageManager (android.content.pm.PackageManager)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 FDroidProviderTest (org.fdroid.fdroid.data.FDroidProviderTest)4 LocalBroadcastManager (androidx.localbroadcastmanager.content.LocalBroadcastManager)3 RepoDetails (org.fdroid.fdroid.mock.RepoDetails)3 SuppressLint (android.annotation.SuppressLint)2