Возможность открытия сценария из файловой системы
This commit is contained in:
parent
15309af6d8
commit
a2249d130a
@ -30,7 +30,17 @@
|
||||
<activity
|
||||
android:name="com.annimon.everlastingsummer.ViewActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:label="@string/app_name" />
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data
|
||||
android:scheme="file"
|
||||
android:host="*"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.rpy" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.annimon.everlastingsummer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.*;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
@ -97,10 +100,23 @@ public final class ViewActivity extends Activity {
|
||||
names.put("odn", new Person("Одногруппник", 0xFFC0C0C0));
|
||||
names.put("mt_voice", new Person("Голос", 0xFF00EA32)); // night 0xFF00B627, sunset: 0xFF00EA32, day: 0xFF00EA32, prolog: 0xFF00EA32
|
||||
|
||||
final String name = getIntent().getStringExtra(EXTRA_NAME);
|
||||
final String scriptpath = PathResolver.script(name);
|
||||
String scriptpath = "";
|
||||
final Intent intent = getIntent();
|
||||
try {
|
||||
Parser.parse(Lexer.tokenize( IOUtil.readContents(getAssets().open(scriptpath)) ));
|
||||
InputStream stream = null;
|
||||
if (intent.hasExtra(EXTRA_NAME)) {
|
||||
scriptpath = PathResolver.script( intent.getStringExtra(EXTRA_NAME) );
|
||||
stream = getAssets().open(scriptpath);
|
||||
} else if (intent.getData() != null) {
|
||||
final Uri fileUri = intent.getData();
|
||||
scriptpath = fileUri.getPath();
|
||||
stream = getContentResolver().openInputStream(fileUri);
|
||||
} else {
|
||||
Toast.makeText(this, "Нет данных для отображения", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
Parser.parse(Lexer.tokenize( IOUtil.readContents(stream) ));
|
||||
Parser.getInstance().next();
|
||||
} catch (Exception ex) {
|
||||
Toast.makeText(this, "Ошибка при открытии файла " + scriptpath, Toast.LENGTH_LONG).show();
|
||||
|
Loading…
Reference in New Issue
Block a user