Skip to content

Commit

Permalink
removed font multipliers
Browse files Browse the repository at this point in the history
  • Loading branch information
DevEmperor committed Oct 1, 2024
1 parent 5434b60 commit d574bcf
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 45 deletions.
40 changes: 27 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,46 +42,60 @@

<activity
android:name=".activities.ChatActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.SavedChatsActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.EditChatActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.ImageActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.CreateImageActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.OpenImageActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.QRCodeActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.UsageActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.SettingsActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.AboutActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.OnboardingActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.InputActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.ChangelogActivity"
android:exported="false" />
android:exported="false"
android:taskAffinity="" />
<activity
android:name=".activities.MainActivity"
android:exported="true"
android:taskAffinity=""
android:theme="@style/Theme.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import net.devemperor.wristassist.BuildConfig;
import net.devemperor.wristassist.R;
import net.devemperor.wristassist.util.WristAssistUtil;


public class AboutActivity extends Activity {
Expand All @@ -20,7 +19,6 @@ protected void onCreate(Bundle savedInstanceState) {

TextView aboutText = findViewById(R.id.version_tv);
aboutText.setText(getString(R.string.wristassist_about, BuildConfig.VERSION_NAME));
aboutText.setTextSize(16 * WristAssistUtil.getFontMultiplier(this));

ImageView icon = findViewById(R.id.icon);
icon.setOnLongClickListener(v -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.devemperor.wristassist.adapters.SavedChatsAdapter;
import net.devemperor.wristassist.database.ChatHistoryDatabaseHelper;
import net.devemperor.wristassist.database.ChatHistoryModel;
import net.devemperor.wristassist.util.WristAssistUtil;

import java.util.List;

Expand Down Expand Up @@ -56,7 +55,6 @@ protected void onCreate(Bundle savedInstanceState) {

TextView noSavedChats = findViewById(R.id.no_saved_chats);
noSavedChats.setVisibility(chats.isEmpty() ? android.view.View.VISIBLE : android.view.View.GONE);
noSavedChats.setTextSize(16 * WristAssistUtil.getFontMultiplier(this));

savedChatsWrv.requestFocus();
savedChatsWrv.setOnGenericMotionListener((v, ev) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public View getView (int position, View convertView, @NonNull ViewGroup parent)

TextView chatItem = listItem.findViewById(R.id.chat_item_text);
chatItem.setTextSize(context.getSharedPreferences("net.devemperor.wristassist", Context.MODE_PRIVATE)
.getInt("net.devemperor.wristassist.font_size", 15) * WristAssistUtil.getFontMultiplier(context));
.getInt("net.devemperor.wristassist.font_size", 15));

ChatMessage chatMessage = objects.get(position).getChatMessage();
chatItem.setOnClickListener(v -> launchTTS(chatMessage.getContent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import net.devemperor.wristassist.R;
import net.devemperor.wristassist.items.MainItem;
import net.devemperor.wristassist.util.WristAssistUtil;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -56,7 +55,6 @@ public void onBindViewHolder(RecyclerViewHolder holder, final int position) {
MainItem dataProvider = data.get(position);

holder.menuItem.setText(dataProvider.getText());
holder.menuItem.setTextSize(24 * WristAssistUtil.getFontMultiplier(holder.menuItem.getContext()));
holder.menuIcon.setImageResource(dataProvider.getIcon());
holder.menuContainer.setOnClickListener(v -> {
if (callback != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import net.devemperor.wristassist.R;
import net.devemperor.wristassist.activities.MainActivity;
import net.devemperor.wristassist.util.WristAssistUtil;

public class OnboardingAdapter extends RecyclerView.Adapter<OnboardingAdapter.ViewHolder> {

Expand All @@ -35,13 +33,7 @@ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
if (position == 0) {
TextView welcomeTv = holder.itemView.findViewById(R.id.welcome_tv);
welcomeTv.setTextSize(20 * WristAssistUtil.getFontMultiplier(welcomeTv.getContext()));
} else if (position == 1) {
TextView infoTv = holder.itemView.findViewById(R.id.info_tv);
infoTv.setTextSize(16 * WristAssistUtil.getFontMultiplier(infoTv.getContext()));
} else if (position == 2) {
if (position == 2) {
ImageView qrCodeIv = holder.itemView.findViewById(R.id.qrcode_iv);
qrCodeIv.setOnClickListener(v -> {
Intent intent = new Intent(v.getContext(), MainActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import net.devemperor.wristassist.R;
import net.devemperor.wristassist.database.ChatHistoryModel;
import net.devemperor.wristassist.util.WristAssistUtil;

import java.util.List;

Expand Down Expand Up @@ -52,7 +51,6 @@ public void onBindViewHolder(RecyclerViewHolder holder, final int position) {
ChatHistoryModel dataProvider = data.get(position);

holder.savedChatTitle.setText(dataProvider.getTitle());
holder.savedChatTitle.setTextSize(18 * WristAssistUtil.getFontMultiplier(holder.savedChatTitle.getContext()));

holder.savedChatContainer.setOnClickListener(v -> {
if (callback != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class UsageAdapter extends ArrayAdapter<UsageModel> {
final Context context;
final List<UsageModel> objects;


public UsageAdapter(@NonNull Context context, @NonNull List<UsageModel> objects) {
super(context, -1, objects);
this.context = context;
Expand All @@ -37,7 +36,6 @@ public View getView (int position, View convertView, @NonNull ViewGroup parent)

TextView modelNameTv = listItem.findViewById(R.id.usage_model_tv);
modelNameTv.setText(WristAssistUtil.translate(context, dataProvider.getModelName()));
modelNameTv.setTextSize(18 * WristAssistUtil.getFontMultiplier(context));

TextView tokensTv = listItem.findViewById(R.id.usage_tokens_tv);
if (dataProvider.getModelName().startsWith("gpt")) {
Expand All @@ -47,12 +45,10 @@ public View getView (int position, View convertView, @NonNull ViewGroup parent)
tokensTv.setText(context.getString(R.string.wristassist_images_count,
String.format(Locale.getDefault(), "%,d", dataProvider.getTokens())));
}
tokensTv.setTextSize(16 * WristAssistUtil.getFontMultiplier(context));

TextView costTv = listItem.findViewById(R.id.usage_cost_tv);
costTv.setText(context.getString(R.string.wristassist_estimated_cost,
String.format(Locale.getDefault(), "%,.2f", dataProvider.getCost())));
costTv.setTextSize(16 * WristAssistUtil.getFontMultiplier(context));

return listItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ public static Bitmap drawableToBitmap(Drawable drawable) {
return bitmap;
}

public static float getFontMultiplier(Context context) {
float fs = context.getResources().getConfiguration().fontScale;
float diff = Math.abs(fs - 1.0f) * 0.3f;
if (fs > 1) {
return 1.0f + diff;
} else {
return 1.0f - diff;
}
}

public static double calcCostChat(String model, long promptTokens, long completionTokens) {
double inputPrice = 0;
double outputPrice = 0;
Expand Down

0 comments on commit d574bcf

Please sign in to comment.