0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 20:02:16 +02:00

animations everywhere (can be turned off)

This commit is contained in:
TrianguloY 2024-03-17 12:09:21 +01:00
parent 74af92bb08
commit a6c62b2ca5
11 changed files with 66 additions and 27 deletions

View File

@ -29,6 +29,7 @@ import com.trianguloy.urlchecker.modules.list.VirusTotalModule;
import com.trianguloy.urlchecker.utilities.AndroidSettings; import com.trianguloy.urlchecker.utilities.AndroidSettings;
import com.trianguloy.urlchecker.utilities.generics.GenericPref; import com.trianguloy.urlchecker.utilities.generics.GenericPref;
import com.trianguloy.urlchecker.utilities.methods.AndroidUtils; import com.trianguloy.urlchecker.utilities.methods.AndroidUtils;
import com.trianguloy.urlchecker.utilities.methods.Animations;
import com.trianguloy.urlchecker.utilities.methods.JavaUtils; import com.trianguloy.urlchecker.utilities.methods.JavaUtils;
import com.trianguloy.urlchecker.utilities.methods.JavaUtils.Function; import com.trianguloy.urlchecker.utilities.methods.JavaUtils.Function;
import com.trianguloy.urlchecker.utilities.methods.PackageUtils; import com.trianguloy.urlchecker.utilities.methods.PackageUtils;
@ -73,6 +74,8 @@ public class BackupActivity extends Activity {
setTitle(R.string.btn_backupRestore); setTitle(R.string.btn_backupRestore);
AndroidUtils.configureUp(this); AndroidUtils.configureUp(this);
Animations.enableAnimationsRecursively(this);
prefs = GenericPref.getPrefs(this); prefs = GenericPref.getPrefs(this);
chk_data = findViewById(R.id.chk_data); chk_data = findViewById(R.id.chk_data);
chk_data_prefs = findViewById(R.id.chk_data_prefs); chk_data_prefs = findViewById(R.id.chk_data_prefs);

View File

@ -100,7 +100,7 @@ public class ModulesActivity extends Activity {
// inflate // inflate
View parent = Inflater.inflate(R.layout.config_module, list); View parent = Inflater.inflate(R.layout.config_module, list);
parent.setTag(module.getId()); parent.setTag(module.getId());
Animations.enableAnimations(parent); Animations.enableAnimationsRecursively(parent); // instead of full activity to avoid 'replacing' when reordering
// configure enable toggle // configure enable toggle
Switch toggleEnable = parent.findViewById(R.id.enable); Switch toggleEnable = parent.findViewById(R.id.enable);

View File

@ -14,6 +14,7 @@ import com.trianguloy.urlchecker.fragments.BrowserButtonsFragment;
import com.trianguloy.urlchecker.fragments.ResultCodeInjector; import com.trianguloy.urlchecker.fragments.ResultCodeInjector;
import com.trianguloy.urlchecker.utilities.AndroidSettings; import com.trianguloy.urlchecker.utilities.AndroidSettings;
import com.trianguloy.urlchecker.utilities.methods.AndroidUtils; import com.trianguloy.urlchecker.utilities.methods.AndroidUtils;
import com.trianguloy.urlchecker.utilities.methods.Animations;
import com.trianguloy.urlchecker.utilities.methods.PackageUtils; import com.trianguloy.urlchecker.utilities.methods.PackageUtils;
import java.util.Objects; import java.util.Objects;
@ -35,6 +36,7 @@ public class SettingsActivity extends Activity {
configureBrowserButtons(); configureBrowserButtons();
configureDayNight(); configureDayNight();
configureLocale(); configureLocale();
Animations.ANIMATIONS(this).attachToSwitch(findViewById(R.id.animations));
// if this was reloaded, some settings may have change, so reload previous one too // if this was reloaded, some settings may have change, so reload previous one too
if (AndroidSettings.wasReloaded(this)) AndroidSettings.markForReloading(this); if (AndroidSettings.wasReloaded(this)) AndroidSettings.markForReloading(this);

View File

@ -24,6 +24,7 @@ import com.trianguloy.urlchecker.modules.list.DrawerModule;
import com.trianguloy.urlchecker.url.UrlData; import com.trianguloy.urlchecker.url.UrlData;
import com.trianguloy.urlchecker.utilities.AndroidSettings; import com.trianguloy.urlchecker.utilities.AndroidSettings;
import com.trianguloy.urlchecker.utilities.methods.AndroidUtils; import com.trianguloy.urlchecker.utilities.methods.AndroidUtils;
import com.trianguloy.urlchecker.utilities.methods.Animations;
import com.trianguloy.urlchecker.utilities.methods.Inflater; import com.trianguloy.urlchecker.utilities.methods.Inflater;
import java.util.ArrayList; import java.util.ArrayList;
@ -256,6 +257,8 @@ public class MainDialog extends Activity {
if (ll_main.getChildCount() == 0) { if (ll_main.getChildCount() == 0) {
ll_main.addView(egg()); // ;) ll_main.addView(egg()); // ;)
} }
Animations.enableAnimationsRecursively(this);
} }
/** /**

View File

@ -1,26 +1,43 @@
package com.trianguloy.urlchecker.utilities.methods; package com.trianguloy.urlchecker.utilities.methods;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.app.Activity;
import android.content.Context;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.trianguloy.urlchecker.utilities.generics.GenericPref;
/** /**
* Animations-related functionality * Animations-related functionality
*/ */
public interface Animations { public interface Animations {
static GenericPref.Bool ANIMATIONS(Context cntx) {
return new GenericPref.Bool("animations", true, cntx);
}
/** /**
* Enables animations for a specific view * Enables animations on all views from this activity
*/ */
static void enableAnimations(View view) { static void enableAnimationsRecursively(Activity cntx) {
if (view instanceof ViewGroup) { if (ANIMATIONS(cntx).get()) enableAnimationsRecursively(cntx.findViewById(android.R.id.content));
final LayoutTransition lt = ((ViewGroup) view).getLayoutTransition(); }
if (lt != null) {
lt.enableTransitionType(LayoutTransition.CHANGING); /**
} else { * Enables animations from all views starting from this parent
AndroidUtils.assertError(view + " doesn't have a LayoutTransition"); */
} static void enableAnimationsRecursively(View parent) {
} else { if (ANIMATIONS(parent.getContext()).get()) _enableAnimationsRecursively(parent);
AndroidUtils.assertError(view + " isn't a ViewGroup"); }
static void _enableAnimationsRecursively(View view) {
if (view instanceof ViewGroup group) {
var lt = new LayoutTransition();
lt.enableTransitionType(LayoutTransition.CHANGING);
group.setLayoutTransition(lt);
for (var i = 0; i < group.getChildCount(); ++i) _enableAnimationsRecursively(group.getChildAt(i));
} }
} }
} }

View File

@ -9,7 +9,6 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/smallPadding"> android:padding="@dimen/smallPadding">
@ -70,7 +69,6 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button

View File

@ -87,6 +87,22 @@
android:saveEnabled="false" /> android:saveEnabled="false" />
</LinearLayout> </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/padding"
android:paddingBottom="@dimen/padding">
<include layout="@layout/separator" />
</FrameLayout>
<Switch
android:id="@+id/animations"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/txt_animation" />
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@ -2,7 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView

View File

@ -4,7 +4,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:animateLayoutChanges="true"
android:background="@drawable/round_border" android:background="@drawable/round_border"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="5dp" android:paddingTop="5dp"
@ -12,8 +11,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:animateLayoutChanges="true">
<TextView <TextView
android:id="@+id/label" android:id="@+id/label"
@ -75,6 +73,7 @@
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="@string/desc_decorations" android:contentDescription="@string/desc_decorations"
android:src="@drawable/t" /> android:src="@drawable/t" />
<Switch <Switch
android:id="@+id/enable" android:id="@+id/enable"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -88,15 +87,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout
android:id="@+id/box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:paddingLeft="25dp"
android:paddingRight="25dp">
</FrameLayout> <FrameLayout
</LinearLayout> android:id="@+id/box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="25dp"
android:paddingRight="25dp">
</FrameLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -52,6 +52,7 @@ Traducciones: %s."</string>
<string name="spin_darkTheme">Oscuro</string> <string name="spin_darkTheme">Oscuro</string>
<string name="spin_lightTheme">Claro</string> <string name="spin_lightTheme">Claro</string>
<string name="txt_locale">Idioma:</string> <string name="txt_locale">Idioma:</string>
<string name="txt_animation">Activar animaciones</string>
<!-- <!--
generic generic
--> -->

View File

@ -52,6 +52,7 @@ Translations: %s."</string>
<string name="spin_darkTheme">Dark</string> <string name="spin_darkTheme">Dark</string>
<string name="spin_lightTheme">Light</string> <string name="spin_lightTheme">Light</string>
<string name="txt_locale">Locale:</string> <string name="txt_locale">Locale:</string>
<string name="txt_animation">Enable animations</string>
<string name="btn_tutorialSettings">Repeat tutorial</string> <string name="btn_tutorialSettings">Repeat tutorial</string>
<string name="btn_backupRestore">Backup / Restore</string> <string name="btn_backupRestore">Backup / Restore</string>
<!-- <!--