Android Open Source - ota-rootkeeper-app Status Row






From Project

Back to project page ota-rootkeeper-app.

License

The source code is released under:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute v...

If you think the Android project ota-rootkeeper-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.projectvoodoo.otarootkeeper.ui;
/*from  w w w.  j  a  v a  2s. c o  m*/
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TableRow;

import org.projectvoodoo.otarootkeeper.R;
import org.projectvoodoo.otarootkeeper.R.id;

public class StatusRow extends TableRow implements OnClickListener {

    private Context context;

    private View mView;

    public StatusRow(Context context, AttributeSet attrs) {
        super(context, attrs);

        this.context = context;
    }

    public void setAvailable(Boolean availability) {

        if (mView != null)
            removeView(mView);

        if (availability)
            mView = inflate(context, R.layout.status_available, null);
        else
            mView = inflate(context, R.layout.status_unavailable, null);

        setCustomPadding();
        addView(mView);
    }

    public void setAvailable(Boolean availability, String googlePlayUrl) {

        if (mView != null)
            removeView(mView);

        if (!availability) {
            mView = inflate(context, R.layout.status_unavailable_with_google_play_link, null);

            Button installButton = (Button) mView.findViewById(id.button_install);
            installButton.setOnClickListener(this);
            installButton.setTag(googlePlayUrl);
            setCustomPadding();
            addView(mView);
        }
    }

    private void setCustomPadding() {
        mView.setPadding(8, 0, 0, 0);
    }

    @Override
    public void onClick(View v) {

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) v.getTag()));
        context.startActivity(intent);

    }

}




Java Source Code List

org.projectvoodoo.otarootkeeper.MainActivity.java
org.projectvoodoo.otarootkeeper.backend.Device.java
org.projectvoodoo.otarootkeeper.backend.SuOperations.java
org.projectvoodoo.otarootkeeper.backend.Utils.java
org.projectvoodoo.otarootkeeper.ui.StatusRow.java