From 8b7f4011454c5cc1d5938c8ef60677834088c617 Mon Sep 17 00:00:00 2001 From: "vlad.nikitin" Date: Mon, 24 Jun 2019 17:39:33 +0300 Subject: [PATCH] =?UTF-8?q?Added=20some=20drawables,=20working=20on=20link?= =?UTF-8?q?s=20to=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../insight/ui/book/GameBookActivity.java | 4 +- .../actions/BottomActionConfirmDialog.java | 3 +- .../insight/ui/book/page/GamePageAdapter.java | 69 +++++++++++++++++- .../action_button_new_disabled.9.png | Bin 0 -> 2755 bytes .../drawable-xxxhdpi/menu_button_active.9.png | Bin 0 -> 4979 bytes .../menu_button_reworked.9.png | Bin 3527 -> 3837 bytes .../res/drawable/game_book_action_state.xml | 2 +- .../res/drawable/selector_menu_button.xml | 6 ++ .../layout/adapter_game_page_text_item.xml | 7 +- .../fragment_bottom_action_confirm_dialog.xml | 14 ++-- .../main/res/layout/fragment_info_dialog.xml | 1 + .../main/res/layout/layout_stats_panel.xml | 2 +- app/src/main/res/values/colors.xml | 10 +++ 13 files changed, 100 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/drawable-xxxhdpi/action_button_new_disabled.9.png create mode 100644 app/src/main/res/drawable-xxxhdpi/menu_button_active.9.png create mode 100644 app/src/main/res/drawable/selector_menu_button.xml diff --git a/app/src/main/java/com/npgames/insight/ui/book/GameBookActivity.java b/app/src/main/java/com/npgames/insight/ui/book/GameBookActivity.java index b87e6c9..7616307 100644 --- a/app/src/main/java/com/npgames/insight/ui/book/GameBookActivity.java +++ b/app/src/main/java/com/npgames/insight/ui/book/GameBookActivity.java @@ -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 @@ -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); diff --git a/app/src/main/java/com/npgames/insight/ui/book/bottom_new/actions/BottomActionConfirmDialog.java b/app/src/main/java/com/npgames/insight/ui/book/bottom_new/actions/BottomActionConfirmDialog.java index 04f76c5..bfbfee7 100644 --- a/app/src/main/java/com/npgames/insight/ui/book/bottom_new/actions/BottomActionConfirmDialog.java +++ b/app/src/main/java/com/npgames/insight/ui/book/bottom_new/actions/BottomActionConfirmDialog.java @@ -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; @@ -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 diff --git a/app/src/main/java/com/npgames/insight/ui/book/page/GamePageAdapter.java b/app/src/main/java/com/npgames/insight/ui/book/page/GamePageAdapter.java index 77b8ed3..bf3aa32 100644 --- a/app/src/main/java/com/npgames/insight/ui/book/page/GamePageAdapter.java +++ b/app/src/main/java/com/npgames/insight/ui/book/page/GamePageAdapter.java @@ -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; @@ -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; @@ -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; @@ -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: @@ -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(); diff --git a/app/src/main/res/drawable-xxxhdpi/action_button_new_disabled.9.png b/app/src/main/res/drawable-xxxhdpi/action_button_new_disabled.9.png new file mode 100644 index 0000000000000000000000000000000000000000..1e8ffbd38f371e500f6811e9ebca0d82cd62d7f9 GIT binary patch literal 2755 zcmds3d2AF_9G<1MEUn-o3P=o@P6PB{cFvvdOju~QTW!VVD4Vnp#eF;Tb~|);XPKFH z7Yy2#qSSg2Y@iULkN_t9fgBQ}L=Kh1h#Vq@5R8x@sPT#hM3Ly5y(k0-G4UTa*_StO zzW4pU-}T<~&YJP~@ZxdB7={gRZ16Q`iSye@`o@`pa{N<+Lv}5}Y?mL1N^?q{TzE^Fwsd&fy z=jK-y6kY9jrE8?`nJ@2KbD(D2xhI_EmA22H?>t>TVV8SNSJw&b@KGmKfxW~Xwe6^1 zxnuti!|{&U4J)`6O9~HPoc`jrw>wWaI|>iS^utxQ?bDm8 zYOb*EOJf3~;pRwx`Pg~$=2f~kUzoJ1vaosd>WvpiSEVjaxHRVB3u7j%+PE1zs9T_Owzwg}M{;sZX z9`GL7xVj5;jVLJiJJ2(*wzObr=hT9a_K4WNgEOx`A_-5Szzs_@%r!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i5wDmC9nYpR(0uGtbSBm-1HxJsXu5KK&3q-b6t$TMH zbh)U!AzyYL(}dH0)ppq{FWHwZm#4a^IQr(nc!t*VS#r?Tab#p$d@htGhud-gi`~Dw zHm5|rqr1H!VpGS!5Xy^`{$a%agK?{g38)y5baiy;^=)lUi|33fR>^6~uObV|DwoeB zn%h2L^5ay=4k{m8ab%a9d1b~$>G<&;{%DY@3#C1Gdo+3dh9rwY*Ah3q$I($ed&;X; b^+M>`Jag^(?HxBE@T-_H$F`@edc}VLouWM~ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/menu_button_reworked.9.png b/app/src/main/res/drawable-xxxhdpi/menu_button_reworked.9.png index f2eee0bc70a12f0d613718cb3092c9f8cfec4081..2574dd63e5a69da50fecdbcef6c9e4ba27470f18 100644 GIT binary patch delta 1362 zcmX>u{a048Gr-TCmrII^fq{Y7)59f*fq{_;h{ZVAfFivdGw*Ix^kih>ET5diI9b6| z!Q4{M(9GDx(o#pk$iUD--@roO&{)^d%*w>T%E)N5JQE+2fTga1nXZvZh@r8SiG`J+ z`D9xbX-vTk77Gkpm*f{`xlq}nPursOB3Dg?PZDQFm4T3TpsE@E|Oo-D>LIyr$& z(Ulm}l@y9gT+2$V$}>{)Y?Xjs!f-qEaktaqI0J zL%+uk5^WEC{0?&7S+cA<=9%2O7sUeKLw35K(vU5cn%@x3Gf_Y&qVK>1PUCN%J>qu? z%{Emzed+)8HV zU{qi^&?^vA-`A05R)2PnAVZxALkoidlLH5XB9Nh>$)ebDvHtu`v(ogm_n+Mueq2OI z!c|d;QIFr~gp-OLhHUc8Dx%duhk#t(AaH~d;E2tW#-Hv2ZNlFP^Eg02j+=} zFJ3z&A&MEC7`{(`d=~080j3}ImUj^9{`{#wj*vTX-!_lU32e)OeCG}Jb5@=IZ0K~; zoH-w8E6|{tmIptdem%X;DL;?RVE*hzb4ZB&6Jj!Fh6P7L$81KJ%?3x#!oyYKQ5w($ zhz!rnt7jMd{~8(hIrnXSFWC7Fi<}u9ko&SPtU z+S#JuKKt#uO(maOIKg28H=E(5lYmo)U0dO;W$$$ES32z#L`cExM;57vITq+P17D7$ zo`c5?&iyM`g;9;i^H51NWT;l6inW_|_hr`tzLdD@X`|lP1K%6DOb6ywSO9lZd9X zL10SC=DVTO^5$(=zwF0<33zgFy~E;^4^!;3B=^<1PjhD<_-@Xq$WRYabify$LJEZ8 z-nzpAGlBu6mKdcCs%;DY8_$kBb@rj!1DMMjRJwL^LOr?N>BE;F6Mi>E9*dr8lFuRs ejq`%j(g%-Ra{1Z(O8{6*GI+ZBxvXdt6$vGr-TCmrII^fq{Y7)59eQNdIDBVC3Uq1F{y(;A-2b=*h^$Q9n6{ak7Gu zg1M!hp_zfDk%^9ik%6JPzJa;Ep|P%kp_PG|m9gb!c_u!l$&DNmlU-Sa!E^zO!DJr} zwaLd=)^487>c+fzBc~Z-efNj(n+y!hdpunnLn>~)y{nif9VpO{xPQ(f^@yaHG~F+@ zVpD%BbVom_mWXoGHM_}evVF!8P0zbWrmeC`zxV6+l0?>v&;HKhTk%Uku>0Dx$U8+* zf84&C)cwEy{Nb0Wb$_aQrak+8{(g6~U-tdy_tYM~ub-Id7w5$O%=d*tiNlNfh6{`f znVs0}biM?6#r$@De8K6DZgm5!t9iEV z@w0j*8!m!w6T39n#R`OkKXcY@zFWTjczSdFw!AWFu;C8D3#V@`+ zJ@XdC`4>LldsE*4@+(ly-0eEyug_hP*7t!*f<4v3cgF}AF+X^w_d46p-1E2UFUNwgzVif{lD?eZHM3`>rS82a zX3#Wuc& - + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_menu_button.xml b/app/src/main/res/drawable/selector_menu_button.xml new file mode 100644 index 0000000..af78c68 --- /dev/null +++ b/app/src/main/res/drawable/selector_menu_button.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_game_page_text_item.xml b/app/src/main/res/layout/adapter_game_page_text_item.xml index 8a8d74e..2640f69 100644 --- a/app/src/main/res/layout/adapter_game_page_text_item.xml +++ b/app/src/main/res/layout/adapter_game_page_text_item.xml @@ -1,13 +1,14 @@ - + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bottom_action_confirm_dialog.xml b/app/src/main/res/layout/fragment_bottom_action_confirm_dialog.xml index fa4a380..e73a4e0 100644 --- a/app/src/main/res/layout/fragment_bottom_action_confirm_dialog.xml +++ b/app/src/main/res/layout/fragment_bottom_action_confirm_dialog.xml @@ -23,10 +23,10 @@ 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"/> + app:layout_constraintBottom_toTopOf="@+id/guideline_bottom" + app:layout_constraintTop_toBottomOf="@+id/guideline_top" > @@ -117,5 +116,4 @@ android:layout_height="1dp" android:orientation="horizontal" app:layout_constraintGuide_percent="0.8"/> - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_info_dialog.xml b/app/src/main/res/layout/fragment_info_dialog.xml index b9e9d1e..6ad9c8e 100644 --- a/app/src/main/res/layout/fragment_info_dialog.xml +++ b/app/src/main/res/layout/fragment_info_dialog.xml @@ -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" diff --git a/app/src/main/res/layout/layout_stats_panel.xml b/app/src/main/res/layout/layout_stats_panel.xml index 3de3c1f..620db09 100644 --- a/app/src/main/res/layout/layout_stats_panel.xml +++ b/app/src/main/res/layout/layout_stats_panel.xml @@ -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" /> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a5422b3..03dcbf0 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,6 +10,11 @@ #c42623 #59995a + #98CAE7 + + #EBEFF2 + #BCD6E7 + #a4a4a5 #eebdbc @@ -19,4 +24,9 @@ @color/red @color/green + + @color/cornflower + + @color/athens_gray + @color/powder_blue