diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java new file mode 100644 index 00000000..b3b6b8a9 --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java @@ -0,0 +1,165 @@ +package com.github.dfa.diaspora_android.activity; + +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.support.design.widget.TabLayout; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.text.Html; +import android.text.SpannableString; +import android.text.util.Linkify; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.github.dfa.diaspora_android.R; + +public class AboutActivity extends AppCompatActivity { + + /** + * The {@link android.support.v4.view.PagerAdapter} that will provide + * fragments for each of the sections. We use a + * {@link FragmentPagerAdapter} derivative, which will keep every + * loaded fragment in memory. If this becomes too memory intensive, it + * may be best to switch to a + * {@link android.support.v4.app.FragmentStatePagerAdapter}. + */ + private SectionsPagerAdapter mSectionsPagerAdapter; + + /** + * The {@link ViewPager} that will host the section contents. + */ + private ViewPager mViewPager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_about); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + // Create the adapter that will return a fragment for each of the three + // primary sections of the activity. + mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); + + // Set up the ViewPager with the sections adapter. + mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager.setAdapter(mSectionsPagerAdapter); + + TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); + tabLayout.setupWithViewPager(mViewPager); + + } + + /** + * Fragment that shows information about the app + */ + public static class AboutFragment extends Fragment { + + public AboutFragment() { + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_about, container, false); + TextView packageName = (TextView) rootView.findViewById(R.id.fragment_about__package_name); + TextView appVersion = (TextView) rootView.findViewById(R.id.fragment_about__app_version); + + if(isAdded()) { + try { + PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); + + packageName.setText(pInfo.packageName); + appVersion.setText(getString(R.string.fragment_about__app_version, pInfo.versionName+ " ("+pInfo.versionCode+")")); + + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + } + return rootView; + } + } + + /** + * Fragment that shows information about the app + */ + public static class LicenseFragment extends Fragment { + + public LicenseFragment() { + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_license, container, false); + return rootView; + } + } + + /** + * Fragment that shows information about the app + */ + public static class DebugFragment extends Fragment { + + public DebugFragment() { + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_about, container, false); + ((TextView) rootView.findViewById(R.id.debug_text)).setText("Debug"); + return rootView; + } + } + + /** + * A {@link FragmentPagerAdapter} that returns a fragment corresponding to + * one of the sections/tabs/pages. + */ + public class SectionsPagerAdapter extends FragmentPagerAdapter { + + public SectionsPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + switch (position) { + case 0: //About + return new AboutFragment(); + case 1: //License + return new LicenseFragment(); + case 3: //Debug + default: + return new DebugFragment(); + } + } + + @Override + public int getCount() { + // Show 3 total pages. + return 3; + } + + @Override + public CharSequence getPageTitle(int position) { + switch (position) { + case 0: + return getString(R.string.about_activity__title_about_app); + case 1: + return getString(R.string.about_activity__title_about_license); + case 2: + return getString(R.string.about_activity__title_debug_info); + } + return null; + } + } +} diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index c9385173..a26780f6 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -768,6 +768,9 @@ public class MainActivity extends AppCompatActivity } return true; } + case R.id.debug: { + startActivity(new Intent(this, AboutActivity.class)); + } } return super.onOptionsItemSelected(item); @@ -1049,14 +1052,14 @@ public class MainActivity extends AppCompatActivity break; case R.id.nav_help_license: { - final CharSequence[] options = {getString(R.string.help_license__name), getString(R.string.help_markdown__name)}; + final CharSequence[] options = {getString(R.string.about_activity__title_about_license), getString(R.string.help_markdown__name)}; new AlertDialog.Builder(MainActivity.this) .setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { - if (options[item].equals(getString(R.string.help_license__name))) { + if (options[item].equals(getString(R.string.about_activity__title_about_license))) { - final SpannableString s = new SpannableString(Html.fromHtml(getString(R.string.help_license__content))); + final SpannableString s = new SpannableString(Html.fromHtml(getString(R.string.fragment_license__license_content))); Linkify.addLinks(s, Linkify.WEB_URLS); final AlertDialog d = new AlertDialog.Builder(MainActivity.this) .setTitle(R.string.help_license__years) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/HtmlTextView.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/HtmlTextView.java new file mode 100644 index 00000000..cb8b30ea --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/HtmlTextView.java @@ -0,0 +1,41 @@ +package com.github.dfa.diaspora_android.ui; + +import android.annotation.TargetApi; +import android.content.Context; +import android.text.Html; +import android.text.SpannableString; +import android.text.util.Linkify; +import android.util.AttributeSet; +import android.widget.TextView; + +import com.github.dfa.diaspora_android.R; + +public class HtmlTextView extends TextView { + + public HtmlTextView(Context context) { + super(context); + init(); + } + + public HtmlTextView(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public HtmlTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + @TargetApi(21) + public HtmlTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + init(); + } + + private void init(){ + final SpannableString content = new SpannableString(Html.fromHtml(getText().toString())); + Linkify.addLinks(content, Linkify.WEB_URLS); + setText(content); + } +} \ No newline at end of file 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 00000000..f1101691 --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml new file mode 100644 index 00000000..7fcdfd61 --- /dev/null +++ b/app/src/main/res/layout/fragment_about.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_license.xml b/app/src/main/res/layout/fragment_license.xml new file mode 100644 index 00000000..97547637 --- /dev/null +++ b/app/src/main/res/layout/fragment_license.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/app/src/main/res/menu/main__menu_bottom.xml b/app/src/main/res/menu/main__menu_bottom.xml index 6e5eee07..c0ed9419 100644 --- a/app/src/main/res/menu/main__menu_bottom.xml +++ b/app/src/main/res/menu/main__menu_bottom.xml @@ -47,5 +47,9 @@ android:icon="@drawable/ic_sync_white_48px" android:title="@string/action_exit_app" app:showAsAction="never" /> + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ad48708c..585811ec 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -74,5 +74,5 @@ Berechtigung erteilt. Bitte versuche es erneut. Markdown Formatierung - Lizenz + Lizenz diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f7fbf7a8..cb8b1536 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -66,5 +66,5 @@ Permiso concedido. Por favor, inténtelo de nuevo. Formato Markdown - Licencia + Licencia diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index ccf762fc..57ff839e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -66,5 +66,5 @@ Permission accordée. Veuillez réessayer. Mise en forme Markdown - Licence + Licence diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index aea4f4fa..15b46b58 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -71,5 +71,5 @@ Permesso garantito. Si prega di riprovare. Formattazione Markdown - Licenza + Licenza diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 77bd26fd..c3d4a083 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -66,5 +66,5 @@ アクセスを許可しました。もう一度やり直してください。 マークダウン書式 - ライセンス + ライセンス diff --git a/app/src/main/res/values-kn/strings.xml b/app/src/main/res/values-kn/strings.xml index a9e5d9ff..cbba6552 100644 --- a/app/src/main/res/values-kn/strings.xml +++ b/app/src/main/res/values-kn/strings.xml @@ -23,5 +23,5 @@ ಎಲ್ಲಾ ಟ್ಯಾಗ್‌ಗಳು - ಪರವಾನಿಗೆ + ಪರವಾನಿಗೆ diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index caed9338..299a3e5e 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -64,5 +64,5 @@ Toestemming verleend. Probeer het opnieuw. Markdown opmaak - Licentie + Licentie diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index e0d52a41..bca7a492 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -66,5 +66,5 @@ Permissão concedida. Por favor, tente novamente. Formatação de markdown - Licença + Licença diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 1d6aa55a..74f79ca4 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -66,5 +66,5 @@ Разрешение получено. Пожалуйста, попробуйте еще раз. Форматирование Markdown - Лицензия + Лицензия diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml index 251fb9fb..e18d571e 100644 --- a/app/src/main/res/values-v21/styles.xml +++ b/app/src/main/res/values-v21/styles.xml @@ -4,6 +4,6 @@ false true true - @android:color/transparent + @color/colorPrimary diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 859c8f4f..b7dd2f36 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,4 +5,6 @@ 16dp 8dp 16dp + 16dp + 8dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 36d80770..474b9da6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ Diaspora + Diaspora for Android @string/diaspora #DiasporaForAndroid The community-run distributed social network @@ -107,9 +108,8 @@ Markdown formatting https://wiki.diasporafoundation.org/Markdown_reference_guide - License Copyright © 2015–2016 - <b>Maintainers:</b><br> + <b>Maintainers:</b><br> • gsantner https://gsantner.github.io<br> • vanitasvitae https://github.com/vanitasvitae<br> <br> @@ -130,5 +130,11 @@ <i>The splashscreen images can be found on flickr: https://www.flickr.com/photos/129581906@N06/sets/72157651933980136/with/16594947123. They were published by \"Lydia\" and are licensed under cc by-nc-sa.</i> + About + License + Debugging + App Version: %1$s + Package Name: %1$s +