use of android.text.InputFilter in project samourai-wallet-android by Samourai-Wallet.
the class SendActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send);
setSupportActionBar(findViewById(R.id.toolbar_send));
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
setTitle("");
// CustomView for showing and hiding body of th UI
sendTransactionDetailsView = findViewById(R.id.sendTransactionDetailsView);
// ViewSwitcher Element for toolbar section of the UI.
// we can switch between Form and review screen with this element
amountViewSwitcher = findViewById(R.id.toolbar_view_switcher);
// Input elements from toolbar section of the UI
toAddressEditText = findViewById(R.id.edt_send_to);
btcEditText = findViewById(R.id.amountBTC);
satEditText = findViewById(R.id.amountSat);
tvToAddress = findViewById(R.id.to_address_review);
tvReviewSpendAmount = findViewById(R.id.send_review_amount);
tvReviewSpendAmountInSats = findViewById(R.id.send_review_amount_in_sats);
tvMaxAmount = findViewById(R.id.totalBTC);
// view elements from review segment and transaction segment can be access through respective
// methods which returns root viewGroup
btnReview = sendTransactionDetailsView.getTransactionView().findViewById(R.id.review_button);
cahootsSwitch = sendTransactionDetailsView.getTransactionView().findViewById(R.id.cahoots_switch);
ricochetHopsSwitch = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_hops_switch);
ricochetTitle = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_desc);
ricochetDesc = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_title);
ricochetStaggeredDelivery = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_staggered_option);
ricochetStaggeredOptionGroup = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_staggered_option_group);
tvSelectedFeeRate = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.selected_fee_rate);
tvSelectedFeeRateLayman = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.selected_fee_rate_in_layman);
tvTotalFee = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.total_fee);
btnSend = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.send_btn);
feeSeekBar = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.fee_seekbar);
tvEstimatedBlockWait = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.est_block_time);
feeSeekBar = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.fee_seekbar);
cahootsGroup = sendTransactionDetailsView.findViewById(R.id.cohoots_options);
cahootsStatusText = sendTransactionDetailsView.findViewById(R.id.cahoot_status_text);
totalMinerFeeLayout = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.total_miner_fee_group);
cahootsNotice = sendTransactionDetailsView.findViewById(R.id.cahoots_not_enabled_notice);
btcEditText.addTextChangedListener(BTCWatcher);
btcEditText.setFilters(new InputFilter[] { new DecimalDigitsInputFilter(8, 8) });
satEditText.addTextChangedListener(satWatcher);
toAddressEditText.addTextChangedListener(AddressWatcher);
btnReview.setOnClickListener(v -> review());
btnSend.setOnClickListener(v -> initiateSpend());
View.OnClickListener clipboardCopy = view -> {
ClipboardManager cm = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = android.content.ClipData.newPlainText("Miner fee", tvTotalFee.getText());
if (cm != null) {
cm.setPrimaryClip(clipData);
Toast.makeText(this, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show();
}
};
tvTotalFee.setOnClickListener(clipboardCopy);
tvSelectedFeeRate.setOnClickListener(clipboardCopy);
SPEND_TYPE = SPEND_BOLTZMANN;
saveChangeIndexes();
setUpRicochet();
setUpCahoots();
setUpFee();
setBalance();
enableReviewButton(false);
setUpBoltzman();
validateSpend();
checkDeepLinks();
if (getIntent().getExtras().containsKey("preselected")) {
preselectedUTXOs = PreSelectUtil.getInstance().getPreSelected(getIntent().getExtras().getString("preselected"));
setBalance();
if (preselectedUTXOs != null && preselectedUTXOs.size() > 0) {
cahootsGroup.setVisibility(View.GONE);
ricochetHopsSwitch.setVisibility(View.GONE);
ricochetTitle.setVisibility(View.GONE);
ricochetDesc.setVisibility(View.GONE);
}
} else {
Disposable disposable = APIFactory.getInstance(getApplicationContext()).walletBalanceObserver.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
if (balance == aLong) {
return;
}
setBalance();
}, Throwable::printStackTrace);
compositeDisposables.add(disposable);
// Update fee
Disposable feeDisposable = Observable.fromCallable(() -> APIFactory.getInstance(getApplicationContext()).getDynamicFees()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(t -> {
Log.i(TAG, "Fees : ".concat(t.toString()));
setUpFee();
}, Throwable::printStackTrace);
compositeDisposables.add(feeDisposable);
if (getIntent().getExtras() != null) {
if (!getIntent().getExtras().containsKey("balance")) {
return;
}
balance = getIntent().getExtras().getLong("balance");
}
}
}
use of android.text.InputFilter in project android-client by GenesisVision.
the class ChangePasswordActivity method setInputFilters.
private void setInputFilters() {
InputFilter filter = (source, start, end, dest, dstart, dend) -> {
for (int i = start; i < end; i++) {
if (Character.isWhitespace(source.charAt(i))) {
return "";
}
}
return null;
};
oldPassword.setFilters(new InputFilter[] { filter });
newPassword.setFilters(new InputFilter[] { filter });
repeatPassword.setFilters(new InputFilter[] { filter });
}
use of android.text.InputFilter in project android-client by GenesisVision.
the class SetupAccountTfaActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(ThemeUtil.getCurrentThemeResource());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setup_account_two_factor);
ButterKnife.bind(this);
Bundle extras = getIntent().getExtras();
if (extras != null && !extras.isEmpty()) {
UUID id = (UUID) extras.getSerializable(EXTRA_ID);
if (id != null) {
presenter.setData(id);
InputFilter[] filters = new InputFilter[1];
filters[0] = new InputFilter.LengthFilter(Constants.TWO_FACTOR_CODE_LENGTH);
code.setFilters(filters);
return;
}
}
Timber.e("Passed empty data to %s", getClass().getSimpleName());
onBackPressed();
}
use of android.text.InputFilter in project android_packages_apps_Settings by omnirom.
the class Utf8ByteLengthFilterTest method testFilter.
@SmallTest
public void testFilter() {
// Define the variables
CharSequence source;
SpannableStringBuilder dest;
// Constructor to create a LengthFilter
InputFilter lengthFilter = new Utf8ByteLengthFilter(10);
InputFilter[] filters = { lengthFilter };
// filter() implicitly invoked. If the total length > filter length, the filter will
// cut off the source CharSequence from beginning to fit the filter length.
source = "abc";
dest = new SpannableStringBuilder("abcdefgh");
dest.setFilters(filters);
dest.insert(1, source);
String expectedString1 = "aabbcdefgh";
assertEquals(expectedString1, dest.toString());
dest.replace(5, 8, source);
String expectedString2 = "aabbcabcgh";
assertEquals(expectedString2, dest.toString());
dest.insert(2, source);
assertEquals(expectedString2, dest.toString());
dest.delete(1, 3);
String expectedString3 = "abcabcgh";
assertEquals(expectedString3, dest.toString());
dest.append("12345");
String expectedString4 = "abcabcgh12";
assertEquals(expectedString4, dest.toString());
// 2 Chinese chars == 6 bytes in UTF-8
source = "\u60a8\u597d";
dest.replace(8, 10, source);
assertEquals(expectedString3, dest.toString());
dest.replace(0, 1, source);
String expectedString5 = "\u60a8bcabcgh";
assertEquals(expectedString5, dest.toString());
dest.replace(0, 4, source);
String expectedString6 = "\u60a8\u597dbcgh";
assertEquals(expectedString6, dest.toString());
// 2 Latin-1 chars == 4 bytes in UTF-8
source = "\u00a3\u00a5";
dest.delete(2, 6);
dest.insert(0, source);
String expectedString7 = "\u00a3\u00a5\u60a8\u597d";
assertEquals(expectedString7, dest.toString());
dest.replace(2, 3, source);
String expectedString8 = "\u00a3\u00a5\u00a3\u597d";
assertEquals(expectedString8, dest.toString());
dest.replace(3, 4, source);
String expectedString9 = "\u00a3\u00a5\u00a3\u00a3\u00a5";
assertEquals(expectedString9, dest.toString());
// filter() explicitly invoked
dest = new SpannableStringBuilder("abcdefgh");
CharSequence beforeFilterSource = "TestLengthFilter";
String expectedAfterFilter = "TestLength";
CharSequence actualAfterFilter = lengthFilter.filter(beforeFilterSource, 0, beforeFilterSource.length(), dest, 0, dest.length());
assertEquals(expectedAfterFilter, actualAfterFilter);
}
use of android.text.InputFilter in project smoke by textbrowser.
the class Settings method prepareListeners.
private void prepareListeners() {
Button button1 = null;
Spinner spinner1 = (Spinner) findViewById(R.id.neighbors_transport);
Switch switch1 = null;
TextView textView1 = (TextView) findViewById(R.id.participant_name);
button1 = (Button) findViewById(R.id.add_neighbor);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
addNeighbor();
}
});
button1 = (Button) findViewById(R.id.add_participant);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
addParticipant();
}
});
button1 = (Button) findViewById(R.id.clear_log);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
m_databaseHelper.clearTable("log");
}
});
button1 = (Button) findViewById(R.id.echo_help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
PopupWindow popupWindow = new PopupWindow(Settings.this);
TextView textView1 = new TextView(Settings.this);
float density = Settings.this.getResources().getDisplayMetrics().density;
textView1.setBackgroundColor(Color.rgb(232, 234, 246));
textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
textView1.setText("Echo queues allow Smoke to echo internal data from " + "local neighbor to local neighbor. Each Echo queue may " + "contain at most " + Neighbor.MAXIMUM_QUEUED_ECHO_PACKETS + " messages. Please note that the " + "Echo mechanism may burden a device. A neighbor will " + "echo data if it discovers that the data are not " + "intended for it.");
textView1.setTextSize(16);
popupWindow.setContentView(textView1);
popupWindow.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
popupWindow.setHeight(450);
popupWindow.setWidth(700);
}
popupWindow.showAsDropDown(view);
}
});
button1 = (Button) findViewById(R.id.epks);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
epks("");
}
});
button1 = (Button) findViewById(R.id.generate_pki);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
preparePKI();
}
});
button1 = (Button) findViewById(R.id.initialize_ozone_help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
PopupWindow popupWindow = new PopupWindow(Settings.this);
TextView textView1 = new TextView(Settings.this);
float density = Settings.this.getResources().getDisplayMetrics().density;
textView1.setBackgroundColor(Color.rgb(232, 234, 246));
textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
textView1.setText("Set the Ozone to IP Address:Port:Type.");
textView1.setTextSize(16);
popupWindow.setContentView(textView1);
popupWindow.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
popupWindow.setHeight(450);
popupWindow.setWidth(700);
}
popupWindow.showAsDropDown(view);
}
});
button1 = (Button) findViewById(R.id.ozone_help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
PopupWindow popupWindow = new PopupWindow(Settings.this);
TextView textView1 = new TextView(Settings.this);
float density = Settings.this.getResources().getDisplayMetrics().density;
textView1.setBackgroundColor(Color.rgb(232, 234, 246));
textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
textView1.setText("An Ozone Address defines a virtual location, " + "a separate device where messages are to be stored for " + "later retrieval. A virtual post office. " + "Please remember to share your Ozone Address with your " + "friends as well as at least one SmokeStack.");
textView1.setTextSize(16);
popupWindow.setContentView(textView1);
popupWindow.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
popupWindow.setHeight(450);
popupWindow.setWidth(700);
}
popupWindow.showAsDropDown(view);
}
});
button1 = (Button) findViewById(R.id.passthrough_help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
PopupWindow popupWindow = new PopupWindow(Settings.this);
TextView textView1 = new TextView(Settings.this);
float density = Settings.this.getResources().getDisplayMetrics().density;
textView1.setBackgroundColor(Color.rgb(232, 234, 246));
textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
textView1.setText("Passthrough neighbors are special full-duplex " + "connections which Smoke utilizes for distributing " + "data to non-Smoke destinations. Data which is " + "received on passthrough connections is echoed " + "directly to other non-passthrough neighbors if " + "echoing is enabled.");
textView1.setTextSize(16);
popupWindow.setContentView(textView1);
popupWindow.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
popupWindow.setHeight(450);
popupWindow.setWidth(700);
}
popupWindow.showAsDropDown(view);
}
});
button1 = (Button) findViewById(R.id.refresh_neighbors);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
populateNeighbors(null);
}
});
button1 = (Button) findViewById(R.id.refresh_participants);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
populateParticipants();
}
});
final DialogInterface.OnCancelListener listener1 = new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
if (State.getInstance().getString("dialog_accepted").equals("true")) {
State.getInstance().reset();
m_databaseHelper.resetAndDrop();
s_cryptography.reset();
Intent intent = getIntent();
startActivity(intent);
finish();
}
}
};
button1 = (Button) findViewById(R.id.reset);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Miscellaneous.showPromptDialog(Settings.this, listener1, "Are you sure that you " + "wish to reset Smoke? All " + "of the data will be removed.");
}
});
button1 = (Button) findViewById(R.id.reset_neighbor_fields);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
RadioButton radioButton1 = (RadioButton) findViewById(R.id.neighbors_ipv4);
Spinner spinner1 = (Spinner) findViewById(R.id.neighbors_transport);
Spinner spinner2 = (Spinner) findViewById(R.id.proxy_type);
Switch switch1 = (Switch) findViewById(R.id.initialize_ozone);
Switch switch2 = (Switch) findViewById(R.id.non_tls);
Switch switch3 = (Switch) findViewById(R.id.passthrough);
TextView proxyIpAddress = (TextView) findViewById(R.id.proxy_ip_address);
TextView proxyPort = (TextView) findViewById(R.id.proxy_port);
TextView textView1 = (TextView) findViewById(R.id.neighbors_ip_address);
TextView textView2 = (TextView) findViewById(R.id.neighbors_port);
TextView textView3 = (TextView) findViewById(R.id.neighbors_scope_id);
switch1.setChecked(false);
switch2.setChecked(false);
switch3.setChecked(false);
proxyIpAddress.setText("");
proxyPort.setText("");
radioButton1.setChecked(true);
spinner1.setSelection(0);
spinner2.setSelection(0);
textView1.setText("");
textView2.setText("4710");
textView3.setText("");
textView1.requestFocus();
}
});
button1 = (Button) findViewById(R.id.reset_participants_fields);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
Switch switch1 = (Switch) findViewById(R.id.as_alias);
TextView textView1 = (TextView) findViewById(R.id.participant_name);
TextView textView2 = (TextView) findViewById(R.id.participant_siphash_id);
switch1.setChecked(true);
textView1.setText("");
textView2.setText("");
textView1.requestFocus();
}
});
final DialogInterface.OnCancelListener listener2 = new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
if (State.getInstance().getString("dialog_accepted").equals("true")) {
TextView textView1 = (TextView) findViewById(R.id.ozone);
textView1.setText("");
m_databaseHelper.reset();
populateFancyKeyData();
populateNeighbors(null);
populateParticipants();
prepareCredentials();
}
}
};
button1 = (Button) findViewById(R.id.save_alias);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
String alias = ((TextView) findViewById(R.id.alias)).getText().toString().trim();
if (!alias.isEmpty() && alias.length() < 8)
Miscellaneous.showErrorDialog(Settings.this, "A Smoke Alias must include at " + "least eight characters. ");
else if (alias.isEmpty()) {
m_databaseHelper.writeSetting(s_cryptography, "alias", "");
s_cryptography.prepareSipHashIds(null);
s_cryptography.prepareSipHashKeys();
} else {
if (m_databaseHelper.readSetting(s_cryptography, "fire_user_name").trim().isEmpty())
m_databaseHelper.writeSetting(s_cryptography, "fire_user_name", alias);
m_databaseHelper.writeSetting(s_cryptography, "alias", alias);
s_cryptography.prepareSipHashIds(alias);
s_cryptography.prepareSipHashKeys();
}
StringBuilder stringBuilder = new StringBuilder();
TextView textView1 = (TextView) findViewById(R.id.siphash_identity);
stringBuilder.append(Miscellaneous.prepareSipHashId(s_cryptography.sipHashId()));
textView1.setText(stringBuilder);
textView1.setTextIsSelectable(true);
textView1.setVisibility(View.VISIBLE);
}
});
button1 = (Button) findViewById(R.id.save_ozone);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
TextView textView1 = (TextView) findViewById(R.id.ozone);
if (!generateOzone(textView1.getText().toString())) {
Miscellaneous.showErrorDialog(Settings.this, "An error occurred while processing the Ozone data.");
textView1.requestFocus();
}
}
});
button1 = (Button) findViewById(R.id.set_password);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
Spinner spinner1 = null;
TextView textView1 = (TextView) findViewById(R.id.password1);
TextView textView2 = (TextView) findViewById(R.id.password2);
textView1.setSelectAllOnFocus(true);
textView2.setSelectAllOnFocus(true);
if (textView1.getText().length() < 1 || !textView1.getText().toString().equals(textView2.getText().toString())) {
String error = "";
if (textView1.getText().length() < 1)
error = "Each password must contain " + "at least one character.";
else
error = "The provided passwords are not identical.";
Miscellaneous.showErrorDialog(Settings.this, error);
textView1.requestFocus();
return;
}
int iterationCount = 1000;
int iterationCountLimit = 7500;
try {
spinner1 = (Spinner) findViewById(R.id.iteration_count);
iterationCount = Integer.parseInt(spinner1.getSelectedItem().toString());
} catch (Exception exception) {
iterationCount = 1000;
}
spinner1 = (Spinner) findViewById(R.id.key_derivation_function);
if (spinner1.getSelectedItem().toString().equals("Argon2id"))
iterationCountLimit = 10;
else
iterationCountLimit = 7500;
if (iterationCount > iterationCountLimit)
Miscellaneous.showPromptDialog(Settings.this, listener2, "You have selected an elevated iteration count. " + "If you proceed, the initialization process may " + "require a significant amount of time to complete. " + "Continue?");
else
prepareCredentials();
}
});
button1 = (Button) findViewById(R.id.share_via_ozone);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
shareSipHashId(-1);
}
});
button1 = (Button) findViewById(R.id.silent_help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
PopupWindow popupWindow = new PopupWindow(Settings.this);
TextView textView1 = new TextView(Settings.this);
float density = Settings.this.getResources().getDisplayMetrics().density;
textView1.setBackgroundColor(Color.rgb(232, 234, 246));
textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
textView1.setText("Disable all status broadcasts. Please note that " + "remote servers may terminate silent connections.");
textView1.setTextSize(16);
popupWindow.setContentView(textView1);
popupWindow.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
popupWindow.setHeight(450);
popupWindow.setWidth(700);
}
popupWindow.showAsDropDown(view);
}
});
button1 = (Button) findViewById(R.id.siphash_help);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Settings.this.isFinishing())
return;
PopupWindow popupWindow = new PopupWindow(Settings.this);
TextView textView1 = new TextView(Settings.this);
float density = Settings.this.getResources().getDisplayMetrics().density;
textView1.setBackgroundColor(Color.rgb(232, 234, 246));
textView1.setPaddingRelative((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density));
if (((Switch) findViewById(R.id.as_alias)).isChecked())
textView1.setText("A Smoke Alias is an arrangement of digits and " + "letters assigned to a specific subscriber " + "(public key pair). " + "The tokens allow participants to exchange public " + "key pairs via the Echo Public Key Sharing (EPKS) " + "protocol. " + "An example Smoke Alias is account@e-mail.org.");
else
textView1.setText("A Smoke ID is an arrangement of hexadecimal " + "characters assigned to a specific subscriber " + "(public key pair). " + "The tokens allow participants to exchange public " + "key pairs via the Echo Public Key Sharing (EPKS) " + "protocol.");
textView1.setTextSize(16);
popupWindow.setContentView(textView1);
popupWindow.setOutsideTouchable(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
popupWindow.setHeight(450);
popupWindow.setWidth(700);
}
popupWindow.showAsDropDown(view);
}
});
switch1 = (Switch) findViewById(R.id.as_alias);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
TextView textView1 = (TextView) findViewById(R.id.at_sign);
TextView textView2 = (TextView) findViewById(R.id.participant_name);
TextView textView3 = (TextView) findViewById(R.id.participant_siphash_id);
if (isChecked) {
textView1.setText("|");
textView3.setFilters(new InputFilter[] {});
textView3.setHint("Smoke Alias");
textView3.setText(textView2.getText());
} else {
textView1.setText("@");
textView3.setFilters(new InputFilter[] { new InputFilter.AllCaps(), s_sipHashInputFilter });
textView3.setHint("Smoke ID");
textView3.setText("");
}
}
});
switch1 = (Switch) findViewById(R.id.automatic_refresh);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
m_databaseHelper.writeSetting(null, "automatic_neighbors_refresh", "true");
startTimers();
} else {
m_databaseHelper.writeSetting(null, "automatic_neighbors_refresh", "false");
stopTimers();
}
}
});
switch1 = (Switch) findViewById(R.id.echo);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
m_databaseHelper.writeSetting(null, "neighbors_echo", "true");
State.getInstance().setNeighborsEcho(true);
} else {
m_databaseHelper.writeSetting(null, "neighbors_echo", "false");
Kernel.getInstance().clearNeighborQueues();
State.getInstance().setNeighborsEcho(false);
}
}
});
switch1 = (Switch) findViewById(R.id.foreground_service);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
SmokeService.startForegroundTask(Settings.this);
m_databaseHelper.writeSetting(null, "foreground_service", "true");
} else {
SmokeService.stopForegroundTask(Settings.this);
m_databaseHelper.writeSetting(null, "foreground_service", "false");
}
}
});
switch1 = (Switch) findViewById(R.id.neighbor_details);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
m_databaseHelper.writeSetting(null, "neighbors_details", "true");
else
m_databaseHelper.writeSetting(null, "neighbors_details", "false");
Switch switch1 = (Switch) findViewById(R.id.automatic_refresh);
if (!switch1.isChecked())
populateNeighbors(null);
}
});
switch1 = (Switch) findViewById(R.id.overwrite);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Button button1 = null;
button1 = (Button) findViewById(R.id.generate_pki);
button1.setEnabled(isChecked);
button1 = (Button) findViewById(R.id.set_password);
button1.setEnabled(isChecked);
}
});
switch1 = (Switch) findViewById(R.id.query_time_server);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
State.getInstance().setQueryTimerServer(isChecked);
m_databaseHelper.writeSetting(null, "query_time_server", isChecked ? "true" : "false");
}
});
switch1 = (Switch) findViewById(R.id.silent);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
State.getInstance().setSilent(isChecked);
m_databaseHelper.writeSetting(null, "silent", isChecked ? "true" : "false");
}
});
switch1 = (Switch) findViewById(R.id.sleepless);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Kernel.getInstance().setWakeLock(isChecked);
m_databaseHelper.writeSetting(null, "always_awake", isChecked ? "true" : "false");
TextView textView1 = (TextView) findViewById(R.id.about);
textView1.setText(About.about());
textView1.append("\n");
textView1.append("WakeLock Locked: " + Miscellaneous.niceBoolean(Kernel.getInstance().wakeLocked()));
textView1.append("\n");
textView1.append("WiFiLock Locked: " + Miscellaneous.niceBoolean(Kernel.getInstance().wifiLocked()));
}
});
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Spinner proxyType = (Spinner) findViewById(R.id.proxy_type);
Switch nonTls = (Switch) findViewById(R.id.non_tls);
TextView proxyIpAddress = (TextView) findViewById(R.id.proxy_ip_address);
TextView proxyPort = (TextView) findViewById(R.id.proxy_port);
if (position == 0) {
/*
** Events may occur prematurely.
*/
boolean isAuthenticated = State.getInstance().isAuthenticated();
nonTls.setEnabled(isAuthenticated);
proxyIpAddress.setEnabled(isAuthenticated);
proxyPort.setEnabled(isAuthenticated);
proxyType.setEnabled(isAuthenticated);
} else {
nonTls.setChecked(false);
nonTls.setEnabled(false);
proxyIpAddress.setEnabled(false);
proxyIpAddress.setText("");
proxyPort.setEnabled(false);
proxyPort.setText("");
proxyType.setEnabled(false);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
textView1.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (s != null) {
Switch switch1 = (Switch) findViewById(R.id.as_alias);
if (switch1.isChecked()) {
TextView textView1 = (TextView) findViewById(R.id.participant_siphash_id);
textView1.setText(s);
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
}
Aggregations