Made header clickable

This commit is contained in:
Denis 2014-11-26 15:01:22 +02:00
parent 96dd45fa21
commit 284e6953c8

View file

@ -3,12 +3,16 @@ package net.osmand.plus.dashboard;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@ -19,10 +23,7 @@ import com.actionbarsherlock.view.MenuItem;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.*;
import net.osmand.plus.activities.HelpActivity;
import net.osmand.plus.activities.MainMenuActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TipsAndTricksActivity;
import net.osmand.plus.activities.*;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.download.*;
@ -36,6 +37,7 @@ import java.util.*;
*/
public class DashboardActivity extends BaseDownloadActivity {
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
public static final boolean TIPS_AND_TRICKS = false;
@ -43,7 +45,21 @@ public class DashboardActivity extends BaseDownloadActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard);
getSupportActionBar().setTitle(R.string.app_name_ver);
final String textVersion = getString(R.string.app_name_ver);
getSupportActionBar().setTitle(textVersion);
final int abTitleId = getResources().getIdentifier("action_bar_title", "id", "android");
final SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
findViewById(abTitleId).setOnClickListener(new View.OnClickListener() {
int i=0;
@Override
public void onClick(View view) {
if(i++ > 8) {
prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
enableLink(DashboardActivity.this, textVersion, (TextView)view);
}
}
});
ColorDrawable color = new ColorDrawable(Color.parseColor("#ff8f00"));
getSupportActionBar().setBackgroundDrawable(color);
getSupportActionBar().setIcon(android.R.color.transparent);
@ -64,6 +80,20 @@ public class DashboardActivity extends BaseDownloadActivity {
}
private static void enableLink(final Activity activity, String textVersion, TextView textVersionView) {
SpannableString content = new SpannableString(textVersion);
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
final Intent mapIntent = new Intent(activity, ContributionVersionActivity.class);
activity.startActivityForResult(mapIntent, 0);
}
}, 0, content.length(), 0);
textVersionView.setText(content);
textVersionView.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.add(0, 0, 0, R.string.close).setIcon(R.drawable.ic_ac_help)