Compare commits
2 Commits
d0858d127a
...
ccfaf87210
Author | SHA1 | Date | |
---|---|---|---|
ccfaf87210 | |||
5925674826 |
@ -34,13 +34,8 @@
|
|||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.CringeAuthenticator">
|
android:theme="@style/Theme.CringeAuthenticator">
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".QRScannerActivity"
|
<activity android:name=".scanner.QRScannerActivity"
|
||||||
android:theme="@style/Theme.CringeAuthenticator">
|
android:theme="@style/Theme.CringeAuthenticator">
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
@ -1,17 +1,32 @@
|
|||||||
package com.cringe_studios.cringe_authenticator;
|
package com.cringe_studios.cringe_authenticator;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.databinding.ActivityIntroBinding;
|
||||||
|
|
||||||
public class IntroActivity extends AppCompatActivity {
|
public class IntroActivity extends AppCompatActivity {
|
||||||
public static boolean show_logoanimation = false;
|
public static boolean show_logoanimation = false;
|
||||||
|
|
||||||
|
private static ActivityIntroBinding binding;
|
||||||
|
|
||||||
|
private MediaPlayer mMediaPlayer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -20,21 +35,55 @@ public class IntroActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (show_logoanimation) {
|
if (show_logoanimation) {
|
||||||
setContentView(R.layout.activity_intro);
|
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 {
|
} 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding = ActivityIntroBinding.inflate(getLayoutInflater());
|
||||||
|
|
||||||
|
Uri uri = Uri.parse(String.format("android.resource://%s/%s", getPackageName(), R.raw.intro));
|
||||||
|
binding.videoView.setVideoURI(uri);
|
||||||
|
binding.videoView.start();
|
||||||
|
|
||||||
|
binding.videoView.setOnPreparedListener(mediaPlayer -> {
|
||||||
|
mMediaPlayer = mediaPlayer;
|
||||||
|
setDimension();
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.videoView.setOnCompletionListener(mp -> openMainActivity());
|
||||||
|
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openMainActivity() {
|
||||||
|
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);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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() {
|
||||||
|
float videoProportion = (float) mMediaPlayer.getVideoHeight() / mMediaPlayer.getVideoWidth();
|
||||||
|
int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||||
|
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||||
|
float screenProportion = (float) screenHeight / (float) screenWidth;
|
||||||
|
ViewGroup.LayoutParams lp = binding.videoView.getLayoutParams();
|
||||||
|
|
||||||
|
if (videoProportion < screenProportion) {
|
||||||
|
lp.height= screenHeight;
|
||||||
|
lp.width = (int) ((float) screenHeight / videoProportion);
|
||||||
|
} else {
|
||||||
|
lp.width = screenWidth;
|
||||||
|
lp.height = (int) ((float) screenWidth * videoProportion);
|
||||||
|
}
|
||||||
|
binding.videoView.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.cringe_studios.cringe_authenticator;
|
package com.cringe_studios.cringe_authenticator;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -9,12 +7,10 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContract;
|
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.biometric.BiometricPrompt;
|
import androidx.biometric.BiometricPrompt;
|
||||||
@ -26,15 +22,14 @@ import androidx.navigation.ui.AppBarConfiguration;
|
|||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.ActivityMainBinding;
|
import com.cringe_studios.cringe_authenticator.databinding.ActivityMainBinding;
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.FragmentDynamicBinding;
|
|
||||||
import com.cringe_studios.cringe_authenticator.fragment.DynamicFragment;
|
import com.cringe_studios.cringe_authenticator.fragment.DynamicFragment;
|
||||||
import com.cringe_studios.cringe_authenticator.fragment.HomeFragment;
|
import com.cringe_studios.cringe_authenticator.fragment.HomeFragment;
|
||||||
import com.cringe_studios.cringe_authenticator.fragment.MenuFragment;
|
import com.cringe_studios.cringe_authenticator.fragment.MenuFragment;
|
||||||
import com.cringe_studios.cringe_authenticator.fragment.SettingsFragment;
|
import com.cringe_studios.cringe_authenticator.fragment.SettingsFragment;
|
||||||
|
import com.cringe_studios.cringe_authenticator.scanner.QRScannerActivity;
|
||||||
|
import com.cringe_studios.cringe_authenticator.scanner.QRScannerContract;
|
||||||
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
|
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
|
||||||
import com.cringe_studios.cringe_authenticator.util.SettingsUtil;
|
import com.cringe_studios.cringe_authenticator.util.SettingsUtil;
|
||||||
import com.cringe_studios.cringe_authenticator_library.OTPType;
|
|
||||||
import com.google.android.material.color.utilities.DynamicColor;
|
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@ -73,10 +68,16 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
launchApp();
|
launchApp();
|
||||||
|
|
||||||
startQRCodeScan = registerForActivityResult(new QRScannerContract(), obj -> {
|
startQRCodeScan = registerForActivityResult(new QRScannerContract(), obj -> {
|
||||||
|
if(obj == null) { // Got some error TODO: show error message
|
||||||
|
Toast.makeText(this, "Failed to scan code", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Fragment fragment = NavigationUtil.getCurrentFragment(this);
|
Fragment fragment = NavigationUtil.getCurrentFragment(this);
|
||||||
if(fragment instanceof DynamicFragment) {
|
if(fragment instanceof DynamicFragment) {
|
||||||
DynamicFragment frag = (DynamicFragment) fragment;
|
DynamicFragment frag = (DynamicFragment) fragment;
|
||||||
SettingsUtil.addOTP(getSharedPreferences("groups", MODE_PRIVATE), frag.getGroupName(), obj);
|
SettingsUtil.addOTP(getSharedPreferences(SettingsUtil.GROUPS_PREFS_NAME, MODE_PRIVATE), frag.getGroupName(), obj);
|
||||||
|
frag.loadOTPs();
|
||||||
}
|
}
|
||||||
Log.i("AMOGUS", "Actually got something bruh" + obj);
|
Log.i("AMOGUS", "Actually got something bruh" + obj);
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ package com.cringe_studios.cringe_authenticator.fragment;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -13,22 +14,26 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.cringe_studios.cringe_authenticator.OTPData;
|
import com.cringe_studios.cringe_authenticator.OTPData;
|
||||||
import com.cringe_studios.cringe_authenticator.R;
|
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.AuthenticateTotpBinding;
|
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.FragmentDynamicBinding;
|
import com.cringe_studios.cringe_authenticator.databinding.FragmentDynamicBinding;
|
||||||
|
import com.cringe_studios.cringe_authenticator.databinding.OtpCodeBinding;
|
||||||
import com.cringe_studios.cringe_authenticator.util.FabUtil;
|
import com.cringe_studios.cringe_authenticator.util.FabUtil;
|
||||||
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
|
|
||||||
import com.cringe_studios.cringe_authenticator.util.SettingsUtil;
|
import com.cringe_studios.cringe_authenticator.util.SettingsUtil;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.cringe_studios.cringe_authenticator_library.OTP;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DynamicFragment extends Fragment {
|
public class DynamicFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String BUNDLE_GROUP = "group";
|
||||||
|
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
private FragmentDynamicBinding binding;
|
private FragmentDynamicBinding binding;
|
||||||
|
|
||||||
|
private Handler handler;
|
||||||
|
|
||||||
|
private Runnable refreshCodes;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -39,7 +44,7 @@ public class DynamicFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
binding = FragmentDynamicBinding.inflate(inflater, container, false);
|
binding = FragmentDynamicBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
groupName = requireArguments().getString("group");
|
groupName = requireArguments().getString(DynamicFragment.BUNDLE_GROUP);
|
||||||
|
|
||||||
/*String[] totps = new String[]{"Code 1", "Code 2", groupName};
|
/*String[] totps = new String[]{"Code 1", "Code 2", groupName};
|
||||||
for(String totp : totps) {
|
for(String totp : totps) {
|
||||||
@ -52,18 +57,31 @@ public class DynamicFragment extends Fragment {
|
|||||||
|
|
||||||
FabUtil.showFabs(getActivity());
|
FabUtil.showFabs(getActivity());
|
||||||
|
|
||||||
|
refreshCodes = () -> {
|
||||||
|
for(int i = 0; i < binding.itemList.getChildCount(); i++) {
|
||||||
|
View v = binding.itemList.getChildAt(i);
|
||||||
|
OTP otp = (OTP) v.getTag();
|
||||||
|
otp.getPin();
|
||||||
|
}
|
||||||
|
handler.postDelayed(refreshCodes, 1000L);
|
||||||
|
};
|
||||||
|
|
||||||
|
handler.post(refreshCodes);
|
||||||
|
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadOTPs() {
|
public void loadOTPs() {
|
||||||
SharedPreferences prefs = getActivity().getSharedPreferences("groups", Context.MODE_PRIVATE);
|
SharedPreferences prefs = getActivity().getSharedPreferences(SettingsUtil.GROUPS_PREFS_NAME, Context.MODE_PRIVATE);
|
||||||
List<OTPData> data = SettingsUtil.getOTPs(prefs, groupName);
|
List<OTPData> data = SettingsUtil.getOTPs(prefs, groupName);
|
||||||
Log.i("AMOGUS", "OTPS: " + data);
|
Log.i("AMOGUS", "OTPS: " + data);
|
||||||
|
|
||||||
|
binding.itemList.removeAllViews();
|
||||||
for(OTPData otp : data) {
|
for(OTPData otp : data) {
|
||||||
AuthenticateTotpBinding itemBinding = AuthenticateTotpBinding.inflate(getLayoutInflater());
|
OtpCodeBinding itemBinding = OtpCodeBinding.inflate(getLayoutInflater());
|
||||||
itemBinding.displayName.setText(otp.getName());
|
itemBinding.label.setText(otp.getName());
|
||||||
itemBinding.totpCode.setText(otp.toOTP().getPin());
|
itemBinding.otpCode.setText(otp.toOTP().getPin());
|
||||||
|
itemBinding.getRoot().setTag(otp.toOTP());
|
||||||
binding.itemList.addView(itemBinding.getRoot());
|
binding.itemList.addView(itemBinding.getRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,6 +92,12 @@ public class DynamicFragment extends Fragment {
|
|||||||
this.binding = null;
|
this.binding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
handler.removeCallbacks(refreshCodes);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
public String getGroupName() {
|
public String getGroupName() {
|
||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,16 +29,16 @@ public class MenuFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
binding = FragmentMenuBinding.inflate(inflater);
|
binding = FragmentMenuBinding.inflate(inflater);
|
||||||
|
|
||||||
String[] items = {"a", "b"};
|
|
||||||
|
|
||||||
SharedPreferences pr = getContext().getSharedPreferences("menu", Context.MODE_PRIVATE);
|
SharedPreferences pr = getContext().getSharedPreferences("menu", Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
String[] items = {"a", "b"};
|
||||||
|
|
||||||
for(String item : items) {
|
for(String item : items) {
|
||||||
MenuItemBinding itemBinding = MenuItemBinding.inflate(inflater);
|
MenuItemBinding itemBinding = MenuItemBinding.inflate(inflater);
|
||||||
itemBinding.button.setText(item);
|
itemBinding.button.setText(item);
|
||||||
itemBinding.button.setOnClickListener(view -> {
|
itemBinding.button.setOnClickListener(view -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("tab", item);
|
bundle.putString(DynamicFragment.BUNDLE_GROUP, item);
|
||||||
NavigationUtil.navigate(this, DynamicFragment.class, bundle);
|
NavigationUtil.navigate(this, DynamicFragment.class, bundle);
|
||||||
});
|
});
|
||||||
itemBinding.button.setOnLongClickListener(view -> {
|
itemBinding.button.setOnLongClickListener(view -> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.cringe_studios.cringe_authenticator;
|
package com.cringe_studios.cringe_authenticator.scanner;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@ -24,6 +24,7 @@ import androidx.camera.lifecycle.ProcessCameraProvider;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.OTPData;
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.ActivityQrScannerBinding;
|
import com.cringe_studios.cringe_authenticator.databinding.ActivityQrScannerBinding;
|
||||||
import com.cringe_studios.cringe_authenticator_library.OTP;
|
import com.cringe_studios.cringe_authenticator_library.OTP;
|
||||||
import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm;
|
import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm;
|
||||||
@ -120,6 +121,8 @@ public class QRScannerActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(code == null) return;
|
||||||
|
|
||||||
Uri uri = Uri.parse(code.getRawValue());
|
Uri uri = Uri.parse(code.getRawValue());
|
||||||
Log.i("AMOGUS", code.getRawValue());
|
Log.i("AMOGUS", code.getRawValue());
|
||||||
Log.i("AMOGUS", uri.getHost());
|
Log.i("AMOGUS", uri.getHost());
|
||||||
@ -180,7 +183,7 @@ public class QRScannerActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void success(OTPData data) {
|
private void success(@NonNull OTPData data) {
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
result.putExtra("data", data);
|
result.putExtra("data", data);
|
||||||
setResult(Activity.RESULT_OK, result);
|
setResult(Activity.RESULT_OK, result);
|
||||||
@ -188,8 +191,7 @@ public class QRScannerActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void error(String errorMessage) {
|
private void error(String errorMessage) {
|
||||||
Intent result = new Intent();
|
setResult(Activity.RESULT_CANCELED, null);
|
||||||
setResult(Activity.RESULT_CANCELED, result);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.cringe_studios.cringe_authenticator;
|
package com.cringe_studios.cringe_authenticator.scanner;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -8,6 +8,8 @@ import androidx.activity.result.contract.ActivityResultContract;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.OTPData;
|
||||||
|
|
||||||
public class QRScannerContract extends ActivityResultContract<Void, OTPData> {
|
public class QRScannerContract extends ActivityResultContract<Void, OTPData> {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -17,7 +19,7 @@ public class QRScannerContract extends ActivityResultContract<Void, OTPData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OTPData parseResult(int result, @Nullable Intent intent) {
|
public @Nullable OTPData parseResult(int result, @Nullable Intent intent) {
|
||||||
if(result != Activity.RESULT_OK || intent == null) {
|
if(result != Activity.RESULT_OK || intent == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
@ -2,6 +2,8 @@ package com.cringe_studios.cringe_authenticator.util;
|
|||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.cringe_studios.cringe_authenticator.OTPData;
|
import com.cringe_studios.cringe_authenticator.OTPData;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -11,6 +13,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class SettingsUtil {
|
public class SettingsUtil {
|
||||||
|
|
||||||
|
public static String
|
||||||
|
GROUPS_PREFS_NAME = "groups",
|
||||||
|
GENERAL_PREFS_NAME = "general";
|
||||||
|
|
||||||
private static final Gson GSON = new Gson();
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
public static List<OTPData> getOTPs(SharedPreferences prefs, String group) {
|
public static List<OTPData> getOTPs(SharedPreferences prefs, String group) {
|
||||||
@ -18,7 +24,7 @@ public class SettingsUtil {
|
|||||||
return Arrays.asList(GSON.fromJson(currentOTPs, OTPData[].class));
|
return Arrays.asList(GSON.fromJson(currentOTPs, OTPData[].class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addOTP(SharedPreferences prefs, String group, OTPData data) {
|
public static void addOTP(SharedPreferences prefs, String group, @NonNull OTPData data) {
|
||||||
List<OTPData> otps = new ArrayList<>(getOTPs(prefs, group));
|
List<OTPData> otps = new ArrayList<>(getOTPs(prefs, group));
|
||||||
otps.add(data);
|
otps.add(data);
|
||||||
|
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/drawer_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:background="#000000">
|
||||||
tools:openDrawer="start">
|
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<VideoView
|
||||||
android:id="@+id/fragment2"
|
android:id="@+id/videoView"
|
||||||
android:name="com.cringe_studios.cringe_authenticator.fragment.Intro"
|
android:layout_width="0dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_height="wrap_content" />
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<?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>
|
|
@ -11,15 +11,15 @@
|
|||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/displayName"
|
android:id="@+id/label"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="My TOTP"
|
android:text="My OTP"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/totpCode"
|
android:id="@+id/otpCode"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="000000"
|
android:text="000000"
|
@ -43,6 +43,4 @@
|
|||||||
libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus
|
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.
|
vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim.
|
||||||
</string>
|
</string>
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user