Skip to content

Commit

Permalink
Card 29 (For now, treat everybody as PRO USER. So no limitation. We need
Browse files Browse the repository at this point in the history
to fix a lot things)
- SyncUploadFragment, UploadActivity.UploadUiFragment: replaced
checkQuotaPerUploadAvailableAndRunAsync with the
tryToRefreshLimitInformationAndRunInContextAsync call in the init method
- AccountLimitUtils: removed all checks from
checkQuotaPerUploadAvailableAndRunAsync and simply added execute
runnable code
  • Loading branch information
httpdispatch committed Oct 31, 2013
1 parent 557797e commit 2e9bbf9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 100 deletions.
9 changes: 3 additions & 6 deletions app/src/com/trovebox/android/app/SyncUploadFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,10 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});
reinitShareSwitches();
AccountLimitUtils.checkQuotaPerUploadAvailableAndRunAsync(new Runnable() {
AccountLimitUtils.tryToRefreshLimitInformationAndRunInContextAsync(new Runnable() {

@Override
public void run() {
CommonUtils.debug(TAG, "Upload limit check passed");
TrackerUtils.trackLimitEvent("sync_upload_enabled_check", "success");
if (!isAdded()) {
return;
}
Expand All @@ -207,10 +205,9 @@ public void run(StringMapParcelableWrapper parameter) {

@Override
public void run() {
CommonUtils.debug(TAG, "Upload limit check failed");
TrackerUtils.trackLimitEvent("sync_upload_enabled_check", "fail");
CommonUtils.debug(TAG, "Limit information refresh failed");
}
}, previousStepFlow.getSelectedCount(), loadingControl);
}, loadingControl);
}

void reinitShareSwitches()
Expand Down
7 changes: 2 additions & 5 deletions app/src/com/trovebox/android/app/UploadActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,10 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
showSelectionDialog();
}
adjustUploadOriginalSwitchVisibility();
AccountLimitUtils.checkQuotaPerOneUploadAvailableAndRunAsync(new Runnable() {
AccountLimitUtils.tryToRefreshLimitInformationAndRunInContextAsync(new Runnable() {

@Override
public void run() {
CommonUtils.debug(TAG, "Upload limit check passed");
TrackerUtils.trackLimitEvent("upload_activity_upload_enabled_check", "success");
if (!isAdded()) {
return;
}
Expand All @@ -349,8 +347,7 @@ public void run(StringMapParcelableWrapper parameter) {

@Override
public void run() {
CommonUtils.debug(TAG, "Upload limit check failed");
TrackerUtils.trackLimitEvent("upload_activity_upload_enabled_check", "fail");
CommonUtils.debug(TAG, "Limit information refresh failed");
}
}, new ProgressDialogLoadingControl(getActivity(), true, true,
getString(R.string.loading)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

package com.trovebox.android.app.net.account;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.trovebox.android.app.Preferences;
import com.trovebox.android.app.R;
import com.trovebox.android.app.TroveboxApplication;
Expand All @@ -14,7 +11,6 @@
import com.trovebox.android.app.net.ProfileResponseUtils;
import com.trovebox.android.app.net.SystemVersionResponseUtils;
import com.trovebox.android.app.net.TroveboxResponseUtils;
import com.trovebox.android.app.provider.UploadsProviderAccessor;
import com.trovebox.android.app.util.CommonUtils;
import com.trovebox.android.app.util.GuiUtils;
import com.trovebox.android.app.util.LoadingControl;
Expand Down Expand Up @@ -95,91 +91,7 @@ public static void checkQuotaPerUploadAvailableAndRunAsync(
final LoadingControl loadingControl
)
{
SystemVersionResponseUtils.tryToUpdateSystemVersionCacheIfNecessaryAndRunInContextAsync(
new Runnable() {

@Override
public void run() {
if (Preferences.isSelfHosted())
{
runnable.run();
} else
{
tryToRefreshLimitInformationAndRunInContextAsync(
new Runnable() {

@Override
public void run() {

if (Preferences.isProUser())
{
runnable.run();
} else
{
int remaining = Preferences
.getRemainingUploadingLimit();
UploadsProviderAccessor uploads = new UploadsProviderAccessor(
TroveboxApplication.getContext());
int pending = uploads.getPendingUploadsCount();
if (remaining - pending >= requiredUploadSlotsCount)
{
CommonUtils.debug(TAG, "Quota check passed");
if (requiredUploadSlotsCount == 1)
{
TrackerUtils.trackLimitEvent(
"quota_per_one_image_check",
"success");
} else
{
TrackerUtils.trackLimitEvent(
"quota_per_multiple_images_check",
"success");
}
runnable.run();
} else
{
CommonUtils.debug(TAG, "Quota check failed");
if (requiredUploadSlotsCount == 1)
{
TrackerUtils
.trackLimitEvent(
"quota_per_one_image_check",
"fail");
Date resetsOnDate = Preferences
.getUploadLimitResetsOnDate();
if (resetsOnDate == null)
{
GuiUtils.alert(R.string.upload_limit_reached_message);
} else
{
GuiUtils.alert(
R.string.upload_limit_reached_with_reset_message,
SimpleDateFormat.getInstance()
.format(resetsOnDate));
}
} else
{
TrackerUtils.trackLimitEvent(
"quota_per_multiple_images_check",
"fail");
GuiUtils.alert(
R.string.upload_limit_for_multiple_upload_reached_message,
requiredUploadSlotsCount, remaining
- pending);
}
if (runnableOnFailure != null)
{
runnableOnFailure.run();
}
}
}
}
},
runnableOnFailure, loadingControl);
}
}
}
, runnableOnFailure, loadingControl);
runnable.run();
}

/**
Expand Down

0 comments on commit 2e9bbf9

Please sign in to comment.