Skip to content

Commit

Permalink
Android: 1.0.3 released
Browse files Browse the repository at this point in the history
- Custom navigator module
- Remove shake listener
  • Loading branch information
acathur committed Sep 9, 2017
1 parent 6676e04 commit 4cdbcae
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 109 deletions.
4 changes: 2 additions & 2 deletions platforms/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.instapp.natex"
minSdkVersion 15
targetSdkVersion 23
versionCode 7
versionName "1.0.2"
versionCode 8
versionName "1.0.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk{
abiFilters "x86"
Expand Down
2 changes: 1 addition & 1 deletion platforms/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<action android:name="com.instapp.natex.protocol.openurl"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="com.taobao.android.intent.category.WEEX"/>
<category android:name="com.instapp.natex.android.intent.category.WEEX"/>

<data android:scheme="http"/>
<data android:scheme="https"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {

Uri uri = Uri.parse(builder.toString());
intent.setData(uri);
intent.addCategory("com.taobao.android.intent.category.WEEX");
intent.addCategory("com.instapp.natex.android.intent.category.WEEX");
intent.setPackage(getPackageName());
startActivity(intent);
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import android.app.Application;

import com.instapp.natex.ApiKey;
import com.instapp.natex.commons.adapter.ImageAdapter;
import com.instapp.natex.commons.util.AppConfig;
import com.instapp.natex.extend.module.WXEventModule;
import com.instapp.natex.extend.module.EventModule;
import com.instapp.natex.extend.module.NavigatorModule;
import com.instapp.natex.pluginmanager.PluginManager;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.taobao.weex.InitConfig;
Expand Down Expand Up @@ -35,7 +35,8 @@ public void onCreate() {
AVAnalytics.enableCrashReport(this, true);

try {
WXSDKEngine.registerModule("event", WXEventModule.class);
WXSDKEngine.registerModule("event", EventModule.class);
WXSDKEngine.registerModule("navigator", NavigatorModule.class);
} catch (WXException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package com.instapp.natex;

import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.SensorManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
Expand All @@ -16,15 +11,11 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.instapp.natex.commons.AbsWeexActivity;
import com.instapp.natex.commons.util.CommonUtils;
import com.instapp.natex.commons.util.DevOptionHandler;
import com.instapp.natex.commons.util.ShakeDetector;
import com.instapp.natex.constants.Constants;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
Expand All @@ -35,20 +26,13 @@
import com.taobao.weex.ui.component.NestedContainer;
import com.taobao.weex.utils.WXSoInstallMgrSdk;

import java.util.LinkedHashMap;


public class WXPageActivity extends AbsWeexActivity implements
WXSDKInstance.NestedInstanceInterceptor {

private static final String TAG = "WXPageActivity";
private ProgressBar mProgressBar;
private TextView mTipView;
private AlertDialog mDevOptionsDialog;
private boolean mIsShakeDetectorStarted = false;
private boolean mIsDevSupportEnabled = WXEnvironment.isApkDebugable();
private final LinkedHashMap<String, DevOptionHandler> mCustomDevOptions = new LinkedHashMap<>();
private ShakeDetector mShakeDetector;

@Override
public void onCreateNestInstance(WXSDKInstance instance, NestedContainer container) {
Expand All @@ -63,16 +47,6 @@ protected void onCreate(Bundle savedInstanceState) {
mProgressBar = (ProgressBar) findViewById(R.id.progress);
mTipView = (TextView) findViewById(R.id.index_tip);

if (mIsDevSupportEnabled && !CommonUtils.hasHardwareMenuKey()) {
mShakeDetector = new ShakeDetector(new ShakeDetector.ShakeListener() {

@Override
public void onShake() {
showDevOptionsDialog();
}
});
}

Uri uri = getIntent().getData();
Bundle bundle = getIntent().getExtras();

Expand Down Expand Up @@ -106,19 +80,11 @@ public void onShake() {
@Override
public void onResume() {
super.onResume();
if (!mIsShakeDetectorStarted && mShakeDetector != null) {
mShakeDetector.start((SensorManager) getApplicationContext().getSystemService(Context.SENSOR_SERVICE));
mIsShakeDetectorStarted = true;
}
}

@Override
public void onPause() {
super.onPause();
if (mIsShakeDetectorStarted && mShakeDetector != null) {
mShakeDetector.stop();
mIsShakeDetectorStarted = false;
}
}

private String getUrl(Uri uri) {
Expand Down Expand Up @@ -249,72 +215,5 @@ private void handleDecodeInternally(String code) {
@Override
public void onDestroy() {
super.onDestroy();
if (mShakeDetector != null) {
mShakeDetector.stop();
}
}

public void showDevOptionsDialog() {
if (mDevOptionsDialog != null || !mIsDevSupportEnabled || ActivityManager.isUserAMonkey()) {
return;
}
LinkedHashMap<String, DevOptionHandler> options = new LinkedHashMap<>();
/* register standard options */
options.put(
getString(R.string.scan_qr_code), new DevOptionHandler() {
@Override
public void onOptionSelected() {
IntentIntegrator integrator = new IntentIntegrator(WXPageActivity.this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setPrompt("Scan a barcode");
//integrator.setCameraId(0); // Use a specific camera of the device
integrator.setBeepEnabled(true);
integrator.setOrientationLocked(false);
integrator.setBarcodeImageEnabled(true);
integrator.setPrompt(getString(R.string.capture_qrcode_prompt));
integrator.initiateScan();
}
});
options.put(
getString(R.string.page_refresh), new DevOptionHandler() {
@Override
public void onOptionSelected() {
createWeexInstance();
renderPage();
}
});

if (mCustomDevOptions.size() > 0) {
options.putAll(mCustomDevOptions);
}

final DevOptionHandler[] optionHandlers = options.values().toArray(new DevOptionHandler[0]);

mDevOptionsDialog =
new AlertDialog.Builder(WXPageActivity.this)
.setItems(
options.keySet().toArray(new String[0]),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
optionHandlers[which].onOptionSelected();
mDevOptionsDialog = null;
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mDevOptionsDialog = null;
}
})
.create();
mDevOptionsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mDevOptionsDialog.show();
}

public void addCustomDevOption(
String optionName,
DevOptionHandler optionHandler) {
mCustomDevOptions.put(optionName, optionHandler);
}
}
1 change: 1 addition & 0 deletions platforms/android/appframework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
provided 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.fresco:fresco:0.10.0'
compile 'com.alibaba:fastjson:1.2.38'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.javassist:javassist:3.20.0-GA'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.taobao.weex.common.WXModuleAnno;


public class WXEventModule extends WXModule {
public class EventModule extends WXModule {

private static final String WEEX_CATEGORY = "com.taobao.android.intent.category.WEEX";

Expand Down
Loading

0 comments on commit 4cdbcae

Please sign in to comment.