add About and License activities

This commit is contained in:
tibbi 2016-07-13 17:28:42 +02:00
parent 4613ad230c
commit 19cccb1abc
22 changed files with 358 additions and 1 deletions

View File

@ -16,5 +16,13 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".activities.AboutActivity"
android:label="@string/about"/>
<activity
android:name=".activities.LicenseActivity"
android:label="@string/third_party_licences"/>
</application>
</manifest>

View File

@ -0,0 +1,24 @@
package com.simplemobiletools.filemanager;
import android.content.Context;
import android.content.SharedPreferences;
public class Config {
private SharedPreferences mPrefs;
public static Config newInstance(Context context) {
return new Config(context);
}
public Config(Context context) {
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
}
public boolean getIsFirstRun() {
return mPrefs.getBoolean(Constants.IS_FIRST_RUN, true);
}
public void setIsFirstRun(boolean firstRun) {
mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply();
}
}

View File

@ -2,4 +2,8 @@ package com.simplemobiletools.filemanager;
public class Constants {
public static final String PATH = "path";
// shared preferences
public static final String PREFS_KEY = "File Manager";
public static final String IS_FIRST_RUN = "is_first_run";
}

View File

@ -0,0 +1,98 @@
package com.simplemobiletools.filemanager.activities;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.simplemobiletools.filemanager.BuildConfig;
import com.simplemobiletools.filemanager.Config;
import com.simplemobiletools.filemanager.R;
import java.util.Calendar;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class AboutActivity extends AppCompatActivity {
@BindView(R.id.about_copyright) TextView mCopyright;
@BindView(R.id.about_email) TextView mEmailTV;
@BindView(R.id.about_rate_us) View mRateUs;
private static Resources mRes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
mRes = getResources();
setupEmail();
setupCopyright();
setupRateUs();
}
private void setupEmail() {
final String email = mRes.getString(R.string.email);
final String appName = mRes.getString(R.string.app_name);
final String href = "<a href=\"mailto:" + email + "?subject=" + appName + "\">" + email + "</a>";
mEmailTV.setText(Html.fromHtml(href));
mEmailTV.setMovementMethod(LinkMovementMethod.getInstance());
}
private void setupCopyright() {
final String versionName = BuildConfig.VERSION_NAME;
final int year = Calendar.getInstance().get(Calendar.YEAR);
final String copyrightText = String.format(mRes.getString(R.string.copyright), versionName, year);
mCopyright.setText(copyrightText);
}
private void setupRateUs() {
if (Config.newInstance(getApplicationContext()).getIsFirstRun()) {
mRateUs.setVisibility(View.GONE);
}
}
@OnClick(R.id.about_rate_us)
public void rateUsClicked() {
final Uri uri = Uri.parse("market://details?id=" + getPackageName());
try {
startActivity(new Intent(Intent.ACTION_VIEW, uri));
} catch (ActivityNotFoundException ignored) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
}
}
@OnClick(R.id.about_license)
public void licenseClicked() {
final Intent intent = new Intent(getApplicationContext(), LicenseActivity.class);
startActivity(intent);
}
@OnClick(R.id.about_facebook)
public void facebookClicked() {
String link = "https://www.facebook.com/simplemobiletools";
try {
getPackageManager().getPackageInfo("com.facebook.katana", 0);
link = "fb://page/150270895341774";
} catch (Exception ignored) {
}
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
}
@OnClick(R.id.about_gplus)
public void googlePlusClicked() {
final String link = "https://plus.google.com/communities/104880861558693868382";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
}
}

View File

@ -0,0 +1,32 @@
package com.simplemobiletools.filemanager.activities;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.simplemobiletools.filemanager.R;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class LicenseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_license);
ButterKnife.bind(this);
}
@OnClick(R.id.license_butterknife_title)
public void butterKnifeClicked() {
openUrl(R.string.butterknife_url);
}
private void openUrl(int id) {
final String url = getResources().getString(id);
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
}
}

View File

@ -1,13 +1,17 @@
package com.simplemobiletools.filemanager.activities;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import com.simplemobiletools.filemanager.Config;
import com.simplemobiletools.filemanager.Constants;
import com.simplemobiletools.filemanager.R;
import com.simplemobiletools.filemanager.Utils;
@ -26,6 +30,12 @@ public class MainActivity extends AppCompatActivity implements ItemsFragment.Ite
tryInitFileManager();
}
@Override
protected void onDestroy() {
super.onDestroy();
Config.newInstance(getApplicationContext()).setIsFirstRun(false);
}
private void tryInitFileManager() {
if (Utils.hasStoragePermission(getApplicationContext())) {
initRootFileManager();
@ -51,6 +61,24 @@ public class MainActivity extends AppCompatActivity implements ItemsFragment.Ite
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).addToBackStack(path).commit();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().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
public void onBackPressed() {
final FragmentManager manager = getSupportFragmentManager();

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/about_scrollview"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/about_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
<TextView
android:id="@+id/about_website"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/website"/>
<TextView
android:id="@+id/about_email_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/about_website"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/email_label"/>
<TextView
android:id="@+id/about_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/about_email_label"
android:text="@string/email"/>
<TextView
android:id="@+id/about_rate_us"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/about_email"
android:layout_marginTop="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/rate_us_underlined"
android:textColor="@color/colorPrimary"/>
<TextView
android:id="@+id/about_license"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/about_rate_us"
android:layout_marginTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:text="@string/third_party_licences_underlined"
android:textColor="@color/colorPrimary"/>
<TextView
android:id="@+id/about_follow_us"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/about_license"
android:paddingBottom="@dimen/social_padding"
android:paddingTop="@dimen/activity_margin"
android:text="@string/follow_us"/>
<ImageView
android:id="@+id/about_facebook"
android:layout_width="@dimen/social_logo"
android:layout_height="@dimen/social_logo"
android:layout_below="@+id/about_follow_us"
android:src="@mipmap/facebook"/>
<ImageView
android:id="@+id/about_gplus"
android:layout_width="@dimen/social_logo"
android:layout_height="@dimen/social_logo"
android:layout_below="@+id/about_follow_us"
android:layout_marginLeft="@dimen/social_padding"
android:layout_toRightOf="@+id/about_facebook"
android:src="@mipmap/gplus"/>
<TextView
android:id="@+id/about_copyright"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/about_gplus"
android:gravity="center_horizontal|bottom"
android:paddingTop="@dimen/activity_margin"
android:text="v1.0\nCopyright © Simple Mobile Tools 2016"/>
</RelativeLayout>
</ScrollView>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/license_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/license"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notice"/>
<TextView
android:id="@+id/license_butterknife_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:text="@string/butterknife_title"
android:textColor="@color/colorPrimary"/>
<TextView
android:id="@+id/license_butterknife_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/butterknife_text"/>
</LinearLayout>
</ScrollView>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/about"
android:title="@string/about"
app:showAsAction="never"/>
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,3 +1,7 @@
<resources>
<dimen name="social_padding">12dp</dimen>
<dimen name="social_logo">50dp</dimen>
<dimen name="settings_padding">12dp</dimen>
<dimen name="normal_text_size">18sp</dimen>
</resources>

View File

@ -1,6 +1,10 @@
<resources>
<dimen name="activity_margin">16dp</dimen>
<dimen name="normal_text_size">14sp</dimen>
<dimen name="medium_margin">8dp</dimen>
<dimen name="icon_size">44dp</dimen>
<dimen name="social_padding">8dp</dimen>
<dimen name="social_logo">40dp</dimen>
<dimen name="settings_padding">8dp</dimen>
<dimen name="normal_text_size">14sp</dimen>
</resources>

View File

@ -2,4 +2,21 @@
<string name="app_name">Simple File Manager</string>
<string name="no_permissions">We need the permission to access your storage</string>
<string name="no_app_found">No app for opening this type of files is available</string>
<!-- About -->
<string name="about">About</string>
<string name="website">More simple apps and source code at:\nhttp://simplemobiletools.com</string>
<string name="email_label">Send your feedback or suggestions to:</string>
<string name="email">hello@simplemobiletools.com</string>
<string name="third_party_licences_underlined"><u>Third party licences</u></string>
<string name="rate_us_underlined"><u>Rate us in the Play Store</u></string>
<string name="follow_us">Follow us:</string>
<string name="copyright">v %1$s\nCopyright © Simple Mobile Tools %2$d</string>
<!--License-->
<string name="notice">This app uses the following third party libraries to make my life easier. Thank you.</string>
<string name="third_party_licences">Third party licences</string>
<string name="butterknife_title"><u>Butter Knife (view injector)</u></string>
<string name="butterknife_text">Copyright 2013 Jake Wharton\n\nLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions and limitations under the License.</string>
<string name="butterknife_url">https://github.com/JakeWharton/butterknife</string>
</resources>