Full Code of rongi/rotate-layout for AI

master 8ca8d6567c71 cached
24 files
27.7 KB
7.9k tokens
16 symbols
1 requests
Download .txt
Repository: rongi/rotate-layout
Branch: master
Commit: 8ca8d6567c71
Files: 24
Total size: 27.7 KB

Directory structure:
gitextract_kr12uiru/

├── .gitignore
├── LICENSE.md
├── README.md
├── build.gradle
├── examples/
│   ├── AndroidManifest.xml
│   ├── build.gradle
│   ├── proguard-rules.pro
│   ├── project.properties
│   ├── res/
│   │   ├── drawable/
│   │   │   └── border.xml
│   │   ├── layout/
│   │   │   ├── activity_main.xml
│   │   │   └── small_form.xml
│   │   ├── values/
│   │   │   ├── strings.xml
│   │   │   └── styles.xml
│   │   └── values-v14/
│   │       └── styles.xml
│   └── src/
│       └── com/
│           └── github/
│               └── rongi/
│                   └── rotate_layout/
│                       └── example/
│                           └── MainActivity.java
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── rotate-layout/
│   ├── AndroidManifest.xml
│   ├── build.gradle
│   ├── res/
│   │   └── values/
│   │       └── attrs.xml
│   └── src/
│       └── com/
│           └── github/
│               └── rongi/
│                   └── rotate_layout/
│                       └── layout/
│                           └── RotateLayout.java
└── settings.gradle

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Local configuration file (sdk path, etc)
local.properties

# Intellij project files
*.iml
.idea/

.DS_Store

build
.gradle
projectFilesBackup

================================================
FILE: LICENSE.md
================================================
The MIT License (MIT)

Copyright (c) 2015 rongi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
Rotate Layout
=============

A custom layout that can rotate it's view

[![Example](https://github.com/rongi/rotate-layout/raw/master/docs/screenshot5.png)](#Example)

Usage
=====

In your layout file add

```xml 
<com.github.rongi.rotate_layout.layout.RotateLayout
	xmlns:app="http://schemas.android.com/apk/res-auto"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	app:angle="90">	<!-- Specify rotate angle here -->

	<YourLayoutHere
		android:layout_width="wrap_content"
		android:layout_height="wrap_content">
	</YourLayoutHere>
</com.github.rongi.rotate_layout.layout.RotateLayout>
```

Voila! Your layout will be rotated 90 degrees.

Download
========

```groovy
implementation 'rongi.rotate-layout:rotate-layout:3.0.0'
```

Features
========

1. The rotated view receives correct touch events.
2. The bounding box is also rotated. This means that if the view was 100x50px before the rotation, then after 90 degrees rotation it will be 50x100px and can fit into another layout with this dimensions.



================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
        classpath 'com.github.dcendents:android-maven-plugin:1.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}


================================================
FILE: examples/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="com.github.rongi.rotate_layout.example"
	>

	<application
		android:allowBackup="true"
		android:icon="@drawable/ic_launcher"
		android:label="@string/app_name"
		android:theme="@style/AppTheme"
		 >
		<activity
			android:name="com.github.rongi.rotate_layout.example.MainActivity"
			android:label="@string/app_name" >
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />

				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
	</application>

</manifest>


================================================
FILE: examples/build.gradle
================================================
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
//            resources.srcDirs = ['src']
//            aidl.srcDirs = ['src']
//            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        applicationId "com.github.rongi.rotate_layout.example"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':rotate-layout')
    compile 'com.jakewharton:butterknife:7.0.1'
}


================================================
FILE: examples/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/dmitry/dev/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}


================================================
FILE: examples/project.properties
================================================
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
android.library.reference.1=../../../git/rotate-layout/library


================================================
FILE: examples/res/drawable/border.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke
        android:width="1dp"
        android:color="#ff0000"/>
    <solid android:color="@android:color/white"/>
</shape>

================================================
FILE: examples/res/layout/activity_main.xml
================================================
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <TextView
        android:id="@+id/hint"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:text="@string/click_on_a_form_to_rotate_it"
        />

    <com.github.rongi.rotate_layout.layout.RotateLayout
        android:id="@+id/form1_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/hint"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dip"
        android:background="#BAE1FF"
        app:angle="0">

        <include
            android:id="@+id/form1"
            layout="@layout/small_form"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dip"/>
    </com.github.rongi.rotate_layout.layout.RotateLayout>

    <com.github.rongi.rotate_layout.layout.RotateLayout
        android:id="@+id/form2_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/form1_container"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dip"
        android:background="#BAE1FF"
        app:angle="75">

        <include
            android:id="@+id/form2"
            layout="@layout/small_form"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dip"/>
    </com.github.rongi.rotate_layout.layout.RotateLayout>

    <com.github.rongi.rotate_layout.layout.RotateLayout
        android:id="@+id/form3_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/form2_container"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dip"
        android:background="#BAE1FF"
        app:angle="180">

        <include
            android:id="@+id/form3"
            layout="@layout/small_form"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dip"/>
    </com.github.rongi.rotate_layout.layout.RotateLayout>

</RelativeLayout>

================================================
FILE: examples/res/layout/small_form.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/border"
                android:padding="5dip">

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/ic_launcher"/>

    <Button
        android:id="@+id/button2"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_below="@id/image"
        android:text="@android:string/cancel"/>

    <Button
        android:id="@+id/button1"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_below="@id/image"
        android:layout_toRightOf="@+id/button2"
        android:text="@android:string/ok"/>

</RelativeLayout>

================================================
FILE: examples/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>

	<string name="app_name">Rotate Layout example</string>
    <string name="click_on_a_form_to_rotate_it">Click on a form to rotate it</string>

</resources>


================================================
FILE: examples/res/values/styles.xml
================================================
<resources>

	<!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
	-->
	<style name="AppBaseTheme" parent="android:Theme.Light">
		<!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
		-->
	</style>

	<!-- Application theme. -->
	<style name="AppTheme" parent="AppBaseTheme">
		<!-- All customizations that are NOT specific to a particular API-level can go here. -->
	</style>

</resources>


================================================
FILE: examples/res/values-v14/styles.xml
================================================
<resources>

	<!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
	-->
	<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
		<!-- API 14 theme customizations can go here. -->
	</style>

</resources>


================================================
FILE: examples/src/com/github/rongi/rotate_layout/example/MainActivity.java
================================================
package com.github.rongi.rotate_layout.example;

import android.app.Activity;
import android.os.Bundle;

import com.github.rongi.rotate_layout.layout.RotateLayout;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends Activity {

	@Bind(R.id.form1_container) RotateLayout form1RotateLayout;
	@Bind(R.id.form2_container) RotateLayout form2RotateLayout;
	@Bind(R.id.form3_container) RotateLayout form3RotateLayout;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		ButterKnife.bind(this);
	}

	/**
	 * Clicking on a form will rotate it
	 */
	@OnClick({R.id.form1_container, R.id.form2_container, R.id.form3_container}) void onForm1ContainerClick(RotateLayout rotateLayout) {
		int newAngle = rotateLayout.getAngle() + 90;
		rotateLayout.setAngle(newAngle);
	}

}


================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Tue Feb 14 14:32:48 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip


================================================
FILE: gradlew
================================================
#!/usr/bin/env bash

##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
    echo "$*"
}

die ( ) {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
    JAVACMD=`cygpath --unix "$JAVACMD"`

    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        i=$((i+1))
    done
    case $i in
        (0) set -- ;;
        (1) set -- "$args0" ;;
        (2) set -- "$args0" "$args1" ;;
        (3) set -- "$args0" "$args1" "$args2" ;;
        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
    JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"


================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega


================================================
FILE: rotate-layout/AndroidManifest.xml
================================================
<manifest package="com.github.rongi.rotate_layout"/>

================================================
FILE: rotate-layout/build.gradle
================================================
apply plugin: 'com.android.library'

version = "3.0.0"

ext {

    // Bintray manual http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
    // To deploy:
    // ./gradlew install
    // ./gradlew bintrayUpload
    bintrayRepo = 'maven'
    bintrayName = 'rotate-layout'

    publishedGroupId = 'rongi.rotate-layout'
    libraryName = 'rotate-layout'
    artifact = 'rotate-layout'

    libraryDescription = 'Custom layout that can rotate it\'s view'

    siteUrl = 'https://github.com/rongi/rotate-layout'
    gitUrl = 'https://github.com/rongi/rotate-layout.git'

    libraryVersion = version

    developerId = 'nickes'
    developerName = 'nickes'
    developerEmail = 'rongi@users.noreply.github.com'

    licenseName = 'The MIT License (MIT)'
    licenseUrl = 'https://github.com/rongi/rotate-layout/blob/master/LICENSE.md'
    allLicenses = ["MIT"]
}

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        minSdkVersion 1
        targetSdkVersion 22
        versionCode 1
        versionName version
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'


================================================
FILE: rotate-layout/res/values/attrs.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <declare-styleable name="RotateLayout">
        <!-- Child view of this layout will be rotated by this angle. -->
        <attr name="angle" format="integer"/>
    </declare-styleable>

</resources>


================================================
FILE: rotate-layout/src/com/github/rongi/rotate_layout/layout/RotateLayout.java
================================================
package com.github.rongi.rotate_layout.layout;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import com.github.rongi.rotate_layout.R;

import static android.view.View.MeasureSpec.UNSPECIFIED;
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.cos;
import static java.lang.Math.sin;

/**
 * Rotates first view in this layout by specified angle.
 * <p>
 * This layout is supposed to have only one view. Behaviour of the views after the first one
 * is not defined.
 * <p>
 * XML attributes
 * See com.github.rongi.rotate_layout.R.styleable#RotateLayout RotateLayout Attributes,
 */
public class RotateLayout extends ViewGroup {

  private int angle;

  private final Matrix rotateMatrix = new Matrix();

  private final Rect viewRectRotated = new Rect();

  private final RectF tempRectF1 = new RectF();
  private final RectF tempRectF2 = new RectF();

  private final float[] viewTouchPoint = new float[2];
  private final float[] childTouchPoint = new float[2];

  private boolean angleChanged = true;

  public RotateLayout(Context context) {
    this(context, null);
  }

  public RotateLayout(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
  }

  public RotateLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RotateLayout);
    angle = a.getInt(R.styleable.RotateLayout_angle, 0);
    a.recycle();

    setWillNotDraw(false);
  }

  /**
   * Returns current angle of this layout
   */
  public int getAngle() {
    return angle;
  }

  /**
   * Sets current angle of this layout.
   */
  public void setAngle(int angle) {
    if (this.angle != angle) {
      this.angle = angle;
      angleChanged = true;
      requestLayout();
      invalidate();
    }
  }

  /**
   * Returns this layout's child or null if there is no any
   */
  public View getView() {
    if (getChildCount() > 0) {
      return getChildAt(0);
    } else {
      return null;
    }
  }

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final View child = getView();
    if (child != null) {
      if (abs(angle % 180) == 90) {
        //noinspection SuspiciousNameCombination
        measureChild(child, heightMeasureSpec, widthMeasureSpec);
        setMeasuredDimension(
          resolveSize(child.getMeasuredHeight(), widthMeasureSpec),
          resolveSize(child.getMeasuredWidth(), heightMeasureSpec));
      } else if (abs(angle % 180) == 0) {
        measureChild(child, widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(
          resolveSize(child.getMeasuredWidth(), widthMeasureSpec),
          resolveSize(child.getMeasuredHeight(), heightMeasureSpec));
      } else {
        int childWithMeasureSpec = MeasureSpec.makeMeasureSpec(0, UNSPECIFIED);
        int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, UNSPECIFIED);
        measureChild(child, childWithMeasureSpec, childHeightMeasureSpec);

        int measuredWidth = (int) ceil(child.getMeasuredWidth() * abs(cos(angle_c())) + child.getMeasuredHeight() * abs(sin(angle_c())));
        int measuredHeight = (int) ceil(child.getMeasuredWidth() * abs(sin(angle_c())) + child.getMeasuredHeight() * abs(cos(angle_c())));

        setMeasuredDimension(
          resolveSize(measuredWidth, widthMeasureSpec),
          resolveSize(measuredHeight, heightMeasureSpec));
      }
    } else {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }

  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int layoutWidth = r - l;
    int layoutHeight = b - t;

    if (angleChanged || changed) {
      final RectF layoutRect = tempRectF1;
      layoutRect.set(0, 0, layoutWidth, layoutHeight);
      final RectF layoutRectRotated = tempRectF2;
      rotateMatrix.setRotate(angle, layoutRect.centerX(), layoutRect.centerY());
      rotateMatrix.mapRect(layoutRectRotated, layoutRect);
      layoutRectRotated.round(viewRectRotated);
      angleChanged = false;
    }

    final View child = getView();
    if (child != null) {
      int childLeft = (layoutWidth - child.getMeasuredWidth()) / 2;
      int childTop = (layoutHeight - child.getMeasuredHeight()) / 2;
      int childRight = childLeft + child.getMeasuredWidth();
      int childBottom = childTop + child.getMeasuredHeight();
      child.layout(childLeft, childTop, childRight, childBottom);
    }
  }

  @Override
  protected void dispatchDraw(Canvas canvas) {
    canvas.save();
    canvas.rotate(-angle, getWidth() / 2f, getHeight() / 2f);
    super.dispatchDraw(canvas);
    canvas.restore();
  }

  @Override
  public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
    invalidate();
    return super.invalidateChildInParent(location, dirty);
  }

  @Override
  public boolean dispatchTouchEvent(MotionEvent event) {
    viewTouchPoint[0] = event.getX();
    viewTouchPoint[1] = event.getY();

    rotateMatrix.mapPoints(childTouchPoint, viewTouchPoint);

    event.setLocation(childTouchPoint[0], childTouchPoint[1]);
    boolean result = super.dispatchTouchEvent(event);
    event.setLocation(viewTouchPoint[0], viewTouchPoint[1]);

    return result;
  }

  /**
   * Circle angle, from 0 to TAU
   */
  private Double angle_c() {
    // True circle constant, not that petty imposter known as "PI"
    double TAU = 2 * PI;
    return TAU * angle / 360;
  }

}


================================================
FILE: settings.gradle
================================================
include ':examples'
include ':rotate-layout'
Download .txt
gitextract_kr12uiru/

├── .gitignore
├── LICENSE.md
├── README.md
├── build.gradle
├── examples/
│   ├── AndroidManifest.xml
│   ├── build.gradle
│   ├── proguard-rules.pro
│   ├── project.properties
│   ├── res/
│   │   ├── drawable/
│   │   │   └── border.xml
│   │   ├── layout/
│   │   │   ├── activity_main.xml
│   │   │   └── small_form.xml
│   │   ├── values/
│   │   │   ├── strings.xml
│   │   │   └── styles.xml
│   │   └── values-v14/
│   │       └── styles.xml
│   └── src/
│       └── com/
│           └── github/
│               └── rongi/
│                   └── rotate_layout/
│                       └── example/
│                           └── MainActivity.java
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── rotate-layout/
│   ├── AndroidManifest.xml
│   ├── build.gradle
│   ├── res/
│   │   └── values/
│   │       └── attrs.xml
│   └── src/
│       └── com/
│           └── github/
│               └── rongi/
│                   └── rotate_layout/
│                       └── layout/
│                           └── RotateLayout.java
└── settings.gradle
Download .txt
SYMBOL INDEX (16 symbols across 2 files)

FILE: examples/src/com/github/rongi/rotate_layout/example/MainActivity.java
  class MainActivity (line 12) | public class MainActivity extends Activity {
    method onCreate (line 18) | @Override
    method onForm1ContainerClick (line 28) | @OnClick({R.id.form1_container, R.id.form2_container, R.id.form3_conta...

FILE: rotate-layout/src/com/github/rongi/rotate_layout/layout/RotateLayout.java
  class RotateLayout (line 33) | public class RotateLayout extends ViewGroup {
    method RotateLayout (line 49) | public RotateLayout(Context context) {
    method RotateLayout (line 53) | public RotateLayout(Context context, AttributeSet attrs) {
    method RotateLayout (line 57) | public RotateLayout(Context context, AttributeSet attrs, int defStyleA...
    method getAngle (line 70) | public int getAngle() {
    method setAngle (line 77) | public void setAngle(int angle) {
    method getView (line 89) | public View getView() {
    method onMeasure (line 97) | @Override
    method onLayout (line 129) | @Override
    method dispatchDraw (line 154) | @Override
    method invalidateChildInParent (line 162) | @Override
    method dispatchTouchEvent (line 168) | @Override
    method angle_c (line 185) | private Double angle_c() {
Condensed preview — 24 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (31K chars).
[
  {
    "path": ".gitignore",
    "chars": 143,
    "preview": "# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Intellij project files\n*.iml\n.idea/\n\n.DS_Store\n\nbuild\n.gr"
  },
  {
    "path": "LICENSE.md",
    "chars": 1072,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2015 rongi\n\nPermission is hereby granted, free of charge, to any person obtaining a"
  },
  {
    "path": "README.md",
    "chars": 1034,
    "preview": "Rotate Layout\n=============\n\nA custom layout that can rotate it's view\n\n[![Example](https://github.com/rongi/rotate-layo"
  },
  {
    "path": "build.gradle",
    "chars": 439,
    "preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    r"
  },
  {
    "path": "examples/AndroidManifest.xml",
    "chars": 643,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\tpackage=\"co"
  },
  {
    "path": "examples/build.gradle",
    "chars": 1705,
    "preview": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 22\n    buildToolsVersion '22.0.1'\n\n    sourceSe"
  },
  {
    "path": "examples/proguard-rules.pro",
    "chars": 660,
    "preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
  },
  {
    "path": "examples/project.properties",
    "chars": 626,
    "preview": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# T"
  },
  {
    "path": "examples/res/drawable/border.xml",
    "chars": 238,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <stroke\n  "
  },
  {
    "path": "examples/res/layout/activity_main.xml",
    "chars": 2571,
    "preview": "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                xmlns:app=\"http://schemas.and"
  },
  {
    "path": "examples/res/layout/small_form.xml",
    "chars": 1043,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      "
  },
  {
    "path": "examples/res/values/strings.xml",
    "chars": 208,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<string name=\"app_name\">Rotate Layout example</string>\n    <string "
  },
  {
    "path": "examples/res/values/styles.xml",
    "chars": 641,
    "preview": "<resources>\n\n\t<!--\n        Base application theme, dependent on API level. This theme is replaced\n        by AppBaseThem"
  },
  {
    "path": "examples/res/values-v14/styles.xml",
    "chars": 363,
    "preview": "<resources>\n\n\t<!--\n        Base application theme for API 14+. This theme completely replaces\n        AppBaseTheme from "
  },
  {
    "path": "examples/src/com/github/rongi/rotate_layout/example/MainActivity.java",
    "chars": 926,
    "preview": "package com.github.rongi.rotate_layout.example;\n\nimport android.app.Activity;\nimport android.os.Bundle;\n\nimport com.gith"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 230,
    "preview": "#Tue Feb 14 14:32:48 CET 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
  },
  {
    "path": "gradlew",
    "chars": 4971,
    "preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start "
  },
  {
    "path": "gradlew.bat",
    "chars": 2314,
    "preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
  },
  {
    "path": "rotate-layout/AndroidManifest.xml",
    "chars": 52,
    "preview": "<manifest package=\"com.github.rongi.rotate_layout\"/>"
  },
  {
    "path": "rotate-layout/build.gradle",
    "chars": 2405,
    "preview": "apply plugin: 'com.android.library'\n\nversion = \"3.0.0\"\n\next {\n\n    // Bintray manual http://inthecheesefactory.com/blog/"
  },
  {
    "path": "rotate-layout/res/values/attrs.xml",
    "chars": 255,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <declare-styleable name=\"RotateLayout\">\n        <!-- Child view "
  },
  {
    "path": "rotate-layout/src/com/github/rongi/rotate_layout/layout/RotateLayout.java",
    "chars": 5824,
    "preview": "package com.github.rongi.rotate_layout.layout;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\ni"
  },
  {
    "path": "settings.gradle",
    "chars": 44,
    "preview": "include ':examples'\ninclude ':rotate-layout'"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the rongi/rotate-layout GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 24 files (27.7 KB), approximately 7.9k tokens, and a symbol index with 16 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!