Java Code Examples for com.grarak.kerneladiutor.utils.Utils#isTV()

The following examples show how to use com.grarak.kerneladiutor.utils.Utils#isTV() . 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: SettingsFragment.java    From KA27 with Apache License 2.0 6 votes vote down vote up
private void navigationDrawerInit() {
    DDivider mNavigationDrawerDividerCard = new DDivider();
    mNavigationDrawerDividerCard.setText(getString(R.string.navigation_drawer));

    addView(mNavigationDrawerDividerCard);

    if (!Utils.isTV(getActivity())) {
        SwitchCardView.DSwitchCard mNavigationDrawerCard = new SwitchCardView.DSwitchCard();
        mNavigationDrawerCard.setTitle(getString(R.string.navigation_drawer));
        mNavigationDrawerCard.setDescription(getString(R.string.navigation_drawer_summary));
        mNavigationDrawerCard.setChecked(Utils.getBoolean("Navbar_Position_Alternate", false, getActivity()));
        mNavigationDrawerCard.setOnDSwitchCardListener(new SwitchCardView.DSwitchCard.OnDSwitchCardListener() {
            @Override
            public void onChecked(SwitchCardView.DSwitchCard dSwitchCard, boolean checked) {
                Utils.saveBoolean("Navbar_Position_Alternate", checked, getActivity());
                MainActivity.reconfigureNavigationDrawer(getContext());
            }
        });

        addView(mNavigationDrawerCard);
    }
}
 
Example 2
Source File: RecyclerViewFragment.java    From KA27 with Apache License 2.0 6 votes vote down vote up
public void setOnScrollListener(RecyclerView recyclerView) {
    if (recyclerView != null) {
        int paddingBottom = recyclerView.getPaddingBottom() +
            getResources().getDimensionPixelSize(R.dimen.basecard_padding);
        if (applyOnBootLayout != null) {
            recyclerView.setPadding(0, applyOnBootLayout.getHeight(), 0, firstOpening ? paddingBottom :
                recyclerView.getPaddingBottom());
            resetTranslations();

            if (!Utils.isTV(getActivity()))
                recyclerView.addOnScrollListener(onScrollListener = new CustomScrollListener());
        } else recyclerView.setPadding(0, 0, 0, firstOpening ? paddingBottom :
            recyclerView.getPaddingBottom());
        recyclerView.setClipToPadding(false);
    }
}
 
Example 3
Source File: SettingsFragment.java    From kernel_adiutor with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);

    darkthemeInit();
    if (!Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en") && !Utils.isTV(getActivity()))
        forceenglishlanguageInit();
    if (Constants.VERSION_NAME.contains("beta")) betainfoInit();
    if (Utils.hasCMSDK()) profileTileInit();
    updatecheckInit();
    applyonbootInit();
    debuggingInit();
    securityInit();
    perappInit();
    showSectionsInit();
}
 
Example 4
Source File: BaseCardView.java    From kernel_adiutor with Apache License 2.0 6 votes vote down vote up
private void setUpCustomLayout() {
    if (customLayout != null && customView != null) {
        innerView.setVisibility(GONE);
        customLayout.setVisibility(VISIBLE);
        customLayout.removeAllViews();
        try {
            ((ViewGroup) customView.getParent()).removeView(customView);
        } catch (NullPointerException ignored) {
        }
        customLayout.addView(customView);
        if (Utils.isTV(getContext())) {
            setFocusable(false);
            setFocusableInTouchMode(false);
        }
    }
}
 
Example 5
Source File: BaseCardView.java    From KA27 with Apache License 2.0 5 votes vote down vote up
private void setUpCustomLayout() {
    if (customLayout != null && customView != null) {
        innerView.setVisibility(GONE);
        customLayout.setVisibility(VISIBLE);
        customLayout.removeAllViews();
        try {
            ((ViewGroup) customView.getParent()).removeView(customView);
        } catch (NullPointerException ignored) {}
        customLayout.addView(customView);
        if (Utils.isTV(getContext())) {
            setFocusable(false);
            setFocusableInTouchMode(false);
        }
    }
}
 
Example 6
Source File: DAdapter.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder) {
    view = viewHolder.itemView;
    if (Utils.isTV(view.getContext())) {
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
    }
    text = (TextView) view.findViewById(R.id.text);
    text.setText(title);
    view.setBackgroundColor(checked ? checkedBackgroundColor : defaultBackgroundColor);
    text.setTextColor(checked ? checkedTextColor : defaultTextColor);
}
 
Example 7
Source File: RecyclerViewFragment.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public int getSpan() {
    int orientation = Utils.getScreenOrientation(getActivity());
    if (Utils.isTV(getActivity())) return 2;
    if (Utils.isTablet(getActivity()))
        return orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 3;
    return orientation == Configuration.ORIENTATION_PORTRAIT ? 1 : 2;
}
 
Example 8
Source File: DownloadCardView.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public DownloadCardView(Context context, final Downloads.Download download) {
    super(context, R.layout.download_cardview);

    final String name = download.getName();
    nameText.setText(Html.fromHtml(name));
    nameText.setMovementMethod(LinkMovementMethod.getInstance());

    String description;
    if ((description = download.getDescription()) != null) {
        descriptionText.setText(Html.fromHtml(description));
        descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
    } else descriptionText.setVisibility(GONE);

    List<String> changelog = download.getChangelogs();
    if (changelog.size() > 0) {
        StringBuilder stringBuilder = new StringBuilder();
        for (String change : changelog)
            if (stringBuilder.length() == 0)
                stringBuilder.append("\u2022").append(" ").append(change);
            else stringBuilder.append("<br>").append("\u2022").append(" ").append(change);
        changelogText.setText(Html.fromHtml(stringBuilder.toString()));
        changelogText.setMovementMethod(LinkMovementMethod.getInstance());
    }

    downloadButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            showDownload(name, download.getMD5sum(), download.getUrl(), download.getInstallMethod());
        }
    });

    if (Utils.isTV(getContext())) {
        downloadButton.setFocusable(true);
        downloadButton.setFocusableInTouchMode(true);
    }
}
 
Example 9
Source File: FileBrowserActivity.java    From KA27 with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder) {
    text = (TextView) viewHolder.itemView.findViewById(R.id.text);
    text.setText(file.getName());
    text.setCompoundDrawablesWithIntrinsicBounds(file.isDirectory() ? R.drawable.ic_folder : R.drawable.ic_file,
        0, 0, 0);

    if (Utils.isTV(viewHolder.itemView.getContext())) {
        viewHolder.itemView.setFocusable(true);
        viewHolder.itemView.setFocusableInTouchMode(true);
    }
}
 
Example 10
Source File: FileBrowserActivity.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder) {
    text = (TextView) viewHolder.itemView.findViewById(R.id.text);
    text.setText(file.getName());
    text.setCompoundDrawablesWithIntrinsicBounds(file.isDirectory() ? R.drawable.ic_folder : R.drawable.ic_file,
            0, 0, 0);

    if (Utils.isTV(viewHolder.itemView.getContext())) {
        viewHolder.itemView.setFocusable(true);
        viewHolder.itemView.setFocusableInTouchMode(true);
    }
}
 
Example 11
Source File: DAdapter.java    From KA27 with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder) {
    view = viewHolder.itemView;
    if (Utils.isTV(view.getContext())) {
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
    }
    text = (TextView) view.findViewById(R.id.text);
    text.setText(title);
    view.setBackgroundColor(checked ? checkedBackgroundColor : defaultBackgroundColor);
    text.setTextColor(checked ? checkedTextColor : defaultTextColor);
}
 
Example 12
Source File: RecyclerViewFragment.java    From KA27 with Apache License 2.0 5 votes vote down vote up
public int getSpan() {
    int orientation = Utils.getScreenOrientation(getActivity());
    if (Utils.isTV(getActivity())) return 2;
    if (Utils.isTablet(getActivity()))
        return orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 3;
    return orientation == Configuration.ORIENTATION_PORTRAIT ? 1 : 2;
}
 
Example 13
Source File: SettingsFragment.java    From KA27 with Apache License 2.0 5 votes vote down vote up
@Override
public void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);

    if (!Utils.sysLocale().startsWith("en") && !Utils.isTV(getActivity()))
        forceenglishlanguageInit();
    darkthemeInit();
    applyonbootInit();
    navigationDrawerInit();
    perappInit();
    securityInit();
    showSectionsInit();
}
 
Example 14
Source File: MainActivity.java    From KA27 with Apache License 2.0 4 votes vote down vote up
@Override
public int getParentViewId() {
    return Utils.isTV(this) ? R.layout.activity_main_tv : R.layout.activity_main;
}
 
Example 15
Source File: MainActivity.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
@Override
public int getParentViewId() {
    return Utils.isTV(this) ? R.layout.activity_main_tv : R.layout.activity_main;
}
 
Example 16
Source File: BaseCardView.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
public BaseCardView(Context context, AttributeSet attributeSet, int layout) {
    super(context, attributeSet);

    // Add a margin
    setMargin();

    // Make a rounded card
    setRadius();

    // Set background color depending on the current theme
    setCardBackgroundColor(getResources().getColor(Utils.DARKTHEME ?
            R.color.card_background_dark : R.color.card_background_light));

    // This will enable the touch feedback of the card
    TypedArray ta = getContext().obtainStyledAttributes(new int[]{R.attr.selectableItemBackground});
    Drawable d = ta.getDrawable(0);
    ta.recycle();
    setForeground(d);

    // Add the base view
    View view = LayoutInflater.from(getContext()).inflate(R.layout.base_cardview, null, false);
    addView(view);

    headerLayout = (LinearLayout) view.findViewById(R.id.header_layout);

    setUpHeader();

    LinearLayout innerLayout = (LinearLayout) view.findViewById(R.id.inner_layout);
    customLayout = (LinearLayout) view.findViewById(R.id.custom_layout);

    // Inflate the innerlayout
    layoutView = LayoutInflater.from(getContext()).inflate(layout, null, false);

    // If sub class overwrites the default layout then don't try to get the TextView
    if (layout == DEFAULT_LAYOUT) {
        innerView = (TextView) layoutView.findViewById(R.id.inner_view);
        if (mTitle != null) innerView.setText(mTitle);
    } else setUpInnerLayout(layoutView);

    // Add innerlayout to base view
    innerLayout.addView(layoutView);
    if (Utils.isTV(getContext())) setFocus();
}
 
Example 17
Source File: InitdFragment.java    From KA27 with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnScrollListener(RecyclerView recyclerView) {
    super.setOnScrollListener(recyclerView);
    if (!Utils.isTV(getActivity()))
        recyclerView.addOnScrollListener(fabHideScrollListener = new FabHideScrollListener());
}
 
Example 18
Source File: MainActivity.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
/**
 * Add all fragments in a list
 */
private void setList() {
    ITEMS.clear();
    ITEMS.add(new DAdapter.MainHeader());
    ITEMS.add(new DAdapter.Header(getString(R.string.information)));
    ITEMS.add(new DAdapter.Item(getString(R.string.kernel_information), new KernelInformationFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.frequency_table), new FrequencyTableFragment()));
    ITEMS.add(new DAdapter.Header(getString(R.string.kernel)));
    ITEMS.add(new DAdapter.Item(getString(R.string.cpu), new CPUFragment()));
    if (CPUVoltage.hasCpuVoltage())
        ITEMS.add(new DAdapter.Item(getString(R.string.cpu_voltage), new CPUVoltageFragment()));
    if (CPUHotplug.hasCpuHotplug())
        ITEMS.add(new DAdapter.Item(getString(R.string.cpu_hotplug), new CPUHotplugFragment()));
    if (CoreControl.hasMinLittle())
        ITEMS.add(new DAdapter.Item(getString(R.string.corecontrol), new CoreControlFragment()));
    if (Thermal.hasThermal())
        ITEMS.add(new DAdapter.Item(getString(R.string.thermal), new ThermalFragment()));
    if (GPU.hasGpuControl())
        ITEMS.add(new DAdapter.Item(getString(R.string.gpu), new GPUFragment()));
    if (Screen.hasScreen())
        ITEMS.add(new DAdapter.Item(getString(R.string.screen), new ScreenFragment()));
    if (Wake.hasWake())
        ITEMS.add(new DAdapter.Item(getString(R.string.wake_controls), new WakeFragment()));
    if (Sound.hasSound())
        ITEMS.add(new DAdapter.Item(getString(R.string.sound), new SoundFragment()));
    if (!Utils.isTV(this))
        ITEMS.add(new DAdapter.Item(getString(R.string.battery), new BatteryFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.io_scheduler), new IOFragment()));
    if (KSM.hasKsm())
        ITEMS.add(new DAdapter.Item(getString(R.string.ksm), new KSMFragment()));
    if (LMK.getMinFrees() != null)
        ITEMS.add(new DAdapter.Item(getString(R.string.low_memory_killer), new LMKFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.virtual_memory), new VMFragment()));
    if (WakeLock.hasAnyWakelocks()) {
        ITEMS.add(new DAdapter.Item(getString(R.string.wakelocks), new WakeLockFragment()));
    }
    if (Entropy.hasEntropy())
        ITEMS.add(new DAdapter.Item(getString(R.string.entropy), new EntropyFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.misc_controls), new MiscFragment()));
    ITEMS.add(new DAdapter.Header(getString(R.string.tools)));
    Downloads downloads;
    if ((downloads = new Downloads(this)).isSupported())
        ITEMS.add(new DAdapter.Item(getString(R.string.downloads),
                DownloadsFragment.newInstance(downloads.getLink())));
    if (Backup.hasBackup())
        ITEMS.add(new DAdapter.Item(getString(R.string.backup), new BackupFragment()));
    if (Buildprop.hasBuildprop() && RootUtils.busyboxInstalled())
        ITEMS.add(new DAdapter.Item(getString(R.string.build_prop_editor), new BuildpropFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.profile), new ProfileFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.recovery), new RecoveryFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.initd), new InitdFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.startup_commands), new StartUpCommandsFragment()));
    ITEMS.add(new DAdapter.Header(getString(R.string.other)));
    ITEMS.add(new DAdapter.Item(getString(R.string.settings), new SettingsFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.faq), new FAQFragment()));
    ITEMS.add(new DAdapter.Item(getString(R.string.about_us), new AboutusFragment()));
}
 
Example 19
Source File: InitdFragment.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnScrollListener(RecyclerView recyclerView) {
    super.setOnScrollListener(recyclerView);
    if (!Utils.isTV(getActivity()))
        recyclerView.addOnScrollListener(fabHideScrollListener = new FabHideScrollListener());
}
 
Example 20
Source File: BaseCardView.java    From KA27 with Apache License 2.0 4 votes vote down vote up
public BaseCardView(Context context, AttributeSet attributeSet, int layout) {
    super(context, attributeSet);

    // Add a margin
    setMargin();

    // Make a rounded card
    setRadius();

    // Set background color depending on the current theme
    setCardBackgroundColor(ContextCompat.getColor(context, Utils.DARKTHEME ?
        R.color.card_background_dark : R.color.card_background_light));

    // This will enable the touch feedback of the card
    TypedArray ta = getContext().obtainStyledAttributes(new int[] {
        R.attr.selectableItemBackground
    });
    Drawable d = ta.getDrawable(0);
    ta.recycle();
    setForeground(d);

    // null parent avoid Layout Inflation without a Parent
    ViewGroup base_parent = (ViewGroup) findViewById(R.id.base_parent);

    // Add the base view
    View view = LayoutInflater.from(getContext()).inflate(R.layout.base_cardview, base_parent, false);
    addView(view);

    headerLayout = (LinearLayout) view.findViewById(R.id.header_layout);

    setUpHeader();

    LinearLayout innerLayout = (LinearLayout) view.findViewById(R.id.inner_layout);
    customLayout = (LinearLayout) view.findViewById(R.id.custom_layout);

    // Inflate the innerlayout
    layoutView = LayoutInflater.from(getContext()).inflate(layout, null, false);

    // If sub class overwrites the default layout then don't try to get the TextView
    if (layout == DEFAULT_LAYOUT) {
        innerView = (TextView) layoutView.findViewById(R.id.inner_view);
        if (mTitle != null) innerView.setText(mTitle);
    } else setUpInnerLayout(layoutView);

    // Add innerlayout to base view
    innerLayout.addView(layoutView);
    if (Utils.isTV(getContext())) setFocus();
}