use of android.support.v7.widget.AppCompatButton in project ChatExchange by HueToYou.
the class AccountsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_accounts, container, false);
getActivity().setTitle(getResources().getText(R.string.app_name));
mAccountManager = AccountManager.get(getActivity());
Account[] accounts = mAccountManager.getAccounts();
LinearLayout accountLayout = (LinearLayout) view.findViewById(R.id.select_account_lin);
List<String> spinnerArray = new ArrayList<String>();
for (final Account account : accounts) {
spinnerArray.add(account.name);
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, spinnerArray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner sItems = (Spinner) accountLayout.findViewById(R.id.accountsSpinner);
sItems.setAdapter(adapter);
Button newAccount = new AppCompatButton(getActivity());
newAccount.setText(getResources().getText(R.string.activity_main_add_account));
newAccount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().startActivity(new Intent(getActivity(), AuthenticatorActivity.class));
}
});
ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.setMargins(0, 20, 0, 0);
newAccount.setLayoutParams(params);
accountLayout.addView(newAccount);
View v = new View(getActivity());
v.setMinimumHeight(2);
v.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
ViewGroup.MarginLayoutParams vparams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
vparams.setMargins(40, 40, 40, 40);
v.setLayoutParams(vparams);
accountLayout.addView(v);
Button newChat = new AppCompatButton(getActivity());
newChat.setText(getResources().getText(R.string.activity_main_add_chat));
newChat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).showAddTabDialog();
}
}
});
accountLayout.addView(newChat);
return view;
}
use of android.support.v7.widget.AppCompatButton in project Rashr by DsLNeXuS.
the class BackupActivity method showPopup.
public void showPopup(final View v, final File file) {
PopupMenu popup = new PopupMenu(mActivity, v);
popup.getMenuInflater().inflate(R.menu.bakmgr_menu, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem menuItem) {
final AppCompatDialog dialog = new AppCompatDialog(mActivity);
dialog.setTitle(R.string.setname);
dialog.setContentView(R.layout.dialog_input);
final AppCompatButton bGo = dialog.findViewById(R.id.bGoBackup);
final AppCompatEditText etFileName = dialog.findViewById(R.id.etFileName);
if (bGo == null || etFileName == null)
return false;
// If current item is 0 (first item) a recovery backup will be edited or created
final File path = mPager.getCurrentItem() == 0 ? App.PathToRecoveryBackups : App.PathToKernelBackups;
try {
switch(menuItem.getItemId()) {
case R.id.iRestore:
FlashUtil RestoreUtil = new FlashUtil(mActivity, file, mPager.getCurrentItem() == 0 ? FlashUtil.JOB_RESTORE_RECOVERY : FlashUtil.JOB_RESTORE_KERNEL);
RestoreUtil.execute();
return true;
case R.id.iRename:
etFileName.setHint(file.getName());
bGo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Name;
if (etFileName.getText() != null && etFileName.isEnabled() && !etFileName.getText().toString().equals("")) {
// User has defined a name for the backup. Use it.
Name = etFileName.getText().toString();
} else {
// Use hint as backup name. Normally the correct version
// and Recovery System (if Rashr could read it out of
// "/cache/recovery/last_log"
Name = String.valueOf(etFileName.getHint());
}
if (!Name.endsWith(App.Device.getRecoveryExt())) {
// Append extension
Name += App.Device.getRecoveryExt();
}
File renamedBackup = new File(path, Name);
if (renamedBackup.exists()) {
Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
// if backup already exists, let the user chose a new name
onMenuItemClick(menuItem);
} else {
if (file.renameTo(renamedBackup)) {
mAdapter.loadBackups();
} else {
Toast.makeText(mActivity, R.string.rename_failed, Toast.LENGTH_SHORT).show();
}
}
dialog.dismiss();
}
});
dialog.show();
return true;
case R.id.iDeleteBackup:
if (file.delete()) {
Toast.makeText(mActivity, mContext.getString(R.string.bak_deleted), Toast.LENGTH_SHORT).show();
}
mAdapter.loadBackups();
return true;
default:
return false;
}
} catch (Exception e) {
if (e.getMessage().contains("EINVAL") && file.getName().contains(":")) {
AlertDialog.Builder adialog = new AlertDialog.Builder(mContext);
adialog.setMessage(R.string.check_name);
adialog.setMessage(R.string.ok);
adialog.show();
}
App.ERRORS.add(App.TAG + " " + e);
return false;
}
}
});
popup.show();
}
use of android.support.v7.widget.AppCompatButton in project twicalico by moko256.
the class ShowTweetActivity method updateView.
private void updateView(Status item) {
TextView tweetIsReply = findViewById(R.id.tweet_show_is_reply_text);
long replyTweetId = item.getInReplyToStatusId();
if (replyTweetId != -1) {
tweetIsReply.setVisibility(VISIBLE);
tweetIsReply.setOnClickListener(v -> startActivity(getIntent(this, replyTweetId)));
} else {
tweetIsReply.setVisibility(GONE);
}
StatusView statusView = new StatusView(this);
statusView.setStatus(item);
ViewGroup cview = (ViewGroup) statusView.getChildAt(0);
ViewGroup sview = (ViewGroup) cview.getChildAt(0);
cview.removeView(sview);
FrameLayout statusViewFrame = findViewById(R.id.tweet_show_tweet);
statusViewFrame.removeAllViews();
statusViewFrame.addView(sview);
((TextView) findViewById(R.id.tweet_show_timestamp)).setText(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(item.getCreatedAt()));
TextView viaText = findViewById(R.id.tweet_show_via);
viaText.setText(TwitterStringUtils.convertUrlSpanToCustomTabs(Html.fromHtml("via:" + item.getSource()), this));
viaText.setMovementMethod(new LinkMovementMethod());
AppCompatEditText replyText = findViewById(R.id.tweet_show_tweet_reply_text);
AppCompatButton replyButton = findViewById(R.id.tweet_show_tweet_reply_button);
UserMentionEntity[] users = item.getUserMentionEntities();
replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
replyButton.setOnClickListener(v -> {
replyButton.setEnabled(false);
PostTweetModel model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
model.setTweetText(replyText.getText().toString());
model.setInReplyToStatusId(item.getId());
subscriptions.add(model.postTweet().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(it -> {
replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
replyButton.setEnabled(true);
Toast.makeText(ShowTweetActivity.this, R.string.succeeded, Toast.LENGTH_SHORT).show();
}, e -> {
e.printStackTrace();
Toast.makeText(ShowTweetActivity.this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
replyButton.setEnabled(true);
}));
});
}
Aggregations