Skip to content

Commit 3db16b2

Browse files
committed
intent.getData().getPath()
1 parent 827ede7 commit 3db16b2

File tree

6 files changed

+36
-200
lines changed

6 files changed

+36
-200
lines changed

PowerFileExplorer/src/main/AndroidManifest.xml

Lines changed: 6 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -178,113 +178,8 @@
178178
<data android:scheme="zxing" android:host="scan" android:path="/" />
179179
</intent-filter>
180180

181-
<!--<intent-filter>
182-
<action android:name="android.intent.action.PICK"/>
183-
<category android:name="android.intent.category.DEFAULT" />
184-
</intent-filter>
185-
<intent-filter>
186-
<action android:name="org.openintents.action.PICK_FILE"/>
187-
<category android:name="android.intent.category.DEFAULT"/>
188-
<data android:scheme="file"/>
189-
<data android:mimeType="*/*"/>
190-
</intent-filter>
191-
<intent-filter>
192-
<action android:name="org.openintents.action.PICK_FILE"/>
193-
<category android:name="android.intent.category.DEFAULT"/>
194-
<data android:scheme="file"/>
195-
</intent-filter>
196-
<intent-filter>
197-
<action android:name="org.openintents.action.PICK_FILE"/>
198-
<category android:name="android.intent.category.DEFAULT"/>
199-
<data android:mimeType="*/*"/>
200-
</intent-filter>
201-
<intent-filter>
202-
<action android:name="org.openintents.action.PICK_FILE"/>
203-
<category android:name="android.intent.category.DEFAULT"/>
204-
</intent-filter>
205-
<intent-filter>
206-
<action android:name="org.openintents.action.PICK_DIRECTORY"/>
207-
<category android:name="android.intent.category.DEFAULT"/>
208-
<data android:scheme="file"/>
209-
</intent-filter>
210-
<intent-filter>
211-
<action android:name="org.openintents.action.PICK_DIRECTORY"/>
212-
<category android:name="android.intent.category.DEFAULT"/>
213-
</intent-filter>
214-
215-
<intent-filter>
216-
<action android:name="android.intent.action.GET_CONTENT"/>
217-
<data android:scheme="file"/>
218-
<data android:mimeType="*/*"/>
219-
<category android:name="android.intent.category.DEFAULT"/>
220-
<category android:name="android.intent.category.OPENABLE"/>
221-
</intent-filter>
222-
<intent-filter>
223-
<action android:name="android.intent.action.GET_CONTENT"/>
224-
<data android:mimeType="*/*"/>
225-
<category android:name="android.intent.category.DEFAULT"/>
226-
<category android:name="android.intent.category.OPENABLE"/>
227-
</intent-filter>
228-
<intent-filter>
229-
<action android:name="android.intent.action.GET_CONTENT"/>
230-
<data android:scheme="file"/>
231-
<category android:name="android.intent.category.DEFAULT"/>
232-
<category android:name="android.intent.category.OPENABLE"/>
233-
</intent-filter>
234-
<intent-filter>
235-
<action android:name="android.intent.action.GET_CONTENT"/>
236-
<category android:name="android.intent.category.DEFAULT"/>
237-
<category android:name="android.intent.category.OPENABLE"/>
238-
</intent-filter>-->
239-
240181
<!-- Filter for multi select feature -->
241-
<!--<intent-filter>
242-
<action android:name="org.openintents.action.MULTI_SELECT"/>
243-
<category android:name="android.intent.category.DEFAULT"/>
244-
</intent-filter>
245-
<intent-filter>
246-
<action android:name="android.intent.action.VIEW"/>
247-
<category android:name="android.intent.category.DEFAULT"/>
248-
<data android:scheme="file"/>
249-
</intent-filter>
250-
<intent-filter>
251-
<action android:name="android.intent.action.VIEW"/>
252-
<category android:name="android.intent.category.DEFAULT" />
253-
<category android:name="android.intent.category.BROWSABLE" />
254-
<data android:scheme="ftp" />
255-
<data android:scheme="file" />
256-
</intent-filter>
257-
<intent-filter>
258-
<action android:name="android.intent.action.VIEW"/>
259-
<category android:name="android.intent.category.DEFAULT" />
260-
<category android:name="android.intent.category.BROWSABLE" />
261-
<data android:scheme="file" />
262-
<data android:mimeType="inode/directory" />
263-
</intent-filter>
264-
<intent-filter>
265-
<action android:name="android.intent.action.VIEW"/>
266-
<category android:name="android.intent.category.DEFAULT"/>
267-
<data android:mimeType="vnd.android.documents/directory"/>
268-
</intent-filter>
269-
<intent-filter>
270-
<action android:name="android.intent.action.VIEW"/>
271-
<category android:name="android.intent.category.DEFAULT"/>
272-
<data android:mimeType="resource/folder" />
273-
<data android:mimeType="inode/directory" />
274-
</intent-filter>
275-
<intent-filter>
276-
<action android:name="android.intent.action.VIEW"/>
277-
<category android:name="android.intent.category.OPENABLE"/>
278-
<data android:mimeType="*/*" android:scheme="content"/>
279-
</intent-filter>
280-
<intent-filter>
281-
<action android:name="android.intent.action.VIEW"/>
282-
<category android:name="android.intent.category.DEFAULT" />
283-
<category android:name="android.intent.category.BROWSABLE" />
284-
<data android:mimeType="application/x-zip-compressed" />
285-
<data android:mimeType="application/zip" />
286-
<data android:pathPattern=".*\.zip" />
287-
</intent-filter>-->
182+
288183
<intent-filter>
289184
<action android:name="android.intent.action.VIEW"/>
290185
<action android:name="android.intent.action.OPEN_DOCUMENT_TREE" />
@@ -351,34 +246,6 @@
351246
<data android:pathPattern=".*\.zpaq"/>
352247
</intent-filter>
353248

354-
<!--<intent-filter>
355-
<action android:name="android.intent.action.SEND"/>
356-
<category android:name="android.intent.category.DEFAULT"/>
357-
<category android:name="android.intent.category.BROWSABLE"/>
358-
<data android:mimeType="*/*"/>
359-
</intent-filter>
360-
361-
<intent-filter>
362-
<action android:name="android.intent.action.SEND_MULTIPLE"/>
363-
<category android:name="android.intent.category.DEFAULT"/>
364-
<category android:name="android.intent.category.BROWSABLE"/>
365-
<data android:mimeType="*/*"/>
366-
</intent-filter>
367-
368-
<intent-filter>
369-
<action android:name="org.openintents.action.PICK_FILE"/>
370-
<action android:name="org.openintents.action.PICK_DIRECTORY"/>
371-
<action android:name="android.intent.action.PICK"/>
372-
<category android:name="android.intent.category.DEFAULT"/>
373-
<category android:name="android.intent.category.BROWSABLE"/>
374-
<category android:name="android.intent.category.OPENABLE"/>
375-
<data android:scheme="file"/>
376-
<data android:scheme="folder"/>
377-
<data android:scheme="directory"/>
378-
<data android:mimeType="resource/folder" />
379-
<data android:mimeType="inode/directory" />
380-
</intent-filter>-->
381-
382249
</activity>
383250

384251
<activity
@@ -477,11 +344,11 @@
477344
android:resource="@xml/searchable" />
478345
<intent-filter>
479346
<action android:name="android.intent.action.VIEW" />
480-
<category android:name="android.intent.category.DEFAULT" />
347+
<action android:name="android.intent.action.OPEN_DOCUMENT" />
348+
<category android:name="android.intent.category.DEFAULT" />
481349
<category android:name="android.intent.category.BROWSABLE"/>
482-
<data android:scheme="file" />
483-
<data android:mimeType="application/x-chm"/>
484-
<!--<data android:pathPattern=".*\.[cC][hH][mM]"/>-->
350+
<data android:mimeType="application/x-chm"/>
351+
<data android:pathPattern=".*\.[cC][hH][mM]"/>
485352
</intent-filter>
486353
</activity>
487354

@@ -524,6 +391,7 @@
524391
android:icon="@drawable/textpng"
525392
android:label="Text Editor"
526393
android:theme="@style/AppTheme"
394+
android:launchMode="standard"
527395
>
528396
<intent-filter>
529397
<action android:name="android.intent.action.MAIN" />

PowerFileExplorer/src/main/java/chm/cblink/nb/chmreader/CHMActivity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ protected void onCreate(Bundle savedInstanceState) {
5858
super.onCreate(savedInstanceState);
5959
setContentView(R.layout.activity_chm);
6060
Intent revIntent = getIntent();
61-
chmFilePath = URLDecoder.decode(revIntent.getDataString()).substring("file://".length());//.getStringExtra("fileName");
62-
Log.d(TAG, "chmFilePath " + chmFilePath);
61+
String dataString = revIntent.getData().getPath();
62+
chmFilePath = URLDecoder.decode(dataString);//.getStringExtra("fileName");
63+
64+
Log.d(TAG, "chmFilePath1 " + chmFilePath + ", intent " + revIntent + ", " + revIntent.getDataString());
6365
Utils.chm = null;
6466
listSite = new ArrayList<>();
6567
initView();
@@ -149,8 +151,8 @@ private void handleIntent(Intent intent) {
149151
} catch (Exception ignored) {
150152
}
151153
} else {
152-
chmFilePath = URLDecoder.decode(intent.getDataString()).substring("file://".length());//.getStringExtra("fileName");
153-
Log.d(TAG, "chmFilePath " + chmFilePath);
154+
chmFilePath = URLDecoder.decode(intent.getData().getPath());//.getStringExtra("fileName");
155+
Log.d(TAG, "chmFilePath2 " + chmFilePath + ", intent " + intent);
154156
Utils.chm = null;
155157
listSite = new ArrayList<>();
156158
initView();

PowerFileExplorer/src/main/java/net/gnu/common/view/SlidingHorizontalScroll.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ private void populateTabStrip() {
195195
final PagerAdapter adapter = mViewPager.getAdapter();
196196
final View.OnClickListener tabClickListener = new TabClickListener();
197197

198-
final int count = adapter.getCount();
198+
final boolean explorerActivity = fra.getActivity() instanceof ExplorerActivity;
199+
final int count = adapter.getCount();
199200
for (int i = 0; i < count; i++) {
200201
View tabView = null;
201202
TextView tabTitleView = null;
@@ -227,11 +228,15 @@ private void populateTabStrip() {
227228
tabTitleView.setSingleLine(true);
228229
tabView.setOnClickListener(tabClickListener);
229230

230-
tabTitleView.setTextColor(ExplorerActivity.TEXT_COLOR);
231-
231+
if (explorerActivity) {
232+
tabTitleView.setTextColor(ExplorerActivity.TEXT_COLOR);
233+
}
234+
232235
mTabStripLinearLayout.addView(tabView);
233236
}
234-
mTabStripLinearLayout.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
237+
if (explorerActivity) {
238+
mTabStripLinearLayout.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
239+
}
235240
}
236241

237242
@Override

PowerFileExplorer/src/main/java/net/gnu/explorer/SlidingTabsFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ public void addTextTab(final Intent intent, String title) {
465465

466466
mTabs.add(mTabs.size() > 1 ? pageSelected : 0, pagerItem);
467467
if (mViewPager != null) {
468+
//addFrag(main, pagerItem);
468469
pagerAdapter.notifyDataSetChanged();
469470
mViewPager.setCurrentItem(pagerAdapter.getCount() - 1);
470471
notifyTitleChange();

PowerFileExplorer/src/main/java/net/gnu/texteditor/TextEditorActivity.java

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -84,56 +84,6 @@ public void onResume() {
8484
Log.d(TAG, "onResume main=" + main);
8585
}
8686

87-
// @Override
88-
// public boolean onPrepareOptionsMenu(Menu menu) {
89-
// Log.d(TAG, "onPrepareOptionsMenu " + menu);
90-
//
91-
// MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
92-
// logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
93-
// logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);
94-
//
95-
// //main.onPrepareOptionsMenu(menu);
96-
// return super.onPrepareOptionsMenu(menu);
97-
// }
98-
99-
// @Override
100-
// public boolean onOptionsItemSelected(MenuItem item) {
101-
// switch(item.getItemId()) {
102-
// case R.id.menu_toggle_log:
103-
// mLogShown = !mLogShown;
104-
// ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
105-
// if (mLogShown) {
106-
// output.setVisibility(View.VISIBLE);
107-
// output.setDisplayedChild(0);
108-
// } else {
109-
// output.setVisibility(View.GONE);//.setDisplayedChild(0);
110-
// }
111-
// supportInvalidateOptionsMenu();
112-
// return true;
113-
// }
114-
// return super.onOptionsItemSelected(item);
115-
// }
116-
117-
/** Create a chain of targets that will receive log data */
118-
// @Override
119-
// public void initializeLogging() {
120-
// // Wraps Android's native log framework.
121-
// LogWrapper logWrapper = new LogWrapper();
122-
// // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
123-
// com.free.common.logger.Log.setLogNode(logWrapper);
124-
//
125-
// // Filter strips out everything except the message text.
126-
// MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
127-
// logWrapper.setNext(msgFilter);
128-
//
129-
// // On screen logging via a fragment with a TextView.
130-
// LogFragment logFragment = (LogFragment) getSupportFragmentManager()
131-
// .findFragmentById(R.id.log_fragment);
132-
// msgFilter.setNext(logFragment.getLogView());
133-
//
134-
// Log.d(TAG, "Ready");
135-
// }
136-
13787
public void quit() {
13888
Log.d(TAG, "quit " + main);
13989
TextFrag.saved = 0;
@@ -147,7 +97,7 @@ public void quit() {
14797

14898
@Override
14999
protected void onNewIntent(Intent intent) {
150-
Log.d(TAG, "onNewIntent " + intent + ", " + intent.getData().getLastPathSegment());
100+
Log.d(TAG, "onNewIntent " + intent + ", " + intent.getData());
151101
super.onNewIntent(intent);
152102
//m.onNewIntent(intent);
153103
//intent = getIntent();

PowerFileExplorer/src/main/java/net/gnu/texteditor/TextFrag.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,12 +2709,22 @@ void applyBootSetting() {
27092709

27102710
@Override
27112711
public void updateColor(View rootView) {
2712-
getView().setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
2713-
mEditor.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
2714-
mEditor.setTextColor(ExplorerActivity.TEXT_COLOR);
27152712
if (!(fragActivity instanceof TextEditorActivity)) {
2713+
getView().setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
2714+
mEditor.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
2715+
mEditor.setTextColor(ExplorerActivity.TEXT_COLOR);
27162716
mToolbarBase.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
27172717
mToolbar.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND);
2718+
2719+
int n = mToolbar.getChildCount();
2720+
for (int i = 0; i < n; i++) {
2721+
View childAt = mToolbar.getChildAt(i);
2722+
if (childAt instanceof ImageView) {
2723+
((ImageView)childAt).setColorFilter(ExplorerActivity.TEXT_COLOR, PorterDuff.Mode.SRC_IN);
2724+
} else if (childAt instanceof Button) {
2725+
((Button)childAt).setTextColor(ExplorerActivity.TEXT_COLOR);
2726+
}
2727+
}
27182728
}
27192729
}
27202730

0 commit comments

Comments
 (0)