AppDetails2 run style formatter and fix line length issues
This commit is contained in:
parent
532d1dfc72
commit
8a0abdd841
@ -48,10 +48,8 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
|
|
||||||
import org.fdroid.fdroid.data.Apk;
|
import org.fdroid.fdroid.data.Apk;
|
||||||
import org.fdroid.fdroid.data.ApkProvider;
|
import org.fdroid.fdroid.data.ApkProvider;
|
||||||
import org.fdroid.fdroid.data.App;
|
import org.fdroid.fdroid.data.App;
|
||||||
@ -69,8 +67,9 @@ import org.fdroid.fdroid.views.apps.FeatureImage;
|
|||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@SuppressWarnings("LineLength")
|
public class AppDetails2 extends AppCompatActivity
|
||||||
public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog.ShareChooserDialogListener, AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks {
|
implements ShareChooserDialog.ShareChooserDialogListener,
|
||||||
|
AppDetailsRecyclerViewAdapter.AppDetailsRecyclerViewAdapterCallbacks {
|
||||||
|
|
||||||
public static final String EXTRA_APPID = "appid";
|
public static final String EXTRA_APPID = "appid";
|
||||||
private static final String TAG = "AppDetails2";
|
private static final String TAG = "AppDetails2";
|
||||||
@ -121,7 +120,8 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
appBarLayout = (AppBarLayout) coordinatorLayout.findViewById(R.id.app_bar);
|
appBarLayout = (AppBarLayout) coordinatorLayout.findViewById(R.id.app_bar);
|
||||||
recyclerView = (RecyclerView) findViewById(R.id.rvDetails);
|
recyclerView = (RecyclerView) findViewById(R.id.rvDetails);
|
||||||
adapter = new AppDetailsRecyclerViewAdapter(this, app, this);
|
adapter = new AppDetailsRecyclerViewAdapter(this, app, this);
|
||||||
OverscrollLinearLayoutManager lm = new OverscrollLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
OverscrollLinearLayoutManager lm = new OverscrollLinearLayoutManager(this,
|
||||||
|
LinearLayoutManager.VERTICAL, false);
|
||||||
lm.setStackFromEnd(false);
|
lm.setStackFromEnd(false);
|
||||||
|
|
||||||
// Has to be invoked after AppDetailsRecyclerViewAdapter is created.
|
// Has to be invoked after AppDetailsRecyclerViewAdapter is created.
|
||||||
@ -146,10 +146,12 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
public int onOverscrollY(int overscroll) {
|
public int onOverscrollY(int overscroll) {
|
||||||
int consumed = 0;
|
int consumed = 0;
|
||||||
if (overscroll < 0) {
|
if (overscroll < 0) {
|
||||||
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
|
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams)
|
||||||
|
appBarLayout.getLayoutParams();
|
||||||
CoordinatorLayout.Behavior behavior = lp.getBehavior();
|
CoordinatorLayout.Behavior behavior = lp.getBehavior();
|
||||||
if (behavior != null && behavior instanceof AppBarLayout.Behavior) {
|
if (behavior != null && behavior instanceof AppBarLayout.Behavior) {
|
||||||
((AppBarLayout.Behavior) behavior).onNestedScroll(coordinatorLayout, appBarLayout, recyclerView, 0, 0, 0, overscroll);
|
((AppBarLayout.Behavior) behavior).onNestedScroll(
|
||||||
|
coordinatorLayout, appBarLayout, recyclerView, 0, 0, 0, overscroll);
|
||||||
consumed = overscroll; // Consume all of it!
|
consumed = overscroll; // Consume all of it!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +175,8 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
final FeatureImage featureImage = (FeatureImage) findViewById(R.id.feature_graphic);
|
final FeatureImage featureImage = (FeatureImage) findViewById(R.id.feature_graphic);
|
||||||
DisplayImageOptions displayImageOptions = Utils.getImageLoadingOptions().build();
|
DisplayImageOptions displayImageOptions = Utils.getImageLoadingOptions().build();
|
||||||
String featureGraphicUrl = app.getFeatureGraphicUrl(this);
|
String featureGraphicUrl = app.getFeatureGraphicUrl(this);
|
||||||
featureImage.loadImageAndDisplay(ImageLoader.getInstance(), displayImageOptions, featureGraphicUrl, app.iconUrl);
|
featureImage.loadImageAndDisplay(ImageLoader.getInstance(), displayImageOptions,
|
||||||
|
featureGraphicUrl, app.iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPackageNameFromIntent(Intent intent) {
|
private String getPackageNameFromIntent(Intent intent) {
|
||||||
@ -197,26 +200,27 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
app = newApp;
|
app = newApp;
|
||||||
|
|
||||||
// Remove all "installed" statuses for this app, since we are now viewing it.
|
// Remove all "installed" statuses for this app, since we are now viewing it.
|
||||||
AppUpdateStatusManager appUpdateStatusManager = AppUpdateStatusManager.getInstance(this);
|
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : appUpdateStatusManager.getByPackageName(app.packageName)) {
|
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(app.packageName)) {
|
||||||
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
||||||
appUpdateStatusManager.removeApk(status.getUniqueKey());
|
ausm.removeApk(status.getUniqueKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some notifications (like "downloading" and "installed") are not shown for this app if it is open in app details.
|
* Some notifications (like "downloading" and "installed") are not shown
|
||||||
* When closing, we need to refresh the notifications, so they are displayed again.
|
* for this app if it is open in app details. When closing, we need to
|
||||||
|
* refresh the notifications, so they are displayed again.
|
||||||
*/
|
*/
|
||||||
private void updateNotificationsForApp() {
|
private void updateNotificationsForApp() {
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
AppUpdateStatusManager appUpdateStatusManager = AppUpdateStatusManager.getInstance(this);
|
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : appUpdateStatusManager.getByPackageName(app.packageName)) {
|
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(app.packageName)) {
|
||||||
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
||||||
appUpdateStatusManager.removeApk(status.getUniqueKey());
|
ausm.removeApk(status.getUniqueKey());
|
||||||
} else {
|
} else {
|
||||||
appUpdateStatusManager.refreshApk(status.getUniqueKey());
|
ausm.refreshApk(status.getUniqueKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,7 +249,8 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
* Then, asks the view to update itself to reflect this status.
|
* Then, asks the view to update itself to reflect this status.
|
||||||
*/
|
*/
|
||||||
private void refreshStatus() {
|
private void refreshStatus() {
|
||||||
Iterator<AppUpdateStatusManager.AppUpdateStatus> statuses = AppUpdateStatusManager.getInstance(this).getByPackageName(app.packageName).iterator();
|
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||||
|
Iterator<AppUpdateStatusManager.AppUpdateStatus> statuses = ausm.getByPackageName(app.packageName).iterator();
|
||||||
if (statuses.hasNext()) {
|
if (statuses.hasNext()) {
|
||||||
AppUpdateStatusManager.AppUpdateStatus status = statuses.next();
|
AppUpdateStatusManager.AppUpdateStatus status = statuses.next();
|
||||||
updateAppStatus(status, false);
|
updateAppStatus(status, false);
|
||||||
@ -304,10 +309,12 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, app.name);
|
shareIntent.putExtra(Intent.EXTRA_SUBJECT, app.name);
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, app.name + " (" + app.summary + ") - https://f-droid.org/app/" + app.packageName);
|
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()) && fdroidApp.bluetoothAdapter != null;
|
||||||
ShareChooserDialog.createChooser((CoordinatorLayout) findViewById(R.id.rootCoordinator), this, this, shareIntent, showNearbyItem);
|
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.rootCoordinator);
|
||||||
|
ShareChooserDialog.createChooser(coordinatorLayout, this, this, shareIntent, showNearbyItem);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.action_ignore_all) {
|
} else if (item.getItemId() == R.id.action_ignore_all) {
|
||||||
app.getPrefs(this).ignoreAllUpdates ^= true;
|
app.getPrefs(this).ignoreAllUpdates ^= true;
|
||||||
@ -420,7 +427,8 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
|
|
||||||
private void initiateInstall(Apk apk) {
|
private void initiateInstall(Apk apk) {
|
||||||
if (isAppDownloading()) {
|
if (isAppDownloading()) {
|
||||||
Log.i(TAG, "Ignoring request to install " + apk.packageName + " version " + apk.versionName + ", as we are already downloading (either that or a different version).");
|
Log.i(TAG, "Ignoring request to install " + apk.packageName + " version " + apk.versionName
|
||||||
|
+ ", as we are already downloading (either that or a different version).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,7 +497,8 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
case ReadyToInstall:
|
case ReadyToInstall:
|
||||||
if (justReceived) {
|
if (justReceived) {
|
||||||
adapter.clearProgress();
|
adapter.clearProgress();
|
||||||
localBroadcastManager.registerReceiver(installReceiver, Installer.getInstallIntentFilter(Uri.parse(newStatus.getUniqueKey())));
|
localBroadcastManager.registerReceiver(installReceiver,
|
||||||
|
Installer.getInstallIntentFilter(Uri.parse(newStatus.getUniqueKey())));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -520,13 +529,19 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
private final BroadcastReceiver appStatusReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver appStatusReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
AppUpdateStatusManager.AppUpdateStatus status = intent.getParcelableExtra(AppUpdateStatusManager.EXTRA_STATUS);
|
AppUpdateStatusManager.AppUpdateStatus status = intent.getParcelableExtra(
|
||||||
|
AppUpdateStatusManager.EXTRA_STATUS);
|
||||||
|
|
||||||
boolean isRemoving = TextUtils.equals(intent.getAction(), AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
|
boolean isRemoving = TextUtils.equals(intent.getAction(),
|
||||||
if (currentStatus != null && isRemoving && !TextUtils.equals(status.getUniqueKey(), currentStatus.getUniqueKey())) {
|
AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
|
||||||
Utils.debugLog(TAG, "Ignoring app status change because it belongs to " + status.getUniqueKey() + " not " + currentStatus.getUniqueKey());
|
if (currentStatus != null
|
||||||
|
&& isRemoving
|
||||||
|
&& !TextUtils.equals(status.getUniqueKey(), currentStatus.getUniqueKey())) {
|
||||||
|
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
||||||
|
+ status.getUniqueKey() + " not " + currentStatus.getUniqueKey());
|
||||||
} else if (status != null && !TextUtils.equals(status.apk.packageName, app.packageName)) {
|
} else if (status != null && !TextUtils.equals(status.apk.packageName, app.packageName)) {
|
||||||
Utils.debugLog(TAG, "Ignoring app status change because it belongs to " + status.apk.packageName + " not " + app.packageName);
|
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
||||||
|
+ status.apk.packageName + " not " + app.packageName);
|
||||||
} else {
|
} else {
|
||||||
updateAppStatus(status, true);
|
updateAppStatus(status, true);
|
||||||
}
|
}
|
||||||
@ -583,15 +598,17 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
case Installer.ACTION_INSTALL_USER_INTERACTION:
|
case Installer.ACTION_INSTALL_USER_INTERACTION:
|
||||||
Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
|
Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
|
||||||
if (!isAppVisible(apk.packageName)) {
|
if (!isAppVisible(apk.packageName)) {
|
||||||
Utils.debugLog(TAG, "Ignore request for user interaction from installer, because " + apk.packageName + " is no longer showing.");
|
Utils.debugLog(TAG, "Ignore request for user interaction from installer, because "
|
||||||
|
+ apk.packageName + " is no longer showing.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.debugLog(TAG, "Automatically showing package manager for " + apk.packageName + " as it is being viewed by the user.");
|
Utils.debugLog(TAG, "Automatically showing package manager for " + apk.packageName
|
||||||
PendingIntent installPendingIntent = intent.getParcelableExtra(Installer.EXTRA_USER_INTERACTION_PI);
|
+ " as it is being viewed by the user.");
|
||||||
|
PendingIntent pendingIntent = intent.getParcelableExtra(Installer.EXTRA_USER_INTERACTION_PI);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
installPendingIntent.send();
|
pendingIntent.send();
|
||||||
} catch (PendingIntent.CanceledException e) {
|
} catch (PendingIntent.CanceledException e) {
|
||||||
Log.e(TAG, "PI canceled", e);
|
Log.e(TAG, "PI canceled", e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user