1+ package com .aexon ;
2+
3+ import android .app .Activity ;
4+ import android .content .Intent ;
5+ import android .graphics .PorterDuff ;
6+ import android .net .Uri ;
7+ import android .os .Bundle ;
8+ import android .text .Html ;
9+ import android .text .method .LinkMovementMethod ;
10+ import android .widget .ImageView ;
11+ import android .widget .LinearLayout ;
12+ import android .widget .ScrollView ;
13+ import android .widget .TextView ;
14+
15+ import androidx .annotation .Nullable ;
16+
17+ import com .aexon .aexon .AexonWindowHelper ;
18+ import com .aexon .material .dialog .AexonAlertDialog ;
19+ import com .aexon .material .toasty .AexonToast ;
20+ import com .aexon .starter .AexonShizukuHelper ;
21+ import com .aexon .starter .AexonStarter ;
22+ import com .aexon .theme .AexonTheme ;
23+ import com .aexon .widget .AexonCompatButton ;
24+
25+ public class ActivasiActivity extends Activity {
26+
27+ private final Aexon .OnBinderReceivedListener activasiBinderReceived = () -> {
28+ if (!isFinishing () && !isDestroyed ()) {
29+ onBackPressed ();
30+ }
31+ };
32+ private AexonShizukuHelper shizuku ;
33+
34+ private LinearLayout linear12 ;
35+ private LinearLayout toolbar ;
36+ private ScrollView vscroll1 ;
37+ private ImageView imageview1 ;
38+ private TextView textview1 ;
39+ private LinearLayout linear1 ;
40+ private LinearLayout card1 ;
41+ private LinearLayout card2 ;
42+ private LinearLayout card3 ;
43+ private LinearLayout linear11 ;
44+ private TextView textview3 ;
45+ private AexonCompatButton connect_shizuku ;
46+ private AexonCompatButton start_shizuku ;
47+ private ImageView imageview6 ;
48+ private TextView textview2 ;
49+ private LinearLayout linear3 ;
50+ private TextView textview5 ;
51+ private AexonCompatButton view_cmd ;
52+ private ImageView imageview2 ;
53+ private TextView textview4 ;
54+ private LinearLayout linear8 ;
55+ private TextView textview7 ;
56+ private AexonCompatButton start_root ;
57+ private ImageView imageview4 ;
58+ private TextView textview6 ;
59+
60+ private Intent aexon_intent = new Intent ();
61+
62+ @ Override
63+ protected void onCreate (@ Nullable Bundle _savedInstanceState ) {
64+ super .onCreate (_savedInstanceState );
65+ setContentView (R .layout .activasi );
66+ initialize (_savedInstanceState );
67+ initializeLogic ();
68+ }
69+
70+ private void initialize (@ Nullable Bundle _savedInstanceState ) {
71+ shizuku = new AexonShizukuHelper (this );
72+ linear12 = findViewById (R .id .linear12 );
73+ toolbar = findViewById (R .id .toolbar );
74+ vscroll1 = findViewById (R .id .vscroll1 );
75+ imageview1 = findViewById (R .id .imageview1 );
76+ textview1 = findViewById (R .id .textview1 );
77+ linear1 = findViewById (R .id .linear1 );
78+ card1 = findViewById (R .id .card1 );
79+ card2 = findViewById (R .id .card2 );
80+ card3 = findViewById (R .id .card3 );
81+ linear11 = findViewById (R .id .linear11 );
82+ textview3 = findViewById (R .id .textview3 );
83+ connect_shizuku = findViewById (R .id .connect_shizuku );
84+ start_shizuku = findViewById (R .id .start_shizuku );
85+ imageview6 = findViewById (R .id .imageview6 );
86+ textview2 = findViewById (R .id .textview2 );
87+ linear3 = findViewById (R .id .linear3 );
88+ textview5 = findViewById (R .id .textview5 );
89+ view_cmd = findViewById (R .id .view_cmd );
90+ imageview2 = findViewById (R .id .imageview2 );
91+ textview4 = findViewById (R .id .textview4 );
92+ linear8 = findViewById (R .id .linear8 );
93+ textview7 = findViewById (R .id .textview7 );
94+ start_root = findViewById (R .id .start_root );
95+ imageview4 = findViewById (R .id .imageview4 );
96+ textview6 = findViewById (R .id .textview6 );
97+
98+ imageview1 .setOnClickListener (_v -> onBackPressed ());
99+
100+ connect_shizuku .setOnClickListener (_v -> {
101+ if (!shizuku .isShizukuInstalled ()) {
102+ AexonAlertDialog dialog = new AexonAlertDialog (ActivasiActivity .this );
103+ dialog .setTitle (R .string .tag_shizuku_title );
104+ dialog .setMessage (R .string .tag_shizuku_dec );
105+ dialog .setPositiveButton (R .string .tag_btn_install , (d , w ) -> {
106+ Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (getString (R .string .tag_url_shizuku )));
107+ startActivity (intent );
108+ });
109+ dialog .setNegativeButton (R .string .tag_btn_cancel , null );
110+ dialog .show ();
111+ return ;
112+ }
113+
114+ if (!shizuku .isShizukuRunning ()) {
115+ AexonToast .make (ActivasiActivity .this ).title (getString (R .string .tag_not_running )).message (getString (R .string .tag_shizuku_dec_toasty )).show ();
116+ return ;
117+ }
118+
119+ if (!shizuku .hasPermission ()) {
120+ shizuku .requestPermission (100 );
121+ return ;
122+ }
123+
124+ AexonToast .make (ActivasiActivity .this ).title (getString (R .string .tag_shizuku_running )).message (getString (R .string .tag_shizuku_running_dec )).show ();
125+ });
126+
127+ start_shizuku .setOnClickListener (_v -> {
128+ if (!shizuku .isShizukuInstalled ()) {
129+ AexonAlertDialog dialog = new AexonAlertDialog (ActivasiActivity .this );
130+ dialog .setTitle (R .string .tag_shizuku_title );
131+ dialog .setMessage (R .string .tag_shizuku_dec );
132+ dialog .setPositiveButton (R .string .tag_btn_install , (d , w ) -> {
133+ Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (getString (R .string .tag_url_shizuku )));
134+ startActivity (intent );
135+ });
136+ dialog .setNegativeButton (R .string .tag_btn_cancel , null );
137+ dialog .show ();
138+ return ;
139+ }
140+
141+ if (!shizuku .hasPermission ()) {
142+ shizuku .requestPermission (100 );
143+ return ;
144+ }
145+
146+ if (!shizuku .isShizukuRunning ()) {
147+ AexonAlertDialog dialog = new AexonAlertDialog (ActivasiActivity .this );
148+ dialog .setTitle (R .string .tag_rish_not_running );
149+ dialog .setMessage (R .string .tag_rish_not_running_dec );
150+ dialog .setNegativeButton (R .string .tag_btn_cancel , null );
151+ dialog .show ();
152+ return ;
153+ }
154+ AexonStarter .newInstance (AexonStarter .MODE_SHIZUKU , shizuku ).show (getFragmentManager (), "loading" );
155+ });
156+
157+ view_cmd .setOnClickListener (_v -> {
158+ InfoDialogPathDialogFragmentActivity bottomSheet = new InfoDialogPathDialogFragmentActivity ();
159+ bottomSheet .show (getFragmentManager (), "InfoDialog" );
160+ });
161+
162+ start_root .setOnClickListener (_v -> {
163+ AexonShizukuHelper .isRooted (rooted -> {
164+ if (!rooted ) {
165+ AexonToast .make (ActivasiActivity .this ).title (getString (R .string .tag_root_not_support )).message (getString (R .string .tag_root_not_support_dec )).show ();
166+ return ;
167+ }
168+ AexonStarter .newInstance (AexonStarter .MODE_ROOT , null ).show (getFragmentManager (), "loading" );
169+ });
170+ });
171+ }
172+
173+ private void initializeLogic () {
174+ textview7 .setText (Html .fromHtml (getString (R .string .tag_dec_rooted ), Html .FROM_HTML_MODE_LEGACY ));
175+ textview7 .setLinkTextColor (0xFF00BCD4 );
176+ textview7 .setMovementMethod (LinkMovementMethod .getInstance ());
177+
178+ AexonTheme theme = AexonTheme .getInstance ();
179+ if (Aexon .isBinder ()) {
180+ onBackPressed ();
181+ return ;
182+ }
183+ imageview1 .setColorFilter (theme .getColorOnSurface (), PorterDuff .Mode .SRC_ATOP );
184+ imageview1 .setBackground (AexonDrawable .oval (this , theme .getColorSurfaceContainer ()));
185+ imageview1 .setClickable (true );
186+ imageview1 .setFocusable (true );
187+ imageview2 .setColorFilter (theme .getColorPrimary (), PorterDuff .Mode .SRC_ATOP );
188+ imageview4 .setColorFilter (theme .getColorPrimary (), PorterDuff .Mode .SRC_ATOP );
189+ imageview6 .setColorFilter (theme .getColorPrimary (), PorterDuff .Mode .SRC_ATOP );
190+ toolbar .setBackgroundColor (theme .getColorSurface ());
191+ vscroll1 .setBackgroundColor (theme .getColorSurface ());
192+
193+ // card card1 & card2 & card3
194+ card1 .setBackground (new AexonDrawable .Builder (theme .getColorSurfaceContainer ()).cornerRadius (SketchwareUtil .getDimension (this , R .dimen .card_radius_medium )).build ().build (ActivasiActivity .this ));
195+ card2 .setBackground (new AexonDrawable .Builder (theme .getColorSurfaceContainer ()).cornerRadius (SketchwareUtil .getDimension (this , R .dimen .card_radius_medium )).build ().build (ActivasiActivity .this ));
196+ card3 .setBackground (new AexonDrawable .Builder (theme .getColorSurfaceContainer ()).cornerRadius (SketchwareUtil .getDimension (this , R .dimen .card_radius_medium )).build ().build (ActivasiActivity .this ));
197+
198+ // warna icon button
199+ connect_shizuku .setIconTint (theme .getColorOnPrimary ());
200+ start_shizuku .setIconTint (theme .getColorOnPrimary ());
201+ view_cmd .setIconTint (theme .getColorOnPrimary ());
202+ start_root .setIconTint (theme .getColorOnPrimary ());
203+
204+ connect_shizuku .setButtonBackgroundColor (theme .getColorPrimary ());
205+ start_shizuku .setButtonBackgroundColor (theme .getColorPrimary ());
206+ view_cmd .setButtonBackgroundColor (theme .getColorPrimary ());
207+ start_root .setButtonBackgroundColor (theme .getColorPrimary ());
208+
209+ AexonWindowHelper .setWindowStyle (getWindow (), theme .getColorSurface ());
210+
211+ start_root .setTextColor (theme .getColorOnPrimary ());
212+ view_cmd .setTextColor (theme .getColorOnPrimary ());
213+ connect_shizuku .setTextColor (theme .getColorOnPrimary ());
214+ start_shizuku .setTextColor (theme .getColorOnPrimary ());
215+
216+ start_root .setButtonRippleColor (theme .getColorOnPrimaryDark ());
217+ view_cmd .setButtonRippleColor (theme .getColorOnPrimaryDark ());
218+ connect_shizuku .setButtonRippleColor (theme .getColorOnPrimaryDark ());
219+ start_shizuku .setButtonRippleColor (theme .getColorOnPrimaryDark ());
220+
221+ textview1 .setTextColor (theme .getColorOnSurface ());
222+ textview2 .setTextColor (theme .getColorOnSurface ());
223+ textview3 .setTextColor (theme .getColorOnSurfaceVariant ());
224+ textview4 .setTextColor (theme .getColorOnSurface ());
225+ textview5 .setTextColor (theme .getColorOnSurfaceVariant ());
226+ textview6 .setTextColor (theme .getColorOnSurface ());
227+ textview7 .setTextColor (theme .getColorOnSurfaceVariant ());
228+ }
229+
230+ @ Override
231+ public void onBackPressed () {
232+ super .finish ();
233+ overridePendingTransition (R .anim .fade_in_back , R .anim .fade_out_back );
234+ }
235+
236+ @ Override
237+ public void onStop () {
238+ super .onStop ();
239+ Aexon .removeBinderReceivedListener (activasiBinderReceived );
240+ }
241+
242+ @ Override
243+ public void onStart () {
244+ super .onStart ();
245+ Aexon .addBinderReceivedListener (activasiBinderReceived );
246+ }
247+
248+ @ Override
249+ public void onDestroy () {
250+ super .onDestroy ();
251+ shizuku .destroy ();
252+ }
253+ }
0 commit comments