Git Product home page Git Product logo

libphone's Introduction

Overview Build Status

libphone is a cross-platform library which supports iOS and Android development in C language, with a focus on a core set features.

Code once, target both.

Contributing

Don't hesitate to make a pull request. All kinds of contribution are welcome.
Note: Please follow the coding style of the existed codes.

Screenshots

Quick Start

libphone is not an IDE, so it's still a requirement that following the official guide to install Xcode or Android Studio(including the jni supports). After doing that, then

  • iOS

    • Create a new Xcode project(Single View Application with all default options)

    • Remove all auto generated files except main.m and Info.plist

    • Replace the whole content inside main.m with the following:

      #import "libphone.h"
      
      @interface iOSAppDelegate : phoneAppDelegate
      @end
      
      @implementation iOSAppDelegate
      @end
      
      int main(int argc, char * argv[]) {
        @autoreleasepool {
          return UIApplicationMain(argc, argv, nil, NSStringFromClass([iOSAppDelegate class]));
        }
      }
    • Remove the Main storyboard file base name key in Info.plist

    • Drag the following files to Xcode:

      src/libphone.c
      src/ios/iosphone.m
      samples/helloworld/helloworld.c
      
    • Change Build Settings

      • Header Search Paths <REPLACE WITH REAL PATH>/libphone/include <REPLACE WITH REAL PATH>/libphone/src
    • Run and and enjoy!

  • Android

    • Create a new project(With Empty Activity and all default options)

    • Modify classpath inside build.grade (Project: <YOUR PROJECT NAME>)

      classpath 'com.android.tools.build:gradle-experimental:0.7.2'
      
    • Modify build.grade (Module: app) according to the following example:

      apply plugin: 'com.android.model.application'
      
      model {
          android {
              compileSdkVersion 23
              buildToolsVersion "23.0.3"
      
              defaultConfig {
                  applicationId "com.example.jeremy.test"
                  minSdkVersion.apiLevel 9
                  targetSdkVersion.apiLevel 23
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      minifyEnabled false
                      //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                      proguardFiles.add(file('proguard-android.txt'))
                  }
              }
          }
      
          android.ndk {
              moduleName "libphone"
              CFlags.add("-I/Users/jeremy/Repositories/libphone/include")
              CFlags.add("-I/Users/jeremy/Repositories/libphone/src")
              ldLibs.add("log")
              ldLibs.add("GLESv2")
              ldLibs.add("android")
          }
      
          android.sources.main {
              java.source.srcDirs = ["src/main/java", "/Users/jeremy/Repositories/libphone/src/android/java"]
              jni.source.srcDirs = ["/Users/jeremy/Repositories/libphone/src/android/jni",
                                    "/Users/jeremy/Repositories/libphone/src",
                                    "/Users/jeremy/Repositories/libphone/samples/helloworld"]
          }
      }
      
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          testCompile 'junit:junit:4.12'
          compile 'com.android.support:appcompat-v7:23.4.0'
      }
    • Modify MainActivity.java

      package <YOUR PACKET NAME>;
      
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import com.libphone.PhoneActivity;
      
      public class MainActivity extends PhoneActivity {
          static {
              System.loadLibrary("libphone");
          }
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
          }
      }
    • Run 'app' and have fun!

Supported platforms

  • Android 2.3+
  • iOS 5.0+

Features

  • View
    • Corner Radius
    • Border
    • Shadow
    • Animation
    • Alpha
    • Rotate
    • Pull to Refresh
    • OpenGL ES 2.0
  • Work Queue
  • Timer
  • Native Thread
  • Asset Reader

Tools

tools/phoneres.py
Generate different kinds of specific image resources which required by both platforms automatically.

tools/phonelayout.py
Generate C codes for view layout based on xml

Licensing

libphone is licensed under the MIT license.

libphone's People

Contributors

huxingyi avatar

Watchers

James Cloos avatar copper lee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.