Browse Source

Activity Transaction animations merged

master
Stefano Pacifici 9 years ago
parent
commit
47103ba3d0
  1. 11
      app/src/main/java/acr/browser/lightning/activity/AppCompatPreferenceActivity.java
  2. 21
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  3. 19
      app/src/main/java/acr/browser/lightning/activity/BrowserApp.java
  4. 25
      app/src/main/java/acr/browser/lightning/app/AppComponent.java
  5. 41
      app/src/main/java/acr/browser/lightning/app/AppModule.java
  6. 32
      app/src/main/java/acr/browser/lightning/app/BrowserApp.java
  7. 19
      app/src/main/java/acr/browser/lightning/bus/BusProvider.java
  8. 7
      app/src/main/java/acr/browser/lightning/dialog/BookmarksDialogBuilder.java
  9. 16
      app/src/main/res/anim/fade_in_scale.xml
  10. 16
      app/src/main/res/anim/fade_out_scale.xml
  11. 12
      app/src/main/res/anim/slide_down_out.xml
  12. 12
      app/src/main/res/anim/slide_in_from_right.xml
  13. 12
      app/src/main/res/anim/slide_out_to_right.xml
  14. 12
      app/src/main/res/anim/slide_up_in.xml

11
app/src/main/java/acr/browser/lightning/activity/AppCompatPreferenceActivity.java

@ -13,6 +13,8 @@ import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import acr.browser.lightning.R;
/** /**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat. * to be used with AppCompat.
@ -26,6 +28,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale);
getDelegate().installViewFactory(); getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState); getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -89,6 +92,14 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
getDelegate().onConfigurationChanged(newConfig); getDelegate().onConfigurationChanged(newConfig);
} }
@Override
protected void onPause() {
super.onPause();
if (isFinishing()) {
overridePendingTransition(R.anim.fade_in_scale, R.anim.slide_out_to_right);
}
}
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();

21
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -178,7 +178,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Image // Image
private Bitmap mDefaultVideoPoster, mWebpageBitmap; private Bitmap mDefaultVideoPoster, mWebpageBitmap;
private final ColorDrawable mBackground = new ColorDrawable(); private final ColorDrawable mBackground = new ColorDrawable();
private Drawable mDeleteIcon, mRefreshIcon, mSearchIcon, mIcon; private Drawable mDeleteIcon, mRefreshIcon, mClearIcon, mIcon;
private DrawerArrowDrawable mArrowDrawable; private DrawerArrowDrawable mArrowDrawable;
// Proxy // Proxy
@ -324,12 +324,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
mDeleteIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_delete); mDeleteIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_delete);
mRefreshIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_refresh); mRefreshIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_refresh);
mSearchIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_forward); mClearIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_delete);
int iconBounds = Utils.dpToPx(30); int iconBounds = Utils.dpToPx(30);
mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds); mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds); mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
mSearchIcon.setBounds(0, 0, iconBounds, iconBounds); mClearIcon.setBounds(0, 0, iconBounds, iconBounds);
mIcon = mRefreshIcon; mIcon = mRefreshIcon;
SearchListenerClass search = new SearchListenerClass(); SearchListenerClass search = new SearchListenerClass();
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
@ -418,8 +418,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
((AutoCompleteTextView) v).selectAll(); // Hack to make sure ((AutoCompleteTextView) v).selectAll(); // Hack to make sure
// the text gets // the text gets
// selected // selected
mIcon = mSearchIcon; mIcon = mClearIcon;
mSearch.setCompoundDrawables(null, null, mSearchIcon, null); mSearch.setCompoundDrawables(null, null, mClearIcon, null);
} }
final Animation anim = new Animation() { final Animation anim = new Animation() {
@ -485,12 +485,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
if (tappedX) { if (tappedX) {
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
if (mSearch.hasFocus()) { if (mSearch.hasFocus()) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mSearch.setText("");
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
} else { } else {
refreshOrStop(); refreshOrStop();
} }
@ -739,6 +734,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return true; return true;
case R.id.action_incognito: case R.id.action_incognito:
startActivity(new Intent(this, IncognitoActivity.class)); startActivity(new Intent(this, IncognitoActivity.class));
overridePendingTransition(R.anim.slide_up_in, R.anim.fade_out_scale);
return true; return true;
case R.id.action_share: case R.id.action_share:
if (mCurrentView != null && !mCurrentView.getUrl().startsWith(Constants.FILE)) { if (mCurrentView != null && !mCurrentView.getUrl().startsWith(Constants.FILE)) {
@ -1203,6 +1199,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (isIncognito() && isFinishing()) {
overridePendingTransition(R.anim.fade_in_scale, R.anim.slide_down_out);
}
BusProvider.getInstance().unregister(busEventListener); BusProvider.getInstance().unregister(busEventListener);
} }

19
app/src/main/java/acr/browser/lightning/activity/BrowserApp.java

@ -1,19 +0,0 @@
package acr.browser.lightning.activity;
import android.app.Application;
import android.content.Context;
public class BrowserApp extends Application {
private static Context context;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
public static Context getAppContext() {
return context;
}
}

25
app/src/main/java/acr/browser/lightning/app/AppComponent.java

@ -0,0 +1,25 @@
package acr.browser.lightning.app;
import javax.inject.Singleton;
import acr.browser.lightning.activity.BrowserActivity;
import acr.browser.lightning.fragment.BookmarkSettingsFragment;
import acr.browser.lightning.fragment.BookmarksFragment;
import acr.browser.lightning.object.SearchAdapter;
import dagger.Component;
/**
* Created by Stefano Pacifici on 01/09/15.
*/
@Singleton
@Component(modules = {AppModule.class})
public interface AppComponent {
void inject(BrowserActivity activity);
void inject(BookmarksFragment fragment);
void inject(BookmarkSettingsFragment fragment);
void inject(SearchAdapter adapter);
}

41
app/src/main/java/acr/browser/lightning/app/AppModule.java

@ -0,0 +1,41 @@
package acr.browser.lightning.app;
import android.content.Context;
import com.squareup.otto.Bus;
import javax.inject.Singleton;
import acr.browser.lightning.database.BookmarkManager;
import dagger.Module;
import dagger.Provides;
/**
* Created by Stefano Pacifici on 01/09/15.
*/
@Module
public class AppModule {
private final BrowserApp app;
private final Bus bus;
public AppModule(BrowserApp app) {
this.app = app;
this.bus = new Bus();
}
@Provides
public Context provideContext() {
return app.getApplicationContext();
}
@Provides
@Singleton
public BookmarkManager provideBookmarkManager() {
return new BookmarkManager(app.getApplicationContext());
}
@Provides
public Bus provideBus() {
return bus;
}
}

32
app/src/main/java/acr/browser/lightning/app/BrowserApp.java

@ -0,0 +1,32 @@
package acr.browser.lightning.app;
import android.app.Application;
import android.content.Context;
import acr.browser.lightning.activity.DaggerAppComponent;
public class BrowserApp extends Application {
private static Context context;
private static AppComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
buildDepencyGraph();
}
public static Context getAppContext() {
return context;
}
public static AppComponent getAppComponent() {
return appComponent;
}
public void buildDepencyGraph() {
appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
}
}

19
app/src/main/java/acr/browser/lightning/bus/BusProvider.java

@ -1,19 +0,0 @@
package acr.browser.lightning.bus;
import com.squareup.otto.Bus;
/**
* Created by Stefano Pacifici on 25/08/15.
*/
public class BusProvider {
private static final Bus bus = new Bus();
public static Bus getInstance() {
return bus;
}
private BusProvider() {
// No instances
}
}

7
app/src/main/java/acr/browser/lightning/dialog/BookmarksDialogBuilder.java

@ -0,0 +1,7 @@
package acr.browser.lightning.dialog;
/**
* Created by Stefano Pacifici on 02/09/15.
*/
public class BookmarksDialogBuilder {
}

16
app/src/main/res/anim/fade_in_scale.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="0.85"
android:fromYScale="0.85"
android:interpolator="@android:interpolator/decelerate_cubic"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1.0"
android:toYScale="1.0" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>

16
app/src/main/res/anim/fade_out_scale.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:interpolator/decelerate_cubic"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="0.85"
android:toYScale="0.85" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>

12
app/src/main/res/anim/slide_down_out.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0%p"
android:interpolator="@android:interpolator/accelerate_cubic"
android:toYDelta="100%p" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>

12
app/src/main/res/anim/slide_in_from_right.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="100%p"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toXDelta="0%p" />
<!--<alpha-->
<!--android:duration="@android:integer/config_mediumAnimTime"-->
<!--android:fromAlpha="0.0"-->
<!--android:toAlpha="1.0" />-->
</set>

12
app/src/main/res/anim/slide_out_to_right.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0%p"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toXDelta="100%p" />
<!--<alpha-->
<!--android:duration="@android:integer/config_mediumAnimTime"-->
<!--android:fromAlpha="0.0"-->
<!--android:toAlpha="1.0" />-->
</set>

12
app/src/main/res/anim/slide_up_in.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%p"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toYDelta="0%p" />
<!--<alpha-->
<!--android:duration="@android:integer/config_mediumAnimTime"-->
<!--android:fromAlpha="0.5"-->
<!--android:toAlpha="1.0" />-->
</set>
Loading…
Cancel
Save