Giter VIP home page Giter VIP logo

libphone's Introduction

Overview

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.

Note: This project is still in the very early stage, NOT suggest used in product environment, because the api is not stable and may be changed in the future. The beta version will be released in a few weeks, from that point, the api will be stable.

Contributing

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

Screenshoots

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 15
                  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")
              CFlags.add("-I/Users/jeremy/Repositories/libphone/samples/ratchet")
              ldLibs.add("log")
          }
      
          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!

Features

  • View
    • Corner Radius
    • Border
    • Shadow
    • Animation
    • Alpha
    • Rotate
    • Pull to Refresh
  • Work Queue
  • Timer

(More functions are under heavy development.)

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

 avatar  avatar  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.