use of android.os.Build in project Slide by ccrama.
the class FolderChooserDialogCreate method onCreateDialog.
@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
return new MaterialDialog.Builder(getActivity()).title(R.string.md_error_label).content(R.string.md_storage_perm_error).positiveText(android.R.string.ok).build();
}
if (getArguments() == null || !getArguments().containsKey("builder")) {
throw new IllegalStateException("You must create a FolderChooserDialog using the Builder.");
}
if (!getArguments().containsKey("current_path")) {
getArguments().putString("current_path", getBuilder().initialPath);
}
parentFolder = new File(getArguments().getString("current_path"));
checkIfCanGoUp();
parentContents = listFiles();
final MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).typeface(getBuilder().mediumFont, getBuilder().regularFont).title(parentFolder.getAbsolutePath()).items(getContentsArray()).itemsCallback(this).onPositive((dialog, which) -> {
dialog.dismiss();
callback.onFolderSelection(FolderChooserDialogCreate.this, parentFolder, getBuilder().isSaveToLocation);
}).onNegative((dialog, which) -> dialog.dismiss()).autoDismiss(false).positiveText(getBuilder().chooseButton).negativeText(getBuilder().cancelButton);
if (getBuilder().allowNewFolder) {
builder.neutralText(getBuilder().newFolderButton);
builder.onNeutral((dialog, which) -> createNewFolder());
}
if ("/".equals(getBuilder().initialPath)) {
canGoUp = false;
}
return builder.build();
}
use of android.os.Build in project fdroidclient by f-droid.
the class RepoDetailsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
FDroidApp fdroidApp = (FDroidApp) getApplication();
fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repo_details);
MaterialToolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
repoView = findViewById(R.id.repo_view);
repoId = getIntent().getLongExtra(ARG_REPO_ID, 0);
repo = RepoProvider.Helper.findById(this, repoId);
TextView inputUrl = findViewById(R.id.input_repo_url);
inputUrl.setText(repo.address);
RecyclerView officialMirrorListView = findViewById(R.id.official_mirror_list);
officialMirrorListView.setLayoutManager(new LinearLayoutManager(this));
adapterToNotify = new MirrorAdapter(repo, repo.mirrors);
officialMirrorListView.setAdapter(adapterToNotify);
RecyclerView userMirrorListView = findViewById(R.id.user_mirror_list);
userMirrorListView.setLayoutManager(new LinearLayoutManager(this));
userMirrorListView.setAdapter(new MirrorAdapter(repo, repo.userMirrors));
if (repo.address.startsWith("content://")) {
// no need to show a QR Code, it is not shareable
return;
}
Uri uri = Uri.parse(repo.address);
uri = uri.buildUpon().appendQueryParameter("fingerprint", repo.fingerprint).build();
String qrUriString = uri.toString();
disposable = Utils.generateQrBitmap(this, qrUriString).subscribe(bitmap -> {
final ImageView qrCode = findViewById(R.id.qr_code);
if (qrCode != null) {
qrCode.setImageBitmap(bitmap);
}
});
}
use of android.os.Build in project material-dialogs by afollestad.
the class MainActivity method showCustomView.
@SuppressWarnings("ResourceAsColor")
@OnClick(R.id.customView)
public void showCustomView() {
MaterialDialog dialog = new MaterialDialog.Builder(this).title(R.string.googleWifi).customView(R.layout.dialog_customview, true).positiveText(R.string.connect).negativeText(android.R.string.cancel).onPositive((dialog1, which) -> showToast("Password: " + passwordInput.getText().toString())).build();
positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
//noinspection ConstantConditions
passwordInput = (EditText) dialog.getCustomView().findViewById(R.id.password);
passwordInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
positiveAction.setEnabled(s.toString().trim().length() > 0);
}
@Override
public void afterTextChanged(Editable s) {
}
});
// Toggling the show password CheckBox will mask or unmask the password input EditText
CheckBox checkbox = (CheckBox) dialog.getCustomView().findViewById(R.id.showPassword);
checkbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
passwordInput.setInputType(!isChecked ? InputType.TYPE_TEXT_VARIATION_PASSWORD : InputType.TYPE_CLASS_TEXT);
passwordInput.setTransformationMethod(!isChecked ? PasswordTransformationMethod.getInstance() : null);
});
int widgetColor = ThemeSingleton.get().widgetColor;
MDTintHelper.setTint(checkbox, widgetColor == 0 ? ContextCompat.getColor(this, R.color.accent) : widgetColor);
MDTintHelper.setTint(passwordInput, widgetColor == 0 ? ContextCompat.getColor(this, R.color.accent) : widgetColor);
dialog.show();
// disabled by default
positiveAction.setEnabled(false);
}
use of android.os.Build in project weex-example by KalicyZhou.
the class WXSoInstallMgrSdk method _cpuType.
private static String _cpuType() {
String abi = _getFieldReflectively(new Build(), "CPU_ABI");
if (abi == null || abi.length() == 0 || abi.equals("Unknown")) {
abi = ARMEABI;
}
abi = abi.toLowerCase();
return abi;
}
use of android.os.Build in project AntennaPod by AntennaPod.
the class StorageErrorActivity method showChooseDataFolderDialog.
// see PreferenceController.showChooseDataFolderDialog()
private void showChooseDataFolderDialog() {
File dataFolder = UserPreferences.getDataFolder(null);
if (dataFolder == null) {
new MaterialDialog.Builder(this).title(R.string.error_label).content(R.string.external_storage_error_msg).neutralText(android.R.string.ok).show();
return;
}
String dataFolderPath = dataFolder.getAbsolutePath();
int selectedIndex = -1;
File[] mediaDirs = ContextCompat.getExternalFilesDirs(this, null);
List<String> folders = new ArrayList<>(mediaDirs.length);
List<CharSequence> choices = new ArrayList<>(mediaDirs.length);
for (int i = 0; i < mediaDirs.length; i++) {
File dir = mediaDirs[i];
if (dir == null || !dir.exists() || !dir.canRead() || !dir.canWrite()) {
continue;
}
String path = mediaDirs[i].getAbsolutePath();
folders.add(path);
if (dataFolderPath.equals(path)) {
selectedIndex = i;
}
int index = path.indexOf("Android");
String choice;
if (index >= 0) {
choice = path.substring(0, index);
} else {
choice = path;
}
long bytes = StorageUtils.getFreeSpaceAvailable(path);
String freeSpace = String.format(getString(R.string.free_space_label), Converter.byteToString(bytes));
choices.add(Html.fromHtml("<html><small>" + choice + " [" + freeSpace + "]" + "</small></html>"));
}
if (choices.size() == 0) {
new MaterialDialog.Builder(this).title(R.string.error_label).content(R.string.external_storage_error_msg).neutralText(android.R.string.ok).show();
return;
}
MaterialDialog dialog = new MaterialDialog.Builder(this).title(R.string.choose_data_directory).content(R.string.choose_data_directory_message).items(choices.toArray(new CharSequence[choices.size()])).itemsCallbackSingleChoice(selectedIndex, (dialog1, itemView, which, text) -> {
String folder = folders.get(which);
UserPreferences.setDataFolder(folder);
leaveErrorState();
return true;
}).negativeText(R.string.cancel_label).cancelable(true).build();
dialog.show();
}
Aggregations