Skip to content

Commit

Permalink
Added some drawables, working on links to справка
Browse files Browse the repository at this point in the history
  • Loading branch information
IstrajI committed Jun 24, 2019
1 parent fc567eb commit 8b7f401
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ public void onCreate(final Bundle savedInstanceState) {
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
ScreenUtils.init(metrics.widthPixels, metrics.heightPixels);


}

@Override
Expand Down Expand Up @@ -329,7 +327,7 @@ public void topPanelOnMenuClick() {

final Bundle bundle = new Bundle();
bundle.putString(CONFIRMATION_TEXT, getString(R.string.action_confirm_dialog_go_to_main_menu));
bundle.putInt(REQUEST_CODE, MED_BAY_CLICK_REQUEST_CODE);
bundle.putInt(REQUEST_CODE, MAIN_MENU_REQUEST_CODE);
bottomActionConfirmDialog.setArguments(bundle);

bottomActionConfirmDialog.setConfirmationListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.text.Layout;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class BottomActionConfirmDialog extends DialogFragment {
@Override
public void onStart() {
super.onStart();
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT);
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
Expand All @@ -12,9 +19,11 @@
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.arellomobile.mvp.MvpDelegate;
import com.npgames.insight.R;
import com.npgames.insight.application.StringUtills;
import com.npgames.insight.data.model.BlockAction;
import com.npgames.insight.data.model.BlockArea;
import com.npgames.insight.data.model.BlockButton;
Expand All @@ -23,7 +32,11 @@
import com.npgames.insight.ui.player.CreatePlayerDexView;
import com.npgames.insight.ui.player.CreatePlayerPrcView;

import org.w3c.dom.Text;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -91,7 +104,8 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch(holder.getItemViewType()) {

case BlockArea.BlockType.TEXT:
((TextViewHolder)holder).textTextView.setText(content);
((TextViewHolder)holder).textTextView.setText(formatLinks(content));
((TextViewHolder)holder).textTextView.setMovementMethod(LinkMovementMethod.getInstance());
break;

case BlockArea.BlockType.BUTTON:
Expand All @@ -111,6 +125,59 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
}
}

private Spannable formatLinks(final String textToFormat) {
final String[] links = new String[]{"(атомарн)+\\S+\\s+(отпечат)+\\S+",
"(бластер)+\\S+",
"(гипервест)+\\S+",
"(гиперкосм)+\\S+",
"(грамор)+\\S+",
"(исин)+\\S+",
"(информационн)+\\S+\\s+(пол)+\\S+",
"(космобот)+\\S+",
"(космическ)+\\S+\\s+(пол(е|ё))+\\S+",
"(луч(е|ё)м(е|ё)т)+\\S+",
"(нипс)+\\S+",
"(охотник)+\\S+\\s+(за)+\\s+(голов)+\\S+",
"(перекр(е|ё)стк) +\\S+",
"(плазмоизлучател) +\\S+",
"(планетарн)+\\S+\\s+(маяк)+\\S+",
"(планетарн)+\\S+\\s+(маяк)+\\S+",};
Spannable formattedText = new SpannableString(textToFormat);

for (int i = 0; i < links.length; i++) {
final Pattern linkPattern = Pattern.compile(links[i], Pattern.CASE_INSENSITIVE);

formattedText = formatOneMatch(formattedText, linkPattern);
}

return formattedText;
}

private Spannable formatOneMatch(final Spannable text, final Pattern pattern) {
final Matcher matcher = pattern.matcher(text);

if (!matcher.find()) {
return text;
} else {
final int startPosition = matcher.start();
final int endPosition = matcher.end();

final Spannable tail = new SpannableString(TextUtils.substring(text, endPosition, text.length()));

text.setSpan(new ClickableSpan() {
@Override
public void onClick(final View widget) {
Log.d("TestPish", "clickWasDone");
}
}, startPosition, endPosition, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

text.setSpan(formatOneMatch(tail, pattern), endPosition, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return text;
}
}



@Override
public int getItemCount() {
return blocks.size();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxxhdpi/menu_button_reworked.9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/game_book_action_state.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/action_button_new_active" android:state_enabled="true" android:state_pressed="true" />
<item android:drawable="@drawable/action_button_new_2_default" android:state_enabled="true" android:state_pressed="false" />
<item android:drawable="@drawable/action_button_new_default" android:state_enabled="false" />
<item android:drawable="@drawable/action_button_new_disabled" android:state_enabled="false" />
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/selector_menu_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/menu_button_active" android:state_enabled="true" android:state_pressed="true" />
<item android:drawable="@drawable/menu_button_reworked" android:state_enabled="true" android:state_pressed="false" />
<item android:drawable="@drawable/menu_button_reworked" android:state_enabled="false" />
</selector>
7 changes: 4 additions & 3 deletions app/src/main/res/layout/adapter_game_page_text_item.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/adapter_game_page_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:textColor="#c6d1d5"
android:textSize="18sp"/>
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
android:layout_height="0dp"
android:scaleType="fitXY"
android:src="@drawable/confirm_dialog_top_panel_left"
app:layout_constraintBottom_toBottomOf="@+id/bottom_action_confirm_dialog_title_layout"
app:layout_constraintBottom_toTopOf="@+id/bottom_action_confirm_dialog_body_layout_scroll_view"
app:layout_constraintLeft_toRightOf="@+id/guideline_left"
app:layout_constraintRight_toLeftOf="@+id/bottom_action_confirm_dialog_title_layout"
app:layout_constraintTop_toTopOf="@+id/bottom_action_confirm_dialog_title_layout"/>
app:layout_constraintTop_toTopOf="@+id/bottom_action_confirm_dialog_title_layout"
app:layout_constraintRight_toLeftOf="@+id/bottom_action_confirm_dialog_title_layout"/>

<FrameLayout
android:id="@+id/bottom_action_confirm_dialog_title_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/confirm_dialog_top_panel_right"
app:layout_constraintRight_toLeftOf="@+id/guideline_right"
app:layout_constraintTop_toTopOf="@+id/guideline_top"
app:layout_constraintBottom_toTopOf="@+id/bottom_action_confirm_dialog_body_layout_scroll_view">

<TextView
Expand All @@ -53,13 +52,14 @@
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/guideline_left"
app:layout_constraintRight_toLeftOf="@+id/guideline_right"
app:layout_constraintBottom_toTopOf="@+id/confirm_dialog_buttons_constraint_layout"
app:layout_constraintTop_toBottomOf="@+id/bottom_action_confirm_dialog_title_layout" >
app:layout_constraintBottom_toTopOf="@+id/guideline_bottom"
app:layout_constraintTop_toBottomOf="@+id/guideline_top" >

<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="80dp"
android:gravity="center"
android:id="@+id/bottom_action_confirm_dialog_body_text_view"
android:background="#e50e1609"
android:paddingTop="16dp"
Expand All @@ -75,7 +75,6 @@
android:layout_height="wrap_content"
android:background="@drawable/confirm_dialog_bottom_panel"
app:layout_constraintLeft_toRightOf="@+id/guideline_left"
app:layout_constraintBottom_toBottomOf="@+id/guideline_bottom"
app:layout_constraintRight_toLeftOf="@+id/guideline_right"
app:layout_constraintTop_toBottomOf="@+id/bottom_action_confirm_dialog_body_layout_scroll_view">

Expand Down Expand Up @@ -117,5 +116,4 @@
android:layout_height="1dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.8"/>

</android.support.constraint.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_info_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
android:layout_width="0dp"
app:layout_constraintHeight_default="wrap"
android:layout_height="0dp"
android:scrollbarThumbVertical="@color/active_color_scheme_2_layer"
app:layout_constraintLeft_toRightOf="@+id/guideline_left"
app:layout_constraintRight_toLeftOf="@+id/guideline_right"
app:layout_constraintTop_toTopOf="@+id/guideline_top"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/layout_stats_panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:id="@+id/top_panel_menu_button_image_view"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:src="@drawable/menu_button_reworked"
android:src="@drawable/selector_menu_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<color name="red">#c42623</color>
<color name="green">#59995a</color>

<color name="cornflower">#98CAE7</color>

<color name="athens_gray">#EBEFF2</color>
<color name="powder_blue">#BCD6E7</color>

<color name="white_dark">#a4a4a5</color>

<color name="death_dialog_go_to_main_menu_text_default_color">#eebdbc</color>
Expand All @@ -19,4 +24,9 @@

<color name="top_panel_view_stats_minus_color">@color/red</color>
<color name="top_panel_view_stats_plus_color">@color/green</color>

<color name="main_color_scheme_1_layer">@color/cornflower</color>

<color name="active_color_scheme_1_layer">@color/athens_gray</color>
<color name="active_color_scheme_2_layer">@color/powder_blue</color>
</resources>

0 comments on commit 8b7f401

Please sign in to comment.