use of android.support.annotation.AttrRes in project gh4a by slapperwan.
the class EditCommentActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(Gh4Application.THEME == R.style.DarkTheme ? R.style.BottomSheetDarkTheme : R.style.BottomSheetLightTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.comment_editor);
mRootLayout = findViewById(R.id.coordinator_layout);
mEditorSheet = findViewById(R.id.bottom_sheet);
if (getIntent().getLongExtra("id", 0L) != 0L) {
ImageView saveButton = mEditorSheet.findViewById(R.id.send_button);
saveButton.setImageResource(UiUtils.resolveDrawable(this, R.attr.saveIcon));
}
mEditorSheet.setCallback(this);
if (getIntent().hasExtra("body")) {
mEditorSheet.setCommentText(getIntent().getStringExtra("body"), false);
getIntent().removeExtra("body");
}
@AttrRes int highlightColorAttr = getIntent().getIntExtra("highlight_color_attr", 0);
if (highlightColorAttr != 0) {
mEditorSheet.setHighlightColor(highlightColorAttr);
}
setResult(RESULT_CANCELED);
}
use of android.support.annotation.AttrRes in project Tusky by Vavassor.
the class AccountActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account);
ButterKnife.bind(this);
if (savedInstanceState != null) {
accountId = savedInstanceState.getString("accountId");
followState = (FollowState) savedInstanceState.getSerializable("followState");
blocking = savedInstanceState.getBoolean("blocking");
muting = savedInstanceState.getBoolean("muting");
} else {
Intent intent = getIntent();
accountId = intent.getStringExtra("id");
followState = FollowState.NOT_FOLLOWING;
blocking = false;
muting = false;
}
loadedAccount = null;
SharedPreferences preferences = getPrivatePreferences();
String loggedInAccountId = preferences.getString("loggedInAccountId", null);
// Setup the toolbar.
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(null);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
// Add a listener to change the toolbar icon color when it enters/exits its collapsed state.
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.account_app_bar_layout);
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@AttrRes
int priorAttribute = R.attr.account_toolbar_icon_tint_uncollapsed;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
@AttrRes int attribute;
if (collapsingToolbar.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingToolbar)) {
toolbar.setTitleTextColor(ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorPrimary));
toolbar.setSubtitleTextColor(ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorSecondary));
attribute = R.attr.account_toolbar_icon_tint_collapsed;
} else {
toolbar.setTitleTextColor(Color.TRANSPARENT);
toolbar.setSubtitleTextColor(Color.TRANSPARENT);
attribute = R.attr.account_toolbar_icon_tint_uncollapsed;
}
if (attribute != priorAttribute) {
priorAttribute = attribute;
Context context = toolbar.getContext();
ThemeUtils.setDrawableTint(context, toolbar.getNavigationIcon(), attribute);
ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute);
}
}
});
// Initialise the default UI states.
floatingBtn.hide();
// Obtain information to fill out the profile.
obtainAccount();
if (!accountId.equals(loggedInAccountId)) {
isSelf = false;
obtainRelationships();
} else {
/* Cause the options menu to update and instead show an options menu for when the
* account being shown is their own account. */
isSelf = true;
invalidateOptionsMenu();
}
// Setup the tabs and timeline pager.
AccountPagerAdapter adapter = new AccountPagerAdapter(getSupportFragmentManager(), this, accountId);
pagerAdapter = adapter;
String[] pageTitles = { getString(R.string.title_statuses), getString(R.string.title_follows), getString(R.string.title_followers) };
adapter.setPageTitles(pageTitles);
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
int pageMargin = getResources().getDimensionPixelSize(R.dimen.tab_page_margin);
viewPager.setPageMargin(pageMargin);
Drawable pageMarginDrawable = ThemeUtils.getDrawable(this, R.attr.tab_page_margin_drawable, R.drawable.tab_page_margin_dark);
viewPager.setPageMarginDrawable(pageMarginDrawable);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
if (tab != null) {
tab.setCustomView(adapter.getTabView(i, tabLayout));
}
}
}
use of android.support.annotation.AttrRes in project gh4a by slapperwan.
the class PullRequestFragment method editComment.
@Override
public void editComment(GitHubCommentBase comment) {
@AttrRes final int highlightColorAttr = mPullRequest.merged() ? R.attr.colorPullRequestMerged : mPullRequest.state() == IssueState.Closed ? R.attr.colorIssueClosed : R.attr.colorIssueOpen;
Intent intent = comment instanceof ReviewComment ? EditPullRequestCommentActivity.makeIntent(getActivity(), mRepoOwner, mRepoName, mPullRequest.number(), comment.id(), 0L, comment.body(), highlightColorAttr) : EditIssueCommentActivity.makeIntent(getActivity(), mRepoOwner, mRepoName, mIssue.number(), comment.id(), comment.body(), highlightColorAttr);
startActivityForResult(intent, REQUEST_EDIT);
}
use of android.support.annotation.AttrRes in project gh4a by slapperwan.
the class IssueFragment method editComment.
@Override
public void editComment(GitHubCommentBase comment) {
@AttrRes int highlightColorAttr = mIssue.state() == IssueState.Closed ? R.attr.colorIssueClosed : R.attr.colorIssueOpen;
Intent intent = EditIssueCommentActivity.makeIntent(getActivity(), mRepoOwner, mRepoName, mIssue.number(), comment.id(), comment.body(), highlightColorAttr);
startActivityForResult(intent, REQUEST_EDIT);
}
use of android.support.annotation.AttrRes in project Tusky by tuskyapp.
the class AccountActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account);
avatar = findViewById(R.id.account_avatar);
header = findViewById(R.id.account_header);
floatingBtn = findViewById(R.id.floating_btn);
followBtn = findViewById(R.id.follow_btn);
followsYouView = findViewById(R.id.account_follows_you);
tabLayout = findViewById(R.id.tab_layout);
accountLockedView = findViewById(R.id.account_locked);
container = findViewById(R.id.activity_account);
followersTextView = findViewById(R.id.followers_tv);
followingTextView = findViewById(R.id.following_tv);
statusesTextView = findViewById(R.id.statuses_btn);
if (savedInstanceState != null) {
accountId = savedInstanceState.getString("accountId");
followState = (FollowState) savedInstanceState.getSerializable("followState");
blocking = savedInstanceState.getBoolean("blocking");
muting = savedInstanceState.getBoolean("muting");
} else {
Intent intent = getIntent();
accountId = intent.getStringExtra("id");
followState = FollowState.NOT_FOLLOWING;
blocking = false;
muting = false;
}
loadedAccount = null;
// Setup the toolbar.
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(null);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
hideFab = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fabHide", false);
// Add a listener to change the toolbar icon color when it enters/exits its collapsed state.
AppBarLayout appBarLayout = findViewById(R.id.account_app_bar_layout);
final CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapsing_toolbar);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@AttrRes
int priorAttribute = R.attr.account_toolbar_icon_tint_uncollapsed;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
@AttrRes int attribute;
if (collapsingToolbar.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingToolbar)) {
toolbar.setTitleTextColor(ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorPrimary));
toolbar.setSubtitleTextColor(ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorSecondary));
attribute = R.attr.account_toolbar_icon_tint_collapsed;
} else {
toolbar.setTitleTextColor(Color.TRANSPARENT);
toolbar.setSubtitleTextColor(Color.TRANSPARENT);
attribute = R.attr.account_toolbar_icon_tint_uncollapsed;
}
if (attribute != priorAttribute) {
priorAttribute = attribute;
Context context = toolbar.getContext();
ThemeUtils.setDrawableTint(context, toolbar.getNavigationIcon(), attribute);
ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute);
}
if (floatingBtn != null && hideFab && !isSelf && !blocking) {
if (verticalOffset > oldOffset) {
floatingBtn.show();
}
if (verticalOffset < oldOffset) {
floatingBtn.hide();
}
}
oldOffset = verticalOffset;
}
});
// Initialise the default UI states.
floatingBtn.hide();
followBtn.setVisibility(View.GONE);
followsYouView.setVisibility(View.GONE);
// Obtain information to fill out the profile.
obtainAccount();
AccountEntity activeAccount = TuskyApplication.getInstance(this).getServiceLocator().get(AccountManager.class).getActiveAccount();
if (accountId.equals(activeAccount.getAccountId())) {
isSelf = true;
} else {
isSelf = false;
obtainRelationships();
}
// Setup the tabs and timeline pager.
AccountPagerAdapter adapter = new AccountPagerAdapter(getSupportFragmentManager(), accountId);
String[] pageTitles = { getString(R.string.title_statuses), getString(R.string.title_media) };
adapter.setPageTitles(pageTitles);
final ViewPager viewPager = findViewById(R.id.pager);
int pageMargin = getResources().getDimensionPixelSize(R.dimen.tab_page_margin);
viewPager.setPageMargin(pageMargin);
Drawable pageMarginDrawable = ThemeUtils.getDrawable(this, R.attr.tab_page_margin_drawable, R.drawable.tab_page_margin_dark);
viewPager.setPageMarginDrawable(pageMarginDrawable);
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(0);
tabLayout.setupWithViewPager(viewPager);
View.OnClickListener accountListClickListener = v -> {
AccountListActivity.Type type;
switch(v.getId()) {
case R.id.followers_tv:
type = AccountListActivity.Type.FOLLOWERS;
break;
case R.id.following_tv:
type = AccountListActivity.Type.FOLLOWING;
break;
default:
throw new AssertionError();
}
Intent intent = AccountListActivity.newIntent(AccountActivity.this, type, accountId);
startActivity(intent);
};
followersTextView.setOnClickListener(accountListClickListener);
followingTextView.setOnClickListener(accountListClickListener);
statusesTextView.setOnClickListener(v -> {
// Make nice ripple effect on tab
// noinspection ConstantConditions
tabLayout.getTabAt(0).select();
final View poorTabView = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(0);
poorTabView.setPressed(true);
tabLayout.postDelayed(() -> poorTabView.setPressed(false), 300);
});
}
Aggregations