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

Commit 3484638c authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Adding a circular progress bar for preloader icons

Change-Id: I1b5ba61c01a16a8cb5d3f9e31f827f8c99a1ffc9
parent f599ccfe
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -52,3 +52,8 @@
-keep class com.android.launcher3.MemoryDumpActivity {
  *;
}

-keep class com.android.launcher3.PreloadIconDrawable {
  public float getAnimationProgress();
  public void setAnimationProgress(float);
}
+3.7 KiB
Loading image diff...
+1.1 KiB
Loading image diff...

res/values/integers.xml

deleted100644 → 0
+0 −22
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->

<resources>
    <integer name="promise_icon_alpha">127</integer>
</resources>
 No newline at end of file
+21 −7
Original line number Diff line number Diff line
@@ -136,7 +136,8 @@ public class BubbleTextView extends TextView {
            setContentDescription(info.contentDescription);
        }
        setTag(info);
        if (info.isPromise()) {

        if (info.wasPromise) {
            applyState();
        }
    }
@@ -431,42 +432,55 @@ public class BubbleTextView extends TextView {
    }

    public void applyState() {
        int alpha = getResources().getInteger(R.integer.promise_icon_alpha);
        final int progressLevel;
        final int state = getState();
        if (DEBUG) Log.d(TAG, "applying icon state: " + state);

        switch(state) {
            case ShortcutInfo.PACKAGE_STATE_DEFAULT:
                super.setText(mDefaultText);
                alpha = 255;
                progressLevel = 100;
                break;

            case ShortcutInfo.PACKAGE_STATE_ENQUEUED:
                setText(R.string.package_state_enqueued);
                progressLevel = 0;
                break;

            case ShortcutInfo.PACKAGE_STATE_DOWNLOADING:
                setText(R.string.package_state_downloading);
                // TODO(sunnygoyal): fix progress
                progressLevel = 30;
                break;

            case ShortcutInfo.PACKAGE_STATE_INSTALLING:
                setText(R.string.package_state_installing);
                progressLevel = 100;
                break;

            case ShortcutInfo.PACKAGE_STATE_ERROR:
                setText(R.string.package_state_error);
                progressLevel = 0;
                break;

            case ShortcutInfo.PACKAGE_STATE_UNKNOWN:
            default:
                progressLevel = 0;
                setText(R.string.package_state_unknown);
                break;
        }
        if (DEBUG) Log.d(TAG, "setting icon alpha to: " + alpha);

        Drawable[] drawables = getCompoundDrawables();
        for (int i = 0; i < drawables.length; i++) {
            if (drawables[i] != null) {
                drawables[i].setAlpha(alpha);
        Drawable top = drawables[1];
        if ((top != null) && !(top instanceof PreloadIconDrawable)) {
            top = new PreloadIconDrawable(top, getResources());
            setCompoundDrawables(drawables[0], top, drawables[2], drawables[3]);
        }
        if (top != null) {
            top.setLevel(progressLevel);
            if ((top instanceof PreloadIconDrawable)
                    && (state == ShortcutInfo.PACKAGE_STATE_DEFAULT)) {
                ((PreloadIconDrawable) top).maybePerformFinishedAnimation();
            }
        }
    }
Loading