rename AppDetails2 to AppDetailsActivity

This also moves it into org.fdroid.fdroid.views
This commit is contained in:
Hans-Christoph Steiner 2018-12-17 17:16:51 +01:00
parent 9cddc0c990
commit 148d1cdc8a
15 changed files with 59 additions and 52 deletions

View File

@ -173,7 +173,7 @@
</activity>
<activity
android:name=".AppDetails2"
android:name=".views.AppDetailsActivity"
android:label="@string/app_details"
android:exported="true"
android:parentActivityName=".views.main.MainActivity"

View File

@ -19,6 +19,7 @@ import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.data.Repo;
import org.fdroid.fdroid.installer.ErrorDialogActivity;
import org.fdroid.fdroid.installer.InstallManagerService;
import org.fdroid.fdroid.views.AppDetailsActivity;
import java.util.ArrayList;
import java.util.Collection;
@ -532,16 +533,16 @@ public final class AppUpdateStatusManager {
/**
* Get a {@link PendingIntent} for a {@link Notification} to send when it
* is clicked. {@link AppDetails2} handles {@code Intent}s that are missing
* or bad {@link AppDetails2#EXTRA_APPID}, so it does not need to be checked
* is clicked. {@link AppDetailsActivity} handles {@code Intent}s that are missing
* or bad {@link AppDetailsActivity#EXTRA_APPID}, so it does not need to be checked
* here.
*/
private PendingIntent getAppDetailsIntent(Apk apk) {
Intent notifyIntent = new Intent(context, AppDetails2.class)
.putExtra(AppDetails2.EXTRA_APPID, apk.packageName);
Intent notifyIntent = new Intent(context, AppDetailsActivity.class)
.putExtra(AppDetailsActivity.EXTRA_APPID, apk.packageName);
return TaskStackBuilder.create(context)
.addParentStack(AppDetails2.class)
.addParentStack(AppDetailsActivity.class)
.addNextIntent(notifyIntent)
.getPendingIntent(apk.packageName.hashCode(), PendingIntent.FLAG_UPDATE_CURRENT);
}

View File

@ -27,8 +27,6 @@ import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -132,9 +130,6 @@ public class FDroidApp extends Application {
// Leaving the fully qualified class name here to help clarify the difference between spongy/bouncy castle.
private static final org.bouncycastle.jce.provider.BouncyCastleProvider BOUNCYCASTLE_PROVIDER;
@SuppressWarnings("unused")
BluetoothAdapter bluetoothAdapter;
/**
* The construction of this notification helper has side effects including listening and
* responding to local broadcasts. It is kept as a reference on the app object here so that
@ -393,7 +388,6 @@ public class FDroidApp extends Application {
CleanCacheService.schedule(this);
notificationHelper = new NotificationHelper(getApplicationContext());
bluetoothAdapter = getBluetoothAdapter();
// There are a couple things to pay attention to with this config: memory usage,
// especially on small devices; and, image processing vulns, since images are
@ -559,16 +553,6 @@ public class FDroidApp extends Application {
return 2;
}
@TargetApi(18)
private BluetoothAdapter getBluetoothAdapter() {
// to use the new, recommended way of getting the adapter
// http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html
if (Build.VERSION.SDK_INT < 18) {
return BluetoothAdapter.getDefaultAdapter();
}
return ((BluetoothManager) getSystemService(BLUETOOTH_SERVICE)).getAdapter();
}
private SharedPreferences getAtStartTimeSharedPreferences() {
return getSharedPreferences("at-start-time", Context.MODE_PRIVATE);
}

View File

@ -53,7 +53,7 @@ public class NfcHelper {
}
@TargetApi(16)
static void disableAndroidBeam(Activity activity) {
public static void disableAndroidBeam(Activity activity) {
if (Build.VERSION.SDK_INT < 16) {
return;
}

View File

@ -27,6 +27,7 @@ import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.utils.DiskCacheUtils;
import org.fdroid.fdroid.data.App;
import org.fdroid.fdroid.views.AppDetailsActivity;
import org.fdroid.fdroid.views.main.MainActivity;
import java.util.ArrayList;
@ -154,7 +155,7 @@ class NotificationHelper {
} else if ((entry.status == AppUpdateStatusManager.Status.Downloading ||
entry.status == AppUpdateStatusManager.Status.ReadyToInstall ||
entry.status == AppUpdateStatusManager.Status.InstallError) &&
AppDetails2.isAppVisible(entry.app.packageName)) {
AppDetailsActivity.isAppVisible(entry.app.packageName)) {
// Ignore downloading, readyToInstall and installError if we are showing the details screen for this app
return true;
}

View File

@ -28,7 +28,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.JobIntentService;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.fdroid.fdroid.AppDetails2;
import org.fdroid.fdroid.views.AppDetailsActivity;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.App;
@ -135,7 +135,7 @@ public class InstallerService extends JobIntentService {
* <p>
* If you quickly cycle between installing an app and uninstalling it, then
* {@link App#installedApk} will still be null when
* {@link AppDetails2#startUninstall()} calls
* {@link AppDetailsActivity#startUninstall()} calls
* this method. It is better to crash earlier here, before the {@link Intent}
* is sent with a null {@link Apk} instance since this service is set to
* receive Sticky Intents. That means they will automatically be resent

View File

@ -434,7 +434,7 @@ public class AppSecurityPermissions {
|| ((pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_PRE23) != 0);
// Dangerous and normal permissions are always shown to the user
// this is matches the permission list in AppDetails2
// this is matches the permission list in AppDetailsActivity
if (isNormal || isDangerous) {
return true;
}

View File

@ -19,11 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.fdroid.fdroid;
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;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@ -31,6 +33,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
@ -49,6 +52,11 @@ import android.view.ViewTreeObserver;
import android.widget.Toast;
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;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.ApkProvider;
import org.fdroid.fdroid.data.App;
@ -59,23 +67,24 @@ import org.fdroid.fdroid.installer.InstallManagerService;
import org.fdroid.fdroid.installer.Installer;
import org.fdroid.fdroid.installer.InstallerFactory;
import org.fdroid.fdroid.installer.InstallerService;
import org.fdroid.fdroid.views.AppDetailsRecyclerViewAdapter;
import org.fdroid.fdroid.views.ShareChooserDialog;
import org.fdroid.fdroid.views.apps.FeatureImage;
import java.util.Iterator;
public class AppDetails2 extends AppCompatActivity
public class AppDetailsActivity extends AppCompatActivity
implements ShareChooserDialog.ShareChooserDialogListener,
AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks {
public static final String EXTRA_APPID = "appid";
private static final String TAG = "AppDetails2";
private static final String TAG = "AppDetailsActivity";
private static final int REQUEST_ENABLE_BLUETOOTH = 2;
private static final int REQUEST_PERMISSION_DIALOG = 3;
private static final int REQUEST_UNINSTALL_DIALOG = 4;
@SuppressWarnings("unused")
protected BluetoothAdapter bluetoothAdapter;
private FDroidApp fdroidApp;
private App app;
private RecyclerView recyclerView;
@ -111,6 +120,8 @@ public class AppDetails2 extends AppCompatActivity
return;
}
bluetoothAdapter = getBluetoothAdapter();
localBroadcastManager = LocalBroadcastManager.getInstance(this);
recyclerView = (RecyclerView) findViewById(R.id.rvDetails);
@ -254,7 +265,7 @@ public class AppDetails2 extends AppCompatActivity
shareIntent.putExtra(Intent.EXTRA_TEXT, app.name + " (" + app.summary
+ ") - https://f-droid.org/app/" + app.packageName);
boolean showNearbyItem = app.isInstalled(getApplicationContext()) && fdroidApp.bluetoothAdapter != null;
boolean showNearbyItem = app.isInstalled(getApplicationContext()) && bluetoothAdapter != null;
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.rootCoordinator);
ShareChooserDialog.createChooser(coordinatorLayout, this, this, shareIntent, showNearbyItem);
return true;
@ -531,7 +542,7 @@ public class AppDetails2 extends AppCompatActivity
getString(R.string.install_error_notify_title),
app.name);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(AppDetails2.this);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(AppDetailsActivity.this);
alertBuilder.setTitle(title);
alertBuilder.setMessage(errorMessage);
alertBuilder.setNeutralButton(android.R.string.ok, null);
@ -584,7 +595,7 @@ public class AppDetails2 extends AppCompatActivity
if (!TextUtils.isEmpty(errorMessage)) {
Log.e(TAG, "uninstall aborted with errorMessage: " + errorMessage);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(AppDetails2.this);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(AppDetailsActivity.this);
Uri uri = intent.getData();
if (uri == null) {
alertBuilder.setTitle(getString(R.string.uninstall_error_notify_title, ""));
@ -656,7 +667,7 @@ public class AppDetails2 extends AppCompatActivity
public void run() {
String packageName = app != null ? app.packageName : null;
if (!resetCurrentApp(packageName)) {
AppDetails2.this.finish();
AppDetailsActivity.this.finish();
return;
}
AppDetailsRecyclerViewAdapter adapter = (AppDetailsRecyclerViewAdapter) recyclerView.getAdapter();
@ -684,6 +695,16 @@ public class AppDetails2 extends AppCompatActivity
NfcHelper.disableAndroidBeam(this);
}
@TargetApi(18)
private BluetoothAdapter getBluetoothAdapter() {
// to use the new, recommended way of getting the adapter
// http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html
if (Build.VERSION.SDK_INT < 18) {
return BluetoothAdapter.getDefaultAdapter();
}
return ((BluetoothManager) getSystemService(BLUETOOTH_SERVICE)).getAdapter();
}
@Override
public void openUrl(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

View File

@ -157,7 +157,7 @@ public class RepoDetailsActivity extends AppCompatActivity {
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver,
new IntentFilter(UpdateService.LOCAL_ACTION_STATUS));
// FDroid.java and AppDetails2 set different NFC actions, so reset here
// FDroid.java and AppDetailsActivity set different NFC actions, so reset here
setNfc();
processIntent(getIntent());
}

View File

@ -28,7 +28,7 @@ import org.fdroid.fdroid.data.AppProvider;
* Full screen view of an apps screenshots to swipe through. This will always
* download the image, even if the user has said not to use "unmetered" networks,
* e.g. WiFi. That is because the user has to click on the thumbnail in
* {@link org.fdroid.fdroid.AppDetails2} in order to bring up this activity.
* {@link AppDetailsActivity} in order to bring up this activity.
* That makes it a specific request for that image, rather than regular
* background loading.
*/

View File

@ -14,7 +14,7 @@ import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.App;
/**
* Loads and displays the small screenshots that are inline in {@link org.fdroid.fdroid.AppDetails2}
* Loads and displays the small screenshots that are inline in {@link AppDetailsActivity}
*/
class ScreenShotsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final String[] screenshots;

View File

@ -27,7 +27,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.fdroid.fdroid.AppDetails2;
import org.fdroid.fdroid.views.AppDetailsActivity;
import org.fdroid.fdroid.AppUpdateStatusManager;
import org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus;
import org.fdroid.fdroid.R;
@ -422,8 +422,8 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
return;
}
Intent intent = new Intent(activity, AppDetails2.class);
intent.putExtra(AppDetails2.EXTRA_APPID, currentApp.packageName);
Intent intent = new Intent(activity, AppDetailsActivity.class);
intent.putExtra(AppDetailsActivity.EXTRA_APPID, currentApp.packageName);
if (Build.VERSION.SDK_INT >= 21) {
String transitionAppIcon = activity.getString(R.string.transition_app_item_icon);
Pair<View, String> iconTransitionPair = Pair.create((View) icon, transitionAppIcon);

View File

@ -21,7 +21,7 @@ import android.widget.TextView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import org.fdroid.fdroid.AppDetails2;
import org.fdroid.fdroid.views.AppDetailsActivity;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.App;
@ -144,7 +144,7 @@ public class AppCardController extends RecyclerView.ViewHolder
}
/**
* When the user clicks/touches an app card, we launch the {@link AppDetails2} activity in response.
* When the user clicks/touches an app card, we launch the {@link AppDetailsActivity} activity in response.
*/
@Override
public void onClick(View v) {
@ -152,8 +152,8 @@ public class AppCardController extends RecyclerView.ViewHolder
return;
}
Intent intent = new Intent(activity, AppDetails2.class);
intent.putExtra(AppDetails2.EXTRA_APPID, currentApp.packageName);
Intent intent = new Intent(activity, AppDetailsActivity.class);
intent.putExtra(AppDetailsActivity.EXTRA_APPID, currentApp.packageName);
if (Build.VERSION.SDK_INT >= 21) {
Pair<View, String> iconTransitionPair = Pair.create((View) icon,
activity.getString(R.string.transition_app_item_icon));

View File

@ -41,7 +41,7 @@ import android.widget.Toast;
import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.ashokvarma.bottomnavigation.TextBadgeItem;
import org.fdroid.fdroid.AppDetails2;
import org.fdroid.fdroid.views.AppDetailsActivity;
import org.fdroid.fdroid.AppUpdateStatusManager;
import org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus;
import org.fdroid.fdroid.BuildConfig;
@ -184,7 +184,7 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
setSelectedMenuInNav();
}
// AppDetails2 and RepoDetailsActivity set different NFC actions, so reset here
// AppDetailsActivity and RepoDetailsActivity set different NFC actions, so reset here
NfcHelper.setAndroidBeam(this, getApplication().getPackageName());
checkForAddRepoIntent(getIntent());
}
@ -309,8 +309,8 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
if (!TextUtils.isEmpty(packageName)) {
Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'");
Intent intentToInvoke = new Intent(this, AppDetails2.class);
intentToInvoke.putExtra(AppDetails2.EXTRA_APPID, packageName);
Intent intentToInvoke = new Intent(this, AppDetailsActivity.class);
intentToInvoke.putExtra(AppDetailsActivity.EXTRA_APPID, packageName);
startActivity(intentToInvoke);
finish();
} else if (!TextUtils.isEmpty(query)) {

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="org.fdroid.fdroid.AppDetails2"
tools:context="org.fdroid.fdroid.views.AppDetailsActivity"
android:background="?attr/appDetailsBackground"
android:id="@+id/rootCoordinator">
@ -52,7 +52,7 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layoutManager="LinearLayoutManager"
tools:context="org.fdroid.fdroid.AppDetails2"
tools:context="org.fdroid.fdroid.views.AppDetailsActivity"
tools:showIn="@layout/app_details2" />
</android.support.design.widget.CoordinatorLayout>