Skip to content

Commit

Permalink
add open file intent filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ToDou committed Nov 21, 2016
1 parent ea1900f commit 23bae01
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ gen/

# Local configuration file (sdk path, etc)
local.properties
gradle.properties
keystore.properties

### Mac
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
android:name=".ui.activity.CodeReadActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/title_activity_code_read"
android:theme="@style/Theme.CodeReader.NoActionBar"/>
android:theme="@style/Theme.CodeReader.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:scheme="content" />
<data android:scheme="file" />
</intent-filter>

</activity>
<activity
android:name="com.loopeer.directorychooser.DirectoryFileChooserActivity"
android:theme="@style/Theme.CodeReader.NoActionBar"/>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/loopeer/codereader/model/Repo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public static Repo parse(FileNod node) {
return result;
}

public Repo(String name, String absolutePath, boolean isFolder) {
this.name = name;
this.absolutePath = absolutePath;
this.isFolder = isFolder;
}

public DirectoryNode toDirectoryNode() {
DirectoryNode node = new DirectoryNode();
node.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ private void parseIntent(Bundle savedInstanceState) {
}
Intent intent = getIntent();
Repo repo = (Repo) intent.getSerializableExtra(Navigator.EXTRA_REPO);
if (repo == null) {
String openFilePath = intent.getData().getPath();
String[] mids = openFilePath.split("/");
String name = mids[mids.length - 1];
repo = new Repo(name, openFilePath, false);
repo.id = String.valueOf(CoReaderDbHelper.getInstance(this).insertRepo(repo));
}
CoReaderDbHelper.getInstance(this).updateRepoLastModify(Long.valueOf(repo.id)
, System.currentTimeMillis());
mDirectoryNode = repo.toDirectoryNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ private void setupToolbar() {
}

private void openFile() {
if (mCodeContentLoader == null) return;
mCodeContentLoader.showProgress();
if (mWebCodeRead == null) {
return;
}
mWebCodeRead.clearHistory();
if (mNode == null) {
if (mOpenFileAfterLoadFinish)
Expand Down Expand Up @@ -169,7 +167,6 @@ private void openImageFile() {
public void openFile(DirectoryNode node) {
mOpenFileAfterLoadFinish = true;
mNode = node;
if (!isVisible()) return;
openFile();
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.3.0-alpha1'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.squareup.sqldelight:gradle-plugin:0.4.4'
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
target_sdk_version=24
min_sdk_version=14
build_tools_version=24.0.0
build_tools_version=25.0.0
compile_sdk_version=24
version_code=8
version_code=9
version_name=1.0.2

support_version=24.1.1
support_version=25.0.1
butterknife_version=8.2.1
markdownj=0.4
retrofit=2.1.0
Expand Down

0 comments on commit 23bae01

Please sign in to comment.