Commit fc045ade authored by noname's avatar noname

ShareFileActivity

parent 9dd62e50
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
*/ */
package cn.garymb.ygomobile; package cn.garymb.ygomobile;
import android.app.AlertDialog;
import android.app.NativeActivity; import android.app.NativeActivity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Resources; import android.content.res.Resources;
...@@ -44,6 +42,7 @@ import cn.garymb.ygomobile.widget.EditWindowCompat; ...@@ -44,6 +42,7 @@ import cn.garymb.ygomobile.widget.EditWindowCompat;
import cn.garymb.ygomobile.widget.overlay.OverlayOvalView; import cn.garymb.ygomobile.widget.overlay.OverlayOvalView;
import cn.garymb.ygomobile.widget.overlay.OverlayView; import cn.garymb.ygomobile.widget.overlay.OverlayView;
import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_SHARE_FILE;
import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_START; import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_START;
import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_STOP; import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_STOP;
...@@ -528,21 +527,21 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -528,21 +527,21 @@ public class YGOMobileActivity extends NativeActivity implements
} }
@Override @Override
public void shareFile(final String title, final String path) { public void shareFile(final String type, final String path) {
//TODO 分享文件
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(YGOMobileActivity.this); Intent intent = new Intent(ACTION_SHARE_FILE);
builder.setTitle(title); intent.addCategory(Intent.CATEGORY_DEFAULT);
builder.setMessage(path); intent.putExtra(IrrlichtBridge.EXTRA_SHARE_TYPE, type);
builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { intent.putExtra(IrrlichtBridge.EXTRA_SHARE_FILE, path);
@Override intent.setPackage(getPackageName());
public void onClick(DialogInterface dialog, int which) { try {
dialog.dismiss(); startActivity(intent);
} } catch (Throwable e) {
}); //ignore
builder.show(); Toast.makeText(YGOMobileActivity.this, "dev error:not found activity.", Toast.LENGTH_SHORT).show();
}
} }
}); });
} }
......
...@@ -26,6 +26,13 @@ import static cn.garymb.ygomobile.utils.ByteUtils.byte2uint; ...@@ -26,6 +26,13 @@ import static cn.garymb.ygomobile.utils.ByteUtils.byte2uint;
public final class IrrlichtBridge { public final class IrrlichtBridge {
public static final String ACTION_START = "cn.garymb.ygomobile.game.start"; public static final String ACTION_START = "cn.garymb.ygomobile.game.start";
public static final String ACTION_STOP = "cn.garymb.ygomobile.game.stop"; public static final String ACTION_STOP = "cn.garymb.ygomobile.game.stop";
/**
* @see #EXTRA_SHARE_FILE
* @see #EXTRA_SHARE_TYPE
*/
public static final String ACTION_SHARE_FILE = "cn.garymb.ygomobile.game.shared.file";
public static final String EXTRA_SHARE_FILE = Intent.EXTRA_STREAM;
public static final String EXTRA_SHARE_TYPE = Intent.EXTRA_TITLE;
public static final String EXTRA_PID = "extras.mypid"; public static final String EXTRA_PID = "extras.mypid";
public static final String EXTRA_ARGV = "extras.argv"; public static final String EXTRA_ARGV = "extras.argv";
public static final String EXTRA_ARGV_TIME_OUT = "extras.argv_timeout"; public static final String EXTRA_ARGV_TIME_OUT = "extras.argv_timeout";
......
...@@ -103,6 +103,17 @@ ...@@ -103,6 +103,17 @@
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name="cn.garymb.ygomobile.ui.activities.ShareFileActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:launchMode="singleTop"
android:theme="@style/AppTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
<intent-filter>
<action android:name="cn.garymb.ygomobile.game.shared.file" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity <activity
android:name="cn.garymb.ygomobile.YGOMobileActivity" android:name="cn.garymb.ygomobile.YGOMobileActivity"
android:theme="@style/AppTheme.Game" android:theme="@style/AppTheme.Game"
......
...@@ -37,12 +37,9 @@ public class App extends GameApplication { ...@@ -37,12 +37,9 @@ public class App extends GameApplication {
initBugly(); initBugly();
} }
@Override @Override
public NativeInitOptions getNativeInitOptions() { public NativeInitOptions getNativeInitOptions() {
NativeInitOptions options = AppsSettings.get().getNativeInitOptions(); return AppsSettings.get().getNativeInitOptions();
return options;
} }
@Override @Override
......
package cn.garymb.ygomobile.ui.activities;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import cn.garymb.ygomobile.core.IrrlichtBridge;
public class ShareFileActivity extends BaseActivity{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO setContentView
doIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
private void doIntent(Intent intent){
String type = intent.getStringExtra(IrrlichtBridge.EXTRA_SHARE_TYPE);
String path = intent.getStringExtra(IrrlichtBridge.EXTRA_SHARE_FILE);
//TODO
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment