Merge "Zen automatic rule page ui changes"
This commit is contained in:
committed by
Android (Google) Code Review
commit
182a0fc91b
@@ -6870,6 +6870,9 @@
|
|||||||
<!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=NONE] -->
|
<!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=NONE] -->
|
||||||
<string name="zen_mode_automation_suggestion_summary">Limit sounds & vibrations at certain times</string>
|
<string name="zen_mode_automation_suggestion_summary">Limit sounds & vibrations at certain times</string>
|
||||||
|
|
||||||
|
<!-- Do not disturb: Switch toggle to toggle whether to use an automatic dnd rule or not [CHAR LIMIT=40] -->
|
||||||
|
<string name="zen_mode_use_automatic_rule">Use rule</string>
|
||||||
|
|
||||||
<!-- Do not disturb: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
|
<!-- Do not disturb: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
|
||||||
<string name="zen_mode_option_important_interruptions">Priority only</string>
|
<string name="zen_mode_option_important_interruptions">Priority only</string>
|
||||||
|
|
||||||
|
@@ -28,12 +28,6 @@
|
|||||||
android:key="zen_automatic_rule_switch"
|
android:key="zen_automatic_rule_switch"
|
||||||
android:layout="@layout/styled_switch_bar" />
|
android:layout="@layout/styled_switch_bar" />
|
||||||
|
|
||||||
<!-- Rule name -->
|
|
||||||
<Preference
|
|
||||||
android:key="rule_name"
|
|
||||||
android:title="@string/zen_mode_rule_name"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<!-- During events for -->
|
<!-- During events for -->
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
android:key="calendar"
|
android:key="calendar"
|
||||||
|
@@ -28,12 +28,6 @@
|
|||||||
android:key="zen_automatic_rule_switch"
|
android:key="zen_automatic_rule_switch"
|
||||||
android:layout="@layout/styled_switch_bar" />
|
android:layout="@layout/styled_switch_bar" />
|
||||||
|
|
||||||
<!-- Rule name -->
|
|
||||||
<Preference
|
|
||||||
android:key="rule_name"
|
|
||||||
android:title="@string/zen_mode_rule_name"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<!-- Days -->
|
<!-- Days -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="days"
|
android:key="days"
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.notification;
|
|||||||
import static com.android.settings.widget.EntityHeaderController.PREF_KEY_APP_HEADER;
|
import static com.android.settings.widget.EntityHeaderController.PREF_KEY_APP_HEADER;
|
||||||
|
|
||||||
import android.app.AutomaticZenRule;
|
import android.app.AutomaticZenRule;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -28,6 +29,7 @@ import android.support.v7.preference.Preference;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.applications.LayoutPreference;
|
import com.android.settings.applications.LayoutPreference;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
@@ -40,6 +42,7 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
|
|||||||
private final String KEY = PREF_KEY_APP_HEADER;
|
private final String KEY = PREF_KEY_APP_HEADER;
|
||||||
private final PreferenceFragment mFragment;
|
private final PreferenceFragment mFragment;
|
||||||
private AutomaticZenRule mRule;
|
private AutomaticZenRule mRule;
|
||||||
|
private String mId;
|
||||||
private EntityHeaderController mController;
|
private EntityHeaderController mController;
|
||||||
|
|
||||||
public ZenAutomaticRuleHeaderPreferenceController(Context context, PreferenceFragment fragment,
|
public ZenAutomaticRuleHeaderPreferenceController(Context context, PreferenceFragment fragment,
|
||||||
@@ -70,6 +73,14 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
|
|||||||
mController = EntityHeaderController
|
mController = EntityHeaderController
|
||||||
.newInstance(mFragment.getActivity(), mFragment,
|
.newInstance(mFragment.getActivity(), mFragment,
|
||||||
pref.findViewById(R.id.entity_header));
|
pref.findViewById(R.id.entity_header));
|
||||||
|
|
||||||
|
mController.setEditZenRuleNameListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ZenRuleNameDialog.show(mFragment, mRule.getName(), null,
|
||||||
|
new RuleNameChangeListener());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pref = mController.setIcon(getIcon())
|
pref = mController.setIcon(getIcon())
|
||||||
@@ -77,7 +88,7 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
|
|||||||
.setPackageName(mRule.getOwner().getPackageName())
|
.setPackageName(mRule.getOwner().getPackageName())
|
||||||
.setUid(mContext.getUserId())
|
.setUid(mContext.getUserId())
|
||||||
.setHasAppInfoLink(false)
|
.setHasAppInfoLink(false)
|
||||||
.setButtonActions(EntityHeaderController.ActionType.ACTION_NONE,
|
.setButtonActions(EntityHeaderController.ActionType.ACTION_DND_RULE_PREFERENCE,
|
||||||
EntityHeaderController.ActionType.ACTION_NONE)
|
EntityHeaderController.ActionType.ACTION_NONE)
|
||||||
.done(mFragment.getActivity(), mContext);
|
.done(mFragment.getActivity(), mContext);
|
||||||
|
|
||||||
@@ -98,7 +109,20 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onResume(AutomaticZenRule rule) {
|
protected void onResume(AutomaticZenRule rule, String id) {
|
||||||
mRule = rule;
|
mRule = rule;
|
||||||
|
mId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RuleNameChangeListener implements ZenRuleNameDialog.PositiveClickListener {
|
||||||
|
public RuleNameChangeListener() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOk(String ruleName, Fragment parent) {
|
||||||
|
mMetricsFeatureProvider.action(mContext,
|
||||||
|
MetricsProto.MetricsEvent.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
|
||||||
|
mRule.setName(ruleName);
|
||||||
|
mBackend.setZenRule(mId, mRule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ import android.app.AutomaticZenRule;
|
|||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ public class ZenAutomaticRuleSwitchPreferenceController extends
|
|||||||
private String mId;
|
private String mId;
|
||||||
private Toast mEnabledToast;
|
private Toast mEnabledToast;
|
||||||
private int mToastTextResource;
|
private int mToastTextResource;
|
||||||
|
private SwitchBar mSwitchBar;
|
||||||
|
|
||||||
public ZenAutomaticRuleSwitchPreferenceController(Context context, Fragment parent,
|
public ZenAutomaticRuleSwitchPreferenceController(Context context, Fragment parent,
|
||||||
int toastTextResource, Lifecycle lifecycle) {
|
int toastTextResource, Lifecycle lifecycle) {
|
||||||
@@ -54,26 +56,34 @@ public class ZenAutomaticRuleSwitchPreferenceController extends
|
|||||||
return mRule != null && mId != null;
|
return mRule != null && mId != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
LayoutPreference pref = (LayoutPreference) screen.findPreference(KEY);
|
||||||
|
mSwitchBar = pref.findViewById(R.id.switch_bar);
|
||||||
|
|
||||||
|
if (mSwitchBar != null) {
|
||||||
|
mSwitchBar.setSwitchBarText(R.string.zen_mode_use_automatic_rule,
|
||||||
|
R.string.zen_mode_use_automatic_rule);
|
||||||
|
try {
|
||||||
|
mSwitchBar.addOnSwitchChangeListener(this);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// an exception is thrown if you try to add the listener twice
|
||||||
|
}
|
||||||
|
mSwitchBar.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onResume(AutomaticZenRule rule, String id) {
|
public void onResume(AutomaticZenRule rule, String id) {
|
||||||
mRule = rule;
|
mRule = rule;
|
||||||
mId = id;
|
mId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
LayoutPreference pref = (LayoutPreference) preference;
|
|
||||||
SwitchBar bar = pref.findViewById(R.id.switch_bar);
|
|
||||||
if (mRule != null) {
|
if (mRule != null) {
|
||||||
bar.setChecked(mRule.isEnabled());
|
mSwitchBar.setChecked(mRule.isEnabled());
|
||||||
}
|
}
|
||||||
if (bar != null) {
|
|
||||||
bar.show();
|
|
||||||
try {
|
|
||||||
bar.addOnSwitchChangeListener(this);
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
// an exception is thrown if you try to add the listener twice
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bar.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -173,8 +173,8 @@ public class ZenModeBackend {
|
|||||||
savePolicy(getNewPriorityCategories(allowSenders, category),
|
savePolicy(getNewPriorityCategories(allowSenders, category),
|
||||||
priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects);
|
priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects);
|
||||||
|
|
||||||
if (ZenModeSettingsBase.DEBUG) Log.d(TAG, "onPrefChange allow=" +
|
if (ZenModeSettingsBase.DEBUG) Log.d(TAG, "onPrefChange allow" +
|
||||||
stringCategory + allowSenders + " allow" + stringCategory + "From="
|
stringCategory + "=" + allowSenders + " allow" + stringCategory + "From="
|
||||||
+ ZenModeConfig.sourceToString(allowSendersFrom));
|
+ ZenModeConfig.sourceToString(allowSendersFrom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import android.app.AutomaticZenRule;
|
import android.app.AutomaticZenRule;
|
||||||
import android.app.Fragment;
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -25,12 +24,10 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.service.notification.ConditionProviderService;
|
import android.service.notification.ConditionProviderService;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
@@ -39,14 +36,11 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
protected static final String TAG = ZenModeSettingsBase.TAG;
|
protected static final String TAG = ZenModeSettingsBase.TAG;
|
||||||
protected static final boolean DEBUG = ZenModeSettingsBase.DEBUG;
|
protected static final boolean DEBUG = ZenModeSettingsBase.DEBUG;
|
||||||
|
|
||||||
private static final String KEY_RULE_NAME = "rule_name";
|
|
||||||
|
|
||||||
protected Context mContext;
|
protected Context mContext;
|
||||||
protected boolean mDisableListeners;
|
protected boolean mDisableListeners;
|
||||||
protected AutomaticZenRule mRule;
|
protected AutomaticZenRule mRule;
|
||||||
protected String mId;
|
protected String mId;
|
||||||
|
|
||||||
private Preference mRuleName;
|
|
||||||
protected ZenAutomaticRuleHeaderPreferenceController mHeader;
|
protected ZenAutomaticRuleHeaderPreferenceController mHeader;
|
||||||
protected ZenAutomaticRuleSwitchPreferenceController mSwitch;
|
protected ZenAutomaticRuleSwitchPreferenceController mSwitch;
|
||||||
|
|
||||||
@@ -79,18 +73,7 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
onCreateInternal();
|
onCreateInternal();
|
||||||
|
|
||||||
final PreferenceScreen root = getPreferenceScreen();
|
|
||||||
mRuleName = root.findPreference(KEY_RULE_NAME);
|
|
||||||
mRuleName.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
showRuleNameDialog();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,7 +100,7 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
mSwitch.displayPreference(screen);
|
mSwitch.displayPreference(screen);
|
||||||
updatePreference(mSwitch);
|
updatePreference(mSwitch);
|
||||||
|
|
||||||
mHeader.onResume(mRule);
|
mHeader.onResume(mRule, mId);
|
||||||
mHeader.displayPreference(screen);
|
mHeader.displayPreference(screen);
|
||||||
updatePreference(mHeader);
|
updatePreference(mHeader);
|
||||||
}
|
}
|
||||||
@@ -161,46 +144,20 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showRuleNameDialog() {
|
|
||||||
ZenRuleNameDialog.show(this, mRule.getName(), null, new RuleNameChangeListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toastAndFinish() {
|
private void toastAndFinish() {
|
||||||
Toast.makeText(mContext, R.string.zen_mode_rule_not_found_text, Toast.LENGTH_SHORT)
|
Toast.makeText(mContext, R.string.zen_mode_rule_not_found_text, Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRuleName() {
|
|
||||||
if (mRule != null) {
|
|
||||||
mRuleName.setSummary(mRule.getName());
|
|
||||||
} else {
|
|
||||||
if (DEBUG) Log.d(TAG, "updateRuleName - mRuleName "
|
|
||||||
+ "not updated; mRuleName returned null");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private AutomaticZenRule getZenRule() {
|
private AutomaticZenRule getZenRule() {
|
||||||
return NotificationManager.from(mContext).getAutomaticZenRule(mId);
|
return NotificationManager.from(mContext).getAutomaticZenRule(mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateControls() {
|
private void updateControls() {
|
||||||
mDisableListeners = true;
|
mDisableListeners = true;
|
||||||
updateRuleName();
|
|
||||||
updateControlsInternal();
|
updateControlsInternal();
|
||||||
updateHeader();
|
updateHeader();
|
||||||
mDisableListeners = false;
|
mDisableListeners = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RuleNameChangeListener implements ZenRuleNameDialog.PositiveClickListener {
|
|
||||||
public RuleNameChangeListener() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOk(String ruleName, Fragment parent) {
|
|
||||||
mMetricsFeatureProvider.action(mContext,
|
|
||||||
MetricsProto.MetricsEvent.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
|
|
||||||
mRule.setName(ruleName);
|
|
||||||
mBackend.setZenRule(mId, mRule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -63,12 +63,14 @@ public class EntityHeaderController {
|
|||||||
|
|
||||||
@IntDef({ActionType.ACTION_NONE,
|
@IntDef({ActionType.ACTION_NONE,
|
||||||
ActionType.ACTION_APP_PREFERENCE,
|
ActionType.ACTION_APP_PREFERENCE,
|
||||||
ActionType.ACTION_NOTIF_PREFERENCE})
|
ActionType.ACTION_NOTIF_PREFERENCE,
|
||||||
|
ActionType.ACTION_DND_RULE_PREFERENCE,})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface ActionType {
|
public @interface ActionType {
|
||||||
int ACTION_NONE = 0;
|
int ACTION_NONE = 0;
|
||||||
int ACTION_APP_PREFERENCE = 1;
|
int ACTION_APP_PREFERENCE = 1;
|
||||||
int ACTION_NOTIF_PREFERENCE = 2;
|
int ACTION_NOTIF_PREFERENCE = 2;
|
||||||
|
int ACTION_DND_RULE_PREFERENCE = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PREF_KEY_APP_HEADER = "pref_app_header";
|
public static final String PREF_KEY_APP_HEADER = "pref_app_header";
|
||||||
@@ -99,6 +101,8 @@ public class EntityHeaderController {
|
|||||||
|
|
||||||
private boolean mIsInstantApp;
|
private boolean mIsInstantApp;
|
||||||
|
|
||||||
|
private View.OnClickListener mEditRuleNameOnClickListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the controller.
|
* Creates a new instance of the controller.
|
||||||
*
|
*
|
||||||
@@ -212,6 +216,11 @@ public class EntityHeaderController {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EntityHeaderController setEditZenRuleNameListener(View.OnClickListener listener) {
|
||||||
|
this.mEditRuleNameOnClickListener = listener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Done mutating entity header, rebinds everything and return a new {@link LayoutPreference}.
|
* Done mutating entity header, rebinds everything and return a new {@link LayoutPreference}.
|
||||||
*/
|
*/
|
||||||
@@ -330,6 +339,16 @@ public class EntityHeaderController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case ActionType.ACTION_DND_RULE_PREFERENCE: {
|
||||||
|
if (mEditRuleNameOnClickListener == null) {
|
||||||
|
button.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
button.setImageResource(R.drawable.ic_mode_edit);
|
||||||
|
button.setVisibility(View.VISIBLE);
|
||||||
|
button.setOnClickListener(mEditRuleNameOnClickListener);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
case ActionType.ACTION_NOTIF_PREFERENCE: {
|
case ActionType.ACTION_NOTIF_PREFERENCE: {
|
||||||
if (mAppNotifPrefIntent == null) {
|
if (mAppNotifPrefIntent == null) {
|
||||||
button.setVisibility(View.GONE);
|
button.setVisibility(View.GONE);
|
||||||
|
@@ -164,6 +164,57 @@ public class EntityHeaderControllerTest {
|
|||||||
verify(mFragment).startActivity(any(Intent.class));
|
verify(mFragment).startActivity(any(Intent.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void bindButton_hasEditRuleNameClickListener_shouldShowButton() {
|
||||||
|
final ResolveInfo info = new ResolveInfo();
|
||||||
|
info.activityInfo = new ActivityInfo();
|
||||||
|
info.activityInfo.packageName = "123";
|
||||||
|
info.activityInfo.name = "321";
|
||||||
|
final View view = mLayoutInflater
|
||||||
|
.inflate(R.layout.settings_entity_header, null /* root */);
|
||||||
|
when(mActivity.getApplicationContext()).thenReturn(mContext);
|
||||||
|
|
||||||
|
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
|
||||||
|
mController.setEditZenRuleNameListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mController.setButtonActions(
|
||||||
|
EntityHeaderController.ActionType.ACTION_DND_RULE_PREFERENCE,
|
||||||
|
EntityHeaderController.ActionType.ACTION_NONE);
|
||||||
|
mController.done(mActivity);
|
||||||
|
|
||||||
|
final ImageButton button1 = view.findViewById(android.R.id.button1);
|
||||||
|
assertThat(button1.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(button1.getDrawable()).isNotNull();
|
||||||
|
assertThat(view.findViewById(android.R.id.button2).getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void bindButton_noEditRuleNameClickListener_shouldNotShowButton() {
|
||||||
|
final ResolveInfo info = new ResolveInfo();
|
||||||
|
info.activityInfo = new ActivityInfo();
|
||||||
|
info.activityInfo.packageName = "123";
|
||||||
|
info.activityInfo.name = "321";
|
||||||
|
final View view = mLayoutInflater
|
||||||
|
.inflate(R.layout.settings_entity_header, null /* root */);
|
||||||
|
when(mActivity.getApplicationContext()).thenReturn(mContext);
|
||||||
|
|
||||||
|
mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
|
||||||
|
mController.setButtonActions(
|
||||||
|
EntityHeaderController.ActionType.ACTION_DND_RULE_PREFERENCE,
|
||||||
|
EntityHeaderController.ActionType.ACTION_NONE);
|
||||||
|
mController.done(mActivity);
|
||||||
|
|
||||||
|
assertThat(view.findViewById(android.R.id.button1).getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
|
assertThat(view.findViewById(android.R.id.button2).getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindButton_noAppPref_shouldNotShowButton() {
|
public void bindButton_noAppPref_shouldNotShowButton() {
|
||||||
final View appLinks = mLayoutInflater
|
final View appLinks = mLayoutInflater
|
||||||
|
Reference in New Issue
Block a user