Improve biometric lock, new comment on issue and pr (wip)

This commit is contained in:
M M Arif 2024-05-07 22:49:54 +05:00
parent 36b45df849
commit a33b470a50
8 changed files with 157 additions and 73 deletions

View File

@ -82,7 +82,11 @@
<activity
android:name=".activities.IssueDetailActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
android:windowSoftInputMode="adjustNothing"/>
android:windowSoftInputMode="adjustResize"/>
<activity
android:name=".activities.BiometricUnlock"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>
<activity
android:name=".activities.RepoDetailActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"

View File

@ -1,13 +1,10 @@
package org.mian.gitnex.activities;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat;
import java.util.Locale;
import java.util.concurrent.Executor;
import org.mian.gitnex.R;
import org.mian.gitnex.core.MainApplication;
import org.mian.gitnex.helpers.AppDatabaseSettings;
@ -128,50 +125,8 @@ public abstract class BaseActivity extends AppCompatActivity {
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY))) {
Executor executor = ContextCompat.getMainExecutor(this);
BiometricPrompt biometricPrompt =
new BiometricPrompt(
this,
executor,
new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationError(
int errorCode, @NonNull CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
// Authentication error, close the app
finish();
}
// Authentication succeeded, continue to app
@Override
public void onAuthenticationSucceeded(
@NonNull BiometricPrompt.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
AppDatabaseSettings.updateSettingsValue(
getApplicationContext(),
"true",
AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY);
}
// Authentication failed, close the app
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
}
});
BiometricPrompt.PromptInfo biometricPromptBuilder =
new BiometricPrompt.PromptInfo.Builder()
.setTitle(getString(R.string.biometricAuthTitle))
.setSubtitle(getString(R.string.biometricAuthSubTitle))
.setNegativeButtonText(getString(R.string.cancelButton))
.build();
biometricPrompt.authenticate(biometricPromptBuilder);
Intent unlockIntent = new Intent(ctx, BiometricUnlock.class);
ctx.startActivity(unlockIntent);
}
}

View File

@ -0,0 +1,80 @@
package org.mian.gitnex.activities;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat;
import java.util.concurrent.Executor;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivityUnlockBinding;
import org.mian.gitnex.helpers.AppDatabaseSettings;
/**
* @author M M Arif
*/
public class BiometricUnlock extends AppCompatActivity {
protected Context ctx = this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityUnlockBinding activityUnlockBinding =
ActivityUnlockBinding.inflate(getLayoutInflater());
setContentView(activityUnlockBinding.getRoot());
}
public void onResume() {
super.onResume();
Executor executor = ContextCompat.getMainExecutor(this);
BiometricPrompt biometricPrompt =
new BiometricPrompt(
this,
executor,
new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationError(
int errorCode, @NonNull CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
// Authentication error, close the app
finish();
}
// Authentication succeeded, continue to app
@Override
public void onAuthenticationSucceeded(
@NonNull BiometricPrompt.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
AppDatabaseSettings.updateSettingsValue(
getApplicationContext(),
"true",
AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY);
finish();
}
// Authentication failed, close the app
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
}
});
BiometricPrompt.PromptInfo biometricPromptBuilder =
new BiometricPrompt.PromptInfo.Builder()
.setTitle(getString(R.string.biometricAuthTitle))
.setSubtitle(getString(R.string.biometricAuthSubTitle))
.setNegativeButtonText(getString(R.string.cancelButton))
.build();
biometricPrompt.authenticate(biometricPromptBuilder);
}
}

View File

@ -303,16 +303,18 @@ public class IssueDetailActivity extends BaseActivity
&& issue.getRepository().getPermissions().isAdmin()
!= null) {
if (issue.getRepository().getPermissions().isAdmin()) {
viewBinding.addNewComment.setVisibility(
View.VISIBLE);
viewBinding.send.setAlpha(.9F);
// viewBinding.addNewComment.setVisibility(
// View.GONE);
} else {
viewBinding.addNewComment.setVisibility(View.GONE);
viewBinding.send.setAlpha(.3F);
}
} else {
viewBinding.addNewComment.setVisibility(View.GONE);
viewBinding.send.setAlpha(.3F);
}
} else {
viewBinding.addNewComment.setVisibility(View.VISIBLE);
viewBinding.send.setAlpha(.9F);
// viewBinding.addNewComment.setVisibility(View.GONE);
}
}
}

View File

@ -4,17 +4,17 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#00000000"
android:pathData="M22,2L11,13"
android:strokeWidth="2"
android:strokeColor="?attr/iconsColor"
android:strokeLineCap="round"
android:strokeLineJoin="round"/>
android:pathData="M4.698,4.034l16.302,7.966l-16.302,7.966a0.503,0.503 0,0 1,-0.546 -0.124a0.555,0.555 0,0 1,-0.12 -0.568l2.468,-7.274l-2.468,-7.274a0.555,0.555 0,0 1,0.12 -0.568a0.503,0.503 0,0 1,0.546 -0.124z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="?attr/iconsColor"
android:strokeLineCap="round"/>
<path
android:fillColor="#00000000"
android:pathData="M22,2l-7,20l-4,-9l-9,-4l20,-7z"
android:strokeWidth="2"
android:strokeColor="?attr/iconsColor"
android:strokeLineCap="round"
android:strokeLineJoin="round"/>
android:pathData="M6.5,12h14.5"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="?attr/iconsColor"
android:strokeLineCap="round"/>
</vector>

View File

@ -4,11 +4,11 @@
android:shape="rectangle">
<solid
android:color="?attr/inputBackgroundColor">
android:color="?attr/materialCardBackgroundColor">
</solid>
<corners
android:radius="3dp">
android:radius="8dp">
</corners>
<padding

View File

@ -63,6 +63,7 @@
android:text="@string/commentButtonText"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:visibility="gone"
app:icon="@drawable/ic_reply" />
<RelativeLayout
@ -89,7 +90,7 @@
android:paddingStart="@dimen/dimen8dp"
android:paddingTop="@dimen/dimen2dp"
android:paddingEnd="@dimen/dimen8dp"
android:paddingBottom="@dimen/dimen8dp">
android:paddingBottom="@dimen/dimen96dp">
<com.google.android.material.card.MaterialCardView
android:id="@+id/titleCard"
@ -153,7 +154,8 @@
android:layout_width="@dimen/dimen24dp"
android:layout_height="@dimen/dimen24dp"
app:cardCornerRadius="@dimen/dimen12dp"
app:cardElevation="@dimen/dimen0dp">
app:cardElevation="@dimen/dimen0dp"
tools:ignore="TooDeepLayout">
<ImageView
android:id="@+id/assigneeAvatar"
@ -371,9 +373,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="@dimen/dimen72dp" />
android:layout_height="wrap_content" />
</FrameLayout>
@ -383,6 +383,42 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="?attr/primaryBackgroundColor"
android:padding="@dimen/dimen8dp">
<EditText
android:id="@+id/comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="@string/commentButtonText"
android:background="@drawable/shape_inputs"
android:inputType="textMultiLine|textImeMultiLine|textCapSentences"
android:labelFor="@+id/comment"
android:layout_weight=".90"
android:maxLines="3"
android:padding="@dimen/dimen8dp"
android:scrollbars="vertical"
android:textColor="?attr/inputTextColor"
android:textSize="@dimen/dimen14sp" />
<ImageButton
android:id="@+id/send"
android:layout_width="@dimen/dimen32dp"
android:layout_height="@dimen/dimen32dp"
android:layout_marginStart="@dimen/dimen12dp"
android:layout_weight=".10"
android:background="?android:attr/selectableItemBackground"
android:layout_gravity="center_vertical"
android:contentDescription="@string/close"
android:src="@drawable/ic_send" />
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</androidx.coordinatorlayout.widget.CoordinatorLayout>