Improve drug detail activity (#25)

This commit is contained in:
Jean-Baptiste 2024-03-26 21:16:21 +01:00 committed by GitHub
parent 0c50427257
commit fb4206f056
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 30 deletions

View file

@ -1,7 +1,5 @@
package net.foucry.pilldroid;
import static net.foucry.pilldroid.R.id.detail_toolbar;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@ -13,8 +11,7 @@ import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import net.foucry.pilldroid.dao.PrescriptionsDAO;
import net.foucry.pilldroid.databases.PrescriptionDatabase;
import net.foucry.pilldroid.models.Prescription;
@ -43,7 +40,7 @@ public class DrugDetailActivity extends AppCompatActivity {
Log.d(TAG, "aPrescription == " + aPrescription);
setContentView(R.layout.drug_detail_activity);
Toolbar toolbar = findViewById(detail_toolbar);
MaterialToolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);

View file

@ -8,9 +8,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import net.foucry.pilldroid.models.Prescription;
/**
@ -52,7 +50,7 @@ public class DrugDetailFragment extends Fragment {
Activity activity = this.getActivity();
assert activity != null;
CollapsingToolbarLayout appBarLayout = activity.findViewById(R.id.toolbar_layout);
MaterialToolbar appBarLayout = activity.findViewById(R.id.toolbar);
if (appBarLayout != null) {
appBarLayout.setTitle(prescription.getName());
}

View file

@ -1,4 +1,4 @@
<vector android:height="60dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="60dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
<path android:fillColor="#FFFFFF" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
</vector>

View file

@ -12,27 +12,25 @@
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:background="@color/ic_launcher_background"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/detail_toolbar" />
app:contentScrim="#0000"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/detail_toolbar"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</com.google.android.material.appbar.AppBarLayout>
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextColor="@color/white"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/drug_detail_container"
@ -43,15 +41,15 @@
</androidx.core.widget.NestedScrollView>
<ImageButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="@dimen/fab_width"
android:layout_height="@dimen/fab_height"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="normal"
android:layout_gravity="end|bottom"
android:layout_marginTop="?attr/actionBarSize"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginBottom="?attr/actionBarSize"
android:scaleType="center"
android:layout_margin="@dimen/fab_margin"
android:contentDescription="@string/save_button"
android:src="@drawable/ic_save_black_24dp"
app:backgroundTint="@android:color/transparent" />
app:srcCompat="@drawable/ic_save_black_24dp"
app:backgroundTint="@color/colorPrimary" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>