Skip to content

Commit

Permalink
Added Sign in With Apple button
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammedAbidNafi committed Jun 2, 2021
1 parent c741b84 commit 923542d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation 'com.factor:bouncy:1.8'
implementation 'com.willowtreeapps:signinwithapplebutton:0.3'


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
Expand All @@ -15,6 +16,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.AppCompatButton;
import androidx.biometric.BiometricManager;
import androidx.biometric.BiometricPrompt;
Expand Down Expand Up @@ -43,6 +45,7 @@
import com.google.firebase.database.ValueEventListener;
import com.margsapp.messenger.Main.MainActivity;
import com.margsapp.messenger.R;
import com.willowtreeapps.signinwithapplebutton.view.SignInWithAppleButton;

import java.text.SimpleDateFormat;
import java.util.Calendar;
Expand All @@ -52,6 +55,7 @@

import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL;
import static com.margsapp.messenger.Settings.AboutActivity.TEXT;
import static com.margsapp.messenger.Settings.CustomiseActivity.THEME;

public class StartActivity extends AppCompatActivity {

Expand All @@ -63,6 +67,9 @@ public class StartActivity extends AppCompatActivity {

FirebaseAuth firebaseAuth;

SignInWithAppleButton signInWithAppleButtonBlack;
SignInWithAppleButton signInWithAppleButtonWhite;

private InterstitialAd mInterstitialAd;

GoogleSignInClient googleSignInClient;
Expand Down Expand Up @@ -170,6 +177,41 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);

signInWithAppleButtonBlack = findViewById(R.id.signInWithAppleButtonBlack);
signInWithAppleButtonWhite = findViewById(R.id.signInWithAppleButtonWhite);

SharedPreferences preferences = getSharedPreferences("theme", 0);
String Theme = preferences.getString(THEME, "");
if(Theme.equals("2")){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
signInWithAppleButtonBlack.setVisibility(View.VISIBLE);
signInWithAppleButtonWhite.setVisibility(View.INVISIBLE);
}

if(Theme.equals("1")){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
signInWithAppleButtonBlack.setVisibility(View.INVISIBLE);
signInWithAppleButtonWhite.setVisibility(View.VISIBLE);
}
if(Theme.equals("0")) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}

signInWithAppleButtonBlack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(),"The most secure login method is coming soon.",Toast.LENGTH_SHORT).show();
}
});
signInWithAppleButtonWhite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(),"The most secure login method is coming soon.",Toast.LENGTH_SHORT).show();
}
});




MobileAds.initialize(this, initializationStatus -> {
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<corners android:radius="10dp"/>
<corners android:radius="15dp"/>

<solid android:color="@color/coral"/>

Expand Down
36 changes: 34 additions & 2 deletions app/src/main/res/layout/activity_start.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
>



<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="@font/nunito_semibold"
android:text="@string/welcome_to_messenger"
android:textColor="@color/blacktext"
android:textAlignment="center"

android:textSize="30dp"
android:textColor="@color/blacktext"

android:textSize="30dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down Expand Up @@ -103,5 +105,35 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.752" />

<com.willowtreeapps.signinwithapplebutton.view.SignInWithAppleButton
android:id="@+id/signInWithAppleButtonBlack"
style="@style/SignInWithAppleButton.Black"
android:layout_width="300dp"
android:layout_height="65dp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/phone"
app:layout_constraintVertical_bias="0.379"
app:sign_in_with_apple_button_cornerRadius="15dp"
app:sign_in_with_apple_button_textType="signInWithApple" />

<com.willowtreeapps.signinwithapplebutton.view.SignInWithAppleButton
android:id="@+id/signInWithAppleButtonWhite"
style="@style/SignInWithAppleButton.White"
android:layout_width="300dp"
android:layout_height="65dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/phone"
app:layout_constraintVertical_bias="0.379"
app:sign_in_with_apple_button_cornerRadius="15dp"
app:sign_in_with_apple_button_textType="signInWithApple" />


</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->

</style>

<style name="Loader" parent="Theme.MaterialComponents.DayNight.NoActionBar">
Expand Down

0 comments on commit 923542d

Please sign in to comment.