Android: Update available SDKs, API 26
This commit is contained in:
parent
352a319086
commit
8715ed6e2e
|
@ -25,34 +25,34 @@ import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
|
private WeakReference<Context> mContext;
|
||||||
|
|
||||||
public static final String build_model = android.os.Build.MODEL;
|
private static final String build_device = android.os.Build.DEVICE;
|
||||||
public static final String build_device = android.os.Build.DEVICE;
|
private static final String build_board = android.os.Build.BOARD;
|
||||||
public static final String build_board = android.os.Build.BOARD;
|
private static final int build_sdk = android.os.Build.VERSION.SDK_INT;
|
||||||
public static final int build_sdk = android.os.Build.VERSION.SDK_INT;
|
|
||||||
|
|
||||||
public static final String DN = "Donut";
|
private static final String DN = "Donut";
|
||||||
public static final String EC = "Eclair";
|
private static final String EC = "Eclair";
|
||||||
public static final String FR = "Froyo";
|
private static final String FR = "Froyo";
|
||||||
public static final String GB = "Gingerbread";
|
private static final String GB = "Gingerbread";
|
||||||
public static final String HC = "Honeycomb";
|
private static final String HC = "Honeycomb";
|
||||||
public static final String IC = "Ice Cream Sandwich";
|
private static final String IC = "Ice Cream Sandwich";
|
||||||
public static final String JB = "JellyBean";
|
private static final String JB = "JellyBean";
|
||||||
public static final String KK = "KitKat";
|
private static final String KK = "KitKat";
|
||||||
public static final String LP = "L Preview";
|
private static final String LL = "Lollipop";
|
||||||
public static final String LL = "Lollipop";
|
private static final String MM = "Marshmallow";
|
||||||
public static final String NL = "New / No Label";
|
private static final String NT = "Nougat";
|
||||||
public static final String NF = "Not Found";
|
private static final String NL = "New / No Label";
|
||||||
|
private static final String NF = "Not Found";
|
||||||
|
|
||||||
|
private String currentTime;
|
||||||
private String unHandledIOE;
|
private String unHandledIOE;
|
||||||
|
|
||||||
private Context mContext;
|
public GenerateLogs(Context reference) {
|
||||||
private String currentTime;
|
this.mContext = new WeakReference<>(reference);
|
||||||
|
|
||||||
public GenerateLogs(Context mContext) {
|
|
||||||
this.mContext = mContext;
|
|
||||||
this.currentTime = String.valueOf(System.currentTimeMillis());
|
this.currentTime = String.valueOf(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
s += "\r\n";
|
s += "\r\n";
|
||||||
s += "BOARD: " + build_board;
|
s += "BOARD: " + build_board;
|
||||||
s += "\r\n";
|
s += "\r\n";
|
||||||
if (String.valueOf(build_sdk) != null) {
|
if (!String.valueOf(build_sdk).equals("")) {
|
||||||
String build_version = NF;
|
String build_version = NF;
|
||||||
if (String.valueOf(build_sdk).equals("L")) {
|
if (String.valueOf(build_sdk).equals("L")) {
|
||||||
build_version = "LP";
|
build_version = "LP";
|
||||||
|
@ -87,9 +87,13 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
build_version = JB;
|
build_version = JB;
|
||||||
} else if (build_sdk >= 19 && build_sdk < 21) {
|
} else if (build_sdk >= 19 && build_sdk < 21) {
|
||||||
build_version = KK;
|
build_version = KK;
|
||||||
} else if (build_sdk >= 21 && build_sdk < 22) {
|
} else if (build_sdk >= 21 && build_sdk < 23) {
|
||||||
build_version = LL;
|
build_version = LL;
|
||||||
} else if (build_sdk >= 22) {
|
} else if (build_sdk >= 23 && build_sdk < 24) {
|
||||||
|
build_version = MM;
|
||||||
|
} else if (build_sdk >= 24 && build_sdk < 26) {
|
||||||
|
build_version = NT;
|
||||||
|
} else if (build_sdk >= 26) {
|
||||||
build_version = NL;
|
build_version = NL;
|
||||||
}
|
}
|
||||||
s += build_version + " (" + build_sdk + ")";
|
s += build_version + " (" + build_sdk + ")";
|
||||||
|
@ -168,7 +172,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
reader.close();
|
reader.close();
|
||||||
mLogcatProc = null;
|
mLogcatProc = null;
|
||||||
reader = null;
|
reader = null;
|
||||||
File memory = new File(mContext.getFilesDir(), "mem_alloc.txt");
|
File memory = new File(mContext.get().getFilesDir(), "mem_alloc.txt");
|
||||||
if (memory.exists()) {
|
if (memory.exists()) {
|
||||||
log.append(separator);
|
log.append(separator);
|
||||||
log.append(separator);
|
log.append(separator);
|
||||||
|
@ -192,7 +196,8 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
writer.close();
|
writer.close();
|
||||||
return log.toString();
|
return log.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
// Could not generate log file
|
||||||
|
// Writing a log is redundant
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -200,19 +205,19 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(final String response) {
|
protected void onPostExecute(final String response) {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
showToastMessage(mContext.getString(R.string.log_saved), Snackbar.LENGTH_LONG);
|
showToastMessage(mContext.get().getString(R.string.log_saved), Snackbar.LENGTH_LONG);
|
||||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mContext
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mContext.get()
|
||||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
android.content.ClipData clip = android.content.ClipData.newPlainText("logcat", response);
|
android.content.ClipData clip = android.content.ClipData.newPlainText("logcat", response);
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Config.git_issues));
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Config.git_issues));
|
||||||
mContext.startActivity(browserIntent);
|
mContext.get().startActivity(browserIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showToastMessage(String message, int duration) {
|
private void showToastMessage(String message, int duration) {
|
||||||
ConstraintLayout layout = (ConstraintLayout)
|
ConstraintLayout layout = (ConstraintLayout)
|
||||||
((Activity) mContext).findViewById(R.id.mainui_layout);
|
((Activity) mContext.get()).findViewById(R.id.mainui_layout);
|
||||||
Snackbar snackbar = Snackbar.make(layout, message, duration);
|
Snackbar snackbar = Snackbar.make(layout, message, duration);
|
||||||
View snackbarLayout = snackbar.getView();
|
View snackbarLayout = snackbar.getView();
|
||||||
ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(
|
ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(
|
||||||
|
@ -228,14 +233,14 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
||||||
textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
|
textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
|
||||||
Drawable drawable;
|
Drawable drawable;
|
||||||
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
||||||
drawable = mContext.getResources().getDrawable(
|
drawable = mContext.get().getResources().getDrawable(
|
||||||
R.drawable.ic_send, ((Activity) mContext).getTheme());
|
R.drawable.ic_send, ((Activity) mContext.get()).getTheme());
|
||||||
} else {
|
} else {
|
||||||
drawable = VectorDrawableCompat.create(mContext.getResources(),
|
drawable = VectorDrawableCompat.create(mContext.get().getResources(),
|
||||||
R.drawable.ic_send, ((Activity) mContext).getTheme());
|
R.drawable.ic_send, ((Activity) mContext.get()).getTheme());
|
||||||
}
|
}
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
||||||
textView.setCompoundDrawablePadding(mContext.getResources()
|
textView.setCompoundDrawablePadding(mContext.get().getResources()
|
||||||
.getDimensionPixelOffset(R.dimen.snackbar_icon_padding));
|
.getDimensionPixelOffset(R.dimen.snackbar_icon_padding));
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue