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 ;
7671import com .grarak .kerneladiutor .fragments .statistics .OverallFragment ;
7772import com .grarak .kerneladiutor .fragments .tools .BackupFragment ;
7873import com .grarak .kerneladiutor .fragments .tools .BuildpropFragment ;
79- import com .grarak .kerneladiutor .fragments .tools .DataSharingFragment ;
8074import com .grarak .kerneladiutor .fragments .tools .InitdFragment ;
8175import com .grarak .kerneladiutor .fragments .tools .OnBootFragment ;
8276import com .grarak .kerneladiutor .fragments .tools .ProfileFragment ;
@@ -188,14 +182,12 @@ public class NavigationActivity extends BaseActivity
188182 sFragments .add (new NavigationFragment (R .string .help , new HelpFragment (), R .drawable .ic_help ));
189183 }
190184
191- private static Thread mPatchingThread ;
192185 private static Callback sCallback ;
193186
194187 private interface Callback {
195188 void onBannerResize ();
196189 }
197190
198- private SparseArray <Drawable > mDrawables = new SparseArray <>();
199191 private Handler mHandler = new Handler ();
200192 private DrawerLayout mDrawer ;
201193 private NavigationView mNavigationView ;
@@ -215,6 +207,42 @@ protected boolean setStatusBarColor() {
215207 @ Override
216208 protected void onCreate (Bundle savedInstanceState ) {
217209 super .onCreate (savedInstanceState );
210+
211+ int result = Prefs .getInt ("license" , -1 , this );
212+ int intentResult = getIntent ().getIntExtra ("result" , -1 );
213+
214+ if ((result == intentResult && (result == 1 || result == 2 )) && mLicenseDialog ) {
215+ ViewUtils .dialogBuilder (getString (R .string .license_invalid ), null ,
216+ new DialogInterface .OnClickListener () {
217+ @ Override
218+ public void onClick (DialogInterface dialog , int which ) {
219+ }
220+ }, new DialogInterface .OnDismissListener () {
221+ @ Override
222+ public void onDismiss (DialogInterface dialog ) {
223+ mLicenseDialog = false ;
224+ Prefs .saveInt ("license" , -1 , NavigationActivity .this );
225+ }
226+ }, this ).show ();
227+ } else if ((result != intentResult || result == 3 ) && mLicenseDialog ) {
228+ ViewUtils .dialogBuilder (getString (R .string .pirated ), null , new DialogInterface .OnClickListener () {
229+ @ Override
230+ public void onClick (DialogInterface dialog , int which ) {
231+ }
232+ }, new DialogInterface .OnDismissListener () {
233+ @ Override
234+ public void onDismiss (DialogInterface dialog ) {
235+ mLicenseDialog = false ;
236+ Prefs .saveInt ("license" , -1 , NavigationActivity .this );
237+ }
238+ }, this ).show ();
239+ } else {
240+ mLicenseDialog = false ;
241+ if (result == 0 ) {
242+ Utils .DONATED = true ;
243+ }
244+ }
245+
218246 sCallback = new Callback () {
219247 @ Override
220248 public void onBannerResize () {
@@ -276,63 +304,7 @@ public void onFocusChange(View v, boolean hasFocus) {
276304 }
277305 onItemSelected (mSelection , false , false );
278306
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-
314307 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- }
336308
337309 if (!mFetchingAds && !Utils .DONATED ) {
338310 mFetchingAds = true ;
@@ -378,9 +350,12 @@ private void appendFragments(boolean setShortcuts) {
378350 for (NavigationFragment navigationFragment : sFragments ) {
379351 Fragment fragment = navigationFragment .mFragment ;
380352 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 );
353+
354+ Drawable drawable = ContextCompat .getDrawable (this ,
355+ Utils .DONATED
356+ && Prefs .getBoolean ("section_icons" , false , this )
357+ && navigationFragment .mDrawable != 0 ? navigationFragment .mDrawable :
358+ R .drawable .ic_blank );
384359
385360 if (fragment == null ) {
386361 lastSubMenu = menu .addSubMenu (id );
@@ -463,15 +438,6 @@ private void setShortcuts() {
463438 shortcutManager .setDynamicShortcuts (shortcutInfos );
464439 }
465440
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-
475441 @ Override
476442 public void onBackPressed () {
477443 if (mDrawer .isDrawerOpen (GravityCompat .START )) {
@@ -512,9 +478,6 @@ public void finish() {
512478 if (mAdsFetcher != null ) {
513479 mAdsFetcher .cancel ();
514480 }
515- if (mPatchingThread != null ) {
516- mPatchingThread .interrupt ();
517- }
518481 RootUtils .closeSU ();
519482 }
520483
0 commit comments