Add menu items to Help and Feedback page

This commit is contained in:
Jimmy Shih
2014-01-08 15:46:41 -08:00
parent 33886cc2ad
commit 68f84c5d39
9 changed files with 87 additions and 224 deletions
@@ -16,17 +16,19 @@
package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.fragments.AboutDialogFragment;
import com.google.android.apps.mytracks.fragments.AboutDialogFragment.AboutCaller;
import com.google.android.apps.mytracks.fragments.EulaDialogFragment;
import com.google.android.apps.mytracks.fragments.EulaDialogFragment.EulaCaller;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.GoogleFeedbackUtils;
import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@@ -37,7 +39,7 @@ import java.util.Locale;
*
* @author Sandor Dornbush
*/
public class HelpActivity extends AbstractMyTracksActivity implements AboutCaller, EulaCaller {
public class HelpActivity extends AbstractMyTracksActivity implements EulaCaller {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -47,7 +49,7 @@ public class HelpActivity extends AbstractMyTracksActivity implements AboutCalle
+ SystemUtils.getMyTracksVersion(this);
ApiAdapterFactory.getApiAdapter()
.setTitleAndSubtitle(this, getString(R.string.menu_help), subtitle);
WebView webView = (WebView) findViewById(R.id.help_webview);
String language = Locale.getDefault().getLanguage();
if (language == null || language.equals("")) {
@@ -57,15 +59,11 @@ public class HelpActivity extends AbstractMyTracksActivity implements AboutCalle
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
findViewById(R.id.help_ok).setOnClickListener(new OnClickListener() {
findViewById(R.id.help_feedback).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
findViewById(R.id.help_about).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
new AboutDialogFragment().show(
getSupportFragmentManager(), AboutDialogFragment.ABOUT_DIALOG_TAG);
GoogleFeedbackUtils.bindFeedback(HelpActivity.this);
}
});
}
@@ -76,9 +74,33 @@ public class HelpActivity extends AbstractMyTracksActivity implements AboutCalle
}
@Override
public void onAboutLicense() {
EulaDialogFragment.newInstance(true)
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.help, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.help_play_store:
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.google.android.maps.mytracks"));
startActivity(intent);
return true;
case R.id.help_eula:
EulaDialogFragment.newInstance(true)
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
return true;
case R.id.help_forum:
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(
"http://groups.google.com/a/googleproductforums.com/forum/#!categories/maps/mytracks/"));
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
@@ -1,80 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.util.SystemUtils;
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.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;
/**
* A DialogFragment to show information about My Tracks.
*
* @author Jimmy Shih
*/
public class AboutDialogFragment extends AbstractMyTracksDialogFragment {
/**
* Interface for caller of this dialog fragment.
*
* @author Jimmy Shih
*/
public interface AboutCaller {
/**
* Called when about license is invoked.
*/
public void onAboutLicense();
}
public static final String ABOUT_DIALOG_TAG = "aboutDialog";
private AboutCaller caller;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
caller = (AboutCaller) activity;
} catch (ClassCastException e) {
throw new ClassCastException(
activity.toString() + " must implement " + AboutCaller.class.getSimpleName());
}
}
@Override
protected Dialog createDialog() {
FragmentActivity fragmentActivity = getActivity();
View view = fragmentActivity.getLayoutInflater().inflate(R.layout.about, null);
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
aboutVersion.setText(SystemUtils.getMyTracksVersion(fragmentActivity));
return new AlertDialog.Builder(fragmentActivity).setNegativeButton(
R.string.about_license, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
caller.onAboutLicense();
}
}).setPositiveButton(R.string.generic_ok, null).setTitle(R.string.help_about).setView(view)
.create();
}
}
@@ -90,7 +90,7 @@ public class EulaDialogFragment extends AbstractMyTracksDialogFragment {
Linkify.addLinks(message, Linkify.WEB_URLS);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setMessage(message)
.setTitle(R.string.eula_title);
.setTitle(R.string.menu_help_eula);
if (hasAccepted) {
builder.setPositiveButton(R.string.generic_ok, null);