Java Code Examples for com.grarak.kerneladiutor.utils.Utils#DONATED

The following examples show how to use com.grarak.kerneladiutor.utils.Utils#DONATED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();

    MainActivity activity = mRefActivity.get();
    if (activity == null) return;
    try {
        PackageManager packageManager = activity.getPackageManager();
        mApplicationInfo = packageManager.getApplicationInfo(
                "com.grarak.kerneladiutordonate", 0);
        mPackageInfo = packageManager.getPackageInfo(
                "com.grarak.kerneladiutordonate", 0);
        if (BuildConfig.DEBUG) {
            Utils.DONATED = false;
        }
    } catch (PackageManager.NameNotFoundException ignored) {
    }
}
 
Example 2
Source File: ProfileEditActivity.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sChanged = false;
    if (!Utils.DONATED) {
        Utils.toast("nice try", this);
        finish();
        return;
    }

    mPosition = getIntent().getIntExtra(POSITION_INTENT, 0);

    setContentView(R.layout.activity_fragments);
    initToolBar();

    getSupportActionBar().setTitle(getString(R.string.edit));

    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame,
            getFragment(), "fragment").commit();
}
 
Example 3
Source File: BannerResizerActivity.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Utils.DONATED) {
        Utils.toast("nice try", this);
        return;
    }
    setContentView(R.layout.activity_fragments);

    initToolBar();

    getSupportActionBar().setTitle(getString(R.string.banner_resizer));
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, getFragment(),
            BannerResizerFragment.class.getSimpleName()).commit();
    findViewById(R.id.content_frame).setPadding(0,
            Math.round(ViewUtils.getActionBarSize(this)), 0, 0);
}
 
Example 4
Source File: SettingsFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
    boolean checked = (boolean) o;
    String key = preference.getKey();
    switch (key) {
        case KEY_FORCE_ENGLISH:
        case KEY_DARK_THEME:
            getActivity().finish();
            Intent intent = new Intent(getActivity(), MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra(NavigationActivity.INTENT_SECTION,
                    SettingsFragment.class.getCanonicalName());
            startActivity(intent);
            return true;
        case KEY_MATERIAL_ICON:
            Utils.setStartActivity(checked, getActivity());
            return true;
        case KEY_HIDE_BANNER:
            if (!Utils.DONATED) {
                ViewUtils.dialogDonate(getActivity()).show();
                return false;
            }
            return true;
        case KEY_SECTIONS_ICON:
            if (key.equals(KEY_SECTIONS_ICON) && !Utils.DONATED) {
                ViewUtils.dialogDonate(getActivity()).show();
                return false;
            }
            ((NavigationActivity) getActivity()).appendFragments();
            return true;
        default:
            if (key.endsWith("_enabled")) {
                ((NavigationActivity) getActivity()).appendFragments();
                return true;
            }
            break;
    }
    return false;
}
 
Example 5
Source File: RecyclerViewFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
public void resizeBanner() {
    if (showViewPager() && !hideBanner() && Utils.DONATED) {
        ViewGroup.LayoutParams layoutParams = mViewPagerParent.getLayoutParams();
        layoutParams.height = AppSettings.getBannerSize(getActivity());
        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), layoutParams.height,
                mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
        mViewPagerParent.requestLayout();
    }
}
 
Example 6
Source File: DataSharingFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onBottomFabClick() {
    super.onBottomFabClick();
    if (!Utils.DONATED) {
        ViewUtils.dialogDonate(getActivity()).show();
        return;
    }

    startActivity(new Intent(getActivity(), DataSharingSearchActivity.class));
}
 
Example 7
Source File: DataSharingSearchActivity.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Utils.DONATED) {
        Utils.toast("nice try", this);
        return;
    }

    setContentView(R.layout.activity_fragments);

    initToolBar();

    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame,
            getFragment(), "create_fragment").commit();
}
 
Example 8
Source File: SettingsFragment.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.settings);

    if (Utils.DONATED) {
        getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
    }

    SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
    if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
        getPreferenceScreen().removePreference(forceEnglish);
    } else {
        forceEnglish.setOnPreferenceChangeListener(this);
    }

    if (Utils.hideStartActivity()) {
        ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                .removePreference(findPreference(KEY_MATERIAL_ICON));
    } else {
        findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
    }

    findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
    findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
    findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
    findPreference(KEY_PRIMARY_COLOR).setOnPreferenceClickListener(this);
    findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
    findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
    findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
    findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

    if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
        findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
    } else {
        ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                findPreference(KEY_LAST_KMSG));
    }

    findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
    findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
    findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
        ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                findPreference(KEY_FINGERPRINT));
    } else {
        mFingerprint = findPreference(KEY_FINGERPRINT);
        mFingerprint.setEnabled(!AppSettings.getPassword(getActivity()).isEmpty());
    }

    NavigationActivity activity = (NavigationActivity) getActivity();
    PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
    for (NavigationActivity.NavigationFragment navigationFragment : activity.getFragments()) {
        Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass;
        int id = navigationFragment.mId;

        if (fragmentClass != null && fragmentClass != SettingsFragment.class) {
            SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                    new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
            switchPreference.setSummary(getString(id));
            switchPreference.setKey(fragmentClass.getSimpleName() + "_enabled");
            switchPreference.setChecked(AppSettings.isFragmentEnabled(fragmentClass, getActivity()));
            switchPreference.setOnPreferenceChangeListener(this);
            switchPreference.setPersistent(true);
            sectionsCategory.addPreference(switchPreference);
        }
    }
}