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

Commit eebbf6d6 authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android (Google) Code Review
Browse files

Merge "Remove unused methods and fields from ImportancePreference" into main

parents 7c23747d 2ccc8304
Loading
Loading
Loading
Loading
+4 −16
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

@@ -44,15 +45,11 @@ public class ImportancePreference extends Preference {

    private boolean mIsConfigurable = true;
    private int mImportance;
    private boolean mDisplayInStatusBar;
    private boolean mDisplayOnLockscreen;
    private View mSilenceButton;
    private View mAlertButton;
    private Context mContext;
    Drawable selectedBackground;
    Drawable unselectedBackground;
    private static final int BUTTON_ANIM_TIME_MS = 100;
    private static final boolean SHOW_BUTTON_SUMMARY = false;

    public ImportancePreference(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
@@ -76,10 +73,9 @@ public class ImportancePreference extends Preference {
    }

    private void init(Context context) {
        mContext = context;
        selectedBackground = mContext.getDrawable(
        selectedBackground = context.getDrawable(
                R.drawable.notification_importance_button_background_selected);
        unselectedBackground = mContext.getDrawable(
        unselectedBackground = context.getDrawable(
                R.drawable.notification_importance_button_background_unselected);
        setLayoutResource(R.layout.notif_importance_preference);
    }
@@ -92,16 +88,8 @@ public class ImportancePreference extends Preference {
        mIsConfigurable = configurable;
    }

    public void setDisplayInStatusBar(boolean display) {
        mDisplayInStatusBar = display;
    }

    public void setDisplayOnLockscreen(boolean display) {
        mDisplayOnLockscreen = display;
    }

    @Override
    public void onBindViewHolder(final PreferenceViewHolder holder) {
    public void onBindViewHolder(@NonNull final PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);
        holder.itemView.setClickable(false);

+2 −6
Original line number Diff line number Diff line
@@ -22,13 +22,12 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import android.app.NotificationChannel;
import android.content.Context;
import android.media.RingtoneManager;
import android.provider.Settings;

import androidx.preference.Preference;

import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.notification.NotificationBackend;

import androidx.preference.Preference;

public class ImportancePreferenceController extends NotificationPreferenceController
        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener  {

@@ -70,9 +69,6 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
            ImportancePreference pref = (ImportancePreference) preference;
            pref.setConfigurable(isChannelConfigurable(mChannel));
            pref.setImportance(mChannel.getImportance());
            pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
            pref.setDisplayOnLockscreen(Settings.Secure.getInt(mContext.getContentResolver(),
                    Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) == 1);
        }
    }

+1 −3
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -220,7 +219,6 @@ public class ImportancePreferenceControllerTest {

        verify(pref, times(1)).setConfigurable(anyBoolean());
        verify(pref, times(1)).setImportance(IMPORTANCE_HIGH);
        verify(pref, times(1)).setDisplayInStatusBar(false);
    }

    @Test
+0 −10
Original line number Diff line number Diff line
@@ -154,12 +154,7 @@ public class ImportancePreferenceTest {
        preference.onBindViewHolder(holder);

        TextView tv = holder.itemView.findViewById(R.id.silence_summary);

        preference.setDisplayInStatusBar(true);
        preference.setDisplayOnLockscreen(true);

        preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);

        assertThat(tv.getText()).isEqualTo(
                mContext.getString(R.string.notification_channel_summary_low));
    }
@@ -176,12 +171,7 @@ public class ImportancePreferenceTest {
        preference.onBindViewHolder(holder);

        TextView tv = holder.itemView.findViewById(R.id.alert_summary);

        preference.setDisplayInStatusBar(true);
        preference.setDisplayOnLockscreen(true);

        preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true);

        assertThat(tv.getText()).isEqualTo(
                mContext.getString(R.string.notification_channel_summary_default));
    }