2121
2222import android .content .DialogInterface ;
2323import android .content .Intent ;
24- import android .content .pm .PackageManager ;
2524import android .content .pm .ShortcutInfo ;
2625import android .content .pm .ShortcutManager ;
2726import android .graphics .drawable .Drawable ;
3837import android .support .v4 .widget .DrawerLayout ;
3938import android .support .v7 .app .ActionBarDrawerToggle ;
4039import android .support .v7 .widget .Toolbar ;
41- import android .util .SparseArray ;
4240import android .view .Menu ;
4341import android .view .MenuItem ;
4442import android .view .SubMenu ;
4543import android .view .View ;
4644
47- import com .crashlytics .android .answers .Answers ;
48- import com .crashlytics .android .answers .CustomEvent ;
49- import com .grarak .kerneladiutor .BuildConfig ;
5045import com .grarak .kerneladiutor .R ;
5146import com .grarak .kerneladiutor .fragments .BaseFragment ;
5247import com .grarak .kerneladiutor .fragments .RecyclerViewFragment ;
@@ -188,14 +183,12 @@ public class NavigationActivity extends BaseActivity
188183 sFragments .add (new NavigationFragment (R .string .help , new HelpFragment (), R .drawable .ic_help ));
189184 }
190185
191- private static Thread mPatchingThread ;
192186 private static Callback sCallback ;
193187
194188 private interface Callback {
195189 void onBannerResize ();
196190 }
197191
198- private SparseArray <Drawable > mDrawables = new SparseArray <>();
199192 private Handler mHandler = new Handler ();
200193 private DrawerLayout mDrawer ;
201194 private NavigationView mNavigationView ;
@@ -215,6 +208,42 @@ protected boolean setStatusBarColor() {
215208 @ Override
216209 protected void onCreate (Bundle savedInstanceState ) {
217210 super .onCreate (savedInstanceState );
211+
212+ int result = Prefs .getInt ("license" , -1 , this );
213+ int intentResult = getIntent ().getIntExtra ("result" , -1 );
214+
215+ if ((result == intentResult && (result == 1 || result == 2 )) && mLicenseDialog ) {
216+ ViewUtils .dialogBuilder (getString (R .string .license_invalid ), null ,
217+ new DialogInterface .OnClickListener () {
218+ @ Override
219+ public void onClick (DialogInterface dialog , int which ) {
220+ }
221+ }, new DialogInterface .OnDismissListener () {
222+ @ Override
223+ public void onDismiss (DialogInterface dialog ) {
224+ mLicenseDialog = false ;
225+ Prefs .saveInt ("license" , -1 , NavigationActivity .this );
226+ }
227+ }, this ).show ();
228+ } else if ((result != intentResult || result == 3 ) && mLicenseDialog ) {
229+ ViewUtils .dialogBuilder (getString (R .string .pirated ), null , new DialogInterface .OnClickListener () {
230+ @ Override
231+ public void onClick (DialogInterface dialog , int which ) {
232+ }
233+ }, new DialogInterface .OnDismissListener () {
234+ @ Override
235+ public void onDismiss (DialogInterface dialog ) {
236+ mLicenseDialog = false ;
237+ Prefs .saveInt ("license" , -1 , NavigationActivity .this );
238+ }
239+ }, this ).show ();
240+ } else {
241+ mLicenseDialog = false ;
242+ if (result == 0 ) {
243+ Utils .DONATED = true ;
244+ }
245+ }
246+
218247 sCallback = new Callback () {
219248 @ Override
220249 public void onBannerResize () {
@@ -276,63 +305,7 @@ public void onFocusChange(View v, boolean hasFocus) {
276305 }
277306 onItemSelected (mSelection , false , false );
278307
279- int result = Prefs .getInt ("license" , -1 , this );
280- int intentResult = getIntent ().getIntExtra ("result" , -1 );
281-
282- if ((result == intentResult && (result == 1 || result == 2 )) && mLicenseDialog ) {
283- ViewUtils .dialogBuilder (getString (R .string .license_invalid ), null ,
284- new DialogInterface .OnClickListener () {
285- @ Override
286- public void onClick (DialogInterface dialog , int which ) {
287- }
288- }, new DialogInterface .OnDismissListener () {
289- @ Override
290- public void onDismiss (DialogInterface dialog ) {
291- mLicenseDialog = false ;
292- Prefs .saveInt ("license" , -1 , NavigationActivity .this );
293- }
294- }, this ).show ();
295- } else if ((result != intentResult || result == 3 ) && mLicenseDialog ) {
296- ViewUtils .dialogBuilder (getString (R .string .pirated ), null , new DialogInterface .OnClickListener () {
297- @ Override
298- public void onClick (DialogInterface dialog , int which ) {
299- }
300- }, new DialogInterface .OnDismissListener () {
301- @ Override
302- public void onDismiss (DialogInterface dialog ) {
303- mLicenseDialog = false ;
304- Prefs .saveInt ("license" , -1 , NavigationActivity .this );
305- }
306- }, this ).show ();
307- } else {
308- mLicenseDialog = false ;
309- if (result == 0 ) {
310- Utils .DONATED = true ;
311- }
312- }
313-
314308 startService (new Intent (this , Monitor .class ));
315- final String androidId = Utils .getAndroidId (this );
316- if (Utils .DONATED && mPatchingThread == null ) {
317- mPatchingThread = new Thread (new Runnable () {
318- @ Override
319- public void run () {
320- try {
321- if (Utils .isPatched (getPackageManager ().getApplicationInfo (
322- "com.grarak.kerneladiutordonate" , 0 ))) {
323- Utils .DONATED = false ;
324- if (!BuildConfig .DEBUG ) {
325- Answers .getInstance ().logCustom (new CustomEvent ("Pirated" )
326- .putCustomAttribute ("android_id" , androidId ));
327- }
328- }
329- } catch (PackageManager .NameNotFoundException ignored ) {
330- }
331- mPatchingThread = null ;
332- }
333- });
334- mPatchingThread .start ();
335- }
336309
337310 if (!mFetchingAds && !Utils .DONATED ) {
338311 mFetchingAds = true ;
@@ -378,9 +351,12 @@ private void appendFragments(boolean setShortcuts) {
378351 for (NavigationFragment navigationFragment : sFragments ) {
379352 Fragment fragment = navigationFragment .mFragment ;
380353 int id = navigationFragment .mId ;
381- Drawable drawable = getNavigationDrawable (navigationFragment .mDrawable == 0
382- || !Prefs .getBoolean ("section_icons" , false , this ) || !Utils .DONATED ?
383- R .drawable .ic_blank : navigationFragment .mDrawable );
354+
355+ Drawable drawable = ContextCompat .getDrawable (this ,
356+ Utils .DONATED
357+ && Prefs .getBoolean ("section_icons" , false , this )
358+ && navigationFragment .mDrawable != 0 ? navigationFragment .mDrawable :
359+ R .drawable .ic_blank );
384360
385361 if (fragment == null ) {
386362 lastSubMenu = menu .addSubMenu (id );
@@ -463,15 +439,6 @@ private void setShortcuts() {
463439 shortcutManager .setDynamicShortcuts (shortcutInfos );
464440 }
465441
466- private Drawable getNavigationDrawable (int drawableId ) {
467- if (mDrawables .indexOfKey (drawableId ) >= 0 ) {
468- return mDrawables .get (drawableId );
469- } else {
470- mDrawables .put (drawableId , ContextCompat .getDrawable (this , drawableId ));
471- return getNavigationDrawable (drawableId );
472- }
473- }
474-
475442 @ Override
476443 public void onBackPressed () {
477444 if (mDrawer .isDrawerOpen (GravityCompat .START )) {
@@ -512,9 +479,6 @@ public void finish() {
512479 if (mAdsFetcher != null ) {
513480 mAdsFetcher .cancel ();
514481 }
515- if (mPatchingThread != null ) {
516- mPatchingThread .interrupt ();
517- }
518482 RootUtils .closeSU ();
519483 }
520484
0 commit comments