Skip to content

Commit

Permalink
* [all] restore android merge to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
luics committed May 10, 2016
1 parent cff558b commit c4e97d5
Show file tree
Hide file tree
Showing 1,153 changed files with 38,108 additions and 12,218 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FORMAT
* `*` update or bugfix
* `-` remove
* `{module}`
* Including: android, ios, jsfm, html5, doc, website, example, test, all
* Including: android, ios, jsfm, html5, component, doc, website, example, test, all

for example:

Expand Down
Empty file modified DO_NOT_FORK_TO_PUBLIC_REPO
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified NOTICE
100755 → 100644
Empty file.
83 changes: 24 additions & 59 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,48 @@

Weex is currently in Pre-release Stage.

We agrees that you may discuss technical information about Weex, except that you may not fork Weex to public repository , write public reviews or post screen shots using information from current repository(https://github.com/alibaba/weex) , redistribute weex within any form.
We agree that you may discuss technical information about Weex, except that you may not fork Weex to public repository , write public reviews or post screen shots using information from current repository(https://github.com/alibaba/weex) , redistribute weex within any form.


> A framework for building Mobile cross-platform UI.
Support Android 4.1 (API 16) and iOS soon. See [Weex website](http://alibaba.github.io/weex/) for more information.

## Meet
## Meet Weex

* Install [Android Playground](http://g.tbcdn.cn/ali-wireless-h5/res/0.0.9/playground.apk).
* [Install Playground](http://alibaba.github.io/weex/download.html).

<img src="http://gtms03.alicdn.com/tps/i3/TB1uH3EMpXXXXcmXFXXdtp1PXXX-476-476.png" width="160" height="160" >
## Use Weex

## Use

* See [Tutorial](http://alibaba.github.io/weex/doc/tutorial).
* See [Weex Documentation](http://alibaba.github.io/weex/doc) for more information.
* See [Tutorial](https://github.com/alibaba/weex/blob/dev/doc/tutorial.md).
* See [Weex Documentation](https://github.com/alibaba/weex/blob/dev/doc/INSTALL.md) for more information.

### Android

0. Prerequisites
0. Install [Node.js](http://nodejs.org/) 4.0+
0. `npm install` to install project
0. Under project root
0. `npm install`, install project
0. `./start`
0. Install [Android Environment](http://developer.android.com/training/basics/firstapp/index.html)
0. Run playground
0. `npm run serve`
0. In Android Studio
0. Open `android/playground`
0. In `app/java/com.alibaba.weex/WXMainActivity`, modify `CURRENT_IP` to your local IP
0. Click <img src="http://gtms04.alicdn.com/tps/i4/TB1wCcqMpXXXXakXpXX3G7tGXXX-34-44.png" height="16" > (`Run` button)
0. Add an example
0. `npm run watch`
0. In `examples`, add a file `newExample.we`
0. In `examples/index.we`, add an item `{name: 'newExample', title: 'New Example'}` for array `data.cases`
0. Run playground, In Android Studio
0. Open `android/playground`
0. In `app/java/com.alibaba.weex/WXMainActivity`, modify `CURRENT_IP` to your local IP
0. Click <img src="http://gtms04.alicdn.com/tps/i4/TB1wCcqMpXXXXakXpXX3G7tGXXX-34-44.png" height="16" > (`Run` button)
0. [Add an example](./examples/README.md#add-an-example)

## Scripts

**clean `*.js` in the folders of `examples/build` and `test/build`**
```shell
npm run clean
```

**transform `*.we` in the folders of `examples` & `test`**
```shell
npm run transform
```

**build js-framework and h5-render**
```shell
npm run build
```

**copy the builded files to `playground`**
```shell
npm run copy
```

**npm run clean && npm run build**
```shell
npm run dev
```

**will run a file server at `12581` port**
```shell
npm run serve
```

**will run a watcher for `*.we` changed**
```shell
npm run watch
```

**will run test under js-framework and h5-render**
```shell
npm run ci
```
See [SCRIPTS.md](SCRIPTS.md) for more information.

## For Windows

Please install [Git for Windows](https://git-scm.com/download/win) or [Cygwin](https://www.cygwin.com/).

## FAQ

See [FAQ](./doc/faq.md) for more information.

## Contributing

See [Weex Contributing Guide](./CONTRIBUTING.md).
See [Weex Contributing Guide](./CONTRIBUTING.md) for more information.
52 changes: 52 additions & 0 deletions SCRIPTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Scripts

There are several scripts for end-user and developer.

## For end-user

**clean `*.js` in `examples/build` and `test/build` folders**
```shell
npm run clean
```

**create `.we` file(run `npm run create -- -h` for help)**
```shell
npm run create -- [name] -o [directory]
```

**transform `*.we` in `examples` and `test` folders**
```shell
npm run transform
```

**npm run clean && npm run transform**
```shell
npm run dev
```

**run a file server at `12580` port**
```shell
npm run serve
```

**run a watcher for `*.we` changed**
```shell
npm run watch
```

## For SDK Developer

**build js-framework and h5-render**
```shell
npm run build
```

**run test under js-framework and h5-render**
```shell
npm run ci
```

**copy the built files to `playground`**
```shell
npm run copy
```
Empty file modified android/.gitignore
100755 → 100644
Empty file.
Empty file modified android/playground/LICENSE
100755 → 100644
Empty file.
Empty file modified android/playground/NOTICE
100755 → 100644
Empty file.
Empty file modified android/playground/README.md
100755 → 100644
Empty file.
Empty file modified android/playground/app/build.gradle
100755 → 100644
Empty file.
Empty file modified android/playground/app/proguard-rules.pro
100755 → 100644
Empty file.
Empty file.
23 changes: 8 additions & 15 deletions ...st/java/com/alibaba/weex/util/Falcon.java → ...oidTest/java/com/alibaba/weex/Falcon.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.alibaba.weex.util;
package com.alibaba.weex;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Build;
import android.os.Looper;
Expand Down Expand Up @@ -110,20 +109,15 @@ private static Bitmap takeBitmapUnchecked(Activity activity) throws InterruptedE
int actionBarHeight = ScreenShot.getActionBarHeight(activity);

View main = activity.getWindow().getDecorView();
int mainWidth = main.getWidth();
int mainHeight = main.getHeight();
// Bitmap bitmapMain = main.getDrawingCache();
//// final Bitmap bitmap = Bitmap.createBitmap(main.getWidth(), main.getHeight(), ARGB_8888);
// // 去掉标题栏
// final Bitmap bitmap = Bitmap.createBitmap(bitmapMain, 0, statusBarHeight + actionBarHeight, main.getWidth(),
// main.getHeight() - statusBarHeight - actionBarHeight);
// main.destroyDrawingCache();

int baseWidth = 750;
float widthScale = ((float) baseWidth) / mainWidth;

// 新建立矩阵 按照宽度缩放因子自适应缩放
Matrix matrix = new Matrix();
matrix.postScale(widthScale, widthScale);

Bitmap bitmap1 = Bitmap.createBitmap(main.getWidth(), main.getHeight(), ARGB_8888);
final Bitmap bitmap = Bitmap.createBitmap(bitmap1, 0, statusBarHeight + actionBarHeight,
mainWidth, mainHeight - statusBarHeight - actionBarHeight, matrix, true);

final Bitmap bitmap = Bitmap.createBitmap(main.getWidth(), main.getHeight(), ARGB_8888);

// We need to do it in main thread
if (Looper.myLooper() == Looper.getMainLooper()) {
Expand Down Expand Up @@ -171,7 +165,6 @@ private static void drawRootToBitmap(ViewRootData config, Bitmap bitmap) {
private static void writeBitmap(Bitmap bitmap, File toFile) throws IOException {
OutputStream outputStream = null;
try {

outputStream = new BufferedOutputStream(new FileOutputStream(toFile));
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
}
Expand Down
39 changes: 18 additions & 21 deletions ...ava/com/alibaba/weex/util/ScreenShot.java → ...est/java/com/alibaba/weex/ScreenShot.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.alibaba.weex.util;
package com.alibaba.weex;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Build;
import android.os.Environment;
Expand Down Expand Up @@ -34,22 +33,11 @@ private static Bitmap takeScreenShot(Activity activity) {
int width = activity.getWindowManager().getDefaultDisplay().getWidth();
int height = activity.getWindowManager().getDefaultDisplay().getHeight();

int baseWidth = 750;
// int baseHeight = height;

// 计算缩放因子
// float heightScale = ((float) baseHeight) / height;
float widthScale = ((float) baseWidth) / width;

// 新建立矩阵 按照宽度缩放因子自适应缩放
Matrix matrix = new Matrix();
matrix.postScale(widthScale, widthScale);

int actionBarHeight = getActionBarHeight(activity);
Log.e("actionBarHeight==", "actionBarHeight==" + actionBarHeight);

Bitmap b = Bitmap.createBitmap(bitmap, 0, statusBarHeight + actionBarHeight, width,
height - statusBarHeight - actionBarHeight, matrix, true);
height - statusBarHeight - actionBarHeight);
view.destroyDrawingCache();
return b;
}
Expand Down Expand Up @@ -103,11 +91,7 @@ public static void saveToSD(Bitmap bmp, String dirName,String fileName) throws I
}

public static void shoot(Activity activity, String pathName) throws IOException {

if(SdCardHelper.isHasSdcard()){
ScreenShot.saveToSD(ScreenShot.takeScreenShot(activity), SdCardHelper.SDCardRoot + "WeexTest/ScreenShot/", pathName /*+System.currentTimeMillis()*/ + ".png");

}
ScreenShot.saveToSD(ScreenShot.takeScreenShot(activity), "sdcard/WeexTest/ScreenShot/", pathName /*+System.currentTimeMillis()*/ + ".png");

}

Expand All @@ -120,21 +104,24 @@ public static void takeScreenShotIncludeDialog(Activity activity, String file){
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED)) {

File dir = new File(SdCardHelper.SDCardRoot +"WeexTest/ScreenShot/");
File dir = new File("sdcard/WeexTest/ScreenShot/");
if(!dir.exists()){
dir.mkdirs();
}

File filePic = new File(SdCardHelper.SDCardRoot + "WeexTest/ScreenShot/"+ file + ".png");

File filePic = new File("sdcard/WeexTest/ScreenShot/"+ file);
if (!filePic.exists()) {
try {
filePic.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}

Falcon.takeScreenshot(activity, filePic);


}

}
Expand Down Expand Up @@ -167,6 +154,13 @@ else if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv,
}

public static int getStatusBarHeight1(Activity activity){
// Rect rectgle= new Rect();
// Window window= activity.getWindow();
// window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
// int StatusBarHeight= rectgle.top;
// int contentViewTop=
// window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
// int TitleBarHeight= contentViewTop - StatusBarHeight;
int result = 0;
int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
Expand All @@ -176,6 +170,7 @@ public static int getStatusBarHeight1(Activity activity){
Log.e("StatusBarHeight==", "StatusBar Height= " + result);

return result;
// return StatusBarHeight;
}
public static int getStatusBarHeight(Activity activity) {
int result = 0;
Expand All @@ -194,6 +189,8 @@ public static int getStatusBarHeight(Activity activity) {
int result4 = display.getHeight() - v.getHeight();

Log.e("StatusBarHeight==", "result1== " + result1 +" result2 = " + result2 + "result3=" + result3 + "result4=" +result4 ) ;


}
return result;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.weex.util;
package com.alibaba.weex;

import android.app.Activity;
import android.view.View;
Expand Down
Empty file.
Loading

0 comments on commit c4e97d5

Please sign in to comment.