Change Activity to AppCompatActivity

This commit is contained in:
proletarius101 2021-01-28 16:52:58 +00:00 committed by Hans-Christoph Steiner
parent 34b24a5b60
commit e2979f632d
45 changed files with 180 additions and 169 deletions

View File

@ -19,14 +19,14 @@
package org.fdroid.fdroid.nearby;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
/**
* Dummy version for basic app flavor.
*/
public class TreeUriScannerIntentService {
public static void onActivityResult(Activity activity, Intent intent) {
public static void onActivityResult(AppCompatActivity activity, Intent intent) {
throw new IllegalStateException("unimplemented");
}
}

View File

@ -1,7 +1,7 @@
package org.fdroid.fdroid.nearby;
import android.annotation.TargetApi;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -195,7 +195,7 @@ public class SwapSuccessView extends SwapView implements LoaderManager.LoaderCal
private final ContentObserver appObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
Activity activity = getActivity();
AppCompatActivity activity = getActivity();
if (activity != null && app != null) {
app = AppProvider.Helper.findSpecificApp(
activity.getContentResolver(),

View File

@ -1,7 +1,7 @@
package org.fdroid.fdroid.nearby;
import android.annotation.TargetApi;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@ -594,7 +594,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
}
private void sendFDroidApk() {
((FDroidApp) getApplication()).sendViaBluetooth(this, Activity.RESULT_OK, BuildConfig.APPLICATION_ID);
((FDroidApp) getApplication()).sendViaBluetooth(this, AppCompatActivity.RESULT_OK, BuildConfig.APPLICATION_ID);
}
/**

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.panic;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
@ -83,7 +83,7 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
prefHide.setEnabled(false);
prefResetRepos.setChecked(false);
prefResetRepos.setEnabled(false);
getActivity().setResult(Activity.RESULT_CANCELED);
getActivity().setResult(AppCompatActivity.RESULT_CANCELED);
} else {
prefHide.setEnabled(true);
prefResetRepos.setEnabled(true);
@ -235,13 +235,13 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
public void onClick(DialogInterface dialogInterface, int i) {
PanicResponder.setTriggerPackageName(getActivity());
showPanicApp(PanicResponder.getTriggerPackageName(getActivity()));
getActivity().setResult(Activity.RESULT_OK);
getActivity().setResult(AppCompatActivity.RESULT_OK);
}
};
DialogInterface.OnClickListener cancelListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
getActivity().setResult(Activity.RESULT_CANCELED);
getActivity().setResult(AppCompatActivity.RESULT_CANCELED);
getActivity().finish();
}
};

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.panic;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
@ -32,15 +32,15 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/**
* This {@link Activity} is purely to run events in response to a panic trigger.
* It needs to be an {@code Activity} rather than a {@link android.app.Service}
* This {@link AppCompatActivity} is purely to run events in response to a panic trigger.
* It needs to be an {@code AppCompatActivity} rather than a {@link android.app.Service}
* so that it can fetch some of the required information about what sent the
* {@link Intent}. This is therefore an {@code Activity} without any UI, which
* {@link Intent}. This is therefore an {@code AppCompatActivity} without any UI, which
* is a special case in Android. All the code must be in
* {@link #onCreate(Bundle)} and {@link #finish()} must be called at the end of
* that method.
*
* @see PanicResponder#receivedTriggerFromConnectedApp(Activity)
* @see PanicResponder#receivedTriggerFromConnectedApp(AppCompatActivity)
*/
public class PanicResponderActivity extends AppCompatActivity {

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.panic;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
@ -14,7 +14,7 @@ import java.util.Set;
public class SelectInstalledAppListAdapter extends InstalledAppListAdapter {
private final Set<String> selectedApps;
SelectInstalledAppListAdapter(Activity activity) {
SelectInstalledAppListAdapter(AppCompatActivity activity) {
super(activity);
Preferences prefs = Preferences.get();
selectedApps = prefs.getPanicWipeSet();

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.panic;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
@ -18,7 +18,7 @@ public class SelectInstalledAppListItemController extends InstalledAppListItemCo
private final Set<String> selectedApps;
public SelectInstalledAppListItemController(Activity activity, View itemView, Set<String> selectedApps) {
public SelectInstalledAppListItemController(AppCompatActivity activity, View itemView, Set<String> selectedApps) {
super(activity, itemView);
this.selectedApps = selectedApps;
}

View File

@ -1,10 +1,12 @@
package org.fdroid.fdroid.views.main;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.views.PreferencesFragment;
import org.fdroid.fdroid.views.updates.UpdatesViewBinder;

View File

@ -1,7 +1,7 @@
package org.fdroid.fdroid.views.main;
import android.Manifest;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.UriPermission;
@ -69,7 +69,7 @@ public class NearbyViewBinder {
private static File externalStorage = null;
private static View swapView;
NearbyViewBinder(final Activity activity, FrameLayout parent) {
NearbyViewBinder(final AppCompatActivity activity, FrameLayout parent) {
swapView = activity.getLayoutInflater().inflate(R.layout.main_tab_swap, parent, true);
TextView subtext = swapView.findViewById(R.id.both_parties_need_fdroid_text);
@ -213,11 +213,11 @@ public class NearbyViewBinder {
}
}
Activity activity = null;
if (context instanceof Activity) {
activity = (Activity) context;
} else if (swapView != null && swapView.getContext() instanceof Activity) {
activity = (Activity) swapView.getContext();
AppCompatActivity activity = null;
if (context instanceof AppCompatActivity) {
activity = (AppCompatActivity) context;
} else if (swapView != null && swapView.getContext() instanceof AppCompatActivity) {
activity = (AppCompatActivity) swapView.getContext();
}
if (activity != null) {

View File

@ -16,7 +16,6 @@
package com.google.zxing.integration.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
@ -25,9 +24,11 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@ -48,8 +49,8 @@ import java.util.Map;
* <p>It does require that the Barcode Scanner (or work-alike) application is installed. The
* {@link #initiateScan()} method will prompt the user to download the application, if needed.</p>
*
* <p>There are a few steps to using this integration. First, your {@link Activity} must implement
* the method {@link Activity#onActivityResult(int, int, Intent)} and include a line of code like this:</p>
* <p>There are a few steps to using this integration. First, your {@link AppCompatActivity} must implement
* the method {@link AppCompatActivity#onActivityResult(int, int, Intent)} and include a line of code like this:</p>
*
* <pre>{@code
* public void onActivityResult(int requestCode, int resultCode, Intent intent) {
@ -73,7 +74,8 @@ import java.util.Map;
*
* <p>Note that {@link #initiateScan()} returns an {@link AlertDialog} which is non-null if the
* user was prompted to download the application. This lets the calling app potentially manage the dialog.
* In particular, ideally, the app dismisses the dialog if it's still active in its {@link Activity#onPause()}
* In particular, ideally, the app dismisses the dialog if it's still active in its
* {@link AppCompatActivity#onPause()}
* method.</p>
*
* <p>You can use {@link #setTitle(String)} to customize the title of this download prompt dialog (or, use
@ -140,7 +142,7 @@ public class IntentIntegrator {
// What else supports this intent?
);
private final Activity activity;
private final AppCompatActivity activity;
private final Fragment fragment;
private String title;
@ -151,9 +153,9 @@ public class IntentIntegrator {
private final Map<String, Object> moreExtras = new HashMap<>(3);
/**
* @param activity {@link Activity} invoking the integration
* @param activity {@link AppCompatActivity} invoking the integration
*/
public IntentIntegrator(Activity activity) {
public IntentIntegrator(AppCompatActivity activity) {
this.activity = activity;
this.fragment = null;
initializeConfiguration();
@ -162,10 +164,10 @@ public class IntentIntegrator {
/**
* @param fragment {@link Fragment} invoking the integration.
* {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead
* of an {@link Activity}
* of an {@link AppCompatActivity}
*/
public IntentIntegrator(Fragment fragment) {
this.activity = fragment.getActivity();
this.activity = (AppCompatActivity) fragment.getActivity();
this.fragment = fragment;
initializeConfiguration();
}
@ -333,7 +335,7 @@ public class IntentIntegrator {
*
* @param intent Intent to start.
* @param code Request code for the activity
* @see android.app.Activity#startActivityForResult(Intent, int)
* @see android.app.AppCompatActivity#startActivityForResult(Intent, int)
* @see android.app.Fragment#startActivityForResult(Intent, int)
*/
protected void startActivityForResult(Intent intent, int code) {
@ -402,8 +404,8 @@ public class IntentIntegrator {
}
/**
* <p>Call this from your {@link Activity}'s
* {@link Activity#onActivityResult(int, int, Intent)} method.</p>
* <p>Call this from your {@link AppCompatActivity}'s
* {@link AppCompatActivity#onActivityResult(int, int, Intent)} method.</p>
*
* @param requestCode request code from {@code onActivityResult()}
* @param resultCode result code from {@code onActivityResult()}
@ -414,7 +416,7 @@ public class IntentIntegrator {
*/
public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
if (resultCode == AppCompatActivity.RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT");
byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES");

View File

@ -31,7 +31,7 @@ import java.util.Locale;
* <p>
* This only really properly queues {@link Intent}s that get filtered out. The
* {@code Intent}s that go on to {@code ManageReposActivity} will not wait
* until for that {@code Activity} to be ready to handle the next. So when
* until for that {@code AppCompatActivity} to be ready to handle the next. So when
* multiple mirrors are discovered at once, only one in that session will
* likely be added.
*/

View File

@ -24,7 +24,7 @@
package org.fdroid.fdroid;
import android.annotation.TargetApi;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Application;
@ -159,7 +159,7 @@ public class FDroidApp extends Application {
curTheme = Preferences.get().getTheme();
}
public void applyTheme(Activity activity) {
public void applyTheme(AppCompatActivity activity) {
activity.setTheme(getCurThemeResId());
setSecureWindow(activity);
}
@ -181,12 +181,12 @@ public class FDroidApp extends Application {
return curTheme == Theme.light;
}
public void applyDialogTheme(Activity activity) {
public void applyDialogTheme(AppCompatActivity activity) {
activity.setTheme(getCurDialogThemeResId());
setSecureWindow(activity);
}
public void setSecureWindow(Activity activity) {
public void setSecureWindow(AppCompatActivity activity) {
if (Preferences.get().preventScreenshots()) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
@ -206,12 +206,12 @@ public class FDroidApp extends Application {
}
/**
* Force reload the {@link Activity to make theme changes take effect.}
* Same as {@link Languages#forceChangeLanguage(Activity)}
* Force reload the {@link AppCompatActivity to make theme changes take effect.}
* Same as {@link Languages#forceChangeLanguage(AppCompatActivity)}
*
* @param activity the {@code Activity} to force reload
* @param activity the {@code AppCompatActivity} to force reload
*/
public static void forceChangeTheme(Activity activity) {
public static void forceChangeTheme(AppCompatActivity activity) {
Intent intent = activity.getIntent();
if (intent == null) { // when launched as LAUNCHER
return;
@ -602,8 +602,8 @@ public class FDroidApp extends Application {
return getSharedPreferences("at-start-time", Context.MODE_PRIVATE);
}
public void sendViaBluetooth(Activity activity, int resultCode, String packageName) {
if (resultCode == Activity.RESULT_CANCELED) {
public void sendViaBluetooth(AppCompatActivity activity, int resultCode, String packageName) {
if (resultCode == AppCompatActivity.RESULT_CANCELED) {
return;
}

View File

@ -1,7 +1,6 @@
package org.fdroid.fdroid;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
@ -9,6 +8,8 @@ import android.content.res.Resources;
import android.os.Build;
import android.text.TextUtils;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
@ -35,7 +36,7 @@ public final class Languages {
DEFAULT_LOCALE = Locale.getDefault();
}
private Languages(Activity activity) {
private Languages(AppCompatActivity activity) {
Set<Locale> localeSet = new LinkedHashSet<>();
localeSet.addAll(Arrays.asList(LOCALES_TO_TEST));
@ -63,10 +64,10 @@ public final class Languages {
}
/**
* @param activity the {@link Activity} this is working as part of
* @param activity the {@link AppCompatActivity} this is working as part of
* @return the singleton to work with
*/
public static Languages get(Activity activity) {
public static Languages get(AppCompatActivity activity) {
if (singleton == null) {
singleton = new Languages(activity);
}
@ -116,11 +117,11 @@ public final class Languages {
}
/**
* Force reload the {@link Activity to make language changes take effect.}
* Force reload the {@link AppCompatActivity to make language changes take effect.}
*
* @param activity the {@code Activity} to force reload
* @param activity the {@code AppCompatActivity} to force reload
*/
public static void forceChangeLanguage(Activity activity) {
public static void forceChangeLanguage(AppCompatActivity activity) {
if (Build.VERSION.SDK_INT >= 24) {
Utils.debugLog(TAG, "Languages.forceChangeLanguage() ignored on >= android-24");
return;

View File

@ -1,7 +1,7 @@
package org.fdroid.fdroid;
import android.annotation.TargetApi;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@ -20,7 +20,7 @@ public class NfcHelper {
return NfcAdapter.getDefaultAdapter(context.getApplicationContext());
}
public static boolean setPushMessage(Activity activity, Uri toShare) {
public static boolean setPushMessage(AppCompatActivity activity, Uri toShare) {
NfcAdapter adapter = getAdapter(activity);
if (adapter != null) {
adapter.setNdefPushMessage(new NdefMessage(new NdefRecord[]{
@ -32,7 +32,7 @@ public class NfcHelper {
}
@TargetApi(16)
public static void setAndroidBeam(Activity activity, String packageName) {
public static void setAndroidBeam(AppCompatActivity activity, String packageName) {
if (Build.VERSION.SDK_INT < 16) {
return;
}
@ -53,7 +53,7 @@ public class NfcHelper {
}
@TargetApi(16)
public static void disableAndroidBeam(Activity activity) {
public static void disableAndroidBeam(AppCompatActivity activity) {
if (Build.VERSION.SDK_INT < 16) {
return;
}

View File

@ -944,7 +944,7 @@ public final class Utils {
}
/**
* Keep an instance of this class as an field in an Activity for figuring out whether the on
* Keep an instance of this class as an field in an AppCompatActivity for figuring out whether the on
* screen keyboard is currently visible or not.
*/
public static class KeyboardStateMonitor {
@ -952,7 +952,7 @@ public final class Utils {
private boolean visible = false;
/**
* @param contentView this must be the top most Container of the layout used by the Activity
* @param contentView this must be the top most Container of the layout used by the AppCompatActivity
*/
public KeyboardStateMonitor(final View contentView) {
contentView.getViewTreeObserver().addOnGlobalLayoutListener(

View File

@ -1,22 +1,24 @@
package org.fdroid.fdroid.data;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import org.fdroid.fdroid.Utils;
/**
* Replies with the public download URL for the OBB that belongs to the
* requesting app/version. If it doesn't know the OBB URL for the requesting
* app, the {@code resultCode} will be {@link Activity#RESULT_CANCELED}. The
* request must be sent with {@link Activity#startActivityForResult(Intent, int)}
* app, the {@code resultCode} will be {@link AppCompatActivity#RESULT_CANCELED}. The
* request must be sent with {@link AppCompatActivity#startActivityForResult(Intent, int)}
* in order to receive a reply, which will include an {@link Intent} with the
* URL as data and the SHA-256 hash as a String {@code Intent} extra.
*/
public class ObbUrlActivity extends Activity {
public class ObbUrlActivity extends AppCompatActivity {
public static final String TAG = "ObbUrlActivity";
public static final String ACTION_GET_OBB_MAIN_URL = "org.fdroid.fdroid.action.GET_OBB_MAIN_URL";

View File

@ -21,7 +21,7 @@
package org.fdroid.fdroid.installer;
import android.annotation.SuppressLint;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Intent;
@ -162,17 +162,17 @@ public class DefaultInstallerActivity extends FragmentActivity {
switch (requestCode) {
case REQUEST_CODE_INSTALL:
switch (resultCode) {
case Activity.RESULT_OK:
case AppCompatActivity.RESULT_OK:
installer.sendBroadcastInstall(canonicalUri,
Installer.ACTION_INSTALL_COMPLETE);
break;
case Activity.RESULT_CANCELED:
case AppCompatActivity.RESULT_CANCELED:
installer.sendBroadcastInstall(canonicalUri,
Installer.ACTION_INSTALL_INTERRUPTED);
break;
case Activity.RESULT_FIRST_USER:
case AppCompatActivity.RESULT_FIRST_USER:
default:
// AOSP returns Activity.RESULT_FIRST_USER on error
// AOSP returns AppCompatActivity.RESULT_FIRST_USER on error
installer.sendBroadcastInstall(canonicalUri,
Installer.ACTION_INSTALL_INTERRUPTED,
getString(R.string.install_error_unknown));
@ -182,13 +182,13 @@ public class DefaultInstallerActivity extends FragmentActivity {
break;
case REQUEST_CODE_UNINSTALL:
switch (resultCode) {
case Activity.RESULT_OK:
case AppCompatActivity.RESULT_OK:
installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_COMPLETE);
break;
case Activity.RESULT_CANCELED:
case AppCompatActivity.RESULT_CANCELED:
installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_INTERRUPTED);
break;
case Activity.RESULT_FIRST_USER:
case AppCompatActivity.RESULT_FIRST_USER:
default:
// AOSP UninstallAppProgress returns RESULT_FIRST_USER on error
installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_INTERRUPTED,

View File

@ -19,7 +19,7 @@
package org.fdroid.fdroid.installer;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@ -52,7 +52,7 @@ public class ErrorDialogActivity extends FragmentActivity {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setResult(Activity.RESULT_OK);
setResult(AppCompatActivity.RESULT_OK);
finish();
}
});
@ -60,7 +60,7 @@ public class ErrorDialogActivity extends FragmentActivity {
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
setResult(Activity.RESULT_CANCELED);
setResult(AppCompatActivity.RESULT_CANCELED);
finish();
}
});

View File

@ -80,7 +80,7 @@ public abstract class Installer {
/**
* Returns permission screen for given apk.
*
* @return Intent with Activity to show required permissions.
* @return Intent with AppCompatActivity to show required permissions.
* Returns null if Installer handles that on itself, e.g., with DefaultInstaller,
* or if no new permissions have been introduced during an update
*/

View File

@ -115,7 +115,7 @@ public class ObfInstallerService extends IntentService {
if (intent != null && intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Log.i(TAG, "No Activity available to handle " + intent);
Log.i(TAG, "No AppCompatActivity available to handle " + intent);
}
sendBroadcastInstall(Installer.ACTION_INSTALL_COMPLETE, canonicalUri, apk, null);
}

View File

@ -366,7 +366,7 @@ public class DownloaderService extends Service {
/**
* Check if a URL is waiting in the queue for downloading or if actively being downloaded.
* This is useful for checking whether to re-register {@link android.content.BroadcastReceiver}s
* in {@link android.app.Activity#onResume()}.
* in {@link android.app.AppCompatActivity#onResume()}.
*/
public static boolean isQueuedOrActive(String canonicalUrl) {
if (TextUtils.isEmpty(canonicalUrl)) { //NOPMD - suggests unreadable format

View File

@ -24,10 +24,6 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.net.Uri;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@ -36,7 +32,13 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
@ -51,7 +53,7 @@ import org.fdroid.fdroid.data.Schema;
* Parts are based on AOSP src/com/android/packageinstaller/PackageInstallerActivity.java
* latest included commit: c23d802958158d522e7350321ad9ac6d43013883
*/
public class InstallConfirmActivity extends FragmentActivity implements OnCancelListener, OnClickListener {
public class InstallConfirmActivity extends AppCompatActivity implements OnCancelListener, OnClickListener {
private Intent intent;

View File

@ -17,7 +17,7 @@
package org.fdroid.fdroid.privileged.views;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.graphics.Rect;
import androidx.annotation.NonNull;
@ -67,7 +67,7 @@ class TabsAdapter extends PagerAdapter
}
}
TabsAdapter(Activity activity, TabHost tabHost, ViewPager pager) {
TabsAdapter(AppCompatActivity activity, TabHost tabHost, ViewPager pager) {
context = activity;
this.tabHost = tabHost;
viewPager = pager;

View File

@ -19,7 +19,7 @@
package org.fdroid.fdroid.privileged.views;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@ -89,7 +89,7 @@ public class UninstallDialogActivity extends FragmentActivity {
public void onClick(DialogInterface dialog, int which) {
Intent data = new Intent();
data.putExtra(Installer.EXTRA_APK, apk);
setResult(Activity.RESULT_OK, intent);
setResult(AppCompatActivity.RESULT_OK, intent);
finish();
}
});
@ -97,7 +97,7 @@ public class UninstallDialogActivity extends FragmentActivity {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setResult(Activity.RESULT_CANCELED);
setResult(AppCompatActivity.RESULT_CANCELED);
finish();
}
});
@ -105,7 +105,7 @@ public class UninstallDialogActivity extends FragmentActivity {
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
setResult(Activity.RESULT_CANCELED);
setResult(AppCompatActivity.RESULT_CANCELED);
finish();
}
});

View File

@ -1,7 +1,7 @@
package org.fdroid.fdroid.qr;
import android.annotation.TargetApi;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.AsyncTask;
@ -17,11 +17,11 @@ import org.fdroid.fdroid.Utils;
public class QrGenAsyncTask extends AsyncTask<String, Void, Void> {
private static final String TAG = "QrGenAsyncTask";
private final Activity activity;
private final AppCompatActivity activity;
private final int viewId;
private Bitmap qrBitmap;
public QrGenAsyncTask(Activity activity, int viewId) {
public QrGenAsyncTask(AppCompatActivity activity, int viewId) {
this.activity = activity;
this.viewId = viewId;
}

View File

@ -22,7 +22,6 @@
package org.fdroid.fdroid.views;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
@ -36,23 +35,26 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewTreeObserver;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.fdroid.fdroid.AppUpdateStatusManager;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.NfcHelper;
@ -314,14 +316,14 @@ public class AppDetailsActivity extends AppCompatActivity
fdroidApp.sendViaBluetooth(this, resultCode, app.packageName);
break;
case REQUEST_PERMISSION_DIALOG:
if (resultCode == Activity.RESULT_OK) {
if (resultCode == AppCompatActivity.RESULT_OK) {
Uri uri = data.getData();
Apk apk = ApkProvider.Helper.findByUri(this, uri, Schema.ApkTable.Cols.ALL);
InstallManagerService.queue(this, app, apk);
}
break;
case REQUEST_UNINSTALL_DIALOG:
if (resultCode == Activity.RESULT_OK) {
if (resultCode == AppCompatActivity.RESULT_OK) {
startUninstall();
}
break;

View File

@ -26,7 +26,6 @@
package org.fdroid.fdroid.views;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -36,6 +35,7 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.CheckBoxPreference;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
@ -160,7 +160,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat
PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_display");
category.removePreference(languagePref);
} else {
Languages languages = Languages.get(getActivity());
Languages languages = Languages.get((AppCompatActivity) getActivity());
languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT);
languagePref.setEntries(languages.getAllNames());
languagePref.setEntryValues(languages.getSupportedLocales());
@ -259,7 +259,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat
case Preferences.PREF_THEME:
entrySummary(key);
if (changing) {
Activity activity = getActivity();
AppCompatActivity activity = (AppCompatActivity) getActivity();
FDroidApp fdroidApp = (FDroidApp) activity.getApplication();
fdroidApp.reloadTheme();
fdroidApp.applyTheme(activity);
@ -290,7 +290,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat
case Preferences.PREF_LANGUAGE:
entrySummary(key);
if (changing) {
Activity activity = getActivity();
AppCompatActivity activity = (AppCompatActivity) getActivity();
Languages.setLanguage(activity);
RepoProvider.Helper.clearEtags(getActivity());
@ -462,7 +462,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat
public boolean onPreferenceChange(Preference preference, Object enabled) {
if ((Boolean) enabled) {
enableProxyCheckPref.setChecked(false);
final Activity activity = getActivity();
final AppCompatActivity activity = (AppCompatActivity) getActivity();
if (!OrbotHelper.isOrbotInstalled(activity)) {
Intent intent = OrbotHelper.getOrbotInstallIntent(activity);
activity.startActivityForResult(intent, REQUEST_INSTALL_ORBOT);

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.apps;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@ -12,10 +12,10 @@ import org.fdroid.fdroid.data.Schema;
class AppListAdapter extends RecyclerView.Adapter<StandardAppListItemController> {
private Cursor cursor;
private final Activity activity;
private final AppCompatActivity activity;
private final AppListItemDivider divider;
AppListAdapter(Activity activity) {
AppListAdapter(AppCompatActivity activity) {
this.activity = activity;
divider = new AppListItemDivider(activity);
setHasStableIds(true);

View File

@ -1,7 +1,7 @@
package org.fdroid.fdroid.views.apps;
import android.annotation.TargetApi;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -68,7 +68,7 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
private static Preferences prefs;
protected final Activity activity;
protected final AppCompatActivity activity;
@NonNull
private final ImageView icon;
@ -111,7 +111,7 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
private AppUpdateStatus currentStatus;
@TargetApi(21)
public AppListItemController(final Activity activity, View itemView) {
public AppListItemController(final AppCompatActivity activity, View itemView) {
super(itemView);
this.activity = activity;
if (prefs == null) {

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.apps;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
@ -18,7 +18,7 @@ import org.fdroid.fdroid.data.App;
* </ul>
*/
public class StandardAppListItemController extends AppListItemController {
public StandardAppListItemController(Activity activity, View itemView) {
public StandardAppListItemController(AppCompatActivity activity, View itemView) {
super(activity, itemView);
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.categories;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@ -53,9 +53,9 @@ public class AppCardController extends RecyclerView.ViewHolder
@Nullable
private App currentApp;
private final Activity activity;
private final AppCompatActivity activity;
public AppCardController(Activity activity, View itemView) {
public AppCardController(AppCompatActivity activity, View itemView) {
super(itemView);
this.activity = activity;

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.categories;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@ -12,9 +12,9 @@ import org.fdroid.fdroid.data.App;
class AppPreviewAdapter extends RecyclerView.Adapter<AppCardController> {
private Cursor cursor;
private final Activity activity;
private final AppCompatActivity activity;
AppPreviewAdapter(Activity activity) {
AppPreviewAdapter(AppCompatActivity activity) {
this.activity = activity;
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.categories;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.loader.app.LoaderManager;
import androidx.recyclerview.widget.ListAdapter;
@ -13,10 +13,10 @@ import java.util.List;
public class CategoryAdapter extends ListAdapter<String, CategoryController> {
private final Activity activity;
private final AppCompatActivity activity;
private final LoaderManager loaderManager;
public CategoryAdapter(Activity activity, LoaderManager loaderManager) {
public CategoryAdapter(AppCompatActivity activity, LoaderManager loaderManager) {
super(new DiffUtil.ItemCallback<String>() {
@Override
public boolean areItemsTheSame(String oldItem, String newItem) {

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.categories;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@ -40,14 +40,14 @@ public class CategoryController extends RecyclerView.ViewHolder implements Loade
private final AppPreviewAdapter appCardsAdapter;
private final FrameLayout background;
private final Activity activity;
private final AppCompatActivity activity;
private final LoaderManager loaderManager;
private final DisplayImageOptions displayImageOptions;
private static int categoryItemCount = 20;
private String currentCategory;
CategoryController(final Activity activity, LoaderManager loaderManager, View itemView) {
CategoryController(final AppCompatActivity activity, LoaderManager loaderManager, View itemView) {
super(itemView);
this.activity = activity;

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.installed;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.database.Cursor;
import android.provider.BaseColumns;
import androidx.annotation.NonNull;
@ -13,12 +13,12 @@ import org.fdroid.fdroid.data.App;
public class InstalledAppListAdapter extends RecyclerView.Adapter<InstalledAppListItemController> {
protected final Activity activity;
protected final AppCompatActivity activity;
@Nullable
private Cursor cursor;
protected InstalledAppListAdapter(Activity activity) {
protected InstalledAppListAdapter(AppCompatActivity activity) {
this.activity = activity;
setHasStableIds(true);
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.installed;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
@ -18,7 +18,7 @@ import org.fdroid.fdroid.views.apps.AppListItemState;
* a specific version of this app.
*/
public class InstalledAppListItemController extends AppListItemController {
public InstalledAppListItemController(Activity activity, View itemView) {
public InstalledAppListItemController(AppCompatActivity activity, View itemView) {
super(activity, itemView);
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.ViewGroup;
@ -22,16 +22,16 @@ public class AppStatus extends AppUpdateData {
public final AppUpdateStatusManager.AppUpdateStatus status;
public AppStatus(Activity activity, AppUpdateStatusManager.AppUpdateStatus status) {
public AppStatus(AppCompatActivity activity, AppUpdateStatusManager.AppUpdateStatus status) {
super(activity);
this.status = status;
}
public static class Delegate extends AdapterDelegate<List<AppUpdateData>> {
private final Activity activity;
private final AppCompatActivity activity;
public Delegate(Activity activity) {
public Delegate(AppCompatActivity activity) {
this.activity = activity;
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
@ -21,7 +21,7 @@ import org.fdroid.fdroid.views.updates.UpdatesAdapter;
* * Recently installed and ready to run.
*/
public class AppStatusListItemController extends AppListItemController {
public AppStatusListItemController(Activity activity, View itemView) {
public AppStatusListItemController(AppCompatActivity activity, View itemView) {
super(activity, itemView);
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
/**
* Used as a common base class for all data types in the {@link
@ -10,9 +10,9 @@ import android.app.Activity;
* to specify a data type more specific than just {@link Object}.
*/
public abstract class AppUpdateData { // NOPMD This abstract class does not have any abstract methods
public final Activity activity;
public final AppCompatActivity activity;
public AppUpdateData(Activity activity) {
public AppUpdateData(AppCompatActivity activity) {
this.activity = activity;
}
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.ViewGroup;
@ -24,16 +24,16 @@ public class KnownVulnApp extends AppUpdateData {
public final App app;
public KnownVulnApp(Activity activity, App app) {
public KnownVulnApp(AppCompatActivity activity, App app) {
super(activity);
this.app = app;
}
public static class Delegate extends AdapterDelegate<List<AppUpdateData>> {
private final Activity activity;
private final AppCompatActivity activity;
public Delegate(Activity activity) {
public Delegate(AppCompatActivity activity) {
this.activity = activity;
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -32,7 +32,7 @@ import org.fdroid.fdroid.views.updates.UpdatesAdapter;
* (e.g. uninstall, update, disable).
*/
public class KnownVulnAppListItemController extends AppListItemController {
public KnownVulnAppListItemController(Activity activity, View itemView) {
public KnownVulnAppListItemController(AppCompatActivity activity, View itemView) {
super(activity, itemView);
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.ViewGroup;
@ -22,16 +22,16 @@ public class UpdateableApp extends AppUpdateData {
public final App app;
public UpdateableApp(Activity activity, App app) {
public UpdateableApp(AppCompatActivity activity, App app) {
super(activity);
this.app = app;
}
public static class Delegate extends AdapterDelegate<List<AppUpdateData>> {
private final Activity activity;
private final AppCompatActivity activity;
public Delegate(Activity activity) {
public Delegate(AppCompatActivity activity) {
this.activity = activity;
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
@ -22,7 +22,7 @@ import org.fdroid.fdroid.views.updates.UpdatesAdapter;
* {@link AppStatusListItemController}.
*/
public class UpdateableAppListItemController extends AppListItemController {
public UpdateableAppListItemController(Activity activity, View itemView) {
public UpdateableAppListItemController(AppCompatActivity activity, View itemView) {
super(activity, itemView);
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.updates.items;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
@ -29,7 +29,7 @@ public class UpdateableAppsHeader extends AppUpdateData {
public final List<UpdateableApp> apps;
public final UpdatesAdapter adapter;
public UpdateableAppsHeader(Activity activity,
public UpdateableAppsHeader(AppCompatActivity activity,
UpdatesAdapter updatesAdapter, List<UpdateableApp> updateableApps) {
super(activity);
apps = updateableApps;
@ -40,7 +40,7 @@ public class UpdateableAppsHeader extends AppUpdateData {
private final LayoutInflater inflater;
public Delegate(Activity activity) {
public Delegate(AppCompatActivity activity) {
inflater = activity.getLayoutInflater();
}

View File

@ -1,6 +1,6 @@
package org.fdroid.fdroid.views.whatsnew;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
@ -19,10 +19,10 @@ import org.fdroid.fdroid.views.categories.AppCardController;
public class WhatsNewAdapter extends RecyclerView.Adapter<AppCardController> {
private Cursor cursor;
private final Activity activity;
private final AppCompatActivity activity;
private final RecyclerView.ItemDecoration appListDecorator;
public WhatsNewAdapter(Activity activity) {
public WhatsNewAdapter(AppCompatActivity activity) {
this.activity = activity;
appListDecorator = new WhatsNewAdapter.ItemDecorator(activity);
}