JunZhang
5 years ago
committed by
GitHub
25 changed files with 1093 additions and 42 deletions
@ -0,0 +1,327 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.cold.ui.fragment.setup; |
|||
|
|||
import android.content.Context; |
|||
import android.graphics.Canvas; |
|||
import android.graphics.Paint; |
|||
import android.os.Bundle; |
|||
import android.util.TypedValue; |
|||
import android.view.LayoutInflater; |
|||
import android.view.View; |
|||
import android.view.View.OnClickListener; |
|||
import android.view.ViewGroup; |
|||
import android.widget.TextView; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
import androidx.databinding.DataBindingUtil; |
|||
import androidx.recyclerview.widget.GridLayoutManager; |
|||
import androidx.recyclerview.widget.RecyclerView; |
|||
import androidx.recyclerview.widget.RecyclerView.Adapter; |
|||
|
|||
import com.cobo.cold.R; |
|||
import com.cobo.cold.databinding.CommonModalBinding; |
|||
import com.cobo.cold.databinding.ModalWithTwoButtonBinding; |
|||
import com.cobo.cold.databinding.RollingDiceBinding; |
|||
import com.cobo.cold.ui.fragment.BaseFragment; |
|||
import com.cobo.cold.ui.modal.ModalDialog; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
public class RollingDiceFragment extends BaseFragment<RollingDiceBinding> { |
|||
|
|||
private DiceGridAdapter adapter; |
|||
private final int INIT_ROLLS = 100; |
|||
private byte[] rolls = new byte[INIT_ROLLS]; |
|||
private int currentPos; |
|||
|
|||
private final int numOfColumn = 10; |
|||
private OnClickListener onClickListener = v -> { |
|||
String tag = (String) v.getTag(); |
|||
if (tag.equals("X")) { |
|||
if (currentPos != 0) { |
|||
currentPos--; |
|||
rolls[currentPos] = 0; |
|||
adapter.notifyItemRangeChanged(currentPos, 2, 1); |
|||
} |
|||
} else { |
|||
rolls[currentPos] = Byte.parseByte(tag); |
|||
currentPos++; |
|||
if (currentPos == rolls.length -1) { |
|||
enlarge(); |
|||
adapter.notifyDataSetChanged(); |
|||
} else { |
|||
adapter.notifyItemRangeChanged(currentPos - 1, 2, 1); |
|||
} |
|||
} |
|||
int first = ((GridLayoutManager)mBinding.diceGrid.getLayoutManager()).findFirstCompletelyVisibleItemPosition(); |
|||
int last = ((GridLayoutManager)mBinding.diceGrid.getLayoutManager()).findLastCompletelyVisibleItemPosition(); |
|||
if (currentPos > last - numOfColumn) { |
|||
mBinding.diceGrid.smoothScrollToPosition(Math.min(currentPos + INIT_ROLLS / 2, rolls.length)); |
|||
} else if(currentPos < first + numOfColumn) { |
|||
int scrollTo = (currentPos - INIT_ROLLS / 2); |
|||
if (scrollTo < 0) return; |
|||
mBinding.diceGrid.smoothScrollToPosition(currentPos - INIT_ROLLS / 2); |
|||
} |
|||
}; |
|||
|
|||
private void enlarge() { |
|||
byte[] enlarge = new byte[rolls.length + INIT_ROLLS]; |
|||
System.arraycopy(rolls, 0, enlarge, 0, rolls.length); |
|||
rolls = enlarge; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
protected int setView() { |
|||
return R.layout.rolling_dice; |
|||
} |
|||
|
|||
@Override |
|||
protected void init(View view) { |
|||
mBinding.toolbar.setNavigationOnClickListener(v -> navigateUp()); |
|||
mBinding.complete.setOnClickListener(v -> onCompleteClick()); |
|||
mBinding.setOnDiceRoll(onClickListener); |
|||
setupDiceGrid(); |
|||
} |
|||
|
|||
private void onCompleteClick() { |
|||
if (currentPos < 50) { |
|||
ModalDialog dialog = new ModalDialog(); |
|||
CommonModalBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mActivity),R.layout.common_modal, |
|||
null,false); |
|||
binding.title.setText(R.string.rolling_not_enough); |
|||
binding.subTitle.setText(mActivity.getString(R.string.rolling_hint_less_than_50,currentPos)); |
|||
binding.confirm.setText(R.string.know); |
|||
binding.close.setVisibility(View.GONE); |
|||
binding.confirm.setOnClickListener(v -> dialog.dismiss()); |
|||
dialog.setBinding(binding); |
|||
dialog.show(mActivity.getSupportFragmentManager(),""); |
|||
} else if(currentPos < 99) { |
|||
ModalDialog dialog = new ModalDialog(); |
|||
ModalWithTwoButtonBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mActivity),R.layout.modal_with_two_button, |
|||
null,false); |
|||
binding.title.setText(R.string.keep_rolling); |
|||
binding.subTitle.setText(mActivity.getString(R.string.rolling_hint_less_than_99,currentPos)); |
|||
binding.left.setText(R.string.confirm_rolling); |
|||
binding.left.setOnClickListener(v -> { |
|||
dialog.dismiss(); |
|||
navigateToGenerateMnemonic(); |
|||
}); |
|||
binding.right.setText(R.string.keep_rolling); |
|||
binding.right.setOnClickListener(v -> dialog.dismiss()); |
|||
dialog.setBinding(binding); |
|||
dialog.show(mActivity.getSupportFragmentManager(),""); |
|||
} else { |
|||
navigateToGenerateMnemonic(); |
|||
} |
|||
} |
|||
|
|||
private void navigateToGenerateMnemonic() { |
|||
Bundle data = new Bundle(); |
|||
data.putByteArray("dice_rolls", Arrays.copyOfRange(rolls,0, currentPos)); |
|||
data.putBoolean("use_dice", true); |
|||
navigate(R.id.action_to_generateMnemonicFragment, data); |
|||
} |
|||
|
|||
private void setupDiceGrid() { |
|||
adapter = new DiceGridAdapter(); |
|||
GridLayoutManager layoutManager = new GridLayoutManager(mActivity,21); |
|||
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { |
|||
@Override |
|||
public int getSpanSize(int position) { |
|||
if (position % numOfColumn == 0) { |
|||
return 3; |
|||
} |
|||
return 2; |
|||
} |
|||
}); |
|||
mBinding.diceGrid.setLayoutManager(layoutManager); |
|||
mBinding.diceGrid.setAdapter(adapter); |
|||
mBinding.diceGrid.addItemDecoration(new TableItemDecoration(mActivity) ); |
|||
} |
|||
|
|||
@Override |
|||
protected void initData(Bundle savedInstanceState) { |
|||
|
|||
} |
|||
|
|||
class DiceGridAdapter extends Adapter<DiceViewHolder> { |
|||
|
|||
@NonNull |
|||
@Override |
|||
public DiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
|||
View view = LayoutInflater.from(mActivity).inflate(R.layout.dice_grid_item,parent,false); |
|||
return new DiceViewHolder(view); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void onBindViewHolder(@NonNull DiceViewHolder holder, int position, @NonNull List<Object> payloads) { |
|||
if (payloads.isEmpty()) { |
|||
onBindViewHolder(holder, position); |
|||
} else { |
|||
int value = (int) payloads.get(0); |
|||
if (value != 0) { |
|||
if (rolls[position] != 0) { |
|||
holder.data.setText(rolls[position] + ""); |
|||
} else { |
|||
holder.data.setText(""); |
|||
} |
|||
} |
|||
if (currentPos == position && rolls[position] == 0) { |
|||
holder.data.setBackground(mActivity.getDrawable(R.drawable.dice_rect)); |
|||
} else { |
|||
holder.data.setBackground(null); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onBindViewHolder(@NonNull DiceViewHolder holder, int position) { |
|||
holder.top.setText(String.valueOf(position + 1)); |
|||
holder.left.setText(String.valueOf(position / numOfColumn + 1)); |
|||
if (rolls[position] != 0) { |
|||
holder.data.setText(String.valueOf(rolls[position])); |
|||
} else { |
|||
holder.data.setText(""); |
|||
} |
|||
if (position == 0) { |
|||
holder.top.setVisibility(View.VISIBLE); |
|||
holder.left.setVisibility(View.VISIBLE); |
|||
} else if(position < numOfColumn){ |
|||
holder.top.setVisibility(View.VISIBLE); |
|||
holder.left.setVisibility(View.GONE); |
|||
} else if(position % numOfColumn == 0) { |
|||
holder.left.setVisibility(View.VISIBLE); |
|||
holder.top.setVisibility(View.GONE); |
|||
} else { |
|||
holder.left.setVisibility(View.GONE); |
|||
holder.top.setVisibility(View.GONE); |
|||
} |
|||
if (currentPos == position && rolls[position] == 0) { |
|||
holder.data.setBackground(mActivity.getDrawable(R.drawable.dice_rect)); |
|||
} else { |
|||
holder.data.setBackground(null); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public int getItemCount() { |
|||
return rolls.length; |
|||
} |
|||
} |
|||
|
|||
class DiceViewHolder extends RecyclerView.ViewHolder { |
|||
|
|||
public TextView left; |
|||
public TextView top; |
|||
public TextView data; |
|||
|
|||
DiceViewHolder(@NonNull View itemView) { |
|||
super(itemView); |
|||
left = itemView.findViewById(R.id.left); |
|||
top = itemView.findViewById(R.id.top); |
|||
data = itemView.findViewById(R.id.data); |
|||
} |
|||
} |
|||
|
|||
class TableItemDecoration extends RecyclerView.ItemDecoration { |
|||
|
|||
private final Paint mPaint; |
|||
private final int dividerWidth; |
|||
|
|||
TableItemDecoration(Context context) { |
|||
mPaint = new Paint(); |
|||
mPaint.setColor(context.getColor(R.color.white40)); |
|||
dividerWidth = dp2px(context, 1); |
|||
mPaint.setStrokeWidth(dividerWidth); |
|||
} |
|||
|
|||
@Override |
|||
public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { |
|||
drawHorizontal(c, parent); |
|||
drawVertical(c, parent); |
|||
} |
|||
|
|||
void drawHorizontal(Canvas c, RecyclerView parent) { |
|||
|
|||
int childCount = parent.getChildCount(); |
|||
for (int i = 0; i < childCount; i++) { |
|||
final View child = parent.getChildAt(i); |
|||
|
|||
int left = child.getLeft(); |
|||
final int right = child.getRight(); |
|||
final int top = child.getBottom(); |
|||
|
|||
if ( i % numOfColumn == 0) { |
|||
left += dp2px(mActivity,14); |
|||
} |
|||
|
|||
if (i + numOfColumn >= childCount) { |
|||
c.drawLine(left, top - dividerWidth, right, top - dividerWidth, mPaint); |
|||
} else { |
|||
c.drawLine(left, top, right, top, mPaint); |
|||
} |
|||
|
|||
//first row
|
|||
if (i < numOfColumn) { |
|||
c.drawLine(left, child.getTop() + (dividerWidth >> 1) + dp2px(mActivity,14), right, |
|||
child.getTop() + (dividerWidth >> 1) + dp2px(mActivity,14), mPaint); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void drawVertical(Canvas c, RecyclerView parent) { |
|||
|
|||
final int childCount = parent.getChildCount(); |
|||
for (int i = 0; i < childCount; i++) { |
|||
final View child = parent.getChildAt(i); |
|||
|
|||
int top = child.getTop(); |
|||
final int bottom = child.getBottom(); |
|||
final int left = child.getRight(); |
|||
|
|||
if (i < numOfColumn) { |
|||
top += dp2px(mActivity,14); |
|||
} |
|||
|
|||
//last column
|
|||
if ((i + 1) % numOfColumn == 0) { |
|||
c.drawLine(left - dividerWidth, top, |
|||
left - dividerWidth, bottom, mPaint); |
|||
} else { |
|||
c.drawLine(left, top, left, bottom, mPaint); |
|||
} |
|||
|
|||
//first column
|
|||
if (i % numOfColumn == 0) { |
|||
c.drawLine(child.getLeft() + (dividerWidth >> 1) + dp2px(mActivity,14), top, |
|||
child.getLeft() + (dividerWidth >> 1) + dp2px(mActivity,14), bottom, mPaint); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
private int dp2px(Context context, int dp) { |
|||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, |
|||
dp, context.getResources().getDisplayMetrics()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,43 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.cold.ui.fragment.setup; |
|||
|
|||
import android.os.Bundle; |
|||
import android.view.View; |
|||
|
|||
import com.cobo.cold.R; |
|||
import com.cobo.cold.databinding.RollingDiceGuideBinding; |
|||
import com.cobo.cold.ui.fragment.BaseFragment; |
|||
|
|||
public class RollingDiceGuideFragment extends BaseFragment<RollingDiceGuideBinding> { |
|||
@Override |
|||
protected int setView() { |
|||
return R.layout.rolling_dice_guide; |
|||
} |
|||
|
|||
@Override |
|||
protected void init(View view) { |
|||
mBinding.toolbar.setNavigationOnClickListener(v -> navigateUp()); |
|||
mBinding.start.setOnClickListener(v -> navigate(R.id.action_to_rollingDiceFragment)); |
|||
} |
|||
|
|||
@Override |
|||
protected void initData(Bundle savedInstanceState) { |
|||
|
|||
} |
|||
} |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<item android:drawable="@drawable/dice_button_bg_pressed" android:state_pressed="true"/> |
|||
<item android:drawable="@drawable/dice_button_bg_normal" android:state_enabled="true" /> |
|||
</selector> |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<solid android:color="#ffffff" /> |
|||
<corners android:radius="3dp" /> |
|||
</shape> |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<solid android:color="#C7CDD5" /> |
|||
<corners android:radius="3dp" /> |
|||
</shape> |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<item android:drawable="@drawable/dice_delete_button_bg_pressed" android:state_pressed="true"/> |
|||
<item android:drawable="@drawable/dice_delete_button_bg_normal" android:state_enabled="true" /> |
|||
</selector> |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<solid android:color="#92959F" /> |
|||
<corners android:radius="3dp" /> |
|||
</shape> |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<solid android:color="#5C606E" /> |
|||
<corners android:radius="3dp" /> |
|||
</shape> |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<stroke android:width="1dp" android:color="@color/white"/> |
|||
</shape> |
@ -0,0 +1,66 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:orientation="horizontal" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
> |
|||
|
|||
<TextView |
|||
android:id="@+id/left" |
|||
android:layout_width="14dp" |
|||
android:layout_height="28dp" |
|||
android:gravity="center" |
|||
android:textStyle="bold" |
|||
android:textSize="12sp" |
|||
android:textColor="@color/white40" |
|||
android:layout_gravity="bottom" |
|||
android:visibility="gone" |
|||
tools:text="2"/> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="vertical"> |
|||
<TextView |
|||
android:id="@+id/top" |
|||
android:layout_width="28dp" |
|||
android:layout_height="14dp" |
|||
android:gravity="top|center_horizontal" |
|||
android:textStyle="bold" |
|||
android:textSize="12sp" |
|||
android:textColor="@color/white40" |
|||
android:layout_gravity="bottom" |
|||
android:visibility="gone" |
|||
tools:text="2"/> |
|||
|
|||
<TextView |
|||
android:id="@+id/data" |
|||
android:layout_width="28dp" |
|||
android:layout_height="28dp" |
|||
android:gravity="center" |
|||
android:textStyle="bold" |
|||
android:textSize="16sp" |
|||
android:textColor="@color/white" |
|||
android:layout_gravity="bottom" |
|||
tools:text="2"/> |
|||
</LinearLayout> |
|||
|
|||
</LinearLayout> |
@ -0,0 +1,99 @@ |
|||
<?xml version="1.0" encoding="utf-8"?><!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<data /> |
|||
|
|||
<FrameLayout |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center"> |
|||
|
|||
<RelativeLayout |
|||
android:layout_width="288dp" |
|||
android:layout_height="wrap_content" |
|||
android:background="@drawable/modal_bg"> |
|||
|
|||
|
|||
<TextView |
|||
android:id="@+id/title" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_centerHorizontal="true" |
|||
android:layout_marginTop="12dp" |
|||
android:textColor="@color/black" |
|||
android:textSize="15sp" |
|||
android:textStyle="bold" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/sub_title" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_below="@id/title" |
|||
android:layout_centerHorizontal="true" |
|||
android:layout_marginHorizontal="16dp" |
|||
android:layout_marginTop="12dp" |
|||
android:gravity="center_horizontal" |
|||
android:textSize="13sp" |
|||
android:visibility="visible" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/action_hint" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_below="@id/sub_title" |
|||
android:layout_centerHorizontal="true" |
|||
android:layout_marginHorizontal="16dp" |
|||
android:gravity="center_horizontal" |
|||
android:textSize="13sp" |
|||
android:visibility="visible" /> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_below="@id/action_hint" |
|||
android:orientation="horizontal"> |
|||
|
|||
<Button |
|||
android:id="@+id/left" |
|||
style="@style/AcceptButton" |
|||
android:layout_width="0dp" |
|||
android:layout_marginStart="16dp" |
|||
android:layout_marginTop="16dp" |
|||
android:layout_marginBottom="20dp" |
|||
android:layout_weight="1" |
|||
android:background="#EBF0F5" |
|||
android:textColor="#8F95AA" |
|||
android:textStyle="bold" /> |
|||
|
|||
<Button |
|||
android:id="@+id/right" |
|||
style="@style/AcceptButton" |
|||
android:layout_width="0dp" |
|||
android:layout_marginHorizontal="16dp" |
|||
android:layout_marginTop="16dp" |
|||
android:layout_marginBottom="20dp" |
|||
android:layout_weight="1" |
|||
android:textStyle="bold" /> |
|||
</LinearLayout> |
|||
|
|||
|
|||
</RelativeLayout> |
|||
|
|||
</FrameLayout> |
|||
</layout> |
@ -0,0 +1,188 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<layout xmlns:tools="http://schemas.android.com/tools" |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
|||
|
|||
<data> |
|||
|
|||
<variable |
|||
name="onDiceRoll" |
|||
type="android.view.View.OnClickListener" /> |
|||
</data> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:orientation="vertical"> |
|||
|
|||
<androidx.appcompat.widget.Toolbar |
|||
android:id="@+id/toolbar" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="?attr/actionBarSize" |
|||
android:background="?attr/colorPrimary" |
|||
app:navigationIcon="@drawable/arrow_left" |
|||
app:popupTheme="@style/AppTheme.PopupOverlay"> |
|||
|
|||
<TextView |
|||
android:id="@+id/toolbar_title" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center" |
|||
android:text="@string/dice_rolls" |
|||
android:textColor="@android:color/white" |
|||
android:textSize="15sp" /> |
|||
</androidx.appcompat.widget.Toolbar> |
|||
|
|||
<include layout="@layout/divider" /> |
|||
|
|||
<androidx.recyclerview.widget.RecyclerView |
|||
android:id="@+id/dice_grid" |
|||
android:layout_gravity="center" |
|||
android:layout_width="294dp" |
|||
android:layout_height="294dp" |
|||
tools:itemCount="100" |
|||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" |
|||
app:spanCount="10" |
|||
tools:listitem="@layout/dice_grid_item"/> |
|||
|
|||
<androidx.legacy.widget.Space |
|||
android:layout_width="match_parent" |
|||
android:layout_height="0dp" |
|||
android:layout_weight="1" /> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal" |
|||
android:layout_marginHorizontal="10dp"> |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="1" |
|||
android:tag="1" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/dice_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="2" |
|||
android:tag="2" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/dice_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="3" |
|||
android:tag="3" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/dice_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
<ImageButton |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:tag="X" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:src="@drawable/delete" |
|||
android:background="@drawable/dice_delete_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
</LinearLayout> |
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal" |
|||
android:layout_marginTop="12dp" |
|||
android:layout_marginBottom="50dp" |
|||
android:layout_marginHorizontal="10dp"> |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="4" |
|||
android:tag="4" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/dice_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="5" |
|||
android:tag="5" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/dice_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
<TextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="6" |
|||
android:tag="6" |
|||
android:gravity="center" |
|||
android:onClick="@{onDiceRoll}" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/dice_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/black"/> |
|||
<TextView |
|||
android:id="@+id/complete" |
|||
android:layout_width="0dp" |
|||
android:layout_height="46dp" |
|||
android:layout_weight="1" |
|||
android:text="@string/complete" |
|||
android:gravity="center" |
|||
android:layout_marginHorizontal="6dp" |
|||
android:background="@drawable/accept_button_bg" |
|||
android:textSize="16sp" |
|||
android:textStyle="bold" |
|||
android:textColor="@color/white"/> |
|||
</LinearLayout> |
|||
</LinearLayout> |
|||
</layout> |
@ -0,0 +1,82 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
~ Copyright (c) 2020 Cobo |
|||
~ |
|||
~ This program is free software: you can redistribute it and/or modify |
|||
~ it under the terms of the GNU General Public License as published by |
|||
~ the Free Software Foundation, either version 3 of the License, or |
|||
~ (at your option) any later version. |
|||
~ |
|||
~ This program is distributed in the hope that it will be useful, |
|||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
~ GNU General Public License for more details. |
|||
~ |
|||
~ You should have received a copy of the GNU General Public License |
|||
~ in the file COPYING. If not, see <http://www.gnu.org/licenses/>. |
|||
--> |
|||
|
|||
<layout xmlns:tools="http://schemas.android.com/tools" |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
|||
|
|||
<data> |
|||
|
|||
</data> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:orientation="vertical"> |
|||
|
|||
<androidx.appcompat.widget.Toolbar |
|||
android:id="@+id/toolbar" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="?attr/actionBarSize" |
|||
android:background="?attr/colorPrimary" |
|||
app:navigationIcon="@drawable/arrow_left" |
|||
app:popupTheme="@style/AppTheme.PopupOverlay"> |
|||
|
|||
<TextView |
|||
android:id="@+id/toolbar_title" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="center" |
|||
android:text="@string/dice_rolls" |
|||
android:textColor="@android:color/white" |
|||
android:textSize="15sp" /> |
|||
</androidx.appcompat.widget.Toolbar> |
|||
|
|||
<include layout="@layout/divider" /> |
|||
|
|||
<com.cobo.cold.ui.views.SpanedTextView |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginHorizontal="16dp" |
|||
android:layout_marginTop="10dp" |
|||
android:text="@string/dice_roll_guide" |
|||
android:textColor="@color/white" /> |
|||
|
|||
<ImageView |
|||
android:id="@+id/tablet" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginTop="50dp" |
|||
android:layout_gravity="center_horizontal" |
|||
android:src="@drawable/dice" |
|||
tools:ignore="ContentDescription" /> |
|||
|
|||
<androidx.legacy.widget.Space |
|||
android:layout_width="match_parent" |
|||
android:layout_height="0dp" |
|||
android:layout_weight="1" /> |
|||
|
|||
<Button |
|||
android:id="@+id/start" |
|||
style="@style/AcceptButton" |
|||
android:layout_width="match_parent" |
|||
android:layout_marginHorizontal="16dp" |
|||
android:layout_marginBottom="18dp" |
|||
android:text="@string/start" /> |
|||
</LinearLayout> |
|||
</layout> |
Loading…
Reference in new issue