mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
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
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fillViewport="true">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<TableLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:stretchColumns="2">
|
||||
<TableRow>
|
||||
android:paddingBottom="2dp"
|
||||
android:stretchColumns="1">
|
||||
<TableRow style="@style/AboutTableRow">
|
||||
<ImageView
|
||||
android:layout_column="1"
|
||||
android:layout_column="0"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/arrow_icon"/>
|
||||
<LinearLayout
|
||||
android:layout_column="2"
|
||||
android:layout_column="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:orientation="vertical">
|
||||
@@ -42,113 +45,58 @@ limitations under the License.
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<View android:layout_height="2dip" />
|
||||
|
||||
<TableRow>
|
||||
<TableRow style="@style/AboutTableRow">
|
||||
<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:textSize="20sp" />
|
||||
style="@style/AboutTextView.Column1"/>
|
||||
<LinearLayout
|
||||
android:layout_column="2"
|
||||
android:layout_column="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/about_bart"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/about_dylan"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/about_jimmy"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/about_leif"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/about_rodrigo"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/about_sandor"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<View android:layout_height="2dip" />
|
||||
|
||||
<TableRow>
|
||||
<TableRow style="@style/AboutTableRow">
|
||||
<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:textSize="20sp" />
|
||||
style="@style/AboutTextView.Column1"/>
|
||||
<TextView
|
||||
android:id="@+id/about_version"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/value_unknown"
|
||||
android:textSize="20sp" />
|
||||
style="@style/AboutTextView"/>
|
||||
</TableRow>
|
||||
|
||||
<View android:layout_height="2dip" />
|
||||
|
||||
<TableRow>
|
||||
<TableRow style="@style/AboutTableRow">
|
||||
<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:textSize="20sp" />
|
||||
style="@style/AboutTextView.Column1"/>
|
||||
<TextView
|
||||
android:autoLink="web"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/my_tracks_web_url"
|
||||
android:textSize="18sp" />
|
||||
</TableRow>
|
||||
|
||||
<View android:layout_height="2dip" />
|
||||
|
||||
<TableRow>
|
||||
style="@style/AboutTextView.Url"/>
|
||||
</TableRow>
|
||||
<TableRow style="@style/AboutTableRow">
|
||||
<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:textSize="20sp" />
|
||||
style="@style/AboutTextView.Column1"/>
|
||||
<TextView
|
||||
android:autoLink="web"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/my_tracks_privacy_url"
|
||||
android:textSize="18sp" />
|
||||
style="@style/AboutTextView.Url"/>
|
||||
</TableRow>
|
||||
|
||||
<View android:layout_height="4dip" />
|
||||
</TableLayout>
|
||||
</ScrollView>
|
||||
@@ -15,6 +15,33 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<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. -->
|
||||
<style name="StatsUnit" parent="@android:Widget.TextView">
|
||||
<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.tasks.StatusAnnouncerFactory;
|
||||
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.UriUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.TabActivity;
|
||||
import android.content.ContentUris;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
@@ -61,6 +65,8 @@ import android.widget.Toast;
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MyTracks extends TabActivity implements OnTouchListener {
|
||||
private static final int DIALOG_EULA_ID = 0;
|
||||
|
||||
private TrackDataHub dataHub;
|
||||
|
||||
/**
|
||||
@@ -188,10 +194,11 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
||||
tabHost.addView(layout);
|
||||
layout.setOnTouchListener(this);
|
||||
|
||||
// This will show the eula until the user accepts or quits the app.
|
||||
Eula.showEulaRequireAcceptance(this);
|
||||
if (!EulaUtil.getEulaValue(this)) {
|
||||
showDialog(DIALOG_EULA_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Log.d(TAG, "MyTracks.onStart");
|
||||
@@ -252,6 +259,40 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
||||
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
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -34,43 +35,54 @@ import android.widget.TextView;
|
||||
*/
|
||||
public class WelcomeActivity extends Activity {
|
||||
|
||||
private static final int DIALOG_ABOUT_ID = 0;
|
||||
private static final int DIALOG_EULA_ID = 1;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.welcome);
|
||||
|
||||
findViewById(R.id.welcome_ok).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.welcome_about).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
showAbout();
|
||||
showDialog(DIALOG_ABOUT_ID);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the "About My Tracks" dialog.
|
||||
*/
|
||||
private void showAbout() {
|
||||
LayoutInflater layoutInflator = LayoutInflater.from(this);
|
||||
View view = layoutInflator.inflate(R.layout.about, null);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.generic_ok, null);
|
||||
builder.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Eula.showEula(WelcomeActivity.this);
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
TextView aboutVersionTextView = (TextView) dialog.findViewById(R.id.about_version);
|
||||
aboutVersionTextView.setText(SystemUtils.getMyTracksVersion(this));
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
AlertDialog.Builder builder;
|
||||
switch (id) {
|
||||
case DIALOG_ABOUT_ID:
|
||||
LayoutInflater layoutInflator = LayoutInflater.from(this);
|
||||
View view = layoutInflator.inflate(R.layout.about, null);
|
||||
TextView aboutVersionTextView = (TextView) view.findViewById(R.id.about_version);
|
||||
aboutVersionTextView.setText(SystemUtils.getMyTracksVersion(this));
|
||||
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.generic_ok, null);
|
||||
builder.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
showDialog(DIALOG_EULA_ID);
|
||||
}
|
||||
});
|
||||
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