Search in sources :

Example 16 with Build

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();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) Environment(android.os.Environment) NonNull(androidx.annotation.NonNull) Dialog(android.app.Dialog) FragmentActivity(androidx.fragment.app.FragmentActivity) ArrayList(java.util.ArrayList) Manifest(android.Manifest) Toast(android.widget.Toast) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Build(android.os.Build) DialogInterface(android.content.DialogInterface) FragmentManager(androidx.fragment.app.FragmentManager) ActivityCompat(androidx.core.app.ActivityCompat) File(java.io.File) Serializable(java.io.Serializable) StringRes(androidx.annotation.StringRes) List(java.util.List) Nullable(androidx.annotation.Nullable) R(com.afollestad.materialdialogs.commons.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Comparator(java.util.Comparator) Collections(java.util.Collections) DialogFragment(androidx.fragment.app.DialogFragment) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) File(java.io.File) NonNull(androidx.annotation.NonNull)

Example 17 with 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);
        }
    });
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) DateUtils(android.text.format.DateUtils) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) ImageView(android.widget.ImageView) NfcNotEnabledActivity(org.fdroid.fdroid.NfcNotEnabledActivity) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) TargetApi(android.annotation.TargetApi) NdefMessage(android.nfc.NdefMessage) NavUtils(androidx.core.app.NavUtils) RepoTable(org.fdroid.fdroid.data.Schema.RepoTable) IntentFilter(android.content.IntentFilter) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) RepoProvider(org.fdroid.fdroid.data.RepoProvider) Disposable(io.reactivex.rxjava3.disposables.Disposable) ContentValues(android.content.ContentValues) MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NfcAdapter(android.nfc.NfcAdapter) UpdateService(org.fdroid.fdroid.UpdateService) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) TextInputLayout(com.google.android.material.textfield.TextInputLayout) Intent(android.content.Intent) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager) Utils(org.fdroid.fdroid.Utils) MenuItem(android.view.MenuItem) HashSet(java.util.HashSet) R(org.fdroid.fdroid.R) Toast(android.widget.Toast) Menu(android.view.Menu) NfcHelper(org.fdroid.fdroid.NfcHelper) Build(android.os.Build) DialogInterface(android.content.DialogInterface) Parcelable(android.os.Parcelable) CompoundButton(android.widget.CompoundButton) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) FDroidApp(org.fdroid.fdroid.FDroidApp) EditText(android.widget.EditText) Repo(org.fdroid.fdroid.data.Repo) MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) FDroidApp(org.fdroid.fdroid.FDroidApp) TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Uri(android.net.Uri)

Example 18 with Build

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);
}
Also used : Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) ButterKnife(butterknife.ButterKnife) GravityEnum(com.afollestad.materialdialogs.GravityEnum) CircleView(com.afollestad.materialdialogs.color.CircleView) Intent(android.content.Intent) ColorDrawable(android.graphics.drawable.ColorDrawable) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) FolderChooserDialog(com.afollestad.materialdialogs.folderselector.FolderChooserDialog) Editable(android.text.Editable) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) ThemeSingleton(com.afollestad.materialdialogs.internal.ThemeSingleton) Manifest(android.Manifest) CheckBox(android.widget.CheckBox) Handler(android.os.Handler) Toast(android.widget.Toast) Menu(android.view.Menu) View(android.view.View) StackingBehavior(com.afollestad.materialdialogs.StackingBehavior) MDTintHelper(com.afollestad.materialdialogs.internal.MDTintHelper) PasswordTransformationMethod(android.text.method.PasswordTransformationMethod) MaterialSimpleListItem(com.afollestad.materialdialogs.simplelist.MaterialSimpleListItem) Build(android.os.Build) TargetApi(android.annotation.TargetApi) ContextCompat(android.support.v4.content.ContextCompat) InputType(android.text.InputType) DialogAction(com.afollestad.materialdialogs.DialogAction) ActivityCompat(android.support.v4.app.ActivityCompat) AppCompatActivity(android.support.v7.app.AppCompatActivity) FileChooserDialog(com.afollestad.materialdialogs.folderselector.FileChooserDialog) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) Color(android.graphics.Color) ColorInt(android.support.annotation.ColorInt) MaterialSimpleListAdapter(com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter) Html(android.text.Html) DialogUtils(com.afollestad.materialdialogs.util.DialogUtils) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ColorChooserDialog(com.afollestad.materialdialogs.color.ColorChooserDialog) EditText(android.widget.EditText) TextWatcher(android.text.TextWatcher) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CheckBox(android.widget.CheckBox) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClick(butterknife.OnClick)

Example 19 with Build

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;
}
Also used : Build(android.os.Build)

Example 20 with Build

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();
}
Also used : Converter(de.danoeh.antennapod.core.util.Converter) Context(android.content.Context) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ArrayList(java.util.ArrayList) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) Manifest(android.Manifest) Button(android.widget.Button) StorageUtils(de.danoeh.antennapod.core.util.StorageUtils) Build(android.os.Build) Log(android.util.Log) R(de.danoeh.antennapod.R) IntentFilter(android.content.IntentFilter) ContextCompat(android.support.v4.content.ContextCompat) TextUtils(android.text.TextUtils) BroadcastReceiver(android.content.BroadcastReceiver) ActivityCompat(android.support.v4.app.ActivityCompat) AppCompatActivity(android.support.v7.app.AppCompatActivity) File(java.io.File) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) Html(android.text.Html) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Activity(android.app.Activity) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

Build (android.os.Build)42 Context (android.content.Context)30 Intent (android.content.Intent)22 List (java.util.List)22 PackageManager (android.content.pm.PackageManager)20 ArrayList (java.util.ArrayList)19 View (android.view.View)16 Toast (android.widget.Toast)15 File (java.io.File)15 Bundle (android.os.Bundle)14 Uri (android.net.Uri)13 TextView (android.widget.TextView)13 Locale (java.util.Locale)13 Manifest (android.Manifest)11 SharedPreferences (android.content.SharedPreferences)11 NonNull (android.support.annotation.NonNull)11 Activity (android.app.Activity)10 DialogInterface (android.content.DialogInterface)10 EditText (android.widget.EditText)10 Arrays (java.util.Arrays)10