Reformated the code and optimized imports

This commit is contained in:
Vlad Mihalachi 2013-09-28 09:44:24 +02:00
parent fca3410f26
commit 474ce28737
13 changed files with 162 additions and 55 deletions

View File

@ -66,6 +66,7 @@ public class HomeActivity extends Activity {
*/ */
protected DrawerLayout mDrawerLayout; protected DrawerLayout mDrawerLayout;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -78,7 +79,7 @@ public class HomeActivity extends Activity {
// Replace fragment // Replace fragment
getFragmentManager() getFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_editor, new NoFileOpenedFragment()) .replace(R.id.fragment_editor, new NoFileOpenedFragment())
.commit(); .commit();
/* First Time we open this activity */ /* First Time we open this activity */
if (savedInstanceState == null) { if (savedInstanceState == null) {
@ -102,6 +103,7 @@ public class HomeActivity extends Activity {
mDrawerToggle.syncState(); mDrawerToggle.syncState();
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -112,6 +114,7 @@ public class HomeActivity extends Activity {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -122,6 +125,7 @@ public class HomeActivity extends Activity {
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -135,6 +139,7 @@ public class HomeActivity extends Activity {
super.onDestroy(); super.onDestroy();
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -144,6 +149,7 @@ public class HomeActivity extends Activity {
mDrawerToggle.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -153,6 +159,7 @@ public class HomeActivity extends Activity {
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -161,7 +168,7 @@ public class HomeActivity extends Activity {
/* If we clicked on the Navigation Drawer Menu item */ /* If we clicked on the Navigation Drawer Menu item */
if (mDrawerToggle.onOptionsItemSelected(item)) { if (mDrawerToggle.onOptionsItemSelected(item)) {
return true; return true;
} else switch (item.getItemId()){ } else switch (item.getItemId()) {
case R.id.im_open: case R.id.im_open:
startActivityForResult(new Intent(HomeActivity.this, SelectFileActivity.class) startActivityForResult(new Intent(HomeActivity.this, SelectFileActivity.class)
.putExtra("path", "") .putExtra("path", "")
@ -176,6 +183,7 @@ public class HomeActivity extends Activity {
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -183,13 +191,16 @@ public class HomeActivity extends Activity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == SELECT_FILE_CODE) { if (resultCode == RESULT_OK && requestCode == SELECT_FILE_CODE) {
String path = data.getStringExtra("path"); String path = data.getStringExtra("path");
if(!TextUtils.isEmpty(path)){ if (!TextUtils.isEmpty(path)) {
EventBus.getDefault().postSticky(new NewFileOpened(path)); EventBus.getDefault().postSticky(new NewFileOpened(path));
} }
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
@ -197,25 +208,25 @@ public class HomeActivity extends Activity {
} }
/** /**
*
* @param event * @param event
*/ */
public void onEvent(FileSelectedEvent event){ public void onEvent(FileSelectedEvent event) {
// Close the drawer // Close the drawer
mDrawerLayout.closeDrawer(Gravity.LEFT); mDrawerLayout.closeDrawer(Gravity.LEFT);
// Replace fragment // Replace fragment
getFragmentManager() getFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_editor, EditorFragment.newInstance(event.getPath())) .replace(R.id.fragment_editor, EditorFragment.newInstance(event.getPath()))
.commit(); .commit();
} }
/** /**
* When a file is saved * When a file is saved
* Invoked by the EditorFragment * Invoked by the EditorFragment
*
* @param event The event called * @param event The event called
*/ */
public void onEvent(FileSavedEvent event){ public void onEvent(FileSavedEvent event) {
try { try {
closeKeyBoard(); closeKeyBoard();
} catch (NullPointerException e) { } catch (NullPointerException e) {
@ -244,7 +255,7 @@ public class HomeActivity extends Activity {
// Replace fragment // Replace fragment
getFragmentManager() getFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_editor, new NoFileOpenedFragment()) .replace(R.id.fragment_editor, new NoFileOpenedFragment())
.commit(); .commit();
} }
} }
@ -252,9 +263,10 @@ public class HomeActivity extends Activity {
/** /**
* When a file can't be opened * When a file can't be opened
* Invoked by the EditorFragment * Invoked by the EditorFragment
*
* @param event The event called * @param event The event called
*/ */
public void onEvent(ErrorOpeningFileEvent event){ public void onEvent(ErrorOpeningFileEvent event) {
// //
mDrawerLayout.openDrawer(Gravity.LEFT); mDrawerLayout.openDrawer(Gravity.LEFT);
// //
@ -262,7 +274,7 @@ public class HomeActivity extends Activity {
// Replace fragment // Replace fragment
getFragmentManager() getFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragment_editor, new NoFileOpenedFragment()) .replace(R.id.fragment_editor, new NoFileOpenedFragment())
.commit(); .commit();
} }
@ -284,7 +296,7 @@ public class HomeActivity extends Activity {
/** /**
* Setup the navigation drawer * Setup the navigation drawer
*/ */
private void setupNavigationDrawer(){ private void setupNavigationDrawer() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
/* Action Bar */ /* Action Bar */
final ActionBar ab = getActionBar(); final ActionBar ab = getActionBar();
@ -299,11 +311,17 @@ public class HomeActivity extends Activity {
R.string.nome_app_turbo_editor, R.string.nome_app_turbo_editor,
R.string.nome_app_turbo_editor) { R.string.nome_app_turbo_editor) {
/**
* {@inheritDoc}
*/
@Override @Override
public void onDrawerClosed(View view) { public void onDrawerClosed(View view) {
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void onDrawerOpened(View drawerView) { public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu(); invalidateOptionsMenu();
@ -316,7 +334,7 @@ public class HomeActivity extends Activity {
/** /**
* Show a dialog with the changelog * Show a dialog with the changelog
*/ */
private void showChangeLog(){ private void showChangeLog() {
final String currentVersion = AppInfoHelper.getCurrentVersion(this); final String currentVersion = AppInfoHelper.getCurrentVersion(this);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final String lastVersion = preferences.getString("last_version", currentVersion); final String lastVersion = preferences.getString("last_version", currentVersion);
@ -329,7 +347,7 @@ public class HomeActivity extends Activity {
/** /**
* Parses the intent * Parses the intent
*/ */
private void parseIntent(Intent intent){ private void parseIntent(Intent intent) {
final String action = intent.getAction(); final String action = intent.getAction();
final String type = intent.getType(); final String type = intent.getType();

View File

@ -12,7 +12,8 @@ import android.widget.TextView;
import com.vmihalachi.turboeditor.R; import com.vmihalachi.turboeditor.R;
public class LicensesActivity extends Activity implements AdapterView.OnItemClickListener{ public class LicensesActivity extends Activity implements AdapterView.OnItemClickListener {
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -27,6 +28,7 @@ public class LicensesActivity extends Activity implements AdapterView.OnItemClic
listView.setAdapter(adapter); listView.setAdapter(adapter);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -34,14 +36,14 @@ public class LicensesActivity extends Activity implements AdapterView.OnItemClic
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String openSourceLib = ((TextView) view.findViewById(android.R.id.text1)).getText().toString(); String openSourceLib = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
Intent browserIntent = null; Intent browserIntent = null;
if(openSourceLib.equals("ChangeLog Library")){ if (openSourceLib.equals("ChangeLog Library")) {
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/gabrielemariotti/changeloglib?source=c#license")); browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/gabrielemariotti/changeloglib?source=c#license"));
} else if(openSourceLib.equals("EventBus")){ } else if (openSourceLib.equals("EventBus")) {
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/greenrobot/EventBus?source=c#license")); browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/greenrobot/EventBus?source=c#license"));
} else if(openSourceLib.equals("commons-io")){ } else if (openSourceLib.equals("commons-io")) {
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://commons.apache.org/proper/commons-io/")); browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://commons.apache.org/proper/commons-io/"));
} }
if(browserIntent != null){ if (browserIntent != null) {
startActivity(browserIntent); startActivity(browserIntent);
} }
} }

View File

@ -30,6 +30,9 @@ import com.vmihalachi.turboeditor.fragment.ChangelogDialogFragment;
import com.vmihalachi.turboeditor.helper.AppInfoHelper; import com.vmihalachi.turboeditor.helper.AppInfoHelper;
public class PreferenceAbout extends PreferenceActivity { public class PreferenceAbout extends PreferenceActivity {
/**
* {@inheritDoc}
*/
@Override @Override
public void onCreate(final Bundle savedInstanceState) { public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -44,6 +47,9 @@ public class PreferenceAbout extends PreferenceActivity {
market = findPreference("aboutactivity_authormarket"); market = findPreference("aboutactivity_authormarket");
if (email != null) { if (email != null) {
email.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { email.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onPreferenceClick(final Preference preference) { public boolean onPreferenceClick(final Preference preference) {
Intent i = new Intent(Intent.ACTION_SEND); Intent i = new Intent(Intent.ACTION_SEND);
@ -61,6 +67,9 @@ public class PreferenceAbout extends PreferenceActivity {
} }
if (changelog != null) { if (changelog != null) {
changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onPreferenceClick(final Preference preference) { public boolean onPreferenceClick(final Preference preference) {
ChangelogDialogFragment.showChangeLogDialog(getFragmentManager()); ChangelogDialogFragment.showChangeLogDialog(getFragmentManager());
@ -70,6 +79,9 @@ public class PreferenceAbout extends PreferenceActivity {
} }
if (open_source_licenses != null) { if (open_source_licenses != null) {
open_source_licenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { open_source_licenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onPreferenceClick(final Preference preference) { public boolean onPreferenceClick(final Preference preference) {
startActivity(new Intent(PreferenceAbout.this, LicensesActivity.class)); startActivity(new Intent(PreferenceAbout.this, LicensesActivity.class));
@ -79,6 +91,9 @@ public class PreferenceAbout extends PreferenceActivity {
} }
if (market != null) { if (market != null) {
market.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { market.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onPreferenceClick(final Preference preference) { public boolean onPreferenceClick(final Preference preference) {
try { try {

View File

@ -57,6 +57,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
.getAbsolutePath(); .getAbsolutePath();
/**
* {@inheritDoc}
*/
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -85,6 +88,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
finish(); finish();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void onItemClick(AdapterView<?> parent, public void onItemClick(AdapterView<?> parent,
View view, int position, long id) { View view, int position, long id) {
@ -106,6 +112,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_select_file, menu); getMenuInflater().inflate(R.menu.activity_select_file, menu);
@ -114,6 +123,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int i = item.getItemId(); int i = item.getItemId();
@ -145,6 +157,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
private class UpdateList extends private class UpdateList extends
AsyncTask<String, Void, LinkedList<AdapterDetailedList.FileDetail>> { AsyncTask<String, Void, LinkedList<AdapterDetailedList.FileDetail>> {
/**
* {@inheritDoc}
*/
@Override @Override
protected LinkedList<AdapterDetailedList.FileDetail> doInBackground(final String... params) { protected LinkedList<AdapterDetailedList.FileDetail> doInBackground(final String... params) {
try { try {
@ -196,6 +211,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void onPostExecute(final LinkedList<AdapterDetailedList.FileDetail> names) { protected void onPostExecute(final LinkedList<AdapterDetailedList.FileDetail> names) {
boolean isRoot = currentFolder.equals("/"); boolean isRoot = currentFolder.equals("/");
@ -207,6 +225,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
public final Comparator<File> getFileNameComparator() { public final Comparator<File> getFileNameComparator() {
return new AlphanumComparator() { return new AlphanumComparator() {
/**
* {@inheritDoc}
*/
@Override @Override
public String getTheString(Object obj) { public String getTheString(Object obj) {
return ((File) obj).getName() return ((File) obj).getName()

View File

@ -73,6 +73,9 @@ public class AdapterDetailedList extends
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public View getView(final int position, public View getView(final int position,
View convertView, final ViewGroup parent) { View convertView, final ViewGroup parent) {
@ -109,29 +112,22 @@ public class AdapterDetailedList extends
final String ext = FilenameUtils.getExtension(fileName); final String ext = FilenameUtils.getExtension(fileName);
if (fileDetail.isFolder()) { if (fileDetail.isFolder()) {
viewHolder.icon.setImageResource(R.color.file_folder); viewHolder.icon.setImageResource(R.color.file_folder);
} } else if (Arrays.asList(MimeTypes.MIME_HTML).contains(ext) || ext.endsWith("html")) {
else if (Arrays.asList(MimeTypes.MIME_HTML).contains(ext) || ext.endsWith("html")) {
viewHolder.icon.setImageResource(R.color.file_html); viewHolder.icon.setImageResource(R.color.file_html);
} } else if (Arrays.asList(MimeTypes.MIME_CODE).contains(ext)
else if (Arrays.asList(MimeTypes.MIME_CODE).contains(ext)
|| fileName.endsWith("css") || fileName.endsWith("css")
|| fileName.endsWith("js")) { || fileName.endsWith("js")) {
viewHolder.icon.setImageResource(R.color.file_code); viewHolder.icon.setImageResource(R.color.file_code);
} } else if (Arrays.asList(MimeTypes.MIME_ARCHIVE).contains(ext)) {
else if (Arrays.asList(MimeTypes.MIME_ARCHIVE).contains(ext)) {
viewHolder.icon.setImageResource(R.color.file_archive); viewHolder.icon.setImageResource(R.color.file_archive);
} } else if (Arrays.asList(MimeTypes.MIME_MUSIC)
else if (Arrays.asList(MimeTypes.MIME_MUSIC)
.contains(ext)) { .contains(ext)) {
viewHolder.icon.setImageResource(R.color.file_media_music); viewHolder.icon.setImageResource(R.color.file_media_music);
} } else if (Arrays.asList(MimeTypes.MIME_PICTURE).contains(ext)) {
else if (Arrays.asList(MimeTypes.MIME_PICTURE).contains(ext)) {
viewHolder.icon.setImageResource(R.color.file_media_picture); viewHolder.icon.setImageResource(R.color.file_media_picture);
} } else if (Arrays.asList(MimeTypes.MIME_VIDEO).contains(ext)) {
else if (Arrays.asList(MimeTypes.MIME_VIDEO).contains(ext)) {
viewHolder.icon.setImageResource(R.color.file_media_video); viewHolder.icon.setImageResource(R.color.file_media_video);
} } else {
else {
viewHolder.icon.setImageResource(R.color.file_text); viewHolder.icon.setImageResource(R.color.file_text);
} }
} }

View File

@ -23,7 +23,7 @@ public class FileSelectedEvent {
private String path; private String path;
public FileSelectedEvent(String path){ public FileSelectedEvent(String path) {
this.path = path; this.path = path;
} }

View File

@ -37,6 +37,9 @@ public class ChangelogDialogFragment extends DialogFragment {
public ChangelogDialogFragment() { public ChangelogDialogFragment() {
} }
/**
* {@inheritDoc}
*/
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
@ -54,6 +57,9 @@ public class ChangelogDialogFragment extends DialogFragment {
} }
) )
.setPositiveButton(R.string.vota, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.vota, new DialogInterface.OnClickListener() {
/**
* {@inheritDoc}
*/
@Override @Override
public void onClick(final DialogInterface dialog, final int which) { public void onClick(final DialogInterface dialog, final int which) {
try { try {
@ -66,7 +72,7 @@ public class ChangelogDialogFragment extends DialogFragment {
} }
public static final void showChangeLogDialog(FragmentManager fragmentManager){ public static final void showChangeLogDialog(FragmentManager fragmentManager) {
ChangelogDialogFragment changelogDialogFragment = new ChangelogDialogFragment(); ChangelogDialogFragment changelogDialogFragment = new ChangelogDialogFragment();
FragmentTransaction ft = fragmentManager.beginTransaction(); FragmentTransaction ft = fragmentManager.beginTransaction();
Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog"); Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog");

View File

@ -89,6 +89,7 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
return frag; return frag;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -98,6 +99,7 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -110,6 +112,7 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
return rootView; return rootView;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -151,6 +154,7 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -185,6 +189,7 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
dialogFrag.show(getFragmentManager().beginTransaction(), "encodingDialog"); dialogFrag.show(getFragmentManager().beginTransaction(), "encodingDialog");
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -224,7 +229,7 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
} }
} }
private void configureEditText(){ private void configureEditText() {
this.mEditor.setHorizontallyScrolling(!this.sWrapText); this.mEditor.setHorizontallyScrolling(!this.sWrapText);
if (!this.sWrapText) { if (!this.sWrapText) {
int paddingLeft = (int) PixelDipConverter.convertDpToPixel(25, getActivity()); int paddingLeft = (int) PixelDipConverter.convertDpToPixel(25, getActivity());
@ -237,6 +242,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
class SaveFile extends AsyncTask<Void, Void, Void> { class SaveFile extends AsyncTask<Void, Void, Void> {
/**
* {@inheritDoc}
*/
@Override @Override
protected Void doInBackground(final Void... voids) { protected Void doInBackground(final Void... voids) {
try { try {
@ -249,6 +257,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
return null; return null;
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void onPostExecute(final Void aVoid) { protected void onPostExecute(final Void aVoid) {
super.onPostExecute(aVoid); super.onPostExecute(aVoid);
@ -257,11 +268,10 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
} }
public static class Editor extends EditText { public static class Editor extends EditText {
protected static final int protected static final int
ID_SELECT_ALL =android. R.id.selectAll, ID_SELECT_ALL = android.R.id.selectAll,
ID_CUT = android.R.id.cut, ID_CUT = android.R.id.cut,
ID_COPY = android.R.id.copy, ID_COPY = android.R.id.copy,
ID_PASTE = android.R.id.paste, ID_PASTE = android.R.id.paste,
@ -300,6 +310,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
private final Runnable updateRunnable = private final Runnable updateRunnable =
new Runnable() { new Runnable() {
/**
* {@inheritDoc}
*/
@Override @Override
public void run() { public void run() {
replaceTextKeepCursor(getText()); replaceTextKeepCursor(getText());
@ -332,6 +345,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
// Syntax editor // Syntax editor
setFilters(new InputFilter[]{ setFilters(new InputFilter[]{
new InputFilter() { new InputFilter() {
/**
* {@inheritDoc}
*/
@Override @Override
public CharSequence filter( public CharSequence filter(
CharSequence source, CharSequence source,
@ -355,6 +371,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
}}); }});
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onKeyShortcut( public boolean onKeyShortcut(
final int keyCode, final KeyEvent event) { final int keyCode, final KeyEvent event) {
@ -383,6 +402,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
return super.onKeyShortcut(keyCode, event); return super.onKeyShortcut(keyCode, event);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onTextContextMenuItem( public boolean onTextContextMenuItem(
final int id) { final int id) {
@ -397,6 +419,9 @@ public class EditorFragment extends Fragment implements EncodingDialogFragment.E
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void onDraw(final Canvas canvas) { public void onDraw(final Canvas canvas) {
if (!EditorFragment.sWrapText) { if (!EditorFragment.sWrapText) {

View File

@ -48,6 +48,9 @@ public class EncodingDialogFragment extends DialogFragment implements TextView.O
return f; return f;
} }
/**
* {@inheritDoc}
*/
@Override @Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) { final Bundle savedInstanceState) {
@ -68,6 +71,9 @@ public class EncodingDialogFragment extends DialogFragment implements TextView.O
final Button button = (Button) view.findViewById(android.R.id.button1); final Button button = (Button) view.findViewById(android.R.id.button1);
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
/**
* {@inheritDoc}
*/
@Override @Override
public void onClick(final View v) { public void onClick(final View v) {
returnData(); returnData();
@ -86,6 +92,9 @@ public class EncodingDialogFragment extends DialogFragment implements TextView.O
this.dismiss(); this.dismiss();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
if (EditorInfo.IME_ACTION_DONE == actionId) { if (EditorInfo.IME_ACTION_DONE == actionId) {

View File

@ -51,6 +51,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
private List<String> fileNames; private List<String> fileNames;
private ArrayAdapter<String> arrayAdapter; private ArrayAdapter<String> arrayAdapter;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -61,6 +62,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
return rootView; return rootView;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -70,6 +72,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
getListView().setMultiChoiceModeListener(this); getListView().setMultiChoiceModeListener(this);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -82,6 +85,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
refreshList(); refreshList();
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -92,6 +96,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -106,6 +111,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
EventBus.getDefault().post(new FileSelectedEvent(filePath)); EventBus.getDefault().post(new FileSelectedEvent(filePath));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -113,6 +119,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
public void onItemCheckedStateChanged(ActionMode actionMode, int position, long l, boolean isChecked) { public void onItemCheckedStateChanged(ActionMode actionMode, int position, long l, boolean isChecked) {
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -123,6 +130,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
return true; return true;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -131,6 +139,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
return false; return false;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -144,7 +153,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
SparseBooleanArray checkedItems = getListView().getCheckedItemPositions(); SparseBooleanArray checkedItems = getListView().getCheckedItemPositions();
// If we have some checked positions // If we have some checked positions
if (checkedItems != null) { if (checkedItems != null) {
for (int i=0; i<checkedItems.size(); i++) { for (int i = 0; i < checkedItems.size(); i++) {
// check if the value is checked // check if the value is checked
if (checkedItems.valueAt(i)) { if (checkedItems.valueAt(i)) {
// remove the checked path, but don't refresh the list // remove the checked path, but don't refresh the list
@ -162,6 +171,7 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -174,15 +184,16 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
/** /**
* When a new file is opened * When a new file is opened
* Invoked by the main activity which receive the intent * Invoked by the main activity which receive the intent
*
* @param event The event called * @param event The event called
*/ */
public void onEvent(NewFileOpened event){ public void onEvent(NewFileOpened event) {
EventBus.getDefault().removeStickyEvent(event); EventBus.getDefault().removeStickyEvent(event);
// File paths saved in preferences // File paths saved in preferences
String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity()); String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity());
for(int i = 0; i < savedPaths.length; i++){ for (int i = 0; i < savedPaths.length; i++) {
// We don't need to save the file path twice // We don't need to save the file path twice
if(savedPaths[i].equals(event.getFilePath())){ if (savedPaths[i].equals(event.getFilePath())) {
// Send the event that a file was selected // Send the event that a file was selected
EventBus.getDefault().post(new FileSelectedEvent(event.getFilePath())); EventBus.getDefault().post(new FileSelectedEvent(event.getFilePath()));
return; return;
@ -194,12 +205,12 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
EventBus.getDefault().post(new FileSelectedEvent(event.getFilePath())); EventBus.getDefault().post(new FileSelectedEvent(event.getFilePath()));
} }
private void addPath(String path){ private void addPath(String path) {
// Add a path and refresh the list // Add a path and refresh the list
addPath(path, true); addPath(path, true);
} }
private void addPath(String path, boolean refreshTheList){ private void addPath(String path, boolean refreshTheList) {
// File paths saved in preferences // File paths saved in preferences
String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity()); String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity());
// StringBuilder // StringBuilder
@ -213,35 +224,35 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
// Put the string and commit // Put the string and commit
PreferenceHelper.setSavedPaths(getActivity(), sb); PreferenceHelper.setSavedPaths(getActivity(), sb);
// Update list // Update list
if(refreshTheList){ if (refreshTheList) {
refreshList(); refreshList();
} }
} }
private void removePath(String path){ private void removePath(String path) {
// Remove the path and refresh the list // Remove the path and refresh the list
removePath(path, true); removePath(path, true);
} }
private void removePath(String path, boolean refresh){ private void removePath(String path, boolean refresh) {
// File paths saved in preferences // File paths saved in preferences
String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity()); String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity());
// StringBuilder // StringBuilder
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// for cycle // for cycle
for (int count = 0; count < savedPaths.length; count++) { for (int count = 0; count < savedPaths.length; count++) {
if(path.equals(savedPaths[count])) continue; if (path.equals(savedPaths[count])) continue;
sb.append(savedPaths[count]).append(","); sb.append(savedPaths[count]).append(",");
} }
// Put the string and commit // Put the string and commit
PreferenceHelper.setSavedPaths(getActivity(), sb); PreferenceHelper.setSavedPaths(getActivity(), sb);
// Update list // Update list
if(refresh){ if (refresh) {
refreshList(); refreshList();
} }
} }
private void refreshList(){ private void refreshList() {
// File paths saved in preferences // File paths saved in preferences
String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity()); String[] savedPaths = PreferenceHelper.getSavedPaths(getActivity());
// File names for the list // File names for the list
@ -249,10 +260,10 @@ public class NavigationDrawerListFragment extends ListFragment implements AbsLis
// StringBuilder that will contain the file paths // StringBuilder that will contain the file paths
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// for cycle to convert paths to names // for cycle to convert paths to names
for(String path : savedPaths){ for (String path : savedPaths) {
File file = new File(path); File file = new File(path);
// Check that the file exist // Check that the file exist
if(file.exists()){ if (file.exists()) {
fileNames.add(FilenameUtils.getName(path)); fileNames.add(FilenameUtils.getName(path));
sb.append(path).append(","); sb.append(path).append(",");
} }

View File

@ -29,6 +29,7 @@ import com.vmihalachi.turboeditor.R;
public class NoFileOpenedFragment extends Fragment { public class NoFileOpenedFragment extends Fragment {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -21,7 +21,7 @@ package com.vmihalachi.turboeditor.util;
public class MimeTypes { public class MimeTypes {
public static final String[] MIME_TEXT = { public static final String[] MIME_TEXT = {
"ajx","am","asa","asc","asp","aspx","awk","bat","c","cdf","cf","cfg","cfm","cgi","cnf","conf","cpp","css","csv","ctl","dat","dhtml","diz","file","forward","grp","h","hpp","hqx","hta","htaccess","htc","htm","html","htpasswd","htt","htx","in","inc","info","ini","ink","java","js","jsp","key","log","logfile","m3u","m4","m4a","mak","map","model","msg","nfo","nsi","info","old","pas","patch","perl","php","php2","php3","php4","php5","php6","phtml","pix","pl","pm","po","pwd","py","qmail","rb","rbl","rbw","readme","reg","rss","rtf","ruby","session","setup","sh","shtm","shtml","sql","ssh","stm","style","svg","tcl","text","threads","tmpl","tpl","txt","ubb","vbs","xhtml","xml","xrc","xsl" "ajx", "am", "asa", "asc", "asp", "aspx", "awk", "bat", "c", "cdf", "cf", "cfg", "cfm", "cgi", "cnf", "conf", "cpp", "css", "csv", "ctl", "dat", "dhtml", "diz", "file", "forward", "grp", "h", "hpp", "hqx", "hta", "htaccess", "htc", "htm", "html", "htpasswd", "htt", "htx", "in", "inc", "info", "ini", "ink", "java", "js", "jsp", "key", "log", "logfile", "m3u", "m4", "m4a", "mak", "map", "model", "msg", "nfo", "nsi", "info", "old", "pas", "patch", "perl", "php", "php2", "php3", "php4", "php5", "php6", "phtml", "pix", "pl", "pm", "po", "pwd", "py", "qmail", "rb", "rbl", "rbw", "readme", "reg", "rss", "rtf", "ruby", "session", "setup", "sh", "shtm", "shtml", "sql", "ssh", "stm", "style", "svg", "tcl", "text", "threads", "tmpl", "tpl", "txt", "ubb", "vbs", "xhtml", "xml", "xrc", "xsl"
}; };
public static final String[] MIME_CODE = { public static final String[] MIME_CODE = {
"xml", "php", "asp", "json", "wiki" "xml", "php", "asp", "json", "wiki"
@ -30,7 +30,7 @@ public class MimeTypes {
"htm" "htm"
}; };
public static final String[] MIME_PICTURE = { public static final String[] MIME_PICTURE = {
"png", "jpeg", "jpg", "ico", "gif", "bmp","tiff" "png", "jpeg", "jpg", "ico", "gif", "bmp", "tiff"
}; };
public static final String[] MIME_MUSIC = { public static final String[] MIME_MUSIC = {
"mp3", "avi", "flac", "mpga" "mp3", "avi", "flac", "mpga"

View File

@ -37,6 +37,9 @@ public class CapitalizedTextView extends TextView {
super(context, attrs, defStyle); super(context, attrs, defStyle);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void setText(final CharSequence text, final BufferType type) { public void setText(final CharSequence text, final BufferType type) {
super.setText(text.toString().toUpperCase(), type); super.setText(text.toString().toUpperCase(), type);