Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 044f4d85 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer Committed by Abhishek Aggarwal
Browse files

remove commented line and rename variables in Widget

parent 4fb90978
Loading
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.owncloud.android.lib.common.OwnCloudClient;

import foundation.e.drive.R;
@@ -71,26 +70,25 @@ public class AccountsActivity extends AppCompatActivity {
                accountManager);
        final OwnCloudClient client = CommonUtils.getOwnCloudClient(account, this);

        final String usedMB = accountManager.getUserData(account, ACCOUNT_DATA_USED_QUOTA_KEY);
        final String totalMB = accountManager.getUserData(account, ACCOUNT_DATA_TOTAL_QUOTA_KEY);
        final String usedQuota = accountManager.getUserData(account, ACCOUNT_DATA_USED_QUOTA_KEY);
        final String totalQuota = accountManager.getUserData(account, ACCOUNT_DATA_TOTAL_QUOTA_KEY);
        final String email = accountManager.getUserData(account, ACCOUNT_DATA_EMAIL);

        binding.name.setText(accountManager.getUserData(account, ACCOUNT_DATA_NAME));
        binding.email.setText(email);

        binding.progress.setMax(convertIntoMB(totalMB));
        binding.progress.setProgress(convertIntoMB(usedMB));
        binding.progress.setMax(convertIntoMB(totalQuota));
        binding.progress.setProgress(convertIntoMB(usedQuota));
        binding.progress.setVisibility(View.VISIBLE);

        binding.plan.setText(getString(R.string.free_plan,
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalMB))));
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalQuota))));

        String[] groups = accountManager.getUserData(account, ACCOUNT_DATA_GROUPS).split(",");
        for (String group : groups) {
            if (group.contains("premium-")) {
                binding.plan.setText(getString(R.string.premium_plan,
                        group.split("-")[1]));

                break;
            }
        }
@@ -99,8 +97,8 @@ public class AccountsActivity extends AppCompatActivity {
        binding.plan.setVisibility(View.VISIBLE);

        binding.status.setText(getString(R.string.progress_status,
                CommonUtils.humanReadableByteCountBin(Long.parseLong(usedMB)),
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalMB))));
                CommonUtils.humanReadableByteCountBin(Long.parseLong(usedQuota)),
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalQuota))));

        String aliases = accountManager.getUserData(account, ACCOUNT_DATA_ALIAS_KEY);
        if (aliases != null && !aliases.isEmpty()) {
@@ -120,7 +118,7 @@ public class AccountsActivity extends AppCompatActivity {
        binding.upgrade.setOnClickListener(v -> {
            final Intent upgradeIntent = buildIntent(Intent.ACTION_VIEW,
                    String.format(EDriveWidget.WEBPAGE, email,
                            dataForWeb(Long.parseLong(totalMB))));
                            dataForWeb(Long.parseLong(totalQuota))));
            startActivity(upgradeIntent);
        });

+0 −1
Original line number Diff line number Diff line
@@ -197,7 +197,6 @@ public class SynchronizationService extends Service implements OnRemoteOperation
                case QUOTA_EXCEEDED:
                    //Case specific to UploadFileOperation
                    Log.w(TAG, "Quota_EXCEEDED");
                    //addNotification(getString(R.string.notif_quota_99Plus_title), getString(R.string.notif_quota_execeeded_text));
                    break;
                case FILE_NOT_FOUND:
                    //Case specific to DownloadFileOperation
+8 −10
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;

@@ -43,9 +42,8 @@ import foundation.e.drive.utils.CommonUtils;
public class EDriveWidget extends AppWidgetProvider {
    public static final String WEBPAGE =
            "https://esolutions.shop/ecloud-subscriptions/?username=%s&token=placeholder&current-quota=%s&from=wp";
    private static final String ADD_ACCOUNT_WEBPAGE = "https://e.foundation/e-email-invite/";

    public static final String ACCOUNT_MANAGER_PACKAGE_NAME = "foundation.e.accountmanager";
    private static final String ADD_ACCOUNT_WEBPAGE = "https://e.foundation/e-email-invite/";
    private static final String GET_ACCOUNT_MANAGER_COMPONENT_NAME = ACCOUNT_MANAGER_PACKAGE_NAME +
            ".ui.setup.LoginActivity";

@@ -159,8 +157,8 @@ public class EDriveWidget extends AppWidgetProvider {
    }

    private void onAccountAvailable(Context context, AccountManager accountManager) {
        final String usedMB = accountManager.getUserData(account, ACCOUNT_DATA_USED_QUOTA_KEY);
        final String totalMB = accountManager.getUserData(account, ACCOUNT_DATA_TOTAL_QUOTA_KEY);
        final String usedQuota = accountManager.getUserData(account, ACCOUNT_DATA_USED_QUOTA_KEY);
        final String totalQuota = accountManager.getUserData(account, ACCOUNT_DATA_TOTAL_QUOTA_KEY);
        final String email = accountManager.getUserData(account, ACCOUNT_DATA_EMAIL);

        if (email == null || email.trim().isEmpty()) {
@@ -175,10 +173,10 @@ public class EDriveWidget extends AppWidgetProvider {
        views.setTextViewText(R.id.email, email);
        views.setTextViewText(R.id.name, accountManager.getUserData(account, ACCOUNT_DATA_NAME));

        views.setProgressBar(R.id.progress, convertIntoMB(totalMB), convertIntoMB(usedMB), false);
        views.setProgressBar(R.id.progress, convertIntoMB(totalQuota), convertIntoMB(usedQuota), false);

        views.setTextViewText(R.id.planName, context.getString(R.string.free_plan,
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalMB))));
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalQuota))));

        String[] groups = accountManager.getUserData(account, ACCOUNT_DATA_GROUPS).split(",");
        for (String group : groups) {
@@ -190,8 +188,8 @@ public class EDriveWidget extends AppWidgetProvider {
        }

        views.setTextViewText(R.id.status, context.getString(R.string.progress_status,
                CommonUtils.humanReadableByteCountBin(Long.parseLong(usedMB)),
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalMB))));
                CommonUtils.humanReadableByteCountBin(Long.parseLong(usedQuota)),
                CommonUtils.humanReadableByteCountBin(Long.parseLong(totalQuota))));
        views.setTextViewText(R.id.sync, context.getString(R.string.last_synced,
                sdf.format(calender.getTime())));

@@ -226,7 +224,7 @@ public class EDriveWidget extends AppWidgetProvider {

        final PendingIntent pendingIntentUpgrade = PendingIntent.getActivity(context, 0,
                buildIntent(Intent.ACTION_VIEW, String.format(WEBPAGE, email,
                        dataForWeb(Long.parseLong(totalMB)))),
                        dataForWeb(Long.parseLong(totalQuota)))),
                PendingIntent.FLAG_IMMUTABLE);
        views.setOnClickPendingIntent(R.id.upgrade, pendingIntentUpgrade);
    }