#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    [Java] Noob, I sincerely Apologize...


    I'm simply trying to port a feature from one Android rom to the other...
    And I've run into an issue.
    Feature originally only centered the clock.
    I want it to center the other bits from the Rom it's being ported to (Weather/Calendar).
    Upon posting to gerrit; I made note of his while being under the assumption that even my noob-self could figure it out.
    Uploaded PS2 and finally tried to build it out...
    pastie . org /5180682 <----Link to entire file
    Code:
        private void updateClockAlign() {
            final Configuration config = getContext().getResources().getConfiguration();
    
            // No alignment on landscape.
            if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                return;
            }
            final int clockAlign = Settings.System.getInt(getContext().getContentResolver(),
                    Settings.System.LOCKSCREEN_CLOCK_ALIGN, 2);
            int margin = (int) Math.round(getContext().getResources().getDimension(
                    R.dimen.keyguard_lockscreen_status_line_font_right_margin));
    
            // Adjust for each layout
            if (config.screenWidthDp >= 600) { // sw600dp
                margin = 0;
            }
    
            int leftMargin = 0, rightMargin = 0;
            int gravity = Gravity.RIGHT;
    
            switch (clockAlign) {
            case 0:
                gravity = Gravity.LEFT;
                leftMargin = margin;
                break;
            case 1:
                gravity = Gravity.CENTER;
                break;
            case 2:
                rightMargin = margin;
                break;
            }
    
            mDigitalClock.setGravity(gravity);
            setSpecificMargins(mDigitalClock, leftMargin, -1, rightMargin, -1);
    
            if (mDateLineView != null) {	
                mDateLineView.setGravity(gravity);
                setSpecificMargins(mDateLineView, leftMargin, -1, rightMargin, -1);
            }
            if (mStatus1View != null) {
                mStatus1View.setGravity(gravity);
                setSpecificMargins(mStatus1View, leftMargin, -1, rightMargin, -1);
            }
            if (mWeatherPanelView != null) {
                mWeatherPanelView.setGravity(gravity);
                setSpecificMargins(mWeatherPanelView, leftMargin, -1, rightMargin, -1);
            }
            if (mCalendarView != null) {
                mCalendarView.setGravity(gravity);
                setSpecificMargins(mCalendarView, leftMargin, -1, rightMargin, -1);
            }
        }
    
        private void setSpecificMargins(View view, int left, int top, int right,
                int bottom) {
            MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams();
            if (left != -1) params.leftMargin = left;
            if (top != -1) params.topMargin = top;
            if (right != -1) params.rightMargin = right;
            if (bottom != -1) params.bottomMargin = bottom;
            view.setLayoutParams(params);
        }
    has the entire file pasted in...Why new users aren't allowed to post links is beyond me.


    It has a problem with lines 528 and 532...
    Cannot get symbol.


    KeyguardStatusViewManager.java:528: cannot find symbol
    symbol : method setGravity(int)
    location: class com.android.internal.policy.impl.WeatherPanel
    mWeatherPanelView.setGravity(gravity);
    ^
    frameworks/base/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java:532: cannot find symbol
    symbol : method setGravity(int)
    location: class android.widget.ViewFlipper
    mCalendarView.setGravity(gravity);
    ^


    Thos two bits are what I added.
    Above that looks exactly the same.
    Me is confuzzled.

    Take note; I don't speak Java. At all. Haha.
    I'm fairly savvy...and thought simply being so would be enough to get this done.

    Edit:
    Also, I've brought this to one of the Rom's developers.
    I'm sure he could have figured it out eventually...
    But a "let me look" and 10 minutes later led to "I'm at a loss on this one."
    I hate bugging them with this noob crap.
    So I appreciate any and all help.
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    What it's telling you is that there is no setGravity method that accepts an int in the classes it shows in the error.

IMN logo majestic logo threadwatch logo seochat tools logo