Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/jellybean' into ics
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike C committed Nov 23, 2012
2 parents 938cb2f + 4ab0701 commit 6e6ea76
Show file tree
Hide file tree
Showing 15 changed files with 1,317 additions and 180 deletions.
20 changes: 18 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,26 @@
android:name=".activities.EditorActivity"
android:label="@string/editor"
android:configChanges="orientation|keyboardHidden|screenSize"
android:icon="@drawable/ic_launcher_editor"
android:exported="false">
android:icon="@drawable/ic_launcher_editor">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />

<data android:scheme="file" />
<data android:mimeType="text/*" />
<data android:mimeType="application/javascript" />
<data android:mimeType="application/json" />
<data android:mimeType="application/xhtml+xml" />
<data android:mimeType="application/xml" />
<data android:mimeType="application/x-msdownload" />
<data android:mimeType="application/x-csh" />
<data android:mimeType="application/x-sh" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.cyanogenmod.filemanager.category.INTERNAL_VIEWER" />
<category android:name="com.cyanogenmod.filemanager.category.EDITOR" />
</intent-filter>
Expand Down
690 changes: 690 additions & 0 deletions res/values-el/strings.xml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,13 @@
<!-- Actions Dialog * Menu * Deselect -->
<string name="actions_menu_deselect">Elvet</string>
<!-- Actions Dialog * Menu * Paste selection -->
<string name="actions_menu_paste_selection">Kijelölés beillesztése</string>
<string name="actions_menu_paste_selection">Kijelöltek beillesztése</string>
<!-- Actions Dialog * Menu * Move selection -->
<string name="actions_menu_move_selection">Kijelölés mozgatása</string>
<string name="actions_menu_move_selection">Kijelöltek mozgatása</string>
<!-- Actions Dialog * Menu * Delete selection -->
<string name="actions_menu_delete_selection">Kijelölés törlése</string>
<string name="actions_menu_delete_selection">Kijelöltek törlése</string>
<!-- Actions Dialog * Menu * Compress selection -->
<string name="actions_menu_compress_selection">Kijelölés tömörítése</string>
<string name="actions_menu_compress_selection">Kijelöltek tömörítése</string>
<!-- Actions Dialog * Menu * Create link -->
<string name="actions_menu_create_link">Link létrehozása</string>
<!-- Actions Dialog * Menu * Open -->
Expand Down Expand Up @@ -555,7 +555,7 @@
<!-- Preferences * General * Use flinger detection -->
<string name="pref_use_flinger">Kézmozdulatok használata</string>
<!-- Preferences * General * Use flinger detection summary -->
<string name="pref_use_flinger_summary">A balról jobbra elhúzott mozdulat használata a fájl vagy mappa törléshez.</string>
<string name="pref_use_flinger_summary">Fájlok és mappák törlése jobbra történő elhúzással.</string>
<!-- Preferences * General * Advanced settings category -->
<string name="pref_general_advanced_settings_category">Speciális</string>
<!-- Preferences * General * Access mode -->
Expand All @@ -575,7 +575,7 @@
<!-- Preferences * Search * Results category -->
<string name="pref_search_results_category">Találatok</string>
<!-- Preferences * Search * Show relevance widget -->
<string name="pref_show_relevance_widget">Vonatkozási modul megjelenítése</string>
<string name="pref_show_relevance_widget">Relevancia modul megjelenítése</string>
<!-- Preferences * Search * Highlight search terms -->
<string name="pref_highlight_terms">Keresési feltételek kiemelése</string>
<!-- Preferences * Search * Sort results mode -->
Expand Down
1 change: 1 addition & 0 deletions res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
<string name="pref_remove_saved_search_terms">Eliminaţi termenii de căutare salvaţi</string>
<string name="pref_remove_saved_search_terms_summary">Apăsaţi pentru eliminarea tuturor termenilor de căutare salvaţi</string>
<string name="pref_remove_saved_search_terms_msg">Toţi termenii de căutare salvaţi au fost eliminaţi.</string>
<string name="pref_themes">Teme</string>
<string name="pref_themes_selection_category">Teme</string>
<string name="pref_themes_set_theme">Aplicaţi tema</string>
<string name="pref_themes_no_preview">Nici o previzualizare\ndisponibilă</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ private void readFile() {
this, R.string.editor_invalid_file_msg, Toast.LENGTH_SHORT);
return;
}
this.mReadOnly = (action.compareTo(Intent.ACTION_VIEW) == 0);
// This var should be set depending on ACTION_VIEW or ACTION_EDIT action, but for
// better compatibility, IntentsActionPolicy use always ACTION_VIEW, so we have
// to ignore this check here
this.mReadOnly = false;

// Read the intent and check that is has a valid request
String path = getIntent().getData().getPath();
Expand Down
107 changes: 101 additions & 6 deletions src/com/cyanogenmod/filemanager/activities/PickerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
Expand All @@ -45,6 +46,7 @@
import com.cyanogenmod.filemanager.adapters.CheckableListAdapter.CheckableItem;
import com.cyanogenmod.filemanager.console.ConsoleBuilder;
import com.cyanogenmod.filemanager.model.FileSystemObject;
import com.cyanogenmod.filemanager.preferences.DisplayRestrictions;
import com.cyanogenmod.filemanager.preferences.FileManagerSettings;
import com.cyanogenmod.filemanager.preferences.Preferences;
import com.cyanogenmod.filemanager.ui.ThemeManager;
Expand All @@ -60,7 +62,9 @@

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* The activity for allow to use a {@link NavigationView} like, to pick a file from other
Expand All @@ -84,7 +88,22 @@ public void onReceive(Context context, Intent intent) {
}
};

private String mMimeType;
// The result code
private static final int RESULT_CROP_IMAGE = 1;

// The component that holds the crop operation. We use Gallery3d because we are confidence
// of his input parameters
private static final ComponentName CROP_COMPONENT =
new ComponentName(
"com.android.gallery3d", //$NON-NLS-1$
"com.android.gallery3d.app.CropImage"); //$NON-NLS-1$

// Gallery crop editor action
private static final String ACTION_CROP = "com.android.camera.action.CROP"; //$NON-NLS-1$

// Extra data for Gallery CROP action
private static final String EXTRA_CROP = "crop"; //$NON-NLS-1$

private FileSystemObject mFso; // The picked item
private AlertDialog mDialog;
private Handler mHandler;
Expand Down Expand Up @@ -151,14 +170,38 @@ public void onConfigurationChanged(Configuration newConfig) {
private void init() {
// Check that call has a valid request (GET_CONTENT a and mime type)
String action = getIntent().getAction();
this.mMimeType = getIntent().getType();
if (action.compareTo(Intent.ACTION_GET_CONTENT.toString()) != 0 ||
this.mMimeType == null) {

if (action.compareTo(Intent.ACTION_GET_CONTENT.toString()) != 0) {
setResult(Activity.RESULT_CANCELED);
finish();
return;
}

// Display restrictions
Map<DisplayRestrictions, Object> restrictions = new HashMap<DisplayRestrictions, Object>();
//- Mime/Type restriction
String mimeType = getIntent().getType();
if (mimeType != null) {
restrictions.put(DisplayRestrictions.MIME_TYPE_RESTRICTION, mimeType);
}
// Other restrictions
Bundle extras = getIntent().getExtras();
if (extras != null) {
//-- File size
if (extras.containsKey(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES)) {
long size =
extras.getLong(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES);
restrictions.put(DisplayRestrictions.SIZE_RESTRICTION, Long.valueOf(size));
}
//-- Local filesystems only
if (extras.containsKey(Intent.EXTRA_LOCAL_ONLY)) {
boolean localOnly = extras.getBoolean(Intent.EXTRA_LOCAL_ONLY);
restrictions.put(
DisplayRestrictions.LOCAL_FILESYSTEM_ONLY_RESTRICTION,
Boolean.valueOf(localOnly));
}
}

// Create or use the console
if (!initializeConsole()) {
// Something when wrong. Display a message and exit
Expand Down Expand Up @@ -187,7 +230,7 @@ public void run() {
// Navigation view
this.mNavigationView =
(NavigationView)this.mRootView.findViewById(R.id.navigation_view);
this.mNavigationView.setMimeType(this.mMimeType);
this.mNavigationView.setRestrictions(restrictions);
this.mNavigationView.setOnFilePickedListener(this);
this.mNavigationView.setBreadcrumb(breadcrumb);

Expand Down Expand Up @@ -265,16 +308,68 @@ private boolean initializeConsole() {
return false;
}

/**
* {@inheritDoc}
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case RESULT_CROP_IMAGE:
// Return what the callee activity returns
setResult(resultCode, data);
finish();
return;

default:
break;
}

// The response is not understood
Log.w(TAG,
String.format(
"Ignore response. requestCode: %s, resultCode: %s, data: %s", //$NON-NLS-1$
Integer.valueOf(requestCode),
Integer.valueOf(resultCode),
data));
DialogHelper.showToast(this, R.string.msgs_operation_failure, Toast.LENGTH_SHORT);
}

/**
* {@inheritDoc}
*/
@Override
public void onDismiss(DialogInterface dialog) {
if (this.mFso != null) {
File src = new File(this.mFso.getFullPath());
if (getIntent().getExtras() != null) {
// Some AOSP applications use the gallery to edit and crop the selected image
// with the Gallery crop editor. In this case pass the picked file to the
// CropActivity with the requested parameters
// Expected result is on onActivityResult
Bundle extras = getIntent().getExtras();
String crop = extras.getString(EXTRA_CROP);
if (Boolean.parseBoolean(crop)) {
// We want to use the Gallery3d activity because we know about it, and his
// parameters. At least we have a compatible one.
Intent intent = new Intent(ACTION_CROP);
if (getIntent().getType() != null) {
intent.setType(getIntent().getType());
}
intent.setData(Uri.fromFile(src));
intent.putExtras(extras);
intent.setComponent(CROP_COMPONENT);
startActivityForResult(intent, RESULT_CROP_IMAGE);
return;
}
}

// Return the picked file, as expected (this activity should fill the intent data
// and return RESULT_OK result)
Intent result = new Intent();
result.setData(Uri.fromFile(new File(this.mFso.getFullPath())));
result.setData(Uri.fromFile(src));
setResult(Activity.RESULT_OK, result);
finish();

} else {
cancel();
}
Expand Down
16 changes: 8 additions & 8 deletions src/com/cyanogenmod/filemanager/commands/java/ReadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import com.cyanogenmod.filemanager.console.InsufficientPermissionsException;
import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory;

import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileReader;
import java.io.FileInputStream;

/**
* A class for read a file.
Expand Down Expand Up @@ -121,12 +121,12 @@ public void execute()
*/
private void read(File file) {
// Read the file
BufferedReader br = null;
BufferedInputStream bis = null;
try {
br = new BufferedReader(new FileReader(file), getBufferSize());
bis = new BufferedInputStream(new FileInputStream(file), getBufferSize());
int read = 0;
char[] data = new char[getBufferSize()];
while ((read = br.read(data, 0, getBufferSize())) != -1) {
byte[] data = new byte[getBufferSize()];
while ((read = bis.read(data, 0, getBufferSize())) != -1) {
if (this.mAsyncResultListener != null) {
byte[] readData = new byte[read];
System.arraycopy(data, 0, readData, 0, read);
Expand Down Expand Up @@ -154,8 +154,8 @@ private void read(File file) {

} finally {
try {
if (br != null) {
br.close();
if (bis != null) {
bis.close();
}
} catch (Throwable _throw) {/**NON BLOCK**/}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2012 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.cyanogenmod.filemanager.preferences;

/**
* An enumeration of the restrictions that can be applied when displaying list of files.
*/
public enum DisplayRestrictions {
/**
* Restriction for display only files with the category.
*/
CATEGORY_TYPE_RESTRICTION,
/**
* Restriction for display only files with the mime/type.
*/
MIME_TYPE_RESTRICTION,
/**
* Restriction for display only files with a size lower than the specified
*/
SIZE_RESTRICTION,
/**
* Restriction for display only files from the local file system. Avoid remote files.
*/
LOCAL_FILESYSTEM_ONLY_RESTRICTION
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.cyanogenmod.filemanager.model.Query;
import com.cyanogenmod.filemanager.model.SearchResult;
import com.cyanogenmod.filemanager.preferences.AccessMode;
import com.cyanogenmod.filemanager.preferences.DisplayRestrictions;
import com.cyanogenmod.filemanager.preferences.FileManagerSettings;
import com.cyanogenmod.filemanager.preferences.NavigationSortMode;
import com.cyanogenmod.filemanager.preferences.ObjectStringIdentifier;
Expand All @@ -40,7 +41,9 @@

import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* A class for paint the resulting file system object of a search.
Expand Down Expand Up @@ -112,11 +115,17 @@ protected Boolean doInBackground(Object... params) {
boolean chRooted =
FileManagerApplication.getAccessMode().compareTo(AccessMode.SAFE) == 0;

// Create display restrictions
Map<DisplayRestrictions, Object> restrictions =
new HashMap<DisplayRestrictions, Object>();
restrictions.put(
DisplayRestrictions.MIME_TYPE_RESTRICTION, MimeTypeHelper.ALL_MIME_TYPES);

//Process all the data
final List<SearchResult> result =
SearchHelper.convertToResults(
FileHelper.applyUserPreferences(
this.mFiles, MimeTypeHelper.ALL_MIME_TYPES, true, chRooted),
this.mFiles, restrictions, true, chRooted),
this.mQueries);
if (mode.compareTo(SearchSortResultMode.NAME) == 0) {
Collections.sort(result, new Comparator<SearchResult>() {
Expand Down
Loading

0 comments on commit 6e6ea76

Please sign in to comment.