-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 增加符号键盘,实现了根据配置加载按键、可以滚动显示键盘、点击上屏的主要功能。 2. 滑动键盘以标签页的形式展示多组多组键盘,标签列表占用原键盘布局的候选栏位置,并且完全共用候选栏的皮肤参数。按键填充在LiquidKeyboard中,除背景色共用原皮肤的背景参数外,其他参数可以单独设定。 3. 在滑动键盘内增加内置剪贴板,提供监控剪贴板变化、列表显示、点击上屏的简单功能。剪贴板删除、查找、合并、编辑等功能目前未实现,背景色参数设定未实现。 4. 去除ScrollView一些未使用的变量。 短期无法完善剪贴板,因此先提交已完成基本功能的代码。
- Loading branch information
Showing
27 changed files
with
1,850 additions
and
99 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -55,3 +55,4 @@ libs/* | |
# vim | ||
*.swp | ||
|
||
/app/release/output-metadata.json |
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
160 changes: 160 additions & 0 deletions
160
app/src/main/java/com/osfans/trime/ime/SymbolKeyboard/ClipboardAdapter.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,160 @@ | ||
package com.osfans.trime.ime.SymbolKeyboard; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.graphics.Typeface; | ||
import android.view.LayoutInflater; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.google.android.flexbox.FlexboxLayoutManager; | ||
import com.osfans.trime.R; | ||
import com.osfans.trime.setup.Config; | ||
|
||
import java.util.List; | ||
|
||
|
||
public class ClipboardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||
private final Context myContext; | ||
private List<SimpleKeyBean> list; | ||
private int keyMarginX, keyMarginTop; | ||
private Integer textColor; | ||
private float textSize; | ||
private Typeface textFont; | ||
|
||
public ClipboardAdapter(Context context, List<SimpleKeyBean> itemlist) { | ||
myContext = context; | ||
list = itemlist; | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return list.size(); | ||
} | ||
|
||
public void configStyle(int keyMarginX, int keyMarginTop) { | ||
this.keyMarginX = keyMarginX; | ||
this.keyMarginTop = keyMarginTop; | ||
|
||
// 边框尺寸、圆角、字号直接读取主题通用参数。配色优先读取liquidKeyboard专用参数。 | ||
Config config = Config.get(myContext); | ||
textColor = config.getLiquidColor("long_text_color"); | ||
if (textColor == null) | ||
textColor = config.getLiquidColor("key_text_color"); | ||
|
||
textSize = config.getFloat("long_text_size"); | ||
if (textSize <= 0) | ||
textSize = config.getFloat("label_text_size"); | ||
|
||
textFont = config.getFont("long_text_font"); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(myContext).inflate(R.layout.simple_key_item, parent, false); | ||
return new ItemViewHolder(view); | ||
} | ||
|
||
static class ItemViewHolder extends RecyclerView.ViewHolder { | ||
public ItemViewHolder(View view) { | ||
super(view); | ||
|
||
listItemLayout = view.findViewById(R.id.listitem_layout); | ||
mTitle = view.findViewById(R.id.simple_key); | ||
} | ||
|
||
LinearLayout listItemLayout; | ||
TextView mTitle; | ||
} | ||
|
||
@SuppressLint("ClickableViewAccessibility") | ||
@Override | ||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int index) { | ||
|
||
if (viewHolder instanceof ClipboardAdapter.ItemViewHolder) { | ||
SimpleKeyBean searchHistoryBean = list.get(index); | ||
final ClipboardAdapter.ItemViewHolder itemViewHold = ((ClipboardAdapter.ItemViewHolder) viewHolder); | ||
|
||
if (textFont != null) | ||
itemViewHold.mTitle.setTypeface(textFont); | ||
itemViewHold.mTitle.setText(searchHistoryBean.getText()); | ||
|
||
if (textSize > 0) | ||
itemViewHold.mTitle.setTextSize(textSize); | ||
|
||
ViewGroup.LayoutParams lp = itemViewHold.listItemLayout.getLayoutParams(); | ||
if (lp instanceof FlexboxLayoutManager.LayoutParams) { | ||
FlexboxLayoutManager.LayoutParams flexboxLp = | ||
(FlexboxLayoutManager.LayoutParams) itemViewHold.listItemLayout.getLayoutParams(); | ||
|
||
itemViewHold.mTitle.setTextColor(textColor); | ||
|
||
int marginTop = flexboxLp.getMarginTop(); | ||
int marginX = flexboxLp.getMarginLeft(); | ||
if (keyMarginTop > 0) | ||
marginTop = keyMarginTop; | ||
if (keyMarginX > 0) | ||
marginX = keyMarginX; | ||
|
||
flexboxLp.setMargins( | ||
marginX, marginTop, marginX, flexboxLp.getMarginBottom() | ||
); | ||
|
||
// TODO 设置剪贴板列表样式 | ||
// copy SimpleAdapter会造成高度始终为3行无法自适应的效果。 | ||
|
||
} | ||
|
||
//如果设置了回调,则设置点击事件 | ||
if (mOnItemClickLitener != null) { | ||
itemViewHold.listItemLayout.setOnClickListener(view -> { | ||
int position = itemViewHold.getLayoutPosition(); | ||
mOnItemClickLitener.onItemClick(itemViewHold.listItemLayout, position); | ||
}); | ||
} | ||
|
||
itemViewHold.listItemLayout.setOnLongClickListener(view -> { | ||
int position = itemViewHold.getLayoutPosition(); | ||
// TODO 长按删除、编辑剪贴板 | ||
// 当文本较长时,目前样式只缩略显示为3行,长按时tosat消息可以预览全文,略有用处。 | ||
Toast.makeText(myContext, list.get(position).getText(), Toast.LENGTH_SHORT).show(); | ||
return true; | ||
}); | ||
|
||
// TODO 剪贴板列表点击时产生背景变色效果 | ||
itemViewHold.listItemLayout.setOnTouchListener((view, motionEvent) -> { | ||
int action = motionEvent.getAction(); | ||
switch (action) { | ||
case MotionEvent.ACTION_DOWN: | ||
|
||
case MotionEvent.ACTION_UP: | ||
case MotionEvent.ACTION_CANCEL: | ||
|
||
break; | ||
} | ||
return false; | ||
}); | ||
|
||
} | ||
} | ||
|
||
/*=====================添加OnItemClickListener回调================================*/ | ||
public interface OnItemClickLitener { | ||
void onItemClick(View view, int position); | ||
} | ||
|
||
private ClipboardAdapter.OnItemClickLitener mOnItemClickLitener; | ||
|
||
public void setOnItemClickLitener(ClipboardAdapter.OnItemClickLitener mOnItemClickLitener) { | ||
this.mOnItemClickLitener = mOnItemClickLitener; | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
app/src/main/java/com/osfans/trime/ime/SymbolKeyboard/ClipboardBean.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,58 @@ | ||
package com.osfans.trime.ime.SymbolKeyboard; | ||
|
||
public class ClipboardBean extends SimpleKeyBean { | ||
private long time; | ||
private String text; | ||
private String html; | ||
private int type; | ||
|
||
public long getTime() { | ||
return time; | ||
} | ||
|
||
public String getHtml() { | ||
return html; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public int getType() { | ||
return type; | ||
} | ||
|
||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
|
||
public void setTime(long time) { | ||
this.time = time; | ||
} | ||
|
||
public void setType(int type) { | ||
this.type = type; | ||
} | ||
|
||
public ClipboardBean(String text) { | ||
this.text = text; | ||
this.time = System.currentTimeMillis(); | ||
this.type = 0; | ||
this.html = ""; | ||
} | ||
|
||
public ClipboardBean(String text, String html) { | ||
this.text = text; | ||
this.time = System.currentTimeMillis(); | ||
this.type = 1; | ||
this.html = html; | ||
} | ||
|
||
public ClipboardBean(String text, String html, int type, long time) { | ||
this.text = text; | ||
this.time = time; | ||
this.type = type; | ||
this.html = html; | ||
} | ||
|
||
} |
Oops, something went wrong.