Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: android styling and conditionals (#103)
* feat: android styling and conditionals * feat: text wrapping * chore: rebase from alpha * fix: resolve merge conflicts Co-authored-by: Vittorio Cellucci <vel@qlik.com>
- Loading branch information
Showing
29 changed files
with
1,010 additions
and
214 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
android/src/main/java/com/qliktrialreactnativestraighttable/CellContentStyle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import com.facebook.react.bridge.ReadableMap; | ||
|
||
public class CellContentStyle extends HeaderContentStyle { | ||
int rowHeight = 1; | ||
CellContentStyle(ReadableMap data) { | ||
super(data); | ||
rowHeight = JsonUtils.getInt(data, "rowHeight", 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
android/src/main/java/com/qliktrialreactnativestraighttable/ClickableTextWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import android.widget.TextView; | ||
|
||
public class ClickableTextWrapper extends TextWrapper{ | ||
ClickableTextWrapper(TableView tableView, TextView textView) { | ||
super(tableView, textView); | ||
} | ||
|
||
@Override | ||
void measureLineCount() { | ||
if(wordCount > 1) { | ||
int lines = calculateLineCount(); | ||
if(lines != lineCount && lines <= wordCount) { | ||
lineCount = lines; | ||
tableView.updateRecyclerViewLineCount(column); | ||
} | ||
} | ||
} | ||
int getMeasureLinedCount(DataColumn column) { | ||
this.column = column; | ||
if(wordCount > 1) { | ||
return calculateLineCount(); | ||
} | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
android/src/main/java/com/qliktrialreactnativestraighttable/ConditionalTypeFaceSpan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.graphics.Paint; | ||
import android.graphics.Typeface; | ||
import android.text.TextPaint; | ||
import android.text.style.TypefaceSpan; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class ConditionalTypeFaceSpan extends TypefaceSpan { | ||
private Typeface newType; | ||
private int textColor = TableTheme.defaultTextColor; | ||
|
||
public ConditionalTypeFaceSpan(Typeface typeface) { | ||
super(typeface); | ||
newType = typeface; | ||
} | ||
public ConditionalTypeFaceSpan(Typeface typeface, int textColor) { | ||
super(typeface); | ||
newType = typeface; | ||
this.textColor = textColor; | ||
} | ||
|
||
public ConditionalTypeFaceSpan(String family, Typeface typeface) { | ||
super(family); | ||
newType = typeface; | ||
} | ||
|
||
public ConditionalTypeFaceSpan(String family, Typeface typeface, int color) { | ||
super(family); | ||
newType = typeface; | ||
textColor = color; | ||
} | ||
|
||
@Override | ||
public void updateDrawState(TextPaint tp) { | ||
apply(tp, newType ); | ||
} | ||
|
||
@Override | ||
public void updateMeasureState(@NonNull TextPaint paint) { | ||
apply(paint, newType); | ||
} | ||
|
||
@SuppressLint("WrongConstant") | ||
private void apply(Paint paint, Typeface tp) { | ||
int oldStyle; | ||
Typeface old = paint.getTypeface(); | ||
if (old == null) { | ||
oldStyle = 0; | ||
} else { | ||
oldStyle = old.getStyle(); | ||
} | ||
|
||
int fake = oldStyle & ~tp.getStyle(); | ||
if ((fake & Typeface.BOLD) != 0) { | ||
paint.setFakeBoldText(true); | ||
} | ||
|
||
paint.setColor(textColor); | ||
paint.setTypeface(tp); | ||
|
||
} | ||
} |
1 change: 1 addition & 0 deletions
1
android/src/main/java/com/qliktrialreactnativestraighttable/Content.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
android/src/main/java/com/qliktrialreactnativestraighttable/CustomLinearLayoutManger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
public class CustomLinearLayoutManger extends LinearLayoutManager { | ||
boolean initialized = false; | ||
CustomRecyclerView recyclerView = null; | ||
CustomLinearLayoutManger(Context context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public void onLayoutCompleted(RecyclerView.State state) { | ||
super.onLayoutCompleted(state); | ||
if(!initialized && recyclerView != null) { | ||
if(recyclerView.testTextWrap()) { | ||
recyclerView = null; | ||
initialized = true; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.