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

Commit fdeb2e50 authored by Michael W's avatar Michael W
Browse files

LineageParts: Misc fixes and improvements

* Use Standardcharsets
* Use try-with-resource
* Explicitly cast where required
* Use Math.min / Math.max
* Instead of storing the Context, store the ContentResolver
* ReportingService: Store ApplicationContext in a variable and use that
  instead of calling the method multiple times

Change-Id: Ic9a697e0b03b87f1bce91adfdbb828759fe2c548
parent c37d2acc
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -542,22 +542,19 @@ public class ContributorsCloudFragment extends Fragment implements SearchView.On
                    // Horizontal
                    canvas.drawText(name, x, y, paint);
                } else {
                    canvas.save();
                    if (r == -1) {
                        // Vertical (-90 rotation)
                        canvas.save();
                        canvas.translate(h, w - h);
                        canvas.rotate(-90, x, y);
                        canvas.drawText(name, x, y, paint);
                        canvas.restore();
                    } else {
                        // Vertical (+90 rotation)
                        canvas.save();
                        canvas.translate(h/2, -h);
                        canvas.rotate(90, x, y);
                    }
                    canvas.drawText(name, x, y, paint);
                    canvas.restore();
                }
                }

                // Calculate focus
                if (selectedId == id) {
@@ -825,8 +822,9 @@ public class ContributorsCloudFragment extends Fragment implements SearchView.On
                    }

                    List<SearchIndexableRaw> result = new ArrayList<>();
                    Cursor c = db.rawQuery(
                            "select id, username from metadata order by commits desc limit 100;", null);
                    try (Cursor c = db.rawQuery(
                            "select id, username from metadata order by commits desc limit 100;",
                            null)) {
                        while (c.moveToNext()) {
                            SearchIndexableRaw raw = new SearchIndexableRaw(context);
                            raw.key = KEY_PREFIX + c.getString(0);
@@ -834,7 +832,7 @@ public class ContributorsCloudFragment extends Fragment implements SearchView.On
                            raw.title = c.getString(1);
                            result.add(raw);
                        }
                    c.close();
                    }
                    db.close();

                    return result;
+2 −2
Original line number Diff line number Diff line
@@ -539,8 +539,8 @@ public class ContributorsCloudViewController implements View.OnTouchListener,

        if (null != imageView) {
            setScale(scale,
                    (imageView.getRight()) / 2,
                    (imageView.getBottom()) / 2,
                    (imageView.getRight()) / 2f,
                    (imageView.getBottom()) / 2f,
                    animate);
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class KeyHandler implements DeviceKeyHandler {
                    mContext.getContentResolver(),
                    LineageSettings.System.PROXIMITY_ON_WAKE, mDefaultProximity ? 1 : 0) == 1;
            if (mProximityWakeSupported && proxWakeEnabled && mProximitySensor != null) {
                mGestureWakeLock.acquire(2 * mProximityTimeOut);
                mGestureWakeLock.acquire(2L * mProximityTimeOut);
                mEventHandler.sendMessageDelayed(msg, mProximityTimeOut);
                processEvent(action);
            } else {
+9 −7
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The CyanogenMod Project
 *               2017 The LineageOS Project
 *               2017-2022 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -38,15 +38,17 @@ public class ReportingService extends IntentService {
    protected void onHandleIntent(Intent intent) {
        JobScheduler js = getSystemService(JobScheduler.class);

        String deviceId = Utilities.getUniqueID(getApplicationContext());
        Context context = getApplicationContext();

        String deviceId = Utilities.getUniqueID(context);
        String deviceName = Utilities.getDevice();
        String deviceVersion = Utilities.getModVersion();
        String deviceCountry = Utilities.getCountryCode(getApplicationContext());
        String deviceCarrier = Utilities.getCarrier(getApplicationContext());
        String deviceCarrierId = Utilities.getCarrierId(getApplicationContext());
        String deviceCountry = Utilities.getCountryCode(context);
        String deviceCarrier = Utilities.getCarrier(context);
        String deviceCarrierId = Utilities.getCarrierId(context);

        final int lineageOldJobId = AnonymousStats.getLastJobId(getApplicationContext());
        final int lineageOrgJobId = AnonymousStats.getNextJobId(getApplicationContext());
        final int lineageOldJobId = AnonymousStats.getLastJobId(context);
        final int lineageOrgJobId = AnonymousStats.getNextJobId(context);

        if (DEBUG) Log.d(TAG, "scheduling job id: " + lineageOrgJobId);

+2 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;

@@ -163,7 +164,7 @@ public class StatsUploadJobService extends JobService {
            urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");

            OutputStream os = urlConnection.getOutputStream();
            os.write(json.toString().getBytes("UTF-8"));
            os.write(json.toString().getBytes(StandardCharsets.UTF_8));
            os.close();

            final int responseCode = urlConnection.getResponseCode();
Loading