use of im.actor.sdk.ActorStyle in project actor-platform by actorapp.
the class GroupInfoFragment method updateBar.
public void updateBar(int offset) {
int baseColor = getResources().getColor(R.color.primary);
ActorStyle style = ActorSDK.sharedActor().style;
if (style.getToolBarColor() != 0) {
baseColor = style.getToolBarColor();
}
if (offset > Screen.dp(248 - 56)) {
((BaseActivity) getActivity()).getSupportActionBar().setBackgroundDrawable(new ColorDrawable(baseColor));
} else {
float alpha = offset / (float) Screen.dp(248 - 56);
int color = Color.argb((int) (255 * alpha), Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor));
((BaseActivity) getActivity()).getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
}
}
use of im.actor.sdk.ActorStyle in project actor-platform by actorapp.
the class BaseActorSettingsFragment method updateActionBar.
private void updateActionBar(int offset) {
if (!animateToolbar) {
return;
}
Activity activity = getActivity();
if (!(activity instanceof BaseActivity)) {
return;
}
ActionBar bar = ((BaseActivity) getActivity()).getSupportActionBar();
if (bar == null) {
return;
}
int fullColor = baseColor;
ActorStyle style = ActorSDK.sharedActor().style;
if (style.getToolBarColor() != 0) {
fullColor = style.getToolBarColor();
}
if (Math.abs(offset) > Screen.dp(248 - 56)) {
bar.setBackgroundDrawable(new ColorDrawable(fullColor));
} else {
float alpha = Math.abs(offset) / (float) Screen.dp(248 - 56);
bar.setBackgroundDrawable(new ColorDrawable(Color.argb((int) (255 * alpha), Color.red(fullColor), Color.green(fullColor), Color.blue(fullColor))));
}
}
use of im.actor.sdk.ActorStyle in project actor-platform by actorapp.
the class Application method onConfigureActorSDK.
@Override
public void onConfigureActorSDK() {
ActorSDK.sharedActor().setDelegate(new ActorSDKDelegate());
ActorSDK.sharedActor().setPushId(209133700967L);
ActorSDK.sharedActor().setOnClientPrivacyEnabled(true);
ActorStyle style = ActorSDK.sharedActor().style;
style.setDialogsActiveTextColor(0xff5882ac);
style.setShowAvatarPrivateInTitle(false);
ActorSDK.sharedActor().setFastShareEnabled(true);
ActorSDK.sharedActor().setCallsEnabled(true);
ActorSDK.sharedActor().setTosUrl("http://actor.im");
ActorSDK.sharedActor().setPrivacyText("bla bla bla");
ActorSDK.sharedActor().setVideoCallsEnabled(true);
ActorSDK.sharedActor().setAutoJoinGroups(new String[] { "actor_news" });
// ActorSDK.sharedActor().setTwitter("");
// ActorSDK.sharedActor().setHomePage("http://www.foo.com");
// ActorSDK.sharedActor().setInviteUrl("http://www.foo.com");
// ActorSDK.sharedActor().setCallsEnabled(true);
// ActorSDK.sharedActor().setEndpoints(new String[]{"tcp://192.168.1.184:9070"});
// ActorStyle style = ActorSDK.sharedActor().style;
// style.setMainColor(Color.parseColor("#529a88"));
// style.setAvatarBackgroundResource(R.drawable.img_profile_avatar_default);
// AbsContent.registerConverter(new ContentConverter() {
// @Override
// public AbsContent convert(AbsContentContainer container) {
// return JsonContent.convert(container, new TCBotMesaage());
// }
//
// @Override
// public boolean validate(AbsContent content) {
// return content instanceof TCBotMesaage;
// }
// });
}
use of im.actor.sdk.ActorStyle in project actor-platform by actorapp.
the class SignInFragment method initView.
private void initView(View v) {
ActorStyle style = ActorSDK.sharedActor().style;
TextView hint = (TextView) v.findViewById(R.id.sign_in_login_hint);
hint.setTextColor(style.getTextSecondaryColor());
signIdEditText = (EditText) v.findViewById(R.id.tv_sign_in);
signIdEditText.setTextColor(style.getTextPrimaryColor());
signIdEditText.setHighlightColor(style.getMainColor());
signIdEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == EditorInfo.IME_ACTION_GO) {
requestCode();
return true;
}
return false;
}
});
int availableAuthType = ActorSDK.sharedActor().getAuthType();
String savedAuthId = messenger().getPreferences().getString("sign_in_auth_id");
signIdEditText.setText(savedAuthId);
boolean needSuggested = savedAuthId == null || savedAuthId.isEmpty();
if (((availableAuthType & AuthActivity.AUTH_TYPE_PHONE) == AuthActivity.AUTH_TYPE_PHONE) && ((availableAuthType & AuthActivity.AUTH_TYPE_EMAIL) == AuthActivity.AUTH_TYPE_EMAIL)) {
// both hints set phone + email by default
if (needSuggested) {
setSuggestedEmail(signIdEditText);
}
} else if ((availableAuthType & AuthActivity.AUTH_TYPE_PHONE) == AuthActivity.AUTH_TYPE_PHONE) {
hint.setText(getString(R.string.sign_in_hint_phone_only));
signIdEditText.setHint(getString(R.string.sign_in_edit_text_hint_phone_only));
signIdEditText.setInputType(EditorInfo.TYPE_CLASS_PHONE);
} else if ((availableAuthType & AuthActivity.AUTH_TYPE_EMAIL) == AuthActivity.AUTH_TYPE_EMAIL) {
hint.setText(getString(R.string.sign_in_hint_email_only));
signIdEditText.setHint(getString(R.string.sign_in_edit_text_hint_email_only));
if (needSuggested) {
setSuggestedEmail(signIdEditText);
}
}
Button singUp = (Button) v.findViewById(R.id.button_sign_up);
singUp.setTextColor(style.getTextSecondaryColor());
onClick(singUp, new View.OnClickListener() {
@Override
public void onClick(View v) {
startSignUp();
}
});
onClick(v, R.id.button_continue, new View.OnClickListener() {
@Override
public void onClick(View view) {
requestCode();
}
});
}
use of im.actor.sdk.ActorStyle in project actor-platform by actorapp.
the class NotificationsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View res = inflater.inflate(R.layout.fr_settings_notifications, container, false);
res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
// Conversation tone
final CheckBox enableTones = (CheckBox) res.findViewById(R.id.enableConversationTones);
enableTones.setChecked(messenger().isConversationTonesEnabled());
View.OnClickListener enableTonesListener = v -> {
messenger().changeConversationTonesEnabled(!messenger().isConversationTonesEnabled());
enableTones.setChecked(messenger().isConversationTonesEnabled());
};
ActorStyle style = ActorSDK.sharedActor().style;
((TextView) res.findViewById(R.id.settings_conversation_tones_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_conversation_tones_hint)).setTextColor(style.getTextSecondaryColor());
enableTones.setOnClickListener(enableTonesListener);
res.findViewById(R.id.conversationTonesCont).setOnClickListener(enableTonesListener);
// Vibration
final CheckBox enableVibration = (CheckBox) res.findViewById(R.id.enableVibration);
enableVibration.setChecked(messenger().isNotificationVibrationEnabled());
View.OnClickListener enableVibrationListener = v -> {
messenger().changeNotificationVibrationEnabled(!messenger().isNotificationVibrationEnabled());
enableVibration.setChecked(messenger().isNotificationVibrationEnabled());
};
enableVibration.setOnClickListener(enableVibrationListener);
res.findViewById(R.id.vibrationCont).setOnClickListener(enableVibrationListener);
((TextView) res.findViewById(R.id.settings_vibration_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_vibration_hint)).setTextColor(style.getTextSecondaryColor());
// Group
final CheckBox enableGroup = (CheckBox) res.findViewById(R.id.enableGroup);
enableGroup.setChecked(messenger().isGroupNotificationsEnabled());
View.OnClickListener enableGroupListener = v -> {
messenger().changeGroupNotificationsEnabled(!messenger().isGroupNotificationsEnabled());
enableGroup.setChecked(messenger().isGroupNotificationsEnabled());
};
enableGroup.setOnClickListener(enableGroupListener);
res.findViewById(R.id.groupCont).setOnClickListener(enableGroupListener);
((TextView) res.findViewById(R.id.settings_group_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_group_hint)).setTextColor(style.getTextSecondaryColor());
// Mentions
final CheckBox enableGroupMentions = (CheckBox) res.findViewById(R.id.enableGroupMentions);
enableGroupMentions.setChecked(messenger().isGroupNotificationsOnlyMentionsEnabled());
View.OnClickListener enableGroupMentionsListener = v -> {
messenger().changeGroupNotificationsOnlyMentionsEnabled(!messenger().isGroupNotificationsOnlyMentionsEnabled());
enableGroupMentions.setChecked(messenger().isGroupNotificationsOnlyMentionsEnabled());
};
enableGroupMentions.setOnClickListener(enableGroupMentionsListener);
res.findViewById(R.id.groupMentionsCont).setOnClickListener(enableGroupMentionsListener);
((TextView) res.findViewById(R.id.settings_group_mentions_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_group_mentions_hint)).setTextColor(style.getTextSecondaryColor());
// Names and messages
final CheckBox enableText = (CheckBox) res.findViewById(R.id.enableTitles);
enableText.setChecked(messenger().isShowNotificationsText());
View.OnClickListener enableTextListener = v -> {
messenger().changeShowNotificationTextEnabled(!messenger().isShowNotificationsText());
enableText.setChecked(messenger().isShowNotificationsText());
};
enableText.setOnClickListener(enableTextListener);
res.findViewById(R.id.titlesCont).setOnClickListener(enableTextListener);
((TextView) res.findViewById(R.id.settings_titles_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_titles_hint)).setTextColor(style.getTextSecondaryColor());
// Sound
View soundPickerCont = res.findViewById(R.id.soundPickerCont);
View soundPickerDivider = res.findViewById(R.id.divider);
if (messenger().isNotificationSoundEnabled()) {
ViewUtils.showViews(false, soundPickerCont, soundPickerDivider);
} else {
ViewUtils.goneViews(false, soundPickerCont, soundPickerDivider);
}
final CheckBox enableSound = (CheckBox) res.findViewById(R.id.enableSound);
enableSound.setChecked(messenger().isNotificationSoundEnabled());
View.OnClickListener enableSoundListener = v -> {
messenger().changeNotificationSoundEnabled(!messenger().isNotificationSoundEnabled());
enableSound.setChecked(messenger().isNotificationSoundEnabled());
// show/hide sound picker
if (messenger().isNotificationSoundEnabled()) {
ViewUtils.showViews(soundPickerCont, soundPickerDivider);
} else {
ViewUtils.goneViews(soundPickerCont, soundPickerDivider);
}
};
enableSound.setOnClickListener(enableSoundListener);
res.findViewById(R.id.soundCont).setOnClickListener(enableSoundListener);
((TextView) res.findViewById(R.id.settings_sound_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_sound_hint)).setTextColor(style.getTextSecondaryColor());
// Sound picker
View.OnClickListener soundPickerListener = v -> {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
Uri currentSound = null;
String defaultPath = null;
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
if (defaultUri != null) {
defaultPath = defaultUri.getPath();
}
String path = messenger().getPreferences().getString("globalNotificationSound");
if (path == null) {
path = defaultPath;
}
if (path != null && !path.equals("none")) {
if (path.equals(defaultPath)) {
currentSound = defaultUri;
} else {
currentSound = Uri.parse(path);
}
}
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
startActivityForResult(intent, SOUND_PICKER_REQUEST_CODE);
};
res.findViewById(R.id.soundPickerCont).setOnClickListener(soundPickerListener);
((TextView) res.findViewById(R.id.settings_sound_picker_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_sound_picker_hint)).setTextColor(style.getTextSecondaryColor());
return res;
}
Aggregations