Add animation on main screen

This commit is contained in:
Victor Shcherb 2011-05-24 01:07:01 +02:00
parent c1405a076d
commit d950574234
4 changed files with 142 additions and 50 deletions

View file

@ -480,6 +480,7 @@ Destination point is widely used to measure distance and to straight forward nav
<color name="menu_background">#FF9030</color>
<color name="color_light_gray">#d7d7d7</color>
<color name="color_black">#000000</color>
<color name="color_transparent">#00000000</color>
<string name="search_activity">Search</string>
<color name="color_white">#FFFFFF</color>
<color name="color_red">#FF0000</color>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<style name="Dialog_Fullscreen" parent="android:Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/color_transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>

View file

@ -40,13 +40,9 @@ public class MainMenuActivity extends Activity {
private static final String TIPS_SHOW = "TIPS_SHOW"; //$NON-NLS-1$
private static final String EXCEPTION_FILE_SIZE = ResourceManager.APP_DIR + "exception.log"; //$NON-NLS-1$
private View showMap;
private View settingsButton;
private View searchButton;
private View favouritesButton;
private View closeButton;
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
public static final int APP_EXIT_CODE = 4;
public void checkPreviousRunsForExceptions(boolean firstTime) {
@ -95,7 +91,15 @@ public class MainMenuActivity extends Activity {
}
}
public Animation getAnimation(int left, int top){
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == APP_EXIT_CODE){
finish();
}
}
public static Animation getAnimation(int left, int top){
Animation anim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, left,
TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, top, TranslateAnimation.RELATIVE_TO_SELF, 0);
anim.setDuration(700);
@ -103,33 +107,28 @@ public class MainMenuActivity extends Activity {
return anim;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu);
View head = (View) findViewById(R.id.Headliner);
public static void onCreateMainMenu(Window window, final Activity activity){
View head = (View) window.findViewById(R.id.Headliner);
head.startAnimation(getAnimation(0, -1));
View leftview = (View) findViewById(R.id.MapButton);
View leftview = (View) window.findViewById(R.id.MapButton);
leftview.startAnimation(getAnimation(-1, 0));
leftview = (View) findViewById(R.id.FavoritesButton);
leftview = (View) window.findViewById(R.id.FavoritesButton);
leftview.startAnimation(getAnimation(-1, 0));
View rightview = (View) findViewById(R.id.SettingsButton);
View rightview = (View) window.findViewById(R.id.SettingsButton);
rightview.startAnimation(getAnimation(1, 0));
rightview = (View) findViewById(R.id.SearchButton);
rightview = (View) window.findViewById(R.id.SearchButton);
rightview.startAnimation(getAnimation(1, 0));
String textVersion = Version.APP_VERSION + " " + Version.APP_DESCRIPTION;
final TextView textVersionView = (TextView) findViewById(R.id.TextVersion);
final TextView textVersionView = (TextView) window.findViewById(R.id.TextVersion);
textVersionView.setText(textVersion);
SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
SharedPreferences prefs = activity.getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
// only one commit should be with contribution version flag
// prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
final TextView appName = (TextView) findViewById(R.id.AppName);
final TextView appName = (TextView) window.findViewById(R.id.AppName);
if (prefs.contains(CONTRIBUTION_VERSION_FLAG)) {
appName.setText("OsmAnd!");
SpannableString content = new SpannableString(textVersion);
@ -137,8 +136,8 @@ public class MainMenuActivity extends Activity {
@Override
public void onClick(View widget) {
final Intent mapIndent = new Intent(MainMenuActivity.this, ContributionVersionActivity.class);
startActivityForResult(mapIndent, 0);
final Intent mapIndent = new Intent(activity, ContributionVersionActivity.class);
activity.startActivityForResult(mapIndent, 0);
}
}, 0, content.length(), 0);
textVersionView.setText(content);
@ -149,61 +148,73 @@ public class MainMenuActivity extends Activity {
@Override
public void onClick(View widget) {
TipsAndTricksActivity activity = new TipsAndTricksActivity(MainMenuActivity.this);
Dialog dlg = activity.getDialogToShowTips(false);
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(activity);
Dialog dlg = tactivity.getDialogToShowTips(false);
dlg.show();
}
}, appLink.length() - 1, appLink.length(), 0);
appName.setText(appLink);
appName.setMovementMethod(LinkMovementMethod.getInstance());
}
showMap = findViewById(R.id.MapButton);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu);
onCreateMainMenu(getWindow(), this);
Window window = getWindow();
final Activity activity = this;
View showMap = window.findViewById(R.id.MapButton);
showMap.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent mapIndent = new Intent(MainMenuActivity.this, MapActivity.class);
startActivityForResult(mapIndent, 0);
final Intent mapIndent = new Intent(activity, MapActivity.class);
activity.startActivityForResult(mapIndent, 0);
}
});
settingsButton = findViewById(R.id.SettingsButton);
View settingsButton = window.findViewById(R.id.SettingsButton);
settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent settings = new Intent(MainMenuActivity.this, SettingsActivity.class);
startActivity(settings);
final Intent settings = new Intent(activity, SettingsActivity.class);
activity.startActivity(settings);
}
});
favouritesButton = findViewById(R.id.FavoritesButton);
View favouritesButton = window.findViewById(R.id.FavoritesButton);
favouritesButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent settings = new Intent(MainMenuActivity.this, FavouritesActivity.class);
startActivity(settings);
final Intent settings = new Intent(activity, FavouritesActivity.class);
activity.startActivity(settings);
}
});
closeButton = findViewById(R.id.CloseButton);
View closeButton = window.findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((OsmandApplication) getApplication()).closeApplication();
finish();
((OsmandApplication) activity.getApplication()).closeApplication();
activity.finish();
}
});
searchButton = findViewById(R.id.SearchButton);
View searchButton = window.findViewById(R.id.SearchButton);
searchButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent search = new Intent(MainMenuActivity.this, SearchActivity.class);
startActivity(search);
final Intent search = new Intent(activity, SearchActivity.class);
activity.startActivity(search);
}
});
((OsmandApplication)getApplication()).checkApplicationIsBeingInitialized(this);
@ -245,8 +256,8 @@ public class MainMenuActivity extends Activity {
if (i < 7){
pref.edit().putInt(TIPS_SHOW, ++i).commit();
if(i == 1 || i == 5){
TipsAndTricksActivity activity = new TipsAndTricksActivity(this);
Dialog dlg = activity.getDialogToShowTips(true);
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
Dialog dlg = tipsActivity.getDialogToShowTips(true);
dlg.show();
}
}

View file

@ -67,6 +67,8 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@ -94,6 +96,9 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
@ -366,9 +371,74 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
public void backToMainMenu(){
Intent newIntent = new Intent(MapActivity.this, MainMenuActivity.class);
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(newIntent);
final Dialog dlg = new Dialog(this, R.style.Dialog_Fullscreen);
final View view = (View) getLayoutInflater().inflate(R.layout.menu, null);
view.setBackgroundColor(Color.argb(200, 150, 150, 150));
dlg.setContentView(view);
MainMenuActivity.onCreateMainMenu(dlg.getWindow(), this);
Animation anim = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
ColorDrawable colorDraw = ((ColorDrawable) view.getBackground());
colorDraw.setAlpha((int) (interpolatedTime * 200));
}
};
anim.setDuration(700);
anim.setInterpolator(new AccelerateInterpolator());
view.setAnimation(anim);
View showMap = dlg.findViewById(R.id.MapButton);
showMap.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dlg.dismiss();
}
});
View settingsButton = dlg.findViewById(R.id.SettingsButton);
settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent settings = new Intent(MapActivity.this, SettingsActivity.class);
MapActivity.this.startActivity(settings);
dlg.dismiss();
}
});
View favouritesButton = dlg.findViewById(R.id.FavoritesButton);
favouritesButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent settings = new Intent(MapActivity.this, FavouritesActivity.class);
MapActivity.this.startActivity(settings);
dlg.dismiss();
}
});
View closeButton = dlg.findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((OsmandApplication) getApplication()).closeApplication();
dlg.dismiss();
MapActivity.this.setResult(MainMenuActivity.APP_EXIT_CODE);
MapActivity.this.finish();
}
});
View searchButton = dlg.findViewById(R.id.SearchButton);
searchButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent search = new Intent(MapActivity.this, SearchActivity.class);
MapActivity.this.startActivity(search);
dlg.dismiss();
}
});
dlg.show();
// Intent newIntent = new Intent(MapActivity.this, MainMenuActivity.class);
//newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(newIntent);
}
@Override