From a28162fc0db6c8951f2b00378bc118170693087e Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 1 Jun 2016 17:44:50 +0200 Subject: [PATCH] add About section --- app/build.gradle | 1 + app/proguard-rules.pro | 13 +++++ app/src/main/AndroidManifest.xml | 5 ++ .../gallery/activities/AboutActivity.java | 55 +++++++++++++++++++ .../gallery/activities/MainActivity.java | 19 +++++++ app/src/main/res/layout/activity_about.xml | 55 +++++++++++++++++++ app/src/main/res/menu/menu.xml | 8 +++ app/src/main/res/values/strings.xml | 9 +++ 8 files changed, 165 insertions(+) create mode 100644 app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java create mode 100644 app/src/main/res/layout/activity_about.xml create mode 100644 app/src/main/res/menu/menu.xml diff --git a/app/build.gradle b/app/build.gradle index 7a481c1b3..4884477ea 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,6 +32,7 @@ dependencies { compile 'com.android.support:design:23.3.0' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1' + compile 'com.jakewharton:butterknife:7.0.1' } def Properties props = new Properties() diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 25ea3346e..9f53b8848 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -15,3 +15,16 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} + +# Butterknife +-keep class butterknife.** { *; } +-dontwarn butterknife.internal.** +-keep class **$$ViewBinder { *; } + +-keepclasseswithmembernames class * { + @butterknife.* ; +} + +-keepclasseswithmembernames class * { + @butterknife.* ; +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 25e2da3f7..43311c536 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,5 +26,10 @@ + + diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java new file mode 100644 index 000000000..464390750 --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java @@ -0,0 +1,55 @@ +package com.simplemobiletools.gallery.activities; + +import android.content.res.Resources; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.widget.TextView; + +import com.simplemobiletools.gallery.BuildConfig; +import com.simplemobiletools.gallery.R; + +import java.util.Calendar; + +import butterknife.Bind; +import butterknife.ButterKnife; + +public class AboutActivity extends AppCompatActivity { + @Bind(R.id.about_copyright) TextView copyright; + @Bind(R.id.about_version) TextView version; + @Bind(R.id.about_email) TextView emailTV; + private Resources res; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_about); + ButterKnife.bind(this); + res = getResources(); + + setupEmail(); + setupVersion(); + setupCopyright(); + } + + private void setupEmail() { + final String email = res.getString(R.string.email); + final String appName = res.getString(R.string.app_name); + final String href = "" + email + ""; + emailTV.setText(Html.fromHtml(href)); + emailTV.setMovementMethod(LinkMovementMethod.getInstance()); + } + + private void setupVersion() { + final String versionName = BuildConfig.VERSION_NAME; + final String versionText = String.format(res.getString(R.string.version), versionName); + version.setText(versionText); + } + + private void setupCopyright() { + final int year = Calendar.getInstance().get(Calendar.YEAR); + final String copyrightText = String.format(res.getString(R.string.copyright), year); + copyright.setText(copyrightText); + } +} diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 227f45b91..e5caa00c3 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -58,6 +58,25 @@ public class MainActivity extends AppCompatActivity setContentView(R.layout.activity_main); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.about: + final Intent intent = new Intent(getApplicationContext(), AboutActivity.class); + startActivity(intent); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + @Override protected void onResume() { super.onResume(); diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml new file mode 100644 index 000000000..e1949cfe6 --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml new file mode 100644 index 000000000..0cce6d24e --- /dev/null +++ b/app/src/main/res/menu/menu.xml @@ -0,0 +1,8 @@ + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 80379c63c..260873966 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,4 +28,13 @@ 1 file deleted %1$d files deleted + + + About + For more simple apps please visit:\nhttp://simplemobiletools.com + You can send your feedback and new app suggestions at: + hello@simplemobiletools.com + License + v %1$s + Copyright © Simple Mobile Tools %1$d