forked from upstream-mirrors/OpenTracks
Fix comment on b32833d4588e
- use Activity.showDialog to display dialogs to avoid memory leaks when just calling dialog.show, and to support rotation.
This commit is contained in:
@@ -16,17 +16,20 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<ScrollView
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:fillViewport="true">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content">
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:stretchColumns="2">
|
android:paddingBottom="2dp"
|
||||||
<TableRow>
|
android:stretchColumns="1">
|
||||||
|
<TableRow style="@style/AboutTableRow">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_column="1"
|
android:layout_column="0"
|
||||||
|
android:scaleType="center"
|
||||||
android:src="@drawable/arrow_icon"/>
|
android:src="@drawable/arrow_icon"/>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_column="2"
|
android:layout_column="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@@ -42,113 +45,58 @@ limitations under the License.
|
|||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow style="@style/AboutTableRow">
|
||||||
<View android:layout_height="2dip" />
|
|
||||||
|
|
||||||
<TableRow>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_column="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:paddingLeft="10dip"
|
|
||||||
android:paddingRight="10dip"
|
|
||||||
android:text="@string/about_team"
|
android:text="@string/about_team"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView.Column1"/>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_column="2"
|
android:layout_column="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/about_bart"
|
android:text="@string/about_bart"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/about_dylan"
|
android:text="@string/about_dylan"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/about_jimmy"
|
android:text="@string/about_jimmy"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/about_leif"
|
android:text="@string/about_leif"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/about_rodrigo"
|
android:text="@string/about_rodrigo"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/about_sandor"
|
android:text="@string/about_sandor"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow style="@style/AboutTableRow">
|
||||||
<View android:layout_height="2dip" />
|
|
||||||
|
|
||||||
<TableRow>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_column="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:paddingLeft="10dip"
|
|
||||||
android:paddingRight="10dip"
|
|
||||||
android:text="@string/about_version"
|
android:text="@string/about_version"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView.Column1"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/about_version"
|
android:id="@+id/about_version"
|
||||||
android:layout_height="wrap_content"
|
style="@style/AboutTextView"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/value_unknown"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow style="@style/AboutTableRow">
|
||||||
<View android:layout_height="2dip" />
|
|
||||||
|
|
||||||
<TableRow>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_column="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:paddingLeft="10dip"
|
|
||||||
android:paddingRight="10dip"
|
|
||||||
android:text="@string/about_support"
|
android:text="@string/about_support"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView.Column1"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:autoLink="web"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/my_tracks_web_url"
|
android:text="@string/my_tracks_web_url"
|
||||||
android:textSize="18sp" />
|
style="@style/AboutTextView.Url"/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow style="@style/AboutTableRow">
|
||||||
<View android:layout_height="2dip" />
|
|
||||||
|
|
||||||
<TableRow>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_column="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:paddingLeft="10dip"
|
|
||||||
android:paddingRight="10dip"
|
|
||||||
android:text="@string/about_privacy"
|
android:text="@string/about_privacy"
|
||||||
android:textSize="20sp" />
|
style="@style/AboutTextView.Column1"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:autoLink="web"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/my_tracks_privacy_url"
|
android:text="@string/my_tracks_privacy_url"
|
||||||
android:textSize="18sp" />
|
style="@style/AboutTextView.Url"/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<View android:layout_height="4dip" />
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
@@ -15,6 +15,33 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
|
<!-- About dialog TableRow -->
|
||||||
|
<style name="AboutTableRow">
|
||||||
|
<item name="android:paddingBottom">2dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- About dialog TextView -->
|
||||||
|
<style name="AboutTextView">
|
||||||
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
<item name="android:layout_width">wrap_content</item>
|
||||||
|
<item name="android:textSize">20sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- About dialog TextView Column1 -->
|
||||||
|
<style name="AboutTextView.Column1">
|
||||||
|
<item name="android:gravity">right</item>
|
||||||
|
<item name="android:layout_column">0</item>
|
||||||
|
<item name="android:paddingLeft">10dp</item>
|
||||||
|
<item name="android:paddingRight">10dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- About dialog TextView Url -->
|
||||||
|
<style name="AboutTextView.Url">
|
||||||
|
<item name="android:autoLink">web</item>
|
||||||
|
<item name="android:textSize">18sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- The style for the unit on the statistics activity. -->
|
<!-- The style for the unit on the statistics activity. -->
|
||||||
<style name="StatsUnit" parent="@android:Widget.TextView">
|
<style name="StatsUnit" parent="@android:Widget.TextView">
|
||||||
<item name="android:gravity">bottom</item>
|
<item name="android:gravity">bottom</item>
|
||||||
|
|||||||
@@ -28,13 +28,17 @@ import com.google.android.apps.mytracks.services.ServiceUtils;
|
|||||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||||
import com.google.android.apps.mytracks.services.tasks.StatusAnnouncerFactory;
|
import com.google.android.apps.mytracks.services.tasks.StatusAnnouncerFactory;
|
||||||
import com.google.android.apps.mytracks.util.ApiFeatures;
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
|
import com.google.android.apps.mytracks.util.EulaUtil;
|
||||||
import com.google.android.apps.mytracks.util.SystemUtils;
|
import com.google.android.apps.mytracks.util.SystemUtils;
|
||||||
import com.google.android.apps.mytracks.util.UriUtils;
|
import com.google.android.apps.mytracks.util.UriUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -61,6 +65,8 @@ import android.widget.Toast;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class MyTracks extends TabActivity implements OnTouchListener {
|
public class MyTracks extends TabActivity implements OnTouchListener {
|
||||||
|
private static final int DIALOG_EULA_ID = 0;
|
||||||
|
|
||||||
private TrackDataHub dataHub;
|
private TrackDataHub dataHub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,10 +194,11 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
|||||||
tabHost.addView(layout);
|
tabHost.addView(layout);
|
||||||
layout.setOnTouchListener(this);
|
layout.setOnTouchListener(this);
|
||||||
|
|
||||||
// This will show the eula until the user accepts or quits the app.
|
if (!EulaUtil.getEulaValue(this)) {
|
||||||
Eula.showEulaRequireAcceptance(this);
|
showDialog(DIALOG_EULA_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
Log.d(TAG, "MyTracks.onStart");
|
Log.d(TAG, "MyTracks.onStart");
|
||||||
@@ -252,6 +259,40 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
switch (id) {
|
||||||
|
case DIALOG_EULA_ID:
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.eula_title);
|
||||||
|
builder.setMessage(R.string.eula_message);
|
||||||
|
builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
EulaUtil.setEulaValue(MyTracks.this);
|
||||||
|
Intent startIntent = new Intent(MyTracks.this, WelcomeActivity.class);
|
||||||
|
startActivityForResult(startIntent, Constants.WELCOME);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(R.string.eula_decline, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setCancelable(true);
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.google.android.maps.mytracks.R;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -34,43 +35,54 @@ import android.widget.TextView;
|
|||||||
*/
|
*/
|
||||||
public class WelcomeActivity extends Activity {
|
public class WelcomeActivity extends Activity {
|
||||||
|
|
||||||
|
private static final int DIALOG_ABOUT_ID = 0;
|
||||||
|
private static final int DIALOG_EULA_ID = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.welcome);
|
setContentView(R.layout.welcome);
|
||||||
|
|
||||||
findViewById(R.id.welcome_ok).setOnClickListener(new OnClickListener() {
|
findViewById(R.id.welcome_ok).setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
findViewById(R.id.welcome_about).setOnClickListener(new OnClickListener() {
|
findViewById(R.id.welcome_about).setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showAbout();
|
showDialog(DIALOG_ABOUT_ID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Shows the "About My Tracks" dialog.
|
protected Dialog onCreateDialog(int id) {
|
||||||
*/
|
AlertDialog.Builder builder;
|
||||||
private void showAbout() {
|
switch (id) {
|
||||||
LayoutInflater layoutInflator = LayoutInflater.from(this);
|
case DIALOG_ABOUT_ID:
|
||||||
View view = layoutInflator.inflate(R.layout.about, null);
|
LayoutInflater layoutInflator = LayoutInflater.from(this);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
View view = layoutInflator.inflate(R.layout.about, null);
|
||||||
builder.setView(view);
|
TextView aboutVersionTextView = (TextView) view.findViewById(R.id.about_version);
|
||||||
builder.setPositiveButton(R.string.generic_ok, null);
|
aboutVersionTextView.setText(SystemUtils.getMyTracksVersion(this));
|
||||||
builder.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
builder = new AlertDialog.Builder(this);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
builder.setView(view);
|
||||||
Eula.showEula(WelcomeActivity.this);
|
builder.setPositiveButton(R.string.generic_ok, null);
|
||||||
}
|
builder.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||||
});
|
@Override
|
||||||
AlertDialog dialog = builder.create();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.show();
|
showDialog(DIALOG_EULA_ID);
|
||||||
|
}
|
||||||
TextView aboutVersionTextView = (TextView) dialog.findViewById(R.id.about_version);
|
});
|
||||||
aboutVersionTextView.setText(SystemUtils.getMyTracksVersion(this));
|
return builder.create();
|
||||||
|
case DIALOG_EULA_ID:
|
||||||
|
builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.eula_title);
|
||||||
|
builder.setMessage(R.string.eula_message);
|
||||||
|
builder.setPositiveButton(R.string.generic_ok, null);
|
||||||
|
builder.setCancelable(true);
|
||||||
|
return builder.create();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user