use of android.support.v7.widget.AppCompatTextView in project Rashr by DsLNeXuS.
the class RashrActivity method onRequestPermissionsResult.
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
// If request is cancelled, the result arrays are empty.
if (// 2 Permissions, Internet and Write storage
grantResults.length == 2 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
final TextView tvLoading = findViewById(R.id.tvLoading);
final Thread StartThread = new Thread(new Runnable() {
@Override
public void run() {
/* Creating needed folder and unpacking files */
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
tvLoading.setText(R.string.loading_data);
}
});
if (App.PathToTmp.exists()) {
Common.deleteFolder(App.PathToTmp, true);
}
for (File i : Folder) {
if (!i.exists()) {
if (!i.mkdirs()) {
App.ERRORS.add(App.TAG + " " + i + " can't be created!");
}
}
}
if (!extractFiles()) {
App.ERRORS.add("Failed to extract files.");
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(mContext, R.string.failed_unpack_files, Toast.LENGTH_LONG).show();
}
});
}
try {
File LogCopy = new File(App.FilesDir, App.LastLog.getName() + ".txt");
App.Shell.execCommand(App.Busybox + " chmod 777 " + App.LastLog);
if (LogCopy.exists())
LogCopy.delete();
App.Shell.execCommand(App.Busybox + " cp " + App.LastLog + " " + LogCopy);
App.Shell.execCommand(App.Busybox + " chmod 777 " + LogCopy);
ApplicationInfo info = getApplicationInfo();
App.Shell.execCommand(App.Busybox + " chown " + info.uid + ":" + info.uid + " " + LogCopy);
App.Shell.execCommand(App.Busybox + " chmod 777 " + LogCopy);
LastLogExists = LogCopy.exists();
} catch (FailedExecuteCommand e) {
App.ERRORS.add(App.TAG + " LastLog not found: " + e);
}
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
checkAppUpdates();
tvLoading.setText(R.string.reading_device);
}
});
if (!App.Device.isSetup()) {
App.Device.setup();
}
/* If device is not supported, you can report it now or close the App */
if ((!App.Device.isRecoverySupported() && !App.Device.isKernelSupported()) && !BuildConfig.DEBUG) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
showDeviceNotSupportedDialog();
}
});
} else {
/* App is first time started so show usage warning */
if (App.Preferences.getBoolean(App.PREF_KEY_FIRST_RUN, true)) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (App.Device.isRecoverySupported() || App.Device.isKernelSupported()) {
// Show only if we can flash
showUsageWarning();
}
}
});
}
}
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
mRoot = (DrawerLayout) View.inflate(mContext, R.layout.activity_rashr, null);
setContentView(mRoot);
ButterKnife.bind(mActivity);
mRoot.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.abc_fade_in));
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(mActivity, mRoot, mToolbar, R.string.app_name, R.string.app_name);
// Coloring drawertoggle
DrawerArrowDrawable coloredArrow = new DrawerArrowDrawable(mContext);
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getTheme();
theme.resolveAttribute(R.attr.colorAccent, typedValue, true);
coloredArrow.setColor(typedValue.data);
toggle.setDrawerArrowDrawable(coloredArrow);
mRoot.addDrawerListener(toggle);
toggle.syncState();
mNavigationView.setNavigationItemSelectedListener(mActivity);
if (mAds != null) {
if (App.Preferences.getBoolean(App.PREF_KEY_ADS, true)) {
mAds.loadAd(new AdRequest.Builder().addTestDevice("BB1FFBF880370A581E6665C69C97D711").build());
} else {
mAds.setVisibility(View.GONE);
mRoot.removeView(mAds);
}
}
if (getIntent().getAction().equals(Intent.ACTION_VIEW)) {
/* Rashr is opened by other app to flash supported files (.zip) or (.img) */
File file = new File(getIntent().getData().getPath());
if (file.exists()) {
if (file.toString().endsWith(Device.EXT_ZIP)) {
/* If it is a zip file open the ScriptManager */
switchTo(ScriptManagerFragment.newInstance(file));
} else if (file.toString().endsWith(Device.EXT_IMG)) {
/* If it is a img file open FlashAs to choose mode (recovery or kernel) */
switchTo(FlashAsFragment.newInstance(mActivity, file));
}
}
} else {
onNavigationItemSelected(mNavigationView.getMenu().getItem(0));
}
} catch (NullPointerException e) {
setContentView(R.layout.err_layout);
App.ERRORS.add("Error while inflating layout:" + e);
AppCompatTextView tv = findViewById(R.id.tvErr);
try {
if (tv != null) {
tv.setText(R.string.failed_setup_layout);
}
} catch (RuntimeException ex) {
App.ERRORS.add(App.TAG + " " + e);
ReportDialog dialog = new ReportDialog(mActivity, e.toString());
dialog.show();
ex.printStackTrace();
}
ReportDialog dialog = new ReportDialog(mActivity, e.toString());
dialog.show();
e.printStackTrace();
}
}
});
}
});
StartThread.start();
} else {
// Permission not garanted
setContentView(R.layout.err_layout);
AppCompatTextView tverr = findViewById(R.id.tvErr);
tverr.setText(R.string.permissions_denied);
}
}
Aggregations