Fix checkstyle errors
This commit is contained in:
parent
0b53f69427
commit
d43b31a701
@ -73,7 +73,6 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
|
|
||||||
private static String visiblePackageName;
|
private static String visiblePackageName;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
fdroidApp = (FDroidApp) getApplication();
|
fdroidApp = (FDroidApp) getApplication();
|
||||||
|
@ -33,7 +33,7 @@ import java.util.Map;
|
|||||||
* and {@code versionCode} since there could be different copies of the same
|
* and {@code versionCode} since there could be different copies of the same
|
||||||
* APK on different servers, signed by different keys, or even different builds.
|
* APK on different servers, signed by different keys, or even different builds.
|
||||||
*/
|
*/
|
||||||
public class AppUpdateStatusManager {
|
public final class AppUpdateStatusManager {
|
||||||
|
|
||||||
static final String BROADCAST_APPSTATUS_LIST_CHANGED = "org.fdroid.fdroid.installer.appstatus.listchange";
|
static final String BROADCAST_APPSTATUS_LIST_CHANGED = "org.fdroid.fdroid.installer.appstatus.listchange";
|
||||||
static final String BROADCAST_APPSTATUS_ADDED = "org.fdroid.fdroid.installer.appstatus.appchange.add";
|
static final String BROADCAST_APPSTATUS_ADDED = "org.fdroid.fdroid.installer.appstatus.appchange.add";
|
||||||
@ -60,6 +60,7 @@ public class AppUpdateStatusManager {
|
|||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AppUpdateStatusManager instance;
|
private static AppUpdateStatusManager instance;
|
||||||
|
|
||||||
public class AppUpdateStatus {
|
public class AppUpdateStatus {
|
||||||
@ -125,7 +126,7 @@ public class AppUpdateStatusManager {
|
|||||||
|
|
||||||
private void updateApkInternal(@NonNull AppUpdateStatus entry, @NonNull Status status, PendingIntent intent) {
|
private void updateApkInternal(@NonNull AppUpdateStatus entry, @NonNull Status status, PendingIntent intent) {
|
||||||
Utils.debugLog(LOGTAG, "Update APK " + entry.apk.apkName + " state to " + status.name());
|
Utils.debugLog(LOGTAG, "Update APK " + entry.apk.apkName + " state to " + status.name());
|
||||||
boolean isStatusUpdate = (entry.status != status);
|
boolean isStatusUpdate = entry.status != status;
|
||||||
entry.status = status;
|
entry.status = status;
|
||||||
entry.intent = intent;
|
entry.intent = intent;
|
||||||
// If intent not set, see if we need to create a default intent
|
// If intent not set, see if we need to create a default intent
|
||||||
@ -187,7 +188,6 @@ public class AppUpdateStatusManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addApks(List<Apk> apksToUpdate, Status status) {
|
public void addApks(List<Apk> apksToUpdate, Status status) {
|
||||||
startBatchUpdates();
|
startBatchUpdates();
|
||||||
for (Apk apk : apksToUpdate) {
|
for (Apk apk : apksToUpdate) {
|
||||||
@ -300,7 +300,7 @@ public class AppUpdateStatusManager {
|
|||||||
|
|
||||||
void clearAllUpdates() {
|
void clearAllUpdates() {
|
||||||
synchronized (appMapping) {
|
synchronized (appMapping) {
|
||||||
for (Iterator<Map.Entry<String, AppUpdateStatus>> it = appMapping.entrySet().iterator(); it.hasNext(); ) {
|
for (Iterator<Map.Entry<String, AppUpdateStatus>> it = appMapping.entrySet().iterator(); it.hasNext();) {
|
||||||
Map.Entry<String, AppUpdateStatus> entry = it.next();
|
Map.Entry<String, AppUpdateStatus> entry = it.next();
|
||||||
if (entry.getValue().status != Status.Installed) {
|
if (entry.getValue().status != Status.Installed) {
|
||||||
it.remove();
|
it.remove();
|
||||||
@ -312,7 +312,7 @@ public class AppUpdateStatusManager {
|
|||||||
|
|
||||||
void clearAllInstalled() {
|
void clearAllInstalled() {
|
||||||
synchronized (appMapping) {
|
synchronized (appMapping) {
|
||||||
for (Iterator<Map.Entry<String, AppUpdateStatus>> it = appMapping.entrySet().iterator(); it.hasNext(); ) {
|
for (Iterator<Map.Entry<String, AppUpdateStatus>> it = appMapping.entrySet().iterator(); it.hasNext();) {
|
||||||
Map.Entry<String, AppUpdateStatus> entry = it.next();
|
Map.Entry<String, AppUpdateStatus> entry = it.next();
|
||||||
if (entry.getValue().status == Status.Installed) {
|
if (entry.getValue().status == Status.Installed) {
|
||||||
it.remove();
|
it.remove();
|
||||||
|
@ -109,28 +109,30 @@ class NotificationHelper {
|
|||||||
BroadcastReceiver receiverAppStatusChanges = new BroadcastReceiver() {
|
BroadcastReceiver receiverAppStatusChanges = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
AppUpdateStatusManager.AppUpdateStatus entry;
|
||||||
|
String url;
|
||||||
|
|
||||||
switch (intent.getAction()) {
|
switch (intent.getAction()) {
|
||||||
case AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED:
|
case AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED:
|
||||||
notificationManager.cancelAll();
|
notificationManager.cancelAll();
|
||||||
updateStatusLists();
|
updateStatusLists();
|
||||||
createSummaryNotifications();
|
createSummaryNotifications();
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus entry : appUpdateStatusManager.getAll()) {
|
for (AppUpdateStatusManager.AppUpdateStatus appUpdateStatus : appUpdateStatusManager.getAll()) {
|
||||||
createNotification(entry);
|
createNotification(appUpdateStatus);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED: {
|
case AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED:
|
||||||
updateStatusLists();
|
updateStatusLists();
|
||||||
createSummaryNotifications();
|
createSummaryNotifications();
|
||||||
String url = intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
|
url = intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
|
||||||
AppUpdateStatusManager.AppUpdateStatus entry = appUpdateStatusManager.get(url);
|
entry = appUpdateStatusManager.get(url);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
createNotification(entry);
|
createNotification(entry);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED:
|
||||||
case AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED: {
|
url = intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
|
||||||
String url = intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
|
entry = appUpdateStatusManager.get(url);
|
||||||
AppUpdateStatusManager.AppUpdateStatus entry = appUpdateStatusManager.get(url);
|
|
||||||
updateStatusLists();
|
updateStatusLists();
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
createNotification(entry);
|
createNotification(entry);
|
||||||
@ -139,9 +141,8 @@ class NotificationHelper {
|
|||||||
createSummaryNotifications();
|
createSummaryNotifications();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED:
|
||||||
case AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED: {
|
url = intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
|
||||||
String url = intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
|
|
||||||
notificationManager.cancel(url, NOTIFY_ID_INSTALLED);
|
notificationManager.cancel(url, NOTIFY_ID_INSTALLED);
|
||||||
notificationManager.cancel(url, NOTIFY_ID_UPDATES);
|
notificationManager.cancel(url, NOTIFY_ID_UPDATES);
|
||||||
updateStatusLists();
|
updateStatusLists();
|
||||||
@ -149,7 +150,6 @@ class NotificationHelper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
LocalBroadcastManager.getInstance(context).registerReceiver(receiverAppStatusChanges, filter);
|
LocalBroadcastManager.getInstance(context).registerReceiver(receiverAppStatusChanges, filter);
|
||||||
}
|
}
|
||||||
@ -181,12 +181,13 @@ class NotificationHelper {
|
|||||||
|
|
||||||
private boolean shouldIgnoreEntry(AppUpdateStatusManager.AppUpdateStatus entry) {
|
private boolean shouldIgnoreEntry(AppUpdateStatusManager.AppUpdateStatus entry) {
|
||||||
// Ignore unknown status
|
// Ignore unknown status
|
||||||
if (entry.status == AppUpdateStatusManager.Status.Unknown)
|
if (entry.status == AppUpdateStatusManager.Status.Unknown) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if ((entry.status == AppUpdateStatusManager.Status.Downloading || entry.status == AppUpdateStatusManager.Status.ReadyToInstall || entry.status == AppUpdateStatusManager.Status.InstallError) &&
|
||||||
|
(AppDetails.isAppVisible(entry.app.packageName) || AppDetails2.isAppVisible(entry.app.packageName))) {
|
||||||
// Ignore downloading, readyToInstall and installError if we are showing the details screen for this app
|
// Ignore downloading, readyToInstall and installError if we are showing the details screen for this app
|
||||||
else if ((entry.status == AppUpdateStatusManager.Status.Downloading || entry.status == AppUpdateStatusManager.Status.ReadyToInstall || entry.status == AppUpdateStatusManager.Status.InstallError) &&
|
|
||||||
(AppDetails.isAppVisible(entry.app.packageName) || AppDetails2.isAppVisible(entry.app.packageName)))
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +228,6 @@ class NotificationHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createSummaryNotifications() {
|
private void createSummaryNotifications() {
|
||||||
if (!notificationManager.areNotificationsEnabled()) {
|
if (!notificationManager.areNotificationsEnabled()) {
|
||||||
return;
|
return;
|
||||||
@ -361,10 +361,11 @@ class NotificationHelper {
|
|||||||
// Handle progress bar (for some states)
|
// Handle progress bar (for some states)
|
||||||
//
|
//
|
||||||
if (status == AppUpdateStatusManager.Status.Downloading) {
|
if (status == AppUpdateStatusManager.Status.Downloading) {
|
||||||
if (entry.progressMax == 0)
|
if (entry.progressMax == 0) {
|
||||||
builder.setProgress(100, 0, true);
|
builder.setProgress(100, 0, true);
|
||||||
else
|
} else {
|
||||||
builder.setProgress(entry.progressMax, entry.progressCurrent, false);
|
builder.setProgress(entry.progressMax, entry.progressCurrent, false);
|
||||||
|
}
|
||||||
} else if (status == AppUpdateStatusManager.Status.Installing) {
|
} else if (status == AppUpdateStatusManager.Status.Installing) {
|
||||||
builder.setProgress(100, 0, true); // indeterminate bar
|
builder.setProgress(100, 0, true); // indeterminate bar
|
||||||
}
|
}
|
||||||
@ -395,8 +396,9 @@ class NotificationHelper {
|
|||||||
sb.append(content);
|
sb.append(content);
|
||||||
inboxStyle.addLine(sb);
|
inboxStyle.addLine(sb);
|
||||||
|
|
||||||
if (text.length() > 0)
|
if (text.length() > 0) {
|
||||||
text.append(", ");
|
text.append(", ");
|
||||||
|
}
|
||||||
text.append(app.name);
|
text.append(app.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,8 +471,9 @@ class NotificationHelper {
|
|||||||
for (int i = 0; i < MAX_INSTALLED_TO_SHOW && i < installed.size(); i++) {
|
for (int i = 0; i < MAX_INSTALLED_TO_SHOW && i < installed.size(); i++) {
|
||||||
AppUpdateStatusManager.AppUpdateStatus entry = installed.get(i);
|
AppUpdateStatusManager.AppUpdateStatus entry = installed.get(i);
|
||||||
App app = entry.app;
|
App app = entry.app;
|
||||||
if (text.length() > 0)
|
if (text.length() > 0) {
|
||||||
text.append(", ");
|
text.append(", ");
|
||||||
|
}
|
||||||
text.append(app.name);
|
text.append(app.name);
|
||||||
}
|
}
|
||||||
bigTextStyle.bigText(text);
|
bigTextStyle.bigText(text);
|
||||||
@ -510,7 +513,8 @@ class NotificationHelper {
|
|||||||
w = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
|
w = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
|
||||||
h = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
|
h = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
|
||||||
} else {
|
} else {
|
||||||
w = h = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
|
w = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
|
||||||
|
h = w;
|
||||||
}
|
}
|
||||||
return new Point(w, h);
|
return new Point(w, h);
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
import org.fdroid.fdroid.AppDetails;
|
|
||||||
import org.fdroid.fdroid.AppDetails2;
|
|
||||||
import org.fdroid.fdroid.AppUpdateStatusManager;
|
import org.fdroid.fdroid.AppUpdateStatusManager;
|
||||||
import org.fdroid.fdroid.Hasher;
|
import org.fdroid.fdroid.Hasher;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user