Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
removed unnecessary fonts and using new calligraphy now
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-bhandari committed Oct 18, 2020
1 parent 60b25a5 commit bc30c8d
Show file tree
Hide file tree
Showing 77 changed files with 821 additions and 1,369 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ dependencies {

//font
//implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.github.takahirom.downloadable.calligraphy:downloadable-calligraphy:0.1.3'
//implementation 'com.github.takahirom.downloadable.calligraphy:downloadable-calligraphy:0.1.3'

implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'

//flow layout
implementation 'com.google.android:flexbox:1.0.0'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/notification_channel"/>
<meta-data
<!--<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
android:resource="@array/preloaded_fonts" />-->

<activity
android:name=".activity.ActivityMain"
Expand Down
Binary file added app/src/main/assets/fonts/robot-regular.ttf
Binary file not shown.
78 changes: 39 additions & 39 deletions app/src/main/java/com/music/player/bhandari/m/MyApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@
import com.music.player.bhandari.m.model.Constants;
import com.music.player.bhandari.m.service.PlayerService;

import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
import io.github.inflationx.viewpump.ViewPump;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* Copyright 2017 Amit Bhandari AB
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

public class MyApp extends Application {
Expand All @@ -41,13 +44,13 @@ public class MyApp extends Application {
public static boolean isAppVisible;

//batch lyrics download service status flag
public static boolean isBatchServiceRunning=false;
public static boolean isBatchServiceRunning = false;

//user signed in or not status flag
public static boolean hasUserSignedIn=false;
public static boolean hasUserSignedIn = false;

//current selected theme id
private static int selectedThemeId=0;
private static int selectedThemeId = 0;

@Override
public void onCreate() {
Expand All @@ -58,48 +61,45 @@ public void onCreate() {

selectedThemeId = pref.getInt(getString(R.string.pref_theme_id), Constants.DEFAULT_THEME_ID);

int id = TypeFaceHelper.getTypeFacePathId();

if(id!=-1) {
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFont(id)
String path = TypeFaceHelper.getTypeFacePath();
if (path != null) {
ViewPump.init(ViewPump.builder()
.addInterceptor(new CalligraphyInterceptor(
new CalligraphyConfig.Builder()
.setDefaultFontPath(path)
.setFontAttrId(R.attr.fontPath)
.build()))
.build());
}
}

public void handleUncaughtException (Thread thread, Throwable e)
{
e.printStackTrace(); // not all Android versions will print the stack trace automatically
Intent intent = new Intent ();
intent.setAction ("com.bhandari.music.SEND_LOG"); // see step 5.
intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application
startActivity (intent);
System.exit(1); // kill off the crashed app
}

public static MyApp getInstance() {
return instance;
}

public static Context getContext(){
public static Context getContext() {
return instance;
}

public static SharedPreferences getPref(){
public static SharedPreferences getPref() {
return pref;
}

public static void setService(PlayerService s){
public static void setService(PlayerService s) {
service = s;
}

public static PlayerService getService(){
return service;
public static PlayerService getService() {
return service;
}

public static boolean isLocked(){return isLocked;}
public static boolean isLocked() {
return isLocked;
}

public static void setLocked(boolean lock){isLocked = lock;}
public static void setLocked(boolean lock) {
isLocked = lock;
}

public static int getSelectedThemeId() {
return selectedThemeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class TypeFaceHelper {

private static Typeface typeface = null;
private static String typefacePath = "";
private static int typefaceId = R.font.manrope;
//private static int typefaceId = R.font.manrope;

public static Typeface getTypeFace(Context context) {
if (typeface == null) {
Expand All @@ -52,9 +52,9 @@ public static Typeface getTypeFace(Context context) {
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/asap.ttf");
break;

case Constants.TYPEFACE.ACME:
/*case Constants.TYPEFACE.ACME:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/acme.ttf");
break;
break;*/
}
}
return typeface;
Expand All @@ -70,10 +70,6 @@ public static String getTypeFacePath() {
typefacePath = "fonts/manrope.ttf";
break;

case Constants.TYPEFACE.SYSTEM_DEFAULT:
typefacePath = "null";
break;

case Constants.TYPEFACE.MONOSPACE:
typefacePath = "fonts/monospace.ttf";
break;
Expand All @@ -82,15 +78,23 @@ public static String getTypeFacePath() {
typefacePath = "fonts/asap.ttf";
break;

case Constants.TYPEFACE.ACME:
/*case Constants.TYPEFACE.ACME:
typefacePath = "fonts/acme.ttf";
break;*/

case Constants.TYPEFACE.ROBOTO:
typefacePath = "fonts/robot-regular.ttf";
break;

case Constants.TYPEFACE.SYSTEM_DEFAULT:
typefacePath = "null";
break;
}

return typefacePath;
}

public static int getTypeFacePathId() {
/*public static int getTypeFacePathId() {
switch (MyApp.getPref().getInt(MyApp.getContext().getString(R.string.pref_text_font), Constants.TYPEFACE.MANROPE)){
case Constants.TYPEFACE.SOFIA:
typefaceId = R.font.sofia;
Expand All @@ -112,7 +116,7 @@ public static int getTypeFacePathId() {
typefaceId = R.font.asap;
break;
case Constants.TYPEFACE.ACME:
*//*case Constants.TYPEFACE.ACME:
typefaceId = R.font.acme;
break;
Expand Down Expand Up @@ -215,9 +219,9 @@ public static int getTypeFacePathId() {
case Constants.TYPEFACE.SOURCE_SANS_PRO:
typefaceId = R.font.source_sans_pro;
break;
break;*//*
}
return typefaceId;
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
import com.music.player.bhandari.m.model.Constants;
import com.music.player.bhandari.m.MyApp;
import com.music.player.bhandari.m.utils.UtilityFun;

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -149,7 +148,7 @@ public void updateDrawState(TextPaint ds) {

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}

private void open_url(String url){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import org.json.JSONObject;

import java.util.ArrayList;

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -189,7 +188,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

import butterknife.BindView;
import butterknife.ButterKnife;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -1102,6 +1102,6 @@ public void onPostExecute(Boolean result) {

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -256,7 +256,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.core.view.GestureDetectorCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;

import android.text.Html;
import android.util.Log;
import android.view.ActionMode;
Expand Down Expand Up @@ -85,7 +89,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.blurry.Blurry;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
* Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -744,7 +748,7 @@ private StringBuilder getSelectedLyricString() {
public void onDestroyActionMode(ActionMode actionMode) {
actionMode.finish();
actionModeActive = false;
lyricThread.setCallback(null);
if (lyricThread != null) lyricThread.setCallback(null);
adapter.clearSelections();
}

Expand Down Expand Up @@ -1034,7 +1038,7 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -226,7 +226,7 @@ public void onRefresh() {

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}
class SentInvitationAdapter extends RecyclerView.Adapter<SentInvitationAdapter.MyViewHolder> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import com.music.player.bhandari.m.R;
import com.music.player.bhandari.m.UIElementHelper.ColorHelper;
import com.music.player.bhandari.m.model.Constants;

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

/**
Copyright 2017 Amit Bhandari AB
Expand Down Expand Up @@ -80,7 +79,7 @@ protected void onCreate(final Bundle savedInstanceState)

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}

@Override
Expand Down
Loading

0 comments on commit bc30c8d

Please sign in to comment.