Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit 20a5f9f

Browse files
committed
Fix section icons disapeering
1 parent ee12a23 commit 20a5f9f

File tree

2 files changed

+47
-80
lines changed

2 files changed

+47
-80
lines changed

app/src/main/java/com/grarak/kerneladiutor/activities/MainActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ protected Boolean doInBackground(Void... params) {
321321
if (mApplicationInfo != null && mPackageInfo != null
322322
&& mPackageInfo.versionCode == 130) {
323323
mPatched = !Utils.getMD5sum(mApplicationInfo.publicSourceDir)
324-
.equals("5c7a92a5b2dcec409035e1114e815b00");
324+
.equals("5c7a92a5b2dcec409035e1114e815b00") || Utils.isPatched(mApplicationInfo);
325325
try {
326326
if (Utils.existFile(mApplicationInfo.dataDir + "/license")) {
327327
String content = Utils.readFile(mApplicationInfo.dataDir + "/license");
@@ -358,6 +358,10 @@ protected void onPostExecute(Boolean donationValid) {
358358
} else if (donationValid) {
359359
launch(1);
360360
} else {
361+
if (mPatched && !BuildConfig.DEBUG) {
362+
Answers.getInstance().logCustom(new CustomEvent("Pirated")
363+
.putCustomAttribute("android_id", Utils.getAndroidId(MainActivity.this)));
364+
}
361365
launch(mPatched ? 3 : -1);
362366
}
363367
}

app/src/main/java/com/grarak/kerneladiutor/activities/NavigationActivity.java

Lines changed: 42 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import android.content.DialogInterface;
2323
import android.content.Intent;
24-
import android.content.pm.PackageManager;
2524
import android.content.pm.ShortcutInfo;
2625
import android.content.pm.ShortcutManager;
2726
import android.graphics.drawable.Drawable;
@@ -38,15 +37,11 @@
3837
import android.support.v4.widget.DrawerLayout;
3938
import android.support.v7.app.ActionBarDrawerToggle;
4039
import android.support.v7.widget.Toolbar;
41-
import android.util.SparseArray;
4240
import android.view.Menu;
4341
import android.view.MenuItem;
4442
import android.view.SubMenu;
4543
import android.view.View;
4644

47-
import com.crashlytics.android.answers.Answers;
48-
import com.crashlytics.android.answers.CustomEvent;
49-
import com.grarak.kerneladiutor.BuildConfig;
5045
import com.grarak.kerneladiutor.R;
5146
import com.grarak.kerneladiutor.fragments.BaseFragment;
5247
import com.grarak.kerneladiutor.fragments.RecyclerViewFragment;
@@ -76,7 +71,6 @@
7671
import com.grarak.kerneladiutor.fragments.statistics.OverallFragment;
7772
import com.grarak.kerneladiutor.fragments.tools.BackupFragment;
7873
import com.grarak.kerneladiutor.fragments.tools.BuildpropFragment;
79-
import com.grarak.kerneladiutor.fragments.tools.DataSharingFragment;
8074
import com.grarak.kerneladiutor.fragments.tools.InitdFragment;
8175
import com.grarak.kerneladiutor.fragments.tools.OnBootFragment;
8276
import 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

Comments
 (0)