use of net.steamcrafted.materialiconlib.MaterialIconView in project CoCoin by Nightonke.
the class TagSettingActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tag_setting);
mContext = this;
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
// Do something for lollipop and above versions
Window window = this.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
} else {
// do something for phones running an SDK before lollipop
}
//noinspection ConstantConditions
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mLayoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
mRecyclerViewDragDropManager.setLongPressTimeout(750);
//adapter
myItemAdapter = new TagDraggableItemAdapter();
mAdapter = myItemAdapter;
// wrap for dragging
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
mRecyclerView.setLayoutManager(mLayoutManager);
// requires *wrapped* adapter
mRecyclerView.setAdapter(mWrappedAdapter);
mRecyclerView.setItemAnimator(animator);
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z1)));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
back = (MaterialIconView) findViewById(R.id.icon_left);
check = (MaterialIconView) findViewById(R.id.check);
title = (TextView) findViewById(R.id.title);
title.setText((RecordManager.TAGS.size() - 2) + mContext.getResources().getString(R.string.tag_number));
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveChanges(true);
}
});
}
use of net.steamcrafted.materialiconlib.MaterialIconView in project CoCoin by Nightonke.
the class AccountBookSettingActivity method init.
// Init the setting activity////////////////////////////////////////////////////////////////////////
private void init() {
back = (MaterialIconView) findViewById(R.id.icon_left);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
logo = (CircleImageView) findViewById(R.id.profile_image);
logo.setOnClickListener(this);
profileLayout = (MaterialRippleLayout) findViewById(R.id.profile_layout);
userNameIcon = (MaterialIconView) findViewById(R.id.user_name_icon);
userEmailIcon = (MaterialIconView) findViewById(R.id.user_email_icon);
userName = (TextView) findViewById(R.id.user_name);
userName.setTypeface(CoCoinUtil.typefaceLatoLight);
userEmail = (TextView) findViewById(R.id.user_email);
userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
loginButton = (TextView) findViewById(R.id.login_button);
loginButton.setTypeface(CoCoinUtil.typefaceLatoLight);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
userOperator();
}
});
expense = (RiseNumberTextView) findViewById(R.id.expense);
expense.setTypeface(CoCoinUtil.typefaceLatoLight);
records = (RiseNumberTextView) findViewById(R.id.records);
records.setTypeface(CoCoinUtil.typefaceLatoLight);
expenseTV = (TextView) findViewById(R.id.expense_text);
expenseTV.setTypeface(CoCoinUtil.GetTypeface());
recordsTV = (TextView) findViewById(R.id.records_text);
recordsTV.setTypeface(CoCoinUtil.GetTypeface());
expense.withNumber(RecordManager.SUM).setDuration(1500).start();
records.withNumber(RecordManager.RECORDS.size()).setDuration(1500).start();
monthLayout = (MaterialRippleLayout) findViewById(R.id.month_layout);
monthIcon = (MaterialIconView) findViewById(R.id.month_limit_icon);
monthMaxExpenseIcon = (MaterialIconView) findViewById(R.id.month_expense_icon);
monthColorRemindIcon = (MaterialIconView) findViewById(R.id.month_color_icon);
monthWarningIcon = (MaterialIconView) findViewById(R.id.warning_expense_icon);
monthColorRemindTypeIcon = (MaterialIconView) findViewById(R.id.month_color_type_icon);
monthColorRemindSelect = (MaterialIconView) findViewById(R.id.month_color_type);
monthColorRemindSelect.setColor(SettingManager.getInstance().getRemindColor());
monthForbiddenIcon = (MaterialIconView) findViewById(R.id.month_forbidden_icon);
monthSB = (Switch) findViewById(R.id.month_limit_enable_button);
monthSB.setOnCheckedChangeListener(this);
monthColorRemindSB = (Switch) findViewById(R.id.month_color_remind_button);
monthColorRemindSB.setOnCheckedChangeListener(this);
monthForbiddenSB = (Switch) findViewById(R.id.month_forbidden_button);
monthForbiddenSB.setOnCheckedChangeListener(this);
monthMaxExpense = (RiseNumberTextView) findViewById(R.id.month_expense);
if (SettingManager.getInstance().getIsMonthLimit())
monthMaxExpense.withNumber(SettingManager.getInstance().getMonthLimit()).setDuration(1000).start();
// change the month limit///////////////////////////////////////////////////////////////////////////
monthMaxExpense.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SettingManager.getInstance().getIsMonthLimit()) {
new MaterialDialog.Builder(mContext).theme(Theme.LIGHT).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).title(R.string.set_month_expense_dialog_title).inputType(InputType.TYPE_CLASS_NUMBER).positiveText(R.string.submit).inputRange(3, 5).input(SettingManager.getInstance().getMonthLimit().toString(), null, new MaterialDialog.InputCallback() {
@Override
public void onInput(MaterialDialog dialog, CharSequence input) {
int newExpense = SettingManager.getInstance().getMonthLimit();
if (input.length() != 0) {
newExpense = Integer.parseInt(input.toString());
}
// the month limit must be smaller than the month warning
if (newExpense < SettingManager.getInstance().getMonthWarning()) {
SettingManager.getInstance().setMonthWarning(((int) (newExpense * 0.8) / 100 * 100));
if (SettingManager.getInstance().getMonthWarning() < 100) {
SettingManager.getInstance().setMonthWarning(100);
}
updateSettingsToServer(UPDATE_MONTH_WARNING);
SettingManager.getInstance().setMainViewRemindColorShouldChange(true);
monthWarning.setText(SettingManager.getInstance().getMonthWarning().toString());
}
SettingManager.getInstance().setMonthLimit(newExpense);
updateSettingsToServer(UPDATE_MONTH_LIMIT);
SettingManager.getInstance().setTodayViewMonthExpenseShouldChange(true);
SettingManager.getInstance().setMainViewMonthExpenseShouldChange(true);
monthMaxExpense.withNumber(SettingManager.getInstance().getMonthLimit()).setDuration(1000).start();
}
}).show();
}
}
});
monthWarning = (RiseNumberTextView) findViewById(R.id.warning_expense);
monthWarning.setText(SettingManager.getInstance().getMonthWarning().toString());
if (SettingManager.getInstance().getIsMonthLimit() && SettingManager.getInstance().getIsColorRemind())
monthWarning.withNumber(SettingManager.getInstance().getMonthWarning()).setDuration(1000).start();
// change month warning/////////////////////////////////////////////////////////////////////////////
monthWarning.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SettingManager.getInstance().getIsMonthLimit() && SettingManager.getInstance().getIsColorRemind()) {
new MaterialDialog.Builder(mContext).theme(Theme.LIGHT).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).title(R.string.set_month_expense_dialog_title).inputType(InputType.TYPE_CLASS_NUMBER).positiveText(R.string.submit).alwaysCallInputCallback().input(null, null, new MaterialDialog.InputCallback() {
@Override
public void onInput(final MaterialDialog dialog, final CharSequence input) {
if (input.length() == 0) {
dialog.setContent(mContext.getResources().getString(R.string.set_warning_expense_dialog_title));
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
} else if (Integer.parseInt(input.toString()) < 100) {
dialog.setContent("≥ 100");
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
} else if (Integer.parseInt(input.toString()) > SettingManager.getInstance().getMonthLimit()) {
dialog.setContent("≤ " + SettingManager.getInstance().getMonthLimit().toString());
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
} else {
dialog.setContent(mContext.getResources().getString(R.string.set_warning_expense_dialog_title));
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
}
dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SettingManager.getInstance().setMonthWarning(Integer.parseInt(input.toString()));
updateSettingsToServer(UPDATE_MONTH_WARNING);
SettingManager.getInstance().setMainViewRemindColorShouldChange(true);
monthWarning.withNumber(SettingManager.getInstance().getMonthWarning()).setDuration(1000).start();
dialog.dismiss();
}
});
}
}).show();
}
}
});
// change month remind color////////////////////////////////////////////////////////////////////////
monthColorRemindSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SettingManager.getInstance().setMainViewRemindColorShouldChange(true);
remindColorSelectDialog.show((AppCompatActivity) mContext);
}
});
monthMaxExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
monthWarning.setTypeface(CoCoinUtil.typefaceLatoLight);
monthLimitTV = (TextView) findViewById(R.id.month_limit_text);
monthLimitTV.setTypeface(CoCoinUtil.GetTypeface());
monthWarningTV = (TextView) findViewById(R.id.warning_expense_text);
monthWarningTV.setTypeface(CoCoinUtil.GetTypeface());
monthMaxExpenseTV = (TextView) findViewById(R.id.month_expense_text);
monthMaxExpenseTV.setTypeface(CoCoinUtil.GetTypeface());
monthColorRemindTV = (TextView) findViewById(R.id.month_color_remind_text);
monthColorRemindTV.setTypeface(CoCoinUtil.GetTypeface());
monthColorRemindTypeTV = (TextView) findViewById(R.id.month_color_type_text);
monthColorRemindTypeTV.setTypeface(CoCoinUtil.GetTypeface());
monthForbiddenTV = (TextView) findViewById(R.id.month_forbidden_text);
monthForbiddenTV.setTypeface(CoCoinUtil.GetTypeface());
accountBookNameLayout = (MaterialRippleLayout) findViewById(R.id.account_book_name_layout);
accountBookNameLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeAccountBookName();
}
});
accountBookName = (TextView) findViewById(R.id.account_book_name);
accountBookName.setTypeface(CoCoinUtil.GetTypeface());
accountBookName.setText(SettingManager.getInstance().getAccountBookName());
accountBookNameTV = (TextView) findViewById(R.id.account_book_name_text);
accountBookNameTV.setTypeface(CoCoinUtil.GetTypeface());
changePasswordLayout = (MaterialRippleLayout) findViewById(R.id.change_password_layout);
changePasswordLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changePassword();
}
});
changePasswordTV = (TextView) findViewById(R.id.change_password_text);
changePasswordTV.setTypeface(CoCoinUtil.GetTypeface());
sortTagsLayout = (MaterialRippleLayout) findViewById(R.id.sort_tags_layout);
sortTagsLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sortTags();
}
});
sortTagsTV = (TextView) findViewById(R.id.sort_tags_text);
sortTagsTV.setTypeface(CoCoinUtil.GetTypeface());
showPictureLayout = (MaterialRippleLayout) findViewById(R.id.whether_show_picture_layout);
showPictureIcon = (MaterialIconView) findViewById(R.id.whether_show_picture_icon);
showPictureSB = (Switch) findViewById(R.id.whether_show_picture_button);
showPictureSB.setOnCheckedChangeListener(this);
showPictureTV = (TextView) findViewById(R.id.whether_show_picture_text);
showPictureTV.setTypeface(CoCoinUtil.GetTypeface());
hollowLayout = (MaterialRippleLayout) findViewById(R.id.whether_show_circle_layout);
hollowIcon = (MaterialIconView) findViewById(R.id.whether_show_circle_icon);
hollowSB = (Switch) findViewById(R.id.whether_show_circle_button);
hollowSB.setOnCheckedChangeListener(this);
hollowTV = (TextView) findViewById(R.id.whether_show_circle_text);
hollowTV.setTypeface(CoCoinUtil.GetTypeface());
updateLayout = (MaterialRippleLayout) findViewById(R.id.update_layout);
updateLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CoCoinUtil.showToast(mContext, mContext.getResources().getString(R.string.checking_update), SuperToast.Background.BLUE);
AppUpdateManager appUpdateManager = new AppUpdateManager(mContext);
appUpdateManager.checkUpdateInfo(true);
}
});
currentVersionTV = (TextView) findViewById(R.id.update_text);
currentVersionTV.setTypeface(CoCoinUtil.GetTypeface());
currentVersionTV.setText(mContext.getResources().getString(R.string.current_version) + CoCoinUtil.GetCurrentVersion());
canBeUpdatedTV = (TextView) findViewById(R.id.update_tag);
canBeUpdatedTV.setTypeface(CoCoinUtil.GetTypeface());
if (SettingManager.getInstance().getCanBeUpdated()) {
canBeUpdatedTV.setVisibility(View.VISIBLE);
} else {
canBeUpdatedTV.setVisibility(View.GONE);
}
boolean loggenOn = SettingManager.getInstance().getLoggenOn();
if (loggenOn) {
// is logged on, set the user name and email
userName.setText(SettingManager.getInstance().getUserName());
userEmail.setText(SettingManager.getInstance().getUserEmail());
loginButton.setText(mContext.getResources().getText(R.string.logout_button));
loginButton.setBackgroundResource(R.drawable.button_logout);
} else {
userName.setText("");
userEmail.setText("");
loginButton.setText(getResourceString(R.string.login_button));
}
setIconEnable(userNameIcon, loggenOn);
setIconEnable(userEmailIcon, loggenOn);
loadLogo();
monthSB.setCheckedImmediately(SettingManager.getInstance().getIsMonthLimit());
setMonthState();
showPictureSB.setCheckedImmediately(SettingManager.getInstance().getShowPicture());
setShowPictureState(SettingManager.getInstance().getShowPicture());
hollowSB.setCheckedImmediately(SettingManager.getInstance().getIsHollow());
setHollowState(SettingManager.getInstance().getIsHollow());
}
Aggregations