aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlaco0416 <laco0416@gmail.com>2014-05-30 01:29:23 +0900
committerlaco0416 <laco0416@gmail.com>2014-05-30 01:29:23 +0900
commit5c4009c80450fac71ab8c476828549e714fe79bf (patch)
treeca30b5c827ee951a8d2d8b56d95c0772d804bf6e /src
parentdd1d0afe2c5db76e90e8a8e74b531701557b92a8 (diff)
downloadSmileEssence-5c4009c80450fac71ab8c476828549e714fe79bf.tar.gz
Implement: license activity
Diffstat (limited to 'src')
-rw-r--r--src/net/lacolaco/smileessence/activity/LicenseActivity.java100
-rw-r--r--src/net/lacolaco/smileessence/view/SettingFragment.java26
2 files changed, 117 insertions, 9 deletions
diff --git a/src/net/lacolaco/smileessence/activity/LicenseActivity.java b/src/net/lacolaco/smileessence/activity/LicenseActivity.java
new file mode 100644
index 00000000..c923105b
--- /dev/null
+++ b/src/net/lacolaco/smileessence/activity/LicenseActivity.java
@@ -0,0 +1,100 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2012-2014 lacolaco.net
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package net.lacolaco.smileessence.activity;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import net.lacolaco.smileessence.Application;
+import net.lacolaco.smileessence.R;
+import net.lacolaco.smileessence.util.Themes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LicenseActivity extends Activity
+{
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ setTheme(Themes.getTheme(((Application) getApplication()).getThemeIndex()));
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.layout_license);
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ setFiles();
+ }
+
+ private void setFiles()
+ {
+ LinearLayout files = (LinearLayout) findViewById(R.id.linear_license_files);
+ List<String> apacheFiles = getFileNames();
+ String marker = getMarkerString();
+ for(String apacheFile : apacheFiles)
+ {
+ TextView name = new TextView(this);
+ name.setText(String.format("%s %s", marker, apacheFile));
+ files.addView(name);
+ }
+ }
+
+ private String getMarkerString()
+ {
+ return getString(R.string.dialog_licenses_list_marker);
+ }
+
+ private List<String> getFileNames()
+ {
+ List<String> apacheFiles = new ArrayList<>();
+ apacheFiles.add(getString(R.string.library_name_twitter4j));
+ apacheFiles.add(getString(R.string.library_name_crouton));
+ apacheFiles.add(getString(R.string.library_name_pull_to_refresh));
+ apacheFiles.add(getString(R.string.library_name_volley));
+ apacheFiles.add(getString(R.string.library_name_activeandroid));
+ apacheFiles.add(getString(R.string.library_name_guava));
+ apacheFiles.add(getString(R.string.library_name_twitter_text));
+ return apacheFiles;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch(item.getItemId())
+ {
+ case android.R.id.home:
+ {
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ }
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/net/lacolaco/smileessence/view/SettingFragment.java b/src/net/lacolaco/smileessence/view/SettingFragment.java
index 178cac51..3cc6793a 100644
--- a/src/net/lacolaco/smileessence/view/SettingFragment.java
+++ b/src/net/lacolaco/smileessence/view/SettingFragment.java
@@ -24,6 +24,7 @@
package net.lacolaco.smileessence.view;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.EditTextPreference;
@@ -32,6 +33,7 @@ import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.text.TextUtils;
import net.lacolaco.smileessence.R;
+import net.lacolaco.smileessence.activity.LicenseActivity;
import net.lacolaco.smileessence.entity.Account;
import net.lacolaco.smileessence.notification.Notificator;
import net.lacolaco.smileessence.preference.UserPreferenceHelper;
@@ -65,6 +67,8 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe
appInfoPreference.setOnPreferenceClickListener(this);
Preference clearAccount = findPreference(R.string.key_setting_clear_account);
clearAccount.setOnPreferenceClickListener(this);
+ Preference license = findPreference(R.string.key_setting_licenses);
+ license.setOnPreferenceClickListener(this);
}
@Override
@@ -154,21 +158,15 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe
@Override
public boolean onPreferenceClick(Preference preference)
{
- if(preference.getKey().contentEquals(getString(R.string.key_setting_application_information)))
+ String key = preference.getKey();
+ if(key.contentEquals(getString(R.string.key_setting_application_information)))
{
SimpleDialogFragment informationDialog = SimpleDialogFragment.newInstance(
R.layout.dialog_app_info,
getString(R.string.dialog_title_about));
DialogHelper.showDialog(getActivity(), informationDialog);
}
- else if(preference.getKey().contentEquals(getString(R.string.key_setting_licenses)))
- {
- SimpleDialogFragment licensesDialog = SimpleDialogFragment.newInstance(
- R.layout.dialog_licenses,
- getString(R.string.dialog_title_licenses));
- DialogHelper.showDialog(getActivity(), licensesDialog);
- }
- else if(preference.getKey().contentEquals(getString(R.string.key_setting_clear_account)))
+ else if(key.contentEquals(getString(R.string.key_setting_clear_account)))
{
ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_clear_account), new Runnable()
{
@@ -181,9 +179,19 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe
}
});
}
+ else if(key.contentEquals(getString(R.string.key_setting_licenses)))
+ {
+ openLicenseActivity();
+ }
return true;
}
+ private void openLicenseActivity()
+ {
+ Intent intent = new Intent(getActivity(), LicenseActivity.class);
+ getActivity().startActivity(intent);
+ }
+
private void finishActivity()
{
getActivity().finish();