use of com.github.pockethub.android.ui.TextWatcherAdapter in project PocketHub by pockethub.
the class CreateGistActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gist_create);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
descriptionText = finder.find(R.id.et_gist_description);
nameText = finder.find(R.id.et_gist_name);
contentText = finder.find(R.id.et_gist_content);
publicCheckBox = finder.find(R.id.cb_public);
final AppBarLayout appBarLayout = finder.find(R.id.appbar);
// Fully expand the AppBar if something in it gets focus
View.OnFocusChangeListener expandAppBarOnFocusChangeListener = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
appBarLayout.setExpanded(true);
}
}
};
nameText.setOnFocusChangeListener(expandAppBarOnFocusChangeListener);
descriptionText.setOnFocusChangeListener(expandAppBarOnFocusChangeListener);
publicCheckBox.setOnFocusChangeListener(expandAppBarOnFocusChangeListener);
// Fully expand the AppBar if something in it changes its value
TextWatcher expandAppBarTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
appBarLayout.setExpanded(true);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
appBarLayout.setExpanded(true);
}
@Override
public void afterTextChanged(Editable s) {
appBarLayout.setExpanded(true);
}
};
nameText.addTextChangedListener(expandAppBarTextWatcher);
descriptionText.addTextChangedListener(expandAppBarTextWatcher);
publicCheckBox.addTextChangedListener(expandAppBarTextWatcher);
publicCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
appBarLayout.setExpanded(true);
}
});
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
String text = ShareUtils.getBody(getIntent());
if (!TextUtils.isEmpty(text)) {
contentText.setText(text);
}
String subject = ShareUtils.getSubject(getIntent());
if (!TextUtils.isEmpty(subject)) {
descriptionText.setText(subject);
}
contentText.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
updateCreateMenu(s);
}
});
updateCreateMenu();
}
use of com.github.pockethub.android.ui.TextWatcherAdapter in project PocketHub by pockethub.
the class RawCommentFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
commentText = finder.find(R.id.et_comment);
addImageFab = finder.find(R.id.fab_add_image);
addImageFab.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Fragment fragment = RawCommentFragment.this;
String permission = Manifest.permission.READ_EXTERNAL_STORAGE;
if (ContextCompat.checkSelfPermission(getActivity(), permission) != PackageManager.PERMISSION_GRANTED) {
PermissionsUtils.askForPermission(fragment, READ_PERMISSION_REQUEST, permission, R.string.read_permission_title, R.string.read_permission_content);
} else {
startImagePicker();
}
} else {
startImagePicker();
}
}
});
commentText.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Activity activity = getActivity();
if (activity != null) {
activity.invalidateOptionsMenu();
}
}
});
commentText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
commentText.requestFocusFromTouch();
return false;
}
});
setText(initComment);
}
use of com.github.pockethub.android.ui.TextWatcherAdapter in project PocketHub by pockethub.
the class EditIssueActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_issue_edit);
titleText = finder.find(R.id.et_issue_title);
bodyText = finder.find(R.id.et_issue_body);
milestoneGraph = finder.find(R.id.ll_milestone_graph);
milestoneText = finder.find(R.id.tv_milestone);
milestoneClosed = finder.find(R.id.v_closed);
assigneeAvatar = finder.find(R.id.iv_assignee_avatar);
assigneeText = finder.find(R.id.tv_assignee_name);
labelsText = finder.find(R.id.tv_labels);
addImageFab = finder.find(R.id.fab_add_image);
Intent intent = getIntent();
if (savedInstanceState != null) {
issue = savedInstanceState.getParcelable(EXTRA_ISSUE);
}
if (issue == null) {
issue = intent.getParcelableExtra(EXTRA_ISSUE);
}
if (issue == null) {
issue = Issue.builder().build();
}
repository = InfoUtils.createRepoFromData(intent.getStringExtra(EXTRA_REPOSITORY_OWNER), intent.getStringExtra(EXTRA_REPOSITORY_NAME));
checkCollaboratorStatus();
setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));
ActionBar actionBar = getSupportActionBar();
if (issue.number() != null && issue.number() > 0) {
if (IssueUtils.isPullRequest(issue)) {
actionBar.setTitle(getString(R.string.pull_request_title) + issue.number());
} else {
actionBar.setTitle(getString(R.string.issue_title) + issue.number());
}
} else {
actionBar.setTitle(R.string.new_issue);
}
actionBar.setSubtitle(InfoUtils.createRepoId(repository));
avatars.bind(actionBar, (User) intent.getParcelableExtra(EXTRA_USER));
titleText.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
super.onTextChanged(s, start, before, count);
updateSaveMenu(s);
}
});
addImageFab.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Activity activity = EditIssueActivity.this;
String permission = Manifest.permission.READ_EXTERNAL_STORAGE;
if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
PermissionsUtils.askForPermission(activity, READ_PERMISSION_REQUEST, permission, R.string.read_permission_title, R.string.read_permission_content);
} else {
startImagePicker();
}
} else {
startImagePicker();
}
}
});
updateSaveMenu();
titleText.setText(issue.title());
bodyText.setText(issue.body());
}
Aggregations