From b3a8539afa68112b275442fb486040a8c25bc9fb Mon Sep 17 00:00:00 2001 From: Vlad Mihalachi Date: Fri, 27 Sep 2013 14:53:36 +0200 Subject: [PATCH] Improved the about page Changelog, Open source licenses --- Turbo Editor/build.gradle | 2 + Turbo Editor/src/main/AndroidManifest.xml | 7 ++- .../turboeditor/DialogStandardFragment.java | 14 ++++++ .../vmihalachi/turboeditor/HomeActivity.java | 18 +++++++ .../turboeditor/LicensesActivity.java | 32 +++++++++++- .../turboeditor/PreferenceAbout.java | 42 ++-------------- .../adapter/AdapterDetailedList.java | 5 +- .../turboeditor/helper/AppInfoHelper.java | 23 +++++++++ .../turboeditor/helper/FileHelper.java | 49 ------------------- Turbo Editor/src/main/res/raw/changelog.xml | 16 ++++++ Turbo Editor/src/main/res/values/arrays.xml | 8 +++ 11 files changed, 125 insertions(+), 91 deletions(-) create mode 100644 Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/AppInfoHelper.java delete mode 100644 Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/FileHelper.java create mode 100644 Turbo Editor/src/main/res/raw/changelog.xml create mode 100644 Turbo Editor/src/main/res/values/arrays.xml diff --git a/Turbo Editor/build.gradle b/Turbo Editor/build.gradle index 7ba5fd8..92114cb 100644 --- a/Turbo Editor/build.gradle +++ b/Turbo Editor/build.gradle @@ -24,5 +24,7 @@ android { dependencies { compile 'com.github.gabrielemariotti.changeloglib:library:1.2.0' + compile 'com.android.support:support-v13:18.0.0' + compile "commons-io:commons-io:2.4" compile fileTree(dir: 'libs', include: '*.jar') } diff --git a/Turbo Editor/src/main/AndroidManifest.xml b/Turbo Editor/src/main/AndroidManifest.xml index b0d25ad..ca471d4 100644 --- a/Turbo Editor/src/main/AndroidManifest.xml +++ b/Turbo Editor/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ + + adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.open_source_libs)); listView.setAdapter(adapter); } + + /** + * {@inheritDoc} + */ + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + String openSourceLib = ((TextView) view.findViewById(android.R.id.text1)).getText().toString(); + Intent browserIntent = null; + if(openSourceLib.equals("ChangeLog Library")){ + browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/gabrielemariotti/changeloglib?source=c#license")); + } else if(openSourceLib.equals("EventBus")){ + browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/greenrobot/EventBus?source=c#license")); + } else if(openSourceLib.equals("commons-io")){ + browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://commons.apache.org/proper/commons-io/")); + } + if(browserIntent != null){ + startActivity(browserIntent); + } + } } diff --git a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/PreferenceAbout.java b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/PreferenceAbout.java index f3b9389..6f398f4 100644 --- a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/PreferenceAbout.java +++ b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/PreferenceAbout.java @@ -19,19 +19,14 @@ package com.vmihalachi.turboeditor; -import android.app.Fragment; -import android.app.FragmentManager; -import android.app.FragmentTransaction; -import android.content.Context; import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; +import com.vmihalachi.turboeditor.helper.AppInfoHelper; + public class PreferenceAbout extends PreferenceActivity { @Override public void onCreate(final Bundle savedInstanceState) { @@ -52,7 +47,7 @@ public class PreferenceAbout extends PreferenceActivity { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[]{"app.feedback.mail@gmail.com"}); - i.putExtra(Intent.EXTRA_SUBJECT, getApplicationName(getBaseContext()) + " " + getCurrentVersion(getBaseContext())); + i.putExtra(Intent.EXTRA_SUBJECT, AppInfoHelper.getApplicationName(getBaseContext()) + " " + AppInfoHelper.getCurrentVersion(getBaseContext())); i.putExtra(Intent.EXTRA_TEXT, ""); try { startActivity(Intent.createChooser(i, getString(R.string.aboutactivity_authoremail_summary))); @@ -66,7 +61,7 @@ public class PreferenceAbout extends PreferenceActivity { changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { - openDialogFragment(new DialogStandardFragment()); + DialogStandardFragment.showChangeLogDialog(getFragmentManager()); return false; } }); @@ -94,33 +89,4 @@ public class PreferenceAbout extends PreferenceActivity { }); } } - - private void openDialogFragment(DialogStandardFragment dialogStandardFragment) { - if (dialogStandardFragment != null) { - FragmentManager fm = getFragmentManager(); - FragmentTransaction ft = fm.beginTransaction(); - Fragment prev = fm.findFragmentByTag("changelogdemo_dialog"); - if (prev != null) { - ft.remove(prev); - } - ft.addToBackStack(null); - - dialogStandardFragment.show(ft, "changelogdemo_dialog"); - } - } - - public static String getApplicationName(final Context context) { - final ApplicationInfo applicationInfo = context.getApplicationInfo(); - return context.getString(applicationInfo.labelRes); - } - - public static String getCurrentVersion(final Context context) { - try { - final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), - 0); - return packageInfo.versionName; - } catch (PackageManager.NameNotFoundException e) { - return ""; - } - } } diff --git a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/adapter/AdapterDetailedList.java b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/adapter/AdapterDetailedList.java index aa944e2..ee5bb8e 100644 --- a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/adapter/AdapterDetailedList.java +++ b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/adapter/AdapterDetailedList.java @@ -30,9 +30,10 @@ import android.widget.ImageView; import android.widget.TextView; import com.vmihalachi.turboeditor.R; -import com.vmihalachi.turboeditor.helper.FileHelper; import com.vmihalachi.turboeditor.util.MimeTypes; +import org.apache.commons.io.FilenameUtils; + import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; @@ -156,7 +157,7 @@ public class AdapterDetailedList extends private void setIcon(final ViewHolder viewHolder, final FileDetail fileDetail) { final String fileName = fileDetail.getName(); - final String ext = FileHelper.getExtension(fileName); + final String ext = FilenameUtils.getExtension(fileName); if (fileDetail.isFolder()) { viewHolder.icon .setImageResource(R.color.file_folder); diff --git a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/AppInfoHelper.java b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/AppInfoHelper.java new file mode 100644 index 0000000..17d8d0f --- /dev/null +++ b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/AppInfoHelper.java @@ -0,0 +1,23 @@ +package com.vmihalachi.turboeditor.helper; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; + +public class AppInfoHelper { + public static String getApplicationName(final Context context) { + final ApplicationInfo applicationInfo = context.getApplicationInfo(); + return context.getString(applicationInfo.labelRes); + } + + public static String getCurrentVersion(final Context context) { + try { + final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), + 0); + return packageInfo.versionName; + } catch (PackageManager.NameNotFoundException e) { + return ""; + } + } +} diff --git a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/FileHelper.java b/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/FileHelper.java deleted file mode 100644 index 78c24b9..0000000 --- a/Turbo Editor/src/main/java/com/vmihalachi/turboeditor/helper/FileHelper.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2013 Vlad Mihalachi - * - * This file is part of Turbo Editor. - * - * Turbo Editor is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Turbo Editor is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Turbo Editor. If not, see . - */ - -package com.vmihalachi.turboeditor.helper; - -import java.io.File; - -public class FileHelper { - /** - * Get the extension of a file - * @param f the file - * @return the extension of a file - */ - public static String getExtension(File f) { - return getExtension(f.getAbsolutePath()); - } - - /** - * Get the extension from a file path - * @param path the path - * @return the extension from a file path - */ - public static String getExtension(String path) { - String ext = null; - String s = path; - int i = s.lastIndexOf('.'); - - if (i > 0 && i < s.length() - 1) { - ext = s.substring(i+1).toLowerCase(); - } - return ext; - } -} diff --git a/Turbo Editor/src/main/res/raw/changelog.xml b/Turbo Editor/src/main/res/raw/changelog.xml new file mode 100644 index 0000000..71319e7 --- /dev/null +++ b/Turbo Editor/src/main/res/raw/changelog.xml @@ -0,0 +1,16 @@ + + + + + Improved the about page + + + + Keyboard now closes when you save a file + Fixed some issues when launching the app + + + + First release + + diff --git a/Turbo Editor/src/main/res/values/arrays.xml b/Turbo Editor/src/main/res/values/arrays.xml new file mode 100644 index 0000000..734e710 --- /dev/null +++ b/Turbo Editor/src/main/res/values/arrays.xml @@ -0,0 +1,8 @@ + + + + ChangeLog Library + EventBus + commons-io + + \ No newline at end of file