1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-25 05:42:10 +01:00

Added lorem ipsum and some more visual tweaks to AboutActivity

This commit is contained in:
vanitasvitae 2016-08-25 00:23:20 +02:00
parent 50f5a79c30
commit c62f38e693
7 changed files with 138 additions and 29 deletions

View file

@ -10,40 +10,34 @@ import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.Html; import android.util.Log;
import android.text.SpannableString;
import android.text.util.Linkify;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.data.AppSettings;
public class AboutActivity extends AppCompatActivity { 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; private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager; private ViewPager mViewPager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about); setContentView(R.layout.activity_about);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AboutActivity.this.onBackPressed();
}
});
// Create the adapter that will return a fragment for each of the three // Create the adapter that will return a fragment for each of the three
// primary sections of the activity. // primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
@ -75,9 +69,8 @@ public class AboutActivity extends AppCompatActivity {
if(isAdded()) { if(isAdded()) {
try { try {
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
packageName.setText(pInfo.packageName); packageName.setText(pInfo.packageName);
appVersion.setText(getString(R.string.fragment_about__app_version, pInfo.versionName+ " ("+pInfo.versionCode+")")); appVersion.setText(getString(R.string.fragment_debug__app_version, pInfo.versionName+ " ("+pInfo.versionCode+")"));
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
@ -114,8 +107,25 @@ public class AboutActivity extends AppCompatActivity {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_about, container, false); View rootView = inflater.inflate(R.layout.fragment_debug, container, false);
((TextView) rootView.findViewById(R.id.debug_text)).setText("Debug"); TextView packageName = (TextView) rootView.findViewById(R.id.fragment_debug__package_name);
TextView appVersion = (TextView) rootView.findViewById(R.id.fragment_debug__app_version);
TextView podDomain = (TextView) rootView.findViewById(R.id.fragment_debug__pod_domain);
if(isAdded()) {
try {
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
AppSettings settings = ((App) getActivity().getApplication()).getSettings();
packageName.setText(pInfo.packageName);
appVersion.setText(getString(R.string.fragment_debug__app_version, pInfo.versionName+ " ("+pInfo.versionCode+")"));
podDomain.setText(getString(R.string.fragment_debug__pod_domain, settings.getPodDomain()));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
return rootView; return rootView;
} }
} }

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
</vector>

View file

@ -14,14 +14,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout <LinearLayout
android:id="@+id/tabs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"/> app:popupTheme="@style/AppTheme.PopupOverlay">
<android.support.v7.widget.Toolbar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toolbar"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager

View file

@ -5,7 +5,6 @@
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.github.dfa.diaspora_android.activity.AboutActivity$AboutFragment"> tools:context="com.github.dfa.diaspora_android.activity.AboutActivity$AboutFragment">
<LinearLayout <LinearLayout
@ -13,10 +12,16 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<!--Vertical padding-->
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="@dimen/activity_vertical_margin" />
<TextView <TextView
android:id="@+id/debug_text" android:id="@+id/fragment_about__app_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAlignment="center"
android:text="@string/diaspora_for_android" android:text="@string/diaspora_for_android"
style="@android:style/TextAppearance.DeviceDefault.Large"/> style="@android:style/TextAppearance.DeviceDefault.Large"/>
@ -29,5 +34,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/fragment_about__app_version"/> android:id="@+id/fragment_about__app_version"/>
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="32dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:text="@string/lorem_ipsum"/>
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView> </android.support.v4.widget.NestedScrollView>

View file

@ -0,0 +1,50 @@
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context="com.github.dfa.diaspora_android.activity.AboutActivity$DebugFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--Vertical padding-->
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="@dimen/activity_vertical_margin" />
<TextView
android:id="@+id/fragment_debug__section_app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/fragment_debug__section_app"
style="@android:style/TextAppearance.DeviceDefault.Large"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragment_debug__package_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragment_debug__app_version"/>
<TextView
android:id="@+id/fragment_debug__section_pod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/fragment_debug__section_pod"
style="@android:style/TextAppearance.DeviceDefault.Large"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragment_debug__pod_domain"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

View file

@ -5,7 +5,6 @@
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.github.dfa.diaspora_android.activity.AboutActivity$LicenseFragment"> tools:context="com.github.dfa.diaspora_android.activity.AboutActivity$LicenseFragment">
<LinearLayout <LinearLayout
@ -13,11 +12,16 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<!--Vertical Padding-->
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="@dimen/activity_vertical_margin" />
<com.github.dfa.diaspora_android.ui.HtmlTextView <com.github.dfa.diaspora_android.ui.HtmlTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/fragment_license__license_content"
android:text="@string/fragment_license__license_content" android:text="@string/fragment_license__license_content"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:linksClickable="true" android:linksClickable="true"
android:autoLink="web"/> android:autoLink="web"/>
</LinearLayout> </LinearLayout>

View file

@ -133,8 +133,12 @@
<string name="about_activity__title_about_app">About</string> <string name="about_activity__title_about_app">About</string>
<string name="about_activity__title_about_license">License</string> <string name="about_activity__title_about_license">License</string>
<string name="about_activity__title_debug_info">Debugging</string> <string name="about_activity__title_debug_info">Debugging</string>
<string name="fragment_about__app_version">App Version: %1$s</string> <string name="fragment_debug__section_app">Application</string>
<string name="fragment_about__package_name">Package Name: %1$s</string> <string name="fragment_debug__section_pod">Diaspora Pod</string>
<string name="fragment_debug__app_version">App Version: %1$s</string>
<string name="fragment_debug__package_name">Package Name: %1$s</string>
<string name="fragment_debug__pod_domain">Pod Domain: %1$s</string>
<string name="lorem_ipsum" translatable="false">Auch gibt es niemanden, der den Schmerz an sich liebt, sucht oder wünscht, nur, weil er Schmerz ist, es sei denn, es kommt zu zufälligen Umständen, in denen Mühen und Schmerz ihm große Freude bereiten können. Um ein triviales Beispiel zu nehmen, wer von uns unterzieht sich je anstrengender körperlicher Betätigung, außer um Vorteile daraus zu ziehen? Aber wer hat irgend ein Recht, einen Menschen zu tadeln, der die Entscheidung trifft, eine Freude zu genießen, die keine unangenehmen Folgen hat, oder einen, der Schmerz vermeidet, welcher keine daraus resultierende Freude nach sich zieht? Auch gibt es niemanden, der den Schmerz an sich liebt, sucht oder wünscht, nur, weil er Schmerz ist, es sei denn, es kommt zu zufälligen Umständen, in denen Mühen und Schmerz ihm große Freude bereiten können. Um ein triviales Beispiel zu nehmen, wer von uns unterzieht sich je anstrengender körperlicher Betätigung, außer um Vorteile daraus zu ziehen? Aber wer hat irgend ein Recht, einen Menschen zu tadeln, der die Entscheidung trifft, eine Freude zu genießen, die keine unangenehmen Folgen hat, oder einen, der Schmerz vermeidet, welcher keine daraus resultierende Freude nach sich zieht?</string>
</resources> </resources>