added Logoanimation
This commit is contained in:
parent
6e19440e3d
commit
75542f0a78
17
.idea/deploymentTargetDropDown.xml
Normal file
17
.idea/deploymentTargetDropDown.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="RFCRB0A9C5T" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-06-22T17:08:06.581574900Z" />
|
||||
</component>
|
||||
</project>
|
BIN
app/raw/intro.mp4
Normal file
BIN
app/raw/intro.mp4
Normal file
Binary file not shown.
@ -15,6 +15,20 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.CringeAuthenticator"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:screenOrientation="sensorPortrait"
|
||||
android:resizeableActivity="false"
|
||||
android:name=".IntroActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.CringeAuthenticator"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.cringe_studios.cringe_authenticator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class IntroActivity extends AppCompatActivity {
|
||||
public static boolean show_logoanimation = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
SharedPreferences p = getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
show_logoanimation = p.getBoolean("Logoanimation", true);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (show_logoanimation) {
|
||||
setContentView(R.layout.activity_intro);
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//Do something after 4000ms
|
||||
Intent m = new Intent(getApplicationContext(), MainActivity.class);
|
||||
m.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(m);
|
||||
}
|
||||
}, 4000);
|
||||
} else {
|
||||
Intent m = new Intent(getApplicationContext(), MainActivity.class);
|
||||
m.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package com.cringe_studios.cringe_authenticator.fragment;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.cringe_studios.cringe_authenticator.R;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link Intro#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class Intro extends Fragment {
|
||||
|
||||
// Create a VideoView variable, a MediaPlayer variable, and an int to hold the current
|
||||
// video position.
|
||||
private VideoView videoBG;
|
||||
MediaPlayer mMediaPlayer;
|
||||
int mCurrentVideoPosition;
|
||||
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
View root = inflater.inflate(R.layout.fragment_intro, container, false);
|
||||
|
||||
// Hook up the VideoView to our UI.
|
||||
videoBG = (VideoView) root.findViewById(R.id.videoView);
|
||||
|
||||
// Build your video Uri
|
||||
Uri uri = Uri.parse("android.resource://" // First start with this,
|
||||
+ requireContext().getPackageName() // then retrieve your package name,
|
||||
+ "/" // add a slash,
|
||||
+ R.raw.intro); // and then finally add your video resource. Make sure it is stored
|
||||
// in the raw folder.
|
||||
|
||||
// Set the new Uri to our VideoView
|
||||
System.out.println(uri);
|
||||
videoBG.setVideoURI(uri);
|
||||
// Start the VideoView
|
||||
videoBG.start();
|
||||
|
||||
// Set an OnPreparedListener for our VideoView. For more information about VideoViews,
|
||||
// check out the Android Docs: https://developer.android.com/reference/android/widget/VideoView.html
|
||||
videoBG.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
setDimension();
|
||||
mMediaPlayer = mediaPlayer;
|
||||
// We want our video to play over and over so we set looping to true.
|
||||
mMediaPlayer.setLooping(true);
|
||||
// We then seek to the current position if it has been set and play the video.
|
||||
if (mCurrentVideoPosition != 0) {
|
||||
mMediaPlayer.seekTo(mCurrentVideoPosition);
|
||||
mMediaPlayer.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
/*================================ Important Section! ================================
|
||||
We must override onPause(), onResume(), and onDestroy() to properly handle our
|
||||
VideoView.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
// Capture the current video position and pause the video.
|
||||
mCurrentVideoPosition = mMediaPlayer.getCurrentPosition();
|
||||
videoBG.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// Restart the video when resuming the Activity
|
||||
videoBG.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
// When the Activity is destroyed, release our MediaPlayer and set it to null.
|
||||
mMediaPlayer.release();
|
||||
mMediaPlayer = null;
|
||||
}
|
||||
private void setDimension() {
|
||||
// Adjust the size of the video
|
||||
// so it fits on the screen
|
||||
float videoProportion = getVideoProportion();
|
||||
int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
float screenProportion = (float) screenHeight / (float) screenWidth;
|
||||
android.view.ViewGroup.LayoutParams lp = videoBG.getLayoutParams();
|
||||
|
||||
if (videoProportion < screenProportion) {
|
||||
lp.height= screenHeight;
|
||||
lp.width = (int) ((float) screenHeight / videoProportion);
|
||||
} else {
|
||||
lp.width = screenWidth;
|
||||
lp.height = (int) ((float) screenWidth * videoProportion);
|
||||
}
|
||||
videoBG.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
// This method gets the proportion of the video that you want to display.
|
||||
// I already know this ratio since my video is hardcoded, you can get the
|
||||
// height and width of your video and appropriately generate the proportion
|
||||
// as :height/width
|
||||
private float getVideoProportion(){
|
||||
return 2.22f;
|
||||
}
|
||||
}
|
16
app/src/main/res/layout/activity_intro.xml
Normal file
16
app/src/main/res/layout/activity_intro.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:openDrawer="start">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fragment2"
|
||||
android:name="com.cringe_studios.cringe_authenticator.fragment.Intro"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
18
app/src/main/res/layout/fragment_intro.xml
Normal file
18
app/src/main/res/layout/fragment_intro.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000"
|
||||
tools:context="fragment.Intro">
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/videoView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
BIN
app/src/main/res/raw/intro.mp4
Normal file
BIN
app/src/main/res/raw/intro.mp4
Normal file
Binary file not shown.
@ -2,4 +2,6 @@
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="colorPrimary">#008BFF</color>
|
||||
<color name="colorSecondary">#90D14C</color>
|
||||
</resources>
|
@ -43,4 +43,6 @@
|
||||
libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus
|
||||
vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim.
|
||||
</string>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user