// Path: app/src/main/java/om/sstvencoder/Utility.java
// public final class Utility {
// 
//     public static android.graphics.Rect getEmbeddedRect(int w, int h, int iw, int ih) {
//         android.graphics.Rect rect;
// 
//         int ow = (9 * w) / 10;
//         int oh = (9 * h) / 10;
// 
//         if (iw * oh < ow * ih) {
//             rect = new android.graphics.Rect(0, 0, (iw * oh) / ih, oh);
//             rect.offset((w - (iw * oh) / ih) / 2, (h - oh) / 2);
//         } else {
//             rect = new android.graphics.Rect(0, 0, ow, (ih * ow) / iw);
//             rect.offset((w - ow) / 2, (h - (ih * ow) / iw) / 2);
//         }
//         return rect;
//     }
// 
//     /* public static void vibrate(int duration, android.content.Context context) {
//         android.os.Vibrator vibrator = (android.os.Vibrator) context.getSystemService(android.content.Context.VIBRATOR_SERVICE);
//         vibrator.vibrate(duration);
//     } */
// 
//     public static String createMessage(Exception ex) {
//         String message = ex.getMessage() + "\n";
//         for (StackTraceElement el : ex.getStackTrace())
//             message += "\n" + el.toString();
//         return message;
//     }
// 
//     public static Intent createEmailIntent(final String subject, final String text) {
//         Intent intent = new Intent(Intent.ACTION_SEND);
//         intent.setType("text/email");
//         intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"olga.rgb@googlemail.com"});
//         intent.putExtra(Intent.EXTRA_SUBJECT, subject);
//         intent.putExtra(Intent.EXTRA_TEXT, text);
//         return intent;
//     }
// 
//     public static int convertToDegrees(int exifOrientation) {
//         switch (exifOrientation) {
//             case ExifInterface.ORIENTATION_ROTATE_90:
//                 return 90;
//             case ExifInterface.ORIENTATION_ROTATE_180:
//                 return 180;
//             case ExifInterface.ORIENTATION_ROTATE_270:
//                 return 270;
//         }
//         return 0;
//     }
// }


import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import om.sstvencoder.Utility;
                x = mCurrent.mW + mBounds.left - mCurrent.mX - m / 2.0f;

            if (mBounds.top + mBounds.height() < m)
                y = mCurrent.mY - mBounds.top - m / 2.0f;
            else if (mCurrent.mH - mBounds.top >= m)
                y = mCurrent.mY;
            else
                y = mCurrent.mH + mCurrent.mY - mBounds.bottom + m / 2.0f;

            mCurrent.set(x, y);
            adjustGeometry();
        }
        adjust();
    }

    public void update(float w, float h) {
        setCurrentGeometry(w, h);
        setTextSizeFactor();
        adjust();
    }

    private void setCurrentGeometry(float w, float h) {
        if (mVertical == null)
            mVertical = new Geometry(mHorizontal.mX - (mHorizontal.mW - w) / 2.0f, (h - mHorizontal.mH) / 2.0f + mHorizontal.mY, w, h);
        else if (mHorizontal == null)
            mHorizontal = new Geometry((w - mVertical.mW) / 2.0f + mVertical.mX, mVertical.mY - (mVertical.mH - h) / 2.0f, w, h);
        mCurrent = w < h ? mVertical : mHorizontal;
    }

    private void setTextSizeFactor() {
// Path: app/src/main/java/om/sstvencoder/Utility.java
// public final class Utility {
// 
//     public static android.graphics.Rect getEmbeddedRect(int w, int h, int iw, int ih) {
//         android.graphics.Rect rect;
// 
//         int ow = (9 * w) / 10;
//         int oh = (9 * h) / 10;
// 
//         if (iw * oh < ow * ih) {
//             rect = new android.graphics.Rect(0, 0, (iw * oh) / ih, oh);
//             rect.offset((w - (iw * oh) / ih) / 2, (h - oh) / 2);
//         } else {
//             rect = new android.graphics.Rect(0, 0, ow, (ih * ow) / iw);
//             rect.offset((w - ow) / 2, (h - (ih * ow) / iw) / 2);
//         }
//         return rect;
//     }
// 
//     /* public static void vibrate(int duration, android.content.Context context) {
//         android.os.Vibrator vibrator = (android.os.Vibrator) context.getSystemService(android.content.Context.VIBRATOR_SERVICE);
//         vibrator.vibrate(duration);
//     } */
// 
//     public static String createMessage(Exception ex) {
//         String message = ex.getMessage() + "\n";
//         for (StackTraceElement el : ex.getStackTrace())
//             message += "\n" + el.toString();
//         return message;
//     }
// 
//     public static Intent createEmailIntent(final String subject, final String text) {
//         Intent intent = new Intent(Intent.ACTION_SEND);
//         intent.setType("text/email");
//         intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"olga.rgb@googlemail.com"});
//         intent.putExtra(Intent.EXTRA_SUBJECT, subject);
//         intent.putExtra(Intent.EXTRA_TEXT, text);
//         return intent;
//     }
// 
//     public static int convertToDegrees(int exifOrientation) {
//         switch (exifOrientation) {
//             case ExifInterface.ORIENTATION_ROTATE_90:
//                 return 90;
//             case ExifInterface.ORIENTATION_ROTATE_180:
//                 return 180;
//             case ExifInterface.ORIENTATION_ROTATE_270:
//                 return 270;
//         }
//         return 0;
//     }
// }


// Path: app/src/main/java/om/sstvencoder/TextOverlay/Label.java
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import om.sstvencoder.Utility;

                x = mCurrent.mW + mBounds.left - mCurrent.mX - m / 2.0f;

            if (mBounds.top + mBounds.height() < m)
                y = mCurrent.mY - mBounds.top - m / 2.0f;
            else if (mCurrent.mH - mBounds.top >= m)
                y = mCurrent.mY;
            else
                y = mCurrent.mH + mCurrent.mY - mBounds.bottom + m / 2.0f;

            mCurrent.set(x, y);
            adjustGeometry();
        }
        adjust();
    }

    public void update(float w, float h) {
        setCurrentGeometry(w, h);
        setTextSizeFactor();
        adjust();
    }

    private void setCurrentGeometry(float w, float h) {
        if (mVertical == null)
            mVertical = new Geometry(mHorizontal.mX - (mHorizontal.mW - w) / 2.0f, (h - mHorizontal.mH) / 2.0f + mHorizontal.mY, w, h);
        else if (mHorizontal == null)
            mHorizontal = new Geometry((w - mVertical.mW) / 2.0f + mVertical.mX, mVertical.mY - (mVertical.mH - h) / 2.0f, w, h);
        mCurrent = w < h ? mVertical : mHorizontal;
    }

    private void setTextSizeFactor() {
        Rect bounds = Utility.getEmbeddedRect((int) mCurrent.mW, (int) mCurrent.mH, 320, 240);