mirror of
https://github.com/Nezumi-2711/PRM392.git
synced 2026-09-22 13:48:29 +00:00
Fix font and improve UI
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -116,7 +116,7 @@ public class Cart extends AppCompatActivity implements GoogleApiClient.Connectio
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ChangePassword extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.waterbase.foodify;
|
||||
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.TextPaint;
|
||||
import android.text.style.TypefaceSpan;
|
||||
|
||||
public class CustomTypefaceSpan extends TypefaceSpan {
|
||||
|
||||
private final Typeface newType;
|
||||
|
||||
public CustomTypefaceSpan(String family, Typeface type) {
|
||||
super(family);
|
||||
newType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
applyCustomTypeFace(ds, newType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint paint) {
|
||||
applyCustomTypeFace(paint, newType);
|
||||
}
|
||||
|
||||
private static void applyCustomTypeFace(Paint paint, Typeface tf) {
|
||||
int oldStyle;
|
||||
Typeface old = paint.getTypeface();
|
||||
if (old == null) {
|
||||
oldStyle = 0;
|
||||
} else {
|
||||
oldStyle = old.getStyle();
|
||||
}
|
||||
|
||||
int fake = oldStyle & ~tf.getStyle();
|
||||
if ((fake & Typeface.BOLD) != 0) {
|
||||
paint.setFakeBoldText(true);
|
||||
}
|
||||
|
||||
if ((fake & Typeface.ITALIC) != 0) {
|
||||
paint.setTextSkewX(-0.25f);
|
||||
}
|
||||
|
||||
paint.setTypeface(tf);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.waterbase.foodify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -19,6 +20,11 @@ import com.waterbase.foodify.Model.Favorites;
|
||||
import com.waterbase.foodify.ViewHolder.FavoritesAdapter;
|
||||
import com.waterbase.foodify.ViewHolder.FavoritesViewHolder;
|
||||
|
||||
import io.github.inflationx.calligraphy3.CalligraphyConfig;
|
||||
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
|
||||
import io.github.inflationx.viewpump.ViewPump;
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
|
||||
|
||||
public class FavoritesActivity extends AppCompatActivity implements RecyclerItemTouchHelperListener {
|
||||
|
||||
RecyclerView recyclerView;
|
||||
@@ -28,9 +34,24 @@ public class FavoritesActivity extends AppCompatActivity implements RecyclerItem
|
||||
|
||||
RelativeLayout rootLayout;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Set font all activity
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
setContentView(R.layout.activity_favorites);
|
||||
|
||||
rootLayout = findViewById(R.id.rootLayout);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class FoodDetail extends AppCompatActivity implements RatingDialogListene
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
@@ -265,26 +265,5 @@ public class FoodDetail extends AppCompatActivity implements RatingDialogListene
|
||||
Toast.makeText(FoodDetail.this, "Cảm ơn bạn đã đánh giá!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
// ratingTbl.child(Common.currentUser.getPhone()).addValueEventListener(new ValueEventListener() {
|
||||
// @Override
|
||||
// public void onDataChange(DataSnapshot dataSnapshot) {
|
||||
// if (dataSnapshot.child(Common.currentUser.getPhone()).exists()) {
|
||||
// //Remove old feedback
|
||||
// ratingTbl.child(Common.currentUser.getPhone()).removeValue();
|
||||
// //Update new feedback
|
||||
// ratingTbl.child(Common.currentUser.getPhone()).setValue(rating);
|
||||
// } else {
|
||||
//
|
||||
// //Update new value
|
||||
// ratingTbl.child(Common.currentUser.getPhone()).setValue(rating);
|
||||
// }
|
||||
// Toast.makeText(FoodDetail.this, "Cảm ơn bạn đã đánh giá món ăn!", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onCancelled(DatabaseError databaseError) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class FoodList extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ForgotPassword extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -3,11 +3,15 @@ package com.waterbase.foodify;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
@@ -96,7 +100,7 @@ public class Home extends AppCompatActivity implements NavigationView.OnNavigati
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
@@ -156,6 +160,23 @@ public class Home extends AppCompatActivity implements NavigationView.OnNavigati
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
//Set font to navigation
|
||||
Menu m = navigationView.getMenu();
|
||||
for (int i=0;i<m.size();i++) {
|
||||
MenuItem mi = m.getItem(i);
|
||||
|
||||
//for aapplying a font to subMenu ...
|
||||
SubMenu subMenu = mi.getSubMenu();
|
||||
if (subMenu != null && subMenu.size() > 0) {
|
||||
for (int j = 0; j < subMenu.size(); j++) {
|
||||
MenuItem subMenuItem = subMenu.getItem(j);
|
||||
applyFontToMenuItem(subMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
//the method we have create in activity
|
||||
applyFontToMenuItem(mi);
|
||||
}
|
||||
|
||||
//Init database
|
||||
database = FirebaseDatabase.getInstance();
|
||||
@@ -217,6 +238,13 @@ public class Home extends AppCompatActivity implements NavigationView.OnNavigati
|
||||
|
||||
}
|
||||
|
||||
private void applyFontToMenuItem(MenuItem mi) {
|
||||
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/font.otf");
|
||||
SpannableString mNewTitle = new SpannableString(mi.getTitle());
|
||||
mNewTitle.setSpan(new CustomTypefaceSpan("" , font), 0 , mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
mi.setTitle(mNewTitle);
|
||||
}
|
||||
|
||||
private void setupSlider() {
|
||||
mSlider = findViewById(R.id.slider);
|
||||
image_list = new HashMap<>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.waterbase.foodify;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -41,6 +42,10 @@ import org.json.JSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.github.inflationx.calligraphy3.CalligraphyConfig;
|
||||
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
|
||||
import io.github.inflationx.viewpump.ViewPump;
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@@ -62,9 +67,24 @@ public class OrderDetail extends AppCompatActivity {
|
||||
|
||||
APIService mService;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Set font all activity
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
setContentView(R.layout.activity_order_detail);
|
||||
|
||||
String comment = "";
|
||||
@@ -135,14 +155,13 @@ public class OrderDetail extends AppCompatActivity {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String order_number = String.valueOf(System.currentTimeMillis());
|
||||
String totalPrice = request.getTotal().substring(0, request.getTotal().length() - 2).replace(".", ""); //Remove character " đ"
|
||||
|
||||
CreateOrder orderApi = new CreateOrder();
|
||||
|
||||
try {
|
||||
JSONObject data = orderApi.createOrder(totalPrice);
|
||||
Log.d("Amount", totalPrice);
|
||||
JSONObject data = orderApi.createOrder(totalPrice, order_number);
|
||||
String code = data.getString("return_code");
|
||||
|
||||
if (code.equals("1")) {
|
||||
@@ -156,7 +175,6 @@ public class OrderDetail extends AppCompatActivity {
|
||||
request.setPaymentStatus("Đã thanh toán!");
|
||||
//Summit to Firebase
|
||||
//We will using System.CurrentMilli to key
|
||||
String order_number = String.valueOf(System.currentTimeMillis());
|
||||
requests.child(order_number).setValue(request);
|
||||
|
||||
sendNotificationOrder(order_number);
|
||||
@@ -209,7 +227,7 @@ public class OrderDetail extends AppCompatActivity {
|
||||
//Create raw payload to send
|
||||
Map<String, String> dataSend = new HashMap<>();
|
||||
dataSend.put("title", "Foodify");
|
||||
dataSend.put("message", "Bạn có 1 đơn hàng mới +" + order_number);
|
||||
dataSend.put("message", "Bạn có 1 đơn hàng mới #" + order_number);
|
||||
DataMessage dataMessage = new DataMessage(serverToken.getToken(), dataSend);
|
||||
|
||||
mService.sendNotification(dataMessage)
|
||||
|
||||
@@ -52,7 +52,7 @@ public class OrderStatus extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SearchActivity extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ShowComment extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SignIn extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
@@ -67,7 +67,7 @@ public class SignIn extends AppCompatActivity {
|
||||
|
||||
txtAppName = (TextView) findViewById(R.id.txtAppName);
|
||||
|
||||
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/NABILA.TTF");
|
||||
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Nabila.ttf");
|
||||
txtAppName.setTypeface(face);
|
||||
|
||||
//Init Firebase
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SignUp extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
@@ -74,7 +74,7 @@ public class SignUp extends AppCompatActivity {
|
||||
|
||||
txtAppName = (TextView) findViewById(R.id.txtAppName);
|
||||
|
||||
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/NABILA.TTF");
|
||||
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Nabila.ttf");
|
||||
txtAppName.setTypeface(face);
|
||||
|
||||
//Init Firebase
|
||||
|
||||
@@ -58,7 +58,7 @@ public class VerifyPhone extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Welcome extends AppCompatActivity {
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/font.ttf")
|
||||
.setDefaultFontPath("fonts/font.otf")
|
||||
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
@@ -53,7 +53,7 @@ public class Welcome extends AppCompatActivity {
|
||||
|
||||
txtSlogan = (TextView) findViewById(R.id.txtSlogan);
|
||||
txtAppName = (TextView) findViewById(R.id.txtAppName);
|
||||
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/NABILA.TTF");
|
||||
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Nabila.ttf");
|
||||
txtSlogan.setTypeface(face);
|
||||
txtAppName.setTypeface(face);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CreateOrder {
|
||||
String Description;
|
||||
String Mac;
|
||||
|
||||
private CreateOrderData(String amount) throws Exception {
|
||||
private CreateOrderData(String amount, String orderId) throws Exception {
|
||||
long appTime = new Date().getTime();
|
||||
AppId = String.valueOf(AppInfo.APP_ID);
|
||||
AppUser = "Android_Demo";
|
||||
@@ -33,7 +33,7 @@ public class CreateOrder {
|
||||
EmbedData = "{}";
|
||||
Items = "[]";
|
||||
BankCode = "zalopayapp";
|
||||
Description = "Merchant pay for order #" + Helpers.getAppTransId();
|
||||
Description = "Thanh toán đơn hàng Foodify #" + orderId;
|
||||
String inputHMac = String.format("%s|%s|%s|%s|%s|%s|%s",
|
||||
this.AppId,
|
||||
this.AppTransId,
|
||||
@@ -47,8 +47,8 @@ public class CreateOrder {
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject createOrder(String amount) throws Exception {
|
||||
CreateOrderData input = new CreateOrderData(amount);
|
||||
public JSONObject createOrder(String amount, String orderId) throws Exception {
|
||||
CreateOrderData input = new CreateOrderData(amount, orderId);
|
||||
|
||||
RequestBody formBody = new FormBody.Builder()
|
||||
.add("app_id", input.AppId)
|
||||
|
||||
@@ -11,17 +11,15 @@
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:weightSum="5"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/food_image"
|
||||
android:src="@drawable/bg4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="4"
|
||||
android:layout_height="250dp"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
|
||||
@@ -30,8 +28,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -51,4 +51,8 @@
|
||||
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
|
||||
</style>
|
||||
|
||||
<style name="fontTextViewStyle" parent="android:Widget.TextView">
|
||||
<item name="android:fontFamily">@fonts/</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user