Skip to content

Commit

Permalink
Add AboutActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
freekzy committed Nov 4, 2013
1 parent 8147fa6 commit 1854b12
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 6 deletions.
5 changes: 5 additions & 0 deletions AndroidManifest.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
android:label="@string/app_name" >
</activity>

<activity
android:label="@string/app_name"
android:name="AboutActivity" >
</activity>

<service
android:name=".ScannerService"
android:process=":.ScannerService"
Expand Down
38 changes: 38 additions & 0 deletions res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
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"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".AboutActivity" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/app_name" />

<TextView
android:id="@+id/about_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/about_version" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingTop="32dp"
android:onClick="onClick_ViewMore"
android:clickable="true"
android:textColor="#00e"
android:text="@string/about_more" />

</LinearLayout>
3 changes: 3 additions & 0 deletions res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
<string name="yes">Да</string>
<string name="no">Нет</string>

<string name="about_version">Версия %1$s</string>
<string name="about_more">Подробнее...</string>

</resources>
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
<string name="yes">Yes</string>
<string name="no">No</string>

<string name="about_version">Version %1$s</string>
<string name="about_more">More...</string>

</resources>
41 changes: 41 additions & 0 deletions src/org/mozilla/mozstumbler/AboutActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.mozilla.mozstumbler;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

public class AboutActivity extends Activity {
private static final String ABOUT_PAGE_URL = "https://wiki.mozilla.org/Services/Location/About";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
}

@Override
protected void onStart()
{
super.onStart();

TextView textView = (TextView) findViewById(R.id.about_version);
String str = getResources().getString(R.string.about_version);
str = String.format(str, PackageUtils.getAppVersion(this));
textView.setText(str);
}

public void onClick_ViewMore(View v) {
Intent openAboutPage = new Intent(Intent.ACTION_VIEW, Uri.parse(ABOUT_PAGE_URL));
startActivity(openAboutPage);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
return false;
}

}
9 changes: 3 additions & 6 deletions src/org/mozilla/mozstumbler/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
public final class MainActivity extends Activity {
private static final String LOGTAG = MainActivity.class.getName();
private static final String LEADERBOARD_URL = "https://location.services.mozilla.com/leaders";
private static final String ABOUT_PAGE_URL = "https://wiki.mozilla.org/Services/Location/About";

private ScannerServiceInterface mConnectionRemote;
private ServiceConnection mConnection;
Expand Down Expand Up @@ -106,6 +105,7 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(LOGTAG, "onCreate");
}

@TargetApi(11)
private void checkGps() {
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

Expand Down Expand Up @@ -272,13 +272,10 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_about) {
Intent openAboutPage = new Intent(Intent.ACTION_VIEW, Uri.parse(ABOUT_PAGE_URL));
startActivity(openAboutPage);
startActivity(new Intent(getApplication(), AboutActivity.class));
return true;
} else if (item.getItemId() == R.id.action_preferences) {
Intent open= new Intent();
open.setClass(getApplication(), PreferencesScreen.class);
startActivity(open);
startActivity(new Intent(getApplication(), PreferencesScreen.class));
return true;
}

Expand Down

0 comments on commit 1854b12

Please sign in to comment.