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

Commit aa92d08b authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Importance slide updates."

parents 085028d7 c9a1884e
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -55,23 +55,26 @@

            <ImageView
                    android:id="@+id/low_importance"
                    android:src="@android:drawable/ic_menu_close_clear_cancel"
                    android:src="@*android:drawable/ic_notification_block"
                    android:layout_gravity="center_vertical|start"
                    android:layout_width="24dp"
                    android:layout_height="24dp" />

            <SeekBar
                    android:id="@*android:id/seekbar"
                    android:layout_marginStart="24dp"
                    android:layout_marginEnd="24dp"
                    android:layout_marginStart="56dp"
                    android:layout_marginEnd="56dp"
                    android:layout_gravity="center_vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusable="true"/>
                    android:focusable="true"
                    android:background="#00ffffff"
                    style="@android:style/Widget.Material.SeekBar.Discrete"
                    android:tickMarkTint="@android:color/black"/>

            <ImageView
                    android:id="@+id/max_importance"
                    android:src="@android:drawable/ic_popup_reminder"
                    android:src="@*android:drawable/ic_notification_alert"
                    android:layout_gravity="center_vertical|end"
                    android:layout_width="24dp"
                    android:layout_height="24dp" />
+0 −32
Original line number Diff line number Diff line
@@ -34,11 +34,8 @@ import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -707,35 +704,6 @@ public final class Utils extends com.android.settingslib.Utils {
        return tm.getSimCount() > 1;
    }

    /**
     * Determine whether a package is a "system package", in which case certain things (like
     * disabling notifications or disabling the package altogether) should be disallowed.
     */
    public static boolean isSystemPackage(PackageManager pm, PackageInfo pkg) {
        if (sSystemSignature == null) {
            sSystemSignature = new Signature[]{ getSystemSignature(pm) };
        }
        return sSystemSignature[0] != null && sSystemSignature[0].equals(getFirstSignature(pkg));
    }

    private static Signature[] sSystemSignature;

    private static Signature getFirstSignature(PackageInfo pkg) {
        if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) {
            return pkg.signatures[0];
        }
        return null;
    }

    private static Signature getSystemSignature(PackageManager pm) {
        try {
            final PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
            return getFirstSignature(sys);
        } catch (NameNotFoundException e) {
        }
        return null;
    }

    /**
     * Returns elapsed time for the given millis, in the following format:
     * 2d 5h 40m 29s
+5 −8
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
    private PreferenceCategory mCategories;
    private AppRow mAppRow;
    private boolean mCreated;
    private boolean mIsSystemPackage;
    private int mUid;

    @Override
@@ -126,12 +125,10 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
            toastAndFinish();
            return;
        }
        mIsSystemPackage = Utils.isSystemPackage(pm, info);

        addPreferencesFromResource(R.xml.app_notification_settings);
        mBlock = (SwitchPreference) findPreference(KEY_BLOCK);

        mAppRow = mBackend.loadAppRow(pm, info.applicationInfo);
        mAppRow = mBackend.loadAppRow(pm, info);

        // load settings intent
        ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
@@ -160,7 +157,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
        }

        mBlock.setChecked(mAppRow.banned);
        updateDependents(mAppRow.banned);
        updateDependents(mAppRow.systemApp, mAppRow.banned);

        mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
@@ -171,7 +168,7 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
                }
                final boolean success =  mBackend.setNotificationsBanned(pkg, mUid, banned);
                if (success) {
                    updateDependents(banned);
                    updateDependents(mAppRow.systemApp, banned);
                }
                return success;
            }
@@ -200,8 +197,8 @@ public class AppNotificationSettings extends SettingsPreferenceFragment {
        }
    }

    private void updateDependents(boolean banned) {
        setVisible(mBlock, !mIsSystemPackage);
    private void updateDependents(boolean isSystemPackage, boolean banned) {
        setVisible(mBlock, !isSystemPackage);
        if (mCategories != null) {
            setVisible(mCategories, !banned);
        }
+10 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
    private Callback mCallback;
    private TextView mSummaryTextView;
    private String mSummary;
    private int mMinProgress;

    public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
@@ -59,6 +60,10 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
        mCallback = callback;
    }

    public void setMinimumProgress(int minProgress) {
        mMinProgress = minProgress;
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder view) {
        super.onBindViewHolder(view);
@@ -72,8 +77,12 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromTouch) {
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
        super.onProgressChanged(seekBar, progress, fromTouch);
        if (progress < mMinProgress) {
            seekBar.setProgress(mMinProgress);
            progress = mMinProgress;
        }
        if (mSummaryTextView != null) {
            mSummaryTextView.setText(getProgressSummary(progress));
        }
+13 −3
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@ import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.graphics.drawable.Drawable;
import android.os.ServiceManager;
import android.service.notification.NotificationListenerService;
import android.util.Log;
import com.android.settingslib.Utils;

import java.util.List;

@@ -52,12 +54,19 @@ public class NotificationBackend {
        return row;
    }

    public TopicRow loadTopicRow(PackageManager pm, ApplicationInfo app, Notification.Topic topic) {
    public AppRow loadAppRow(PackageManager pm, PackageInfo app) {
        final AppRow row = loadAppRow(pm, app.applicationInfo);
        row.systemApp = Utils.isSystemPackage(pm, app);
        return row;
    }

    public TopicRow loadTopicRow(PackageManager pm, PackageInfo app, Notification.Topic topic) {
        final TopicRow row = new TopicRow();
        row.pkg = app.packageName;
        row.uid = app.uid;
        row.uid = app.applicationInfo.uid;
        row.label = topic.getLabel();
        row.icon = app.loadIcon(pm);
        row.icon = app.applicationInfo.loadIcon(pm);
        row.systemApp = Utils.isSystemPackage(pm, app);
        row.topic = topic;
        row.priority = getBypassZenMode(row.pkg, row.uid, row.topic);
        row.sensitive = getSensitive(row.pkg, row.uid, row.topic);
@@ -170,6 +179,7 @@ public class NotificationBackend {
        public Intent settingsIntent;
        public boolean banned;
        public boolean first;  // first app in section
        public boolean systemApp;
    }

    public static class TopicRow extends AppRow {
Loading