add an About activity

This commit is contained in:
tibbi 2016-04-06 20:22:06 +02:00
parent 87de7daf41
commit 42f9815fd9
8 changed files with 60 additions and 0 deletions

View File

@ -39,5 +39,9 @@
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
<activity
android:name="com.simplemobiletools.calculator.AboutActivity"
android:screenOrientation="portrait"/>
</application>
</manifest>

View File

@ -0,0 +1,14 @@
package com.simplemobiletools.calculator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
setTitle(getResources().getString(R.string.about));
}
}

View File

@ -1,8 +1,12 @@
package com.simplemobiletools.calculator;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
@ -28,6 +32,25 @@ public class MainActivity extends AppCompatActivity implements Calculator {
AutofitHelper.create(result);
}
@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);
}
}
private void setupResultView() {
final Resources res = getResources();
result.setBackgroundColor(res.getColor(android.R.color.white));

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/about_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View File

@ -7,6 +7,7 @@
android:layout_height="match_parent"
android:background="@color/dark_grey"
android:orientation="vertical"
android:theme="@style/MainTheme"
tools:context=".MainActivity">
<TextView

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>

View File

@ -1,3 +1,4 @@
<resources>
<string name="app_name">Simple Calculator</string>
<string name="about">About</string>
</resources>

View File

@ -4,6 +4,9 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MainTheme" parent="@style/AppTheme">
<item name="android:textColor">@android:color/white</item>
</style>