Search in sources :

Example 41 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project CircularReveal by ozodrukh.

the class SpringSettingsBottomDialog method createConfigurationView.

private SeekBar createConfigurationView(CharSequence label, int defaultVal, SeekBar.OnSeekBarChangeListener changeListener) {
    final TextView labelView = new AppCompatTextView(getContext(), null, R.style.TextAppearance_AppCompat_Caption);
    labelView.setText(label);
    labelView.setLayoutParams(createMarginLayoutParams(MATCH_PARENT, WRAP_CONTENT, 0, 0, 0, dp(8)));
    final SeekBar seekBar = new SeekBar(getContext());
    seekBar.setProgress(defaultVal);
    seekBar.setMax(100);
    seekBar.setOnSeekBarChangeListener(changeListener);
    seekBar.setLayoutParams(createMarginLayoutParams(MATCH_PARENT, WRAP_CONTENT, 0, 0, 0, dp(16)));
    addView(labelView);
    addView(seekBar);
    return seekBar;
}
Also used : SeekBar(android.widget.SeekBar) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) TextView(android.widget.TextView)

Example 42 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project Rashr by DsLNeXuS.

the class RashrActivity method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    // If request is cancelled, the result arrays are empty.
    if (// 2 Permissions, Internet and Write storage
    grantResults.length == 2 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
        final TextView tvLoading = findViewById(R.id.tvLoading);
        final Thread StartThread = new Thread(new Runnable() {

            @Override
            public void run() {
                /* Creating needed folder and unpacking files */
                mActivity.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        tvLoading.setText(R.string.loading_data);
                    }
                });
                if (App.PathToTmp.exists()) {
                    Common.deleteFolder(App.PathToTmp, true);
                }
                for (File i : Folder) {
                    if (!i.exists()) {
                        if (!i.mkdirs()) {
                            App.ERRORS.add(App.TAG + " " + i + " can't be created!");
                        }
                    }
                }
                if (!extractFiles()) {
                    App.ERRORS.add("Failed to extract files.");
                    mActivity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            Toast.makeText(mContext, R.string.failed_unpack_files, Toast.LENGTH_LONG).show();
                        }
                    });
                }
                try {
                    File LogCopy = new File(App.FilesDir, App.LastLog.getName() + ".txt");
                    App.Shell.execCommand(App.Busybox + " chmod 777 " + App.LastLog);
                    if (LogCopy.exists())
                        LogCopy.delete();
                    App.Shell.execCommand(App.Busybox + " cp " + App.LastLog + " " + LogCopy);
                    App.Shell.execCommand(App.Busybox + " chmod 777 " + LogCopy);
                    ApplicationInfo info = getApplicationInfo();
                    App.Shell.execCommand(App.Busybox + " chown " + info.uid + ":" + info.uid + " " + LogCopy);
                    App.Shell.execCommand(App.Busybox + " chmod 777 " + LogCopy);
                    LastLogExists = LogCopy.exists();
                } catch (FailedExecuteCommand e) {
                    App.ERRORS.add(App.TAG + " LastLog not found: " + e);
                }
                mActivity.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        checkAppUpdates();
                        tvLoading.setText(R.string.reading_device);
                    }
                });
                if (!App.Device.isSetup()) {
                    App.Device.setup();
                }
                /* If device is not supported, you can report it now or close the App */
                if ((!App.Device.isRecoverySupported() && !App.Device.isKernelSupported()) && !BuildConfig.DEBUG) {
                    mActivity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            showDeviceNotSupportedDialog();
                        }
                    });
                } else {
                    /* App is first time started so show usage warning */
                    if (App.Preferences.getBoolean(App.PREF_KEY_FIRST_RUN, true)) {
                        mActivity.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                if (App.Device.isRecoverySupported() || App.Device.isKernelSupported()) {
                                    // Show only if we can flash
                                    showUsageWarning();
                                }
                            }
                        });
                    }
                }
                mActivity.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            mRoot = (DrawerLayout) View.inflate(mContext, R.layout.activity_rashr, null);
                            setContentView(mRoot);
                            ButterKnife.bind(mActivity);
                            mRoot.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.abc_fade_in));
                            mToolbar = findViewById(R.id.toolbar);
                            setSupportActionBar(mToolbar);
                            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(mActivity, mRoot, mToolbar, R.string.app_name, R.string.app_name);
                            // Coloring drawertoggle
                            DrawerArrowDrawable coloredArrow = new DrawerArrowDrawable(mContext);
                            TypedValue typedValue = new TypedValue();
                            Resources.Theme theme = getTheme();
                            theme.resolveAttribute(R.attr.colorAccent, typedValue, true);
                            coloredArrow.setColor(typedValue.data);
                            toggle.setDrawerArrowDrawable(coloredArrow);
                            mRoot.addDrawerListener(toggle);
                            toggle.syncState();
                            mNavigationView.setNavigationItemSelectedListener(mActivity);
                            if (mAds != null) {
                                if (App.Preferences.getBoolean(App.PREF_KEY_ADS, true)) {
                                    mAds.loadAd(new AdRequest.Builder().addTestDevice("BB1FFBF880370A581E6665C69C97D711").build());
                                } else {
                                    mAds.setVisibility(View.GONE);
                                    mRoot.removeView(mAds);
                                }
                            }
                            if (getIntent().getAction().equals(Intent.ACTION_VIEW)) {
                                /* Rashr is opened by other app to flash supported files (.zip) or (.img) */
                                File file = new File(getIntent().getData().getPath());
                                if (file.exists()) {
                                    if (file.toString().endsWith(Device.EXT_ZIP)) {
                                        /* If it is a zip file open the ScriptManager */
                                        switchTo(ScriptManagerFragment.newInstance(file));
                                    } else if (file.toString().endsWith(Device.EXT_IMG)) {
                                        /* If it is a img file open FlashAs to choose mode (recovery or kernel) */
                                        switchTo(FlashAsFragment.newInstance(mActivity, file));
                                    }
                                }
                            } else {
                                onNavigationItemSelected(mNavigationView.getMenu().getItem(0));
                            }
                        } catch (NullPointerException e) {
                            setContentView(R.layout.err_layout);
                            App.ERRORS.add("Error while inflating layout:" + e);
                            AppCompatTextView tv = findViewById(R.id.tvErr);
                            try {
                                if (tv != null) {
                                    tv.setText(R.string.failed_setup_layout);
                                }
                            } catch (RuntimeException ex) {
                                App.ERRORS.add(App.TAG + " " + e);
                                ReportDialog dialog = new ReportDialog(mActivity, e.toString());
                                dialog.show();
                                ex.printStackTrace();
                            }
                            ReportDialog dialog = new ReportDialog(mActivity, e.toString());
                            dialog.show();
                            e.printStackTrace();
                        }
                    }
                });
            }
        });
        StartThread.start();
    } else {
        // Permission not garanted
        setContentView(R.layout.err_layout);
        AppCompatTextView tverr = findViewById(R.id.tvErr);
        tverr.setText(R.string.permissions_denied);
    }
}
Also used : FailedExecuteCommand(org.sufficientlysecure.rootcommands.util.FailedExecuteCommand) ApplicationInfo(android.content.pm.ApplicationInfo) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AdRequest(com.google.android.gms.ads.AdRequest) DrawerArrowDrawable(android.support.v7.graphics.drawable.DrawerArrowDrawable) AppCompatTextView(android.support.v7.widget.AppCompatTextView) TextView(android.widget.TextView) Resources(android.content.res.Resources) File(java.io.File) TypedValue(android.util.TypedValue)

Example 43 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project MaterialFBook by ZeeRooo.

the class CookingAToast method cooking.

@CheckResult
public static Toast cooking(Context context, CharSequence message_to_show, int text_color, int background, int icon_toast, boolean duration) {
    View view = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.cooking_a_toast, null);
    view.setBackgroundColor(background);
    AppCompatImageView icon = (AppCompatImageView) view.findViewById(R.id.icon);
    icon.setImageResource(icon_toast);
    AppCompatTextView message = (AppCompatTextView) view.findViewById(R.id.message);
    message.setText(message_to_show);
    message.setTextColor(text_color);
    Toast toast = new Toast(context);
    toast.setView(view);
    toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0);
    if (duration) {
        toast.setDuration(Toast.LENGTH_LONG);
    } else {
        toast.setDuration(Toast.LENGTH_SHORT);
    }
    return toast;
}
Also used : Toast(android.widget.Toast) LayoutInflater(android.view.LayoutInflater) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) CheckResult(android.support.annotation.CheckResult)

Example 44 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project Stringlate by LonamiWebs.

the class ActivityUtils method showDialogWithHtmlTextView.

public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) {
    AppCompatTextView textView = new AppCompatTextView(_context);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics());
    textView.setMovementMethod(new LinkMovementMethod());
    textView.setPadding(padding, 0, padding, 0);
    textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text);
    AlertDialog.Builder dialog = new AlertDialog.Builder(_context).setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener).setTitle(resTitleId).setView(textView);
    dialog.show();
}
Also used : SpannableString(android.text.SpannableString) AlertDialog(android.support.v7.app.AlertDialog) AppCompatTextView(android.support.v7.widget.AppCompatTextView) LinkMovementMethod(android.text.method.LinkMovementMethod)

Example 45 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project memetastic by gsantner.

the class ActivityUtils method showDialogWithHtmlTextView.

public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) {
    AppCompatTextView textView = new AppCompatTextView(_context);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics());
    textView.setMovementMethod(new LinkMovementMethod());
    textView.setPadding(padding, 0, padding, 0);
    textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text);
    AlertDialog.Builder dialog = new AlertDialog.Builder(_context).setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener).setTitle(resTitleId).setView(textView);
    dialog.show();
}
Also used : SpannableString(android.text.SpannableString) AlertDialog(android.support.v7.app.AlertDialog) AppCompatTextView(android.support.v7.widget.AppCompatTextView) LinkMovementMethod(android.text.method.LinkMovementMethod)

Aggregations

AppCompatTextView (android.support.v7.widget.AppCompatTextView)45 View (android.view.View)26 AppCompatButton (android.support.v7.widget.AppCompatButton)9 AppCompatImageView (android.support.v7.widget.AppCompatImageView)7 ProgressBar (android.widget.ProgressBar)7 Sigchain (co.krypt.krypton.team.Sigchain)7 AlertDialog (android.support.v7.app.AlertDialog)6 Button (android.widget.Button)6 DialogInterface (android.content.DialogInterface)4 ConstraintLayout (android.support.constraint.ConstraintLayout)4 ViewGroup (android.view.ViewGroup)4 TextView (android.widget.TextView)4 Context (android.content.Context)3 Handler (android.os.Handler)3 Nullable (android.support.annotation.Nullable)3 Espresso.onView (android.support.test.espresso.Espresso.onView)3 MediumTest (android.support.test.filters.MediumTest)3 AppCompatEditText (android.support.v7.widget.AppCompatEditText)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2