Search in sources :

Example 46 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class AboutFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ScalpelHelperFragment.attachTo(this);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    activity.getSupportActionBar().setTitle(null);
    // Seems that ScrollView intercepts touch event, so we have to set the onTouchListener on a
    // view inside it.
    mContainerLayout.setOnTouchListener(new KonamiCodeDetector(activity) {

        @Override
        public void onDetected() {
            onEnableScalpel();
        }
    });
    mVersionText.setText(getString(R.string.about_version_format, BuildConfig.VERSION_NAME));
    mDoubanButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Activity activity = getActivity();
            activity.startActivity(ProfileActivity.makeIntent("douban-douya", activity));
        }
    });
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) KonamiCodeDetector(me.zhanghai.android.douya.ui.KonamiCodeDetector) ProfileActivity(me.zhanghai.android.douya.profile.ui.ProfileActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View)

Example 47 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project SwipeToLoadLayout by Aspsine.

the class BaseToolbarFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    if (toolbar != null) {
        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
        final ActionBar actionbar = getSupportActionBar();
        actionbar.setHomeAsUpIndicator(R.mipmap.ic_menu);
        actionbar.setDisplayHomeAsUpEnabled(true);
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 48 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Rashr by DsLNeXuS.

the class SettingsFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = inflater.inflate(R.layout.fragment_settings, container, false);
    final AppCompatButton bSetDevName = (AppCompatButton) root.findViewById(R.id.bSetDevName);
    final AppCompatCheckBox cbShowAds = (AppCompatCheckBox) root.findViewById(R.id.cbShowAds);
    final AppCompatCheckBox cbLog = (AppCompatCheckBox) root.findViewById(R.id.cbLog);
    //        final AppCompatCheckBox cbDarkUI = (AppCompatCheckBox) root.findViewById(R.id.cbDarkUI);
    final AppCompatCheckBox cbCheckUpdates = (AppCompatCheckBox) root.findViewById(R.id.cbCheckUpdates);
    final AppCompatCheckBox cbHideUpToDateHint = (AppCompatCheckBox) root.findViewById(R.id.cbShowUpToDateHints);
    final AppCompatCheckBox cbSkipSizeCheck = (AppCompatCheckBox) root.findViewById(R.id.cbSkipSizeChecking);
    final AppCompatCheckBox cbSkipValidate = (AppCompatCheckBox) root.findViewById(R.id.cbSkipValidateImages);
    final AppCompatButton bShowLogs = (AppCompatButton) root.findViewById(R.id.bShowLogs);
    final AppCompatButton bReport = (AppCompatButton) root.findViewById(R.id.bReport);
    final AppCompatButton bShowChangelog = (AppCompatButton) root.findViewById(R.id.bShowChangelog);
    final AppCompatButton bReset = (AppCompatButton) root.findViewById(R.id.bReset);
    final AppCompatButton bClearCache = (AppCompatButton) root.findViewById(R.id.bClearCache);
    final AppCompatButton bShowLicences = (AppCompatButton) root.findViewById(R.id.bShowLicenses);
    //        cbDarkUI.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME,
    //                Const.PREF_KEY_DARK_UI));
    cbShowAds.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_ADS));
    cbLog.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_LOG));
    cbCheckUpdates.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_CHECK_UPDATES));
    cbShowAds.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_ADS));
    cbHideUpToDateHint.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_HIDE_UPDATE_HINTS));
    cbSkipSizeCheck.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_SIZE_CHECK));
    cbSkipValidate.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_IMAGE_CHECK));
    //        cbDarkUI.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    //            @Override
    //            public void onCheckedChanged(CompoundButton view, boolean isChecked) {
    //                Common.setBooleanPref(view.getContext(), Const.PREF_NAME,
    //                        Const.PREF_KEY_DARK_UI, isChecked);
    //                RashrActivity.isDark = isChecked;
    //            }
    //        });
    cbLog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_LOG, isChecked);
            root.findViewById(R.id.bShowLogs).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
        }
    });
    cbCheckUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_CHECK_UPDATES, isChecked);
        }
    });
    cbShowAds.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_ADS, isChecked);
        }
    });
    cbHideUpToDateHint.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_HIDE_UPDATE_HINTS, isChecked);
        }
    });
    cbSkipSizeCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Common.setBooleanPref(buttonView.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_SIZE_CHECK, isChecked);
        }
    });
    cbSkipValidate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Common.setBooleanPref(buttonView.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_IMAGE_CHECK, isChecked);
        }
    });
    final RashrActivity activity = (RashrActivity) getActivity();
    bReport.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ReportDialog dialog = new ReportDialog(activity, "");
            dialog.show();
        }
    });
    bShowLogs.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showLogs();
        }
    });
    bShowLogs.setVisibility(cbLog.isChecked() ? View.VISIBLE : View.INVISIBLE);
    bReset.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AppCompatActivity activity = (AppCompatActivity) getActivity();
            SharedPreferences.Editor editor = activity.getSharedPreferences(Const.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().apply();
            editor = activity.getSharedPreferences(Const.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().apply();
            RashrActivity.firstSetup(v.getContext());
        }
    });
    bClearCache.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(v.getContext());
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.delete_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (!Common.deleteFolder(Const.PathToCWM, false) || !Common.deleteFolder(Const.PathToTWRP, false) || !Common.deleteFolder(Const.PathToPhilz, false) || !Common.deleteFolder(Const.PathToStockRecovery, false) || !Common.deleteFolder(Const.PathToStockKernel, false)) {
                        Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getActivity(), R.string.files_deleted, Toast.LENGTH_SHORT).show();
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
        }
    });
    bShowChangelog.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SettingsFragment.showChangelog(v.getContext());
        }
    });
    bShowLicences.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new LicensesDialog.Builder(v.getContext()).setNotices(R.raw.licenses_notice).setIncludeOwnLicense(true).build().show();
        }
    });
    bSetDevName.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AppCompatEditText et = new AppCompatEditText(v.getContext());
            AlertDialog.Builder inputDialog = new AlertDialog.Builder(v.getContext());
            String dev_name = Common.getStringPref(v.getContext(), Const.PREF_NAME, Const.PREF_KEY_DEVICE_NAME);
            if (dev_name.equals(""))
                dev_name = RashrApp.DEVICE.getName();
            et.setText(dev_name);
            inputDialog.setTitle(R.string.device_name);
            inputDialog.setView(et);
            inputDialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String name = et.getText().toString();
                    if (!name.equals("")) {
                        Common.setStringPref(getContext(), Const.PREF_NAME, Const.PREF_KEY_DEVICE_NAME, et.getText().toString());
                        Snackbar.make(bSetDevName, R.string.please_restart, Snackbar.LENGTH_SHORT).show();
                    }
                }
            });
            inputDialog.setNeutralButton(R.string.reset, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Common.setStringPref(getContext(), Const.PREF_NAME, Const.PREF_KEY_DEVICE_NAME, Build.DEVICE.toLowerCase());
                }
            });
            inputDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            inputDialog.show();
        }
    });
    return root;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) AppCompatActivity(android.support.v7.app.AppCompatActivity) LicensesDialog(de.psdev.licensesdialog.LicensesDialog) View(android.view.View) WebView(android.webkit.WebView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) CompoundButton(android.widget.CompoundButton)

Example 49 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project YourAppIdea by Michenux.

the class NavigationDrawerFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Activity activity = getActivity();
    mDrawerLayoutView = (DrawerLayout) activity.findViewById(mNavConf.getDrawerLayoutViewId());
    mDrawerToggle = new ActionBarDrawerToggle(this.getActivity(), mDrawerLayoutView, (Toolbar) activity.findViewById(mNavConf.getToolbarId()), mNavConf.getDrawerOpenDesc(), mNavConf.getDrawerCloseDesc()) {

        public void onDrawerClosed(View view) {
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(mTitle);
            if (NavigationDrawerFragment.this.mSelectItemOnClosed != null) {
                NavigationDrawerFragment.this.deferedOnNavItemSelected();
            }
        }

        public void onDrawerOpened(View drawerView) {
            getActivity().setTitle(mDrawerTitle);
        }
    };
    mDrawerLayoutView.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    setTitle(mTitle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) AppCompatActivity(android.support.v7.app.AppCompatActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 50 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project screenplay by weefbellington.

the class DrawerHelper method bind.

public void bind(Activity activity, DrawerLayout layout) {
    drawerLayout = layout;
    drawerToggle = createDrawerToggle(activity);
    LayoutInflater inflater = activity.getLayoutInflater();
    inflater.inflate(R.layout.navigation_menu, getLayout());
    getLayout().setDrawerListener(drawerToggle);
    ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
}
Also used : LayoutInflater(android.view.LayoutInflater) AppCompatActivity(android.support.v7.app.AppCompatActivity) ActionBar(android.support.v7.app.ActionBar)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)99 View (android.view.View)43 ActionBar (android.support.v7.app.ActionBar)36 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 Toolbar (android.support.v7.widget.Toolbar)14 BindView (butterknife.BindView)11 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Transition (android.transition.Transition)7 MenuItem (android.view.MenuItem)7 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Bundle (android.os.Bundle)4 FragmentManager (android.support.v4.app.FragmentManager)4