Improved the about page

Changelog, Open source licenses
This commit is contained in:
Vlad Mihalachi 2013-09-27 14:53:36 +02:00
parent 4d641485a5
commit b3a8539afa
11 changed files with 125 additions and 91 deletions

View File

@ -24,5 +24,7 @@ android {
dependencies { dependencies {
compile 'com.github.gabrielemariotti.changeloglib:library:1.2.0' 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') compile fileTree(dir: 'libs', include: '*.jar')
} }

View File

@ -21,7 +21,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vmihalachi.turboeditor" package="com.vmihalachi.turboeditor"
android:versionCode="2" android:versionCode="2"
android:versionName="0.2" android:versionName="0.3"
android:installLocation="auto"> android:installLocation="auto">
<uses-sdk <uses-sdk
@ -76,6 +76,11 @@
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/aboutactivity_info_category"/> android:label="@string/aboutactivity_info_category"/>
<activity
android:name="com.vmihalachi.turboeditor.LicensesActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/open_source_license"/>
<activity <activity
android:name="com.vmihalachi.turboeditor.SelectFileActivity" android:name="com.vmihalachi.turboeditor.SelectFileActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"

View File

@ -18,6 +18,9 @@ package com.vmihalachi.turboeditor;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -65,4 +68,15 @@ public class DialogStandardFragment extends DialogFragment {
.create(); .create();
} }
public static final void showChangeLogDialog(FragmentManager fragmentManager){
DialogStandardFragment dialogStandardFragment = new DialogStandardFragment();
FragmentTransaction ft = fragmentManager.beginTransaction();
Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
dialogStandardFragment.show(ft, "changelogdemo_dialog");
}
} }

View File

@ -23,9 +23,11 @@ import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.text.TextUtils; import android.text.TextUtils;
@ -40,6 +42,7 @@ import com.vmihalachi.turboeditor.event.ErrorOpeningFileEvent;
import com.vmihalachi.turboeditor.event.FileSavedEvent; import com.vmihalachi.turboeditor.event.FileSavedEvent;
import com.vmihalachi.turboeditor.event.FileSelectedEvent; import com.vmihalachi.turboeditor.event.FileSelectedEvent;
import com.vmihalachi.turboeditor.event.NewFileOpened; import com.vmihalachi.turboeditor.event.NewFileOpened;
import com.vmihalachi.turboeditor.helper.AppInfoHelper;
import de.greenrobot.event.EventBus; import de.greenrobot.event.EventBus;
@ -85,6 +88,8 @@ public class HomeActivity extends Activity {
} }
// //
receiveIntent(); receiveIntent();
//
showChangeLog();
} }
/** /**
@ -338,4 +343,17 @@ public class HomeActivity extends Activity {
EventBus.getDefault().postSticky(new NewFileOpened(intent.getData().getPath())); EventBus.getDefault().postSticky(new NewFileOpened(intent.getData().getPath()));
} }
} }
/**
*
*/
private void showChangeLog(){
final String currentVersion = AppInfoHelper.getCurrentVersion(this);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final String lastVersion = preferences.getString("last_version", currentVersion);
preferences.edit().putString("last_version", currentVersion).commit();
if (!lastVersion.equals(currentVersion)) {
DialogStandardFragment.showChangeLogDialog(getFragmentManager());
}
}
} }

View File

@ -1,16 +1,46 @@
package com.vmihalachi.turboeditor; package com.vmihalachi.turboeditor;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
public class LicensesActivity extends Activity { public class LicensesActivity extends Activity implements AdapterView.OnItemClickListener{
/**
* {@inheritDoc}
*/
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_licenses); setContentView(R.layout.activity_licenses);
ListView listView = (ListView) findViewById(android.R.id.list); ListView listView = (ListView) findViewById(android.R.id.list);
listView.setOnItemClickListener(this);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.open_source_libs));
listView.setAdapter(adapter); 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);
}
}
} }

View File

@ -19,19 +19,14 @@
package com.vmihalachi.turboeditor; 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.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import com.vmihalachi.turboeditor.helper.AppInfoHelper;
public class PreferenceAbout extends PreferenceActivity { public class PreferenceAbout extends PreferenceActivity {
@Override @Override
public void onCreate(final Bundle savedInstanceState) { public void onCreate(final Bundle savedInstanceState) {
@ -52,7 +47,7 @@ public class PreferenceAbout extends PreferenceActivity {
Intent i = new Intent(Intent.ACTION_SEND); Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822"); i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"app.feedback.mail@gmail.com"}); 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, ""); i.putExtra(Intent.EXTRA_TEXT, "");
try { try {
startActivity(Intent.createChooser(i, getString(R.string.aboutactivity_authoremail_summary))); startActivity(Intent.createChooser(i, getString(R.string.aboutactivity_authoremail_summary)));
@ -66,7 +61,7 @@ public class PreferenceAbout extends PreferenceActivity {
changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(final Preference preference) { public boolean onPreferenceClick(final Preference preference) {
openDialogFragment(new DialogStandardFragment()); DialogStandardFragment.showChangeLogDialog(getFragmentManager());
return false; 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 "";
}
}
} }

View File

@ -30,9 +30,10 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.vmihalachi.turboeditor.R; import com.vmihalachi.turboeditor.R;
import com.vmihalachi.turboeditor.helper.FileHelper;
import com.vmihalachi.turboeditor.util.MimeTypes; import com.vmihalachi.turboeditor.util.MimeTypes;
import org.apache.commons.io.FilenameUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -156,7 +157,7 @@ public class AdapterDetailedList extends
private void setIcon(final ViewHolder viewHolder, private void setIcon(final ViewHolder viewHolder,
final FileDetail fileDetail) { final FileDetail fileDetail) {
final String fileName = fileDetail.getName(); final String fileName = fileDetail.getName();
final String ext = FileHelper.getExtension(fileName); final String ext = FilenameUtils.getExtension(fileName);
if (fileDetail.isFolder()) { if (fileDetail.isFolder()) {
viewHolder.icon viewHolder.icon
.setImageResource(R.color.file_folder); .setImageResource(R.color.file_folder);

View File

@ -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 "";
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog bulletedList="true">
<changelogversion versionName="0.3" changeDate="Sep 27, 2013">
<changelogtext>Improved the about page</changelogtext>
</changelogversion>
<changelogversion versionName="0.2" changeDate="Sep 25, 2013">
<changelogtext>Keyboard now closes when you save a file</changelogtext>
<changelogtext>Fixed some issues when launching the app</changelogtext>
</changelogversion>
<changelogversion versionName="0.1" changeDate="Sep 24, 2013">
<changelogtext>First release</changelogtext>
</changelogversion>
</changelog>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="open_source_libs">
<item>ChangeLog Library</item>
<item>EventBus</item>
<item>commons-io</item>
</string-array>
</resources>