remove bug report
This commit is contained in:
parent
fcba3228ee
commit
c9300d0395
42 changed files with 0 additions and 1626 deletions
|
|
@ -1,387 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.bugreport;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringDef;
|
||||
import androidx.annotation.StringRes;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||
import com.kabouzeid.appthemehelper.util.TintHelper;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.misc.DialogAsyncTask;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsThemeActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.bugreport.model.DeviceInfo;
|
||||
import com.kabouzeid.gramophone.ui.activities.bugreport.model.Report;
|
||||
import com.kabouzeid.gramophone.ui.activities.bugreport.model.github.ExtraInfo;
|
||||
import com.kabouzeid.gramophone.ui.activities.bugreport.model.github.GithubLogin;
|
||||
import com.kabouzeid.gramophone.ui.activities.bugreport.model.github.GithubTarget;
|
||||
|
||||
import org.eclipse.egit.github.core.Issue;
|
||||
import org.eclipse.egit.github.core.client.GitHubClient;
|
||||
import org.eclipse.egit.github.core.client.RequestException;
|
||||
import org.eclipse.egit.github.core.service.IssueService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class BugReportActivity extends AbsThemeActivity {
|
||||
|
||||
private static final int STATUS_BAD_CREDENTIALS = 401;
|
||||
private static final int STATUS_ISSUES_NOT_ENABLED = 410;
|
||||
|
||||
@StringDef({RESULT_OK, RESULT_BAD_CREDENTIALS, RESULT_INVALID_TOKEN, RESULT_ISSUES_NOT_ENABLED,
|
||||
RESULT_UNKNOWN})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
private @interface Result {
|
||||
}
|
||||
|
||||
private static final String RESULT_OK = "RESULT_OK";
|
||||
private static final String RESULT_BAD_CREDENTIALS = "RESULT_BAD_CREDENTIALS";
|
||||
private static final String RESULT_INVALID_TOKEN = "RESULT_INVALID_TOKEN";
|
||||
private static final String RESULT_ISSUES_NOT_ENABLED = "RESULT_ISSUES_NOT_ENABLED";
|
||||
private static final String RESULT_UNKNOWN = "RESULT_UNKNOWN";
|
||||
|
||||
private DeviceInfo deviceInfo;
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
@BindView(R.id.input_layout_title)
|
||||
TextInputLayout inputLayoutTitle;
|
||||
@BindView(R.id.input_title)
|
||||
TextInputEditText inputTitle;
|
||||
@BindView(R.id.input_layout_description)
|
||||
TextInputLayout inputLayoutDescription;
|
||||
@BindView(R.id.input_description)
|
||||
TextInputEditText inputDescription;
|
||||
@BindView(R.id.air_textDeviceInfo)
|
||||
TextView textDeviceInfo;
|
||||
|
||||
@BindView(R.id.input_layout_username)
|
||||
TextInputLayout inputLayoutUsername;
|
||||
@BindView(R.id.input_username)
|
||||
TextInputEditText inputUsername;
|
||||
@BindView(R.id.input_layout_password)
|
||||
TextInputLayout inputLayoutPassword;
|
||||
@BindView(R.id.input_password)
|
||||
TextInputEditText inputPassword;
|
||||
@BindView(R.id.option_use_account)
|
||||
RadioButton optionUseAccount;
|
||||
@BindView(R.id.option_anonymous)
|
||||
RadioButton optionManual;
|
||||
|
||||
@BindView(R.id.button_send)
|
||||
FloatingActionButton sendFab;
|
||||
|
||||
private static final String ISSUE_TRACKER_LINK = "https://github.com/kabouzeid/Phonograph";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_bug_report);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setTaskDescriptionColorAuto();
|
||||
|
||||
initViews();
|
||||
|
||||
if (TextUtils.isEmpty(getTitle()))
|
||||
setTitle(R.string.report_an_issue);
|
||||
|
||||
|
||||
deviceInfo = new DeviceInfo(this);
|
||||
textDeviceInfo.setText(deviceInfo.toString());
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
final int accentColor = ThemeStore.accentColor(this);
|
||||
final int primaryColor = ThemeStore.primaryColor(this);
|
||||
toolbar.setBackgroundColor(primaryColor);
|
||||
setSupportActionBar(toolbar);
|
||||
//noinspection ConstantConditions
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
TintHelper.setTintAuto(optionUseAccount, accentColor, false);
|
||||
optionUseAccount.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
inputTitle.setEnabled(true);
|
||||
inputDescription.setEnabled(true);
|
||||
inputUsername.setEnabled(true);
|
||||
inputPassword.setEnabled(true);
|
||||
|
||||
optionManual.setChecked(false);
|
||||
sendFab.hide(new FloatingActionButton.OnVisibilityChangedListener() {
|
||||
@Override
|
||||
public void onHidden(FloatingActionButton fab) {
|
||||
super.onHidden(fab);
|
||||
sendFab.setImageResource(R.drawable.ic_send_white_24dp);
|
||||
sendFab.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
TintHelper.setTintAuto(optionManual, accentColor, false);
|
||||
optionManual.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
inputTitle.setEnabled(false);
|
||||
inputDescription.setEnabled(false);
|
||||
inputUsername.setEnabled(false);
|
||||
inputPassword.setEnabled(false);
|
||||
|
||||
optionUseAccount.setChecked(false);
|
||||
sendFab.hide(new FloatingActionButton.OnVisibilityChangedListener() {
|
||||
@Override
|
||||
public void onHidden(FloatingActionButton fab) {
|
||||
super.onHidden(fab);
|
||||
sendFab.setImageResource(R.drawable.ic_open_in_browser_white_24dp);
|
||||
sendFab.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inputPassword.setOnEditorActionListener((textView, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
reportIssue();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
textDeviceInfo.setOnClickListener(v -> copyDeviceInfoToClipBoard());
|
||||
|
||||
TintHelper.setTintAuto(sendFab, accentColor, true);
|
||||
sendFab.setOnClickListener(v -> reportIssue());
|
||||
|
||||
TintHelper.setTintAuto(inputTitle, accentColor, false);
|
||||
TintHelper.setTintAuto(inputDescription, accentColor, false);
|
||||
TintHelper.setTintAuto(inputUsername, accentColor, false);
|
||||
TintHelper.setTintAuto(inputPassword, accentColor, false);
|
||||
}
|
||||
|
||||
private void reportIssue() {
|
||||
if (optionUseAccount.isChecked()) {
|
||||
if (!validateInput()) return;
|
||||
String username = inputUsername.getText().toString();
|
||||
String password = inputPassword.getText().toString();
|
||||
sendBugReport(new GithubLogin(username, password));
|
||||
} else {
|
||||
copyDeviceInfoToClipBoard();
|
||||
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(ISSUE_TRACKER_LINK));
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDeviceInfoToClipBoard() {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText(getString(R.string.device_info), deviceInfo.toMarkdown());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toast.makeText(BugReportActivity.this, R.string.copied_device_info_to_clipboard, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private boolean validateInput() {
|
||||
boolean hasErrors = false;
|
||||
|
||||
if (optionUseAccount.isChecked()) {
|
||||
if (TextUtils.isEmpty(inputUsername.getText())) {
|
||||
setError(inputLayoutUsername, R.string.bug_report_no_username);
|
||||
hasErrors = true;
|
||||
} else {
|
||||
removeError(inputLayoutUsername);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(inputPassword.getText())) {
|
||||
setError(inputLayoutPassword, R.string.bug_report_no_password);
|
||||
hasErrors = true;
|
||||
} else {
|
||||
removeError(inputLayoutPassword);
|
||||
}
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(inputTitle.getText())) {
|
||||
setError(inputLayoutTitle, R.string.bug_report_no_title);
|
||||
hasErrors = true;
|
||||
} else {
|
||||
removeError(inputLayoutTitle);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(inputDescription.getText())) {
|
||||
setError(inputLayoutDescription, R.string.bug_report_no_description);
|
||||
hasErrors = true;
|
||||
} else {
|
||||
removeError(inputLayoutDescription);
|
||||
}
|
||||
|
||||
return !hasErrors;
|
||||
}
|
||||
|
||||
private void setError(TextInputLayout editTextLayout, @StringRes int errorRes) {
|
||||
editTextLayout.setError(getString(errorRes));
|
||||
}
|
||||
|
||||
private void removeError(TextInputLayout editTextLayout) {
|
||||
editTextLayout.setError(null);
|
||||
}
|
||||
|
||||
private void sendBugReport(GithubLogin login) {
|
||||
if (!validateInput()) return;
|
||||
|
||||
String bugTitle = inputTitle.getText().toString();
|
||||
String bugDescription = inputDescription.getText().toString();
|
||||
|
||||
Report report = new Report(bugTitle, bugDescription, deviceInfo, new ExtraInfo());
|
||||
GithubTarget target = new GithubTarget("kabouzeid", "Phonograph");
|
||||
|
||||
ReportIssueAsyncTask.report(this, report, target, login);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private static class ReportIssueAsyncTask extends DialogAsyncTask<Void, Void, String> {
|
||||
private final Report report;
|
||||
private final GithubTarget target;
|
||||
private final GithubLogin login;
|
||||
|
||||
public static void report(Activity activity, Report report, GithubTarget target,
|
||||
GithubLogin login) {
|
||||
new ReportIssueAsyncTask(activity, report, target, login).execute();
|
||||
}
|
||||
|
||||
private ReportIssueAsyncTask(Activity activity, Report report, GithubTarget target,
|
||||
GithubLogin login) {
|
||||
super(activity);
|
||||
this.report = report;
|
||||
this.target = target;
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog createDialog(@NonNull Context context) {
|
||||
return new MaterialDialog.Builder(context)
|
||||
.progress(true, 0)
|
||||
.progressIndeterminateStyle(true)
|
||||
.title(R.string.bug_report_uploading)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Result
|
||||
protected String doInBackground(Void... params) {
|
||||
GitHubClient client;
|
||||
if (login.shouldUseApiToken()) {
|
||||
client = new GitHubClient().setOAuth2Token(login.getApiToken());
|
||||
} else {
|
||||
client = new GitHubClient().setCredentials(login.getUsername(), login.getPassword());
|
||||
}
|
||||
|
||||
Issue issue = new Issue().setTitle(report.getTitle()).setBody(report.getDescription());
|
||||
try {
|
||||
new IssueService(client).createIssue(target.getUsername(), target.getRepository(), issue);
|
||||
return RESULT_OK;
|
||||
} catch (RequestException e) {
|
||||
switch (e.getStatus()) {
|
||||
case STATUS_BAD_CREDENTIALS:
|
||||
if (login.shouldUseApiToken())
|
||||
return RESULT_INVALID_TOKEN;
|
||||
return RESULT_BAD_CREDENTIALS;
|
||||
case STATUS_ISSUES_NOT_ENABLED:
|
||||
return RESULT_ISSUES_NOT_ENABLED;
|
||||
default:
|
||||
e.printStackTrace();
|
||||
return RESULT_UNKNOWN;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return RESULT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(@Result String result) {
|
||||
super.onPostExecute(result);
|
||||
|
||||
Context context = getContext();
|
||||
if (context == null) return;
|
||||
|
||||
switch (result) {
|
||||
case RESULT_OK:
|
||||
tryToFinishActivity();
|
||||
break;
|
||||
case RESULT_BAD_CREDENTIALS:
|
||||
new MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_wrong_credentials)
|
||||
.positiveText(android.R.string.ok)
|
||||
.show();
|
||||
break;
|
||||
case RESULT_INVALID_TOKEN:
|
||||
new MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_invalid_token)
|
||||
.positiveText(android.R.string.ok)
|
||||
.show();
|
||||
break;
|
||||
case RESULT_ISSUES_NOT_ENABLED:
|
||||
new MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_issues_not_available)
|
||||
.positiveText(android.R.string.ok)
|
||||
.show();
|
||||
break;
|
||||
default:
|
||||
new MaterialDialog.Builder(context)
|
||||
.title(R.string.bug_report_failed)
|
||||
.content(R.string.bug_report_failed_unknown)
|
||||
.positiveText(android.R.string.ok)
|
||||
.onPositive((dialog, which) -> tryToFinishActivity())
|
||||
.cancelListener(dialog -> tryToFinishActivity())
|
||||
.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void tryToFinishActivity() {
|
||||
Context context = getContext();
|
||||
if (context instanceof Activity && !((Activity) context).isFinishing()) {
|
||||
((Activity) context).finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.bugreport.model;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import androidx.annotation.IntRange;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DeviceInfo {
|
||||
private final int versionCode;
|
||||
private final String versionName;
|
||||
private final String buildVersion = Build.VERSION.INCREMENTAL;
|
||||
private final String releaseVersion = Build.VERSION.RELEASE;
|
||||
@IntRange(from = 0)
|
||||
private final int sdkVersion = Build.VERSION.SDK_INT;
|
||||
private final String buildID = Build.DISPLAY;
|
||||
private final String brand = Build.BRAND;
|
||||
private final String manufacturer = Build.MANUFACTURER;
|
||||
private final String device = Build.DEVICE;
|
||||
private final String model = Build.MODEL;
|
||||
private final String product = Build.PRODUCT;
|
||||
private final String hardware = Build.HARDWARE;
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("deprecation")
|
||||
private final String[] abis = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
||||
Build.SUPPORTED_ABIS : new String[]{Build.CPU_ABI, Build.CPU_ABI2};
|
||||
@SuppressLint("NewApi")
|
||||
private final String[] abis32Bits = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
||||
Build.SUPPORTED_32_BIT_ABIS : null;
|
||||
@SuppressLint("NewApi")
|
||||
private final String[] abis64Bits = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
||||
Build.SUPPORTED_64_BIT_ABIS : null;
|
||||
|
||||
public DeviceInfo(Context context) {
|
||||
PackageInfo packageInfo;
|
||||
try {
|
||||
packageInfo = context.getPackageManager()
|
||||
.getPackageInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
packageInfo = null;
|
||||
}
|
||||
if (packageInfo != null) {
|
||||
versionCode = packageInfo.versionCode;
|
||||
versionName = packageInfo.versionName;
|
||||
} else {
|
||||
versionCode = -1;
|
||||
versionName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toMarkdown() {
|
||||
return "Device info:\n"
|
||||
+ "---\n"
|
||||
+ "<table>\n"
|
||||
+ "<tr><td>App version</td><td>" + versionName + "</td></tr>\n"
|
||||
+ "<tr><td>App version code</td><td>" + versionCode + "</td></tr>\n"
|
||||
+ "<tr><td>Android build version</td><td>" + buildVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android release version</td><td>" + releaseVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android SDK version</td><td>" + sdkVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android build ID</td><td>" + buildID + "</td></tr>\n"
|
||||
+ "<tr><td>Device brand</td><td>" + brand + "</td></tr>\n"
|
||||
+ "<tr><td>Device manufacturer</td><td>" + manufacturer + "</td></tr>\n"
|
||||
+ "<tr><td>Device name</td><td>" + device + "</td></tr>\n"
|
||||
+ "<tr><td>Device model</td><td>" + model + "</td></tr>\n"
|
||||
+ "<tr><td>Device product name</td><td>" + product + "</td></tr>\n"
|
||||
+ "<tr><td>Device hardware name</td><td>" + hardware + "</td></tr>\n"
|
||||
+ "<tr><td>ABIs</td><td>" + Arrays.toString(abis) + "</td></tr>\n"
|
||||
+ "<tr><td>ABIs (32bit)</td><td>" + Arrays.toString(abis32Bits) + "</td></tr>\n"
|
||||
+ "<tr><td>ABIs (64bit)</td><td>" + Arrays.toString(abis64Bits) + "</td></tr>\n"
|
||||
+ "</table>\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "App version: " + versionName + "\n"
|
||||
+ "App version code: " + versionCode + "\n"
|
||||
+ "Android build version: " + buildVersion + "\n"
|
||||
+ "Android release version: " + releaseVersion + "\n"
|
||||
+ "Android SDK version: " + sdkVersion + "\n"
|
||||
+ "Android build ID: " + buildID + "\n"
|
||||
+ "Device brand: " + brand + "\n"
|
||||
+ "Device manufacturer: " + manufacturer + "\n"
|
||||
+ "Device name: " + device + "\n"
|
||||
+ "Device model: " + model + "\n"
|
||||
+ "Device product name: " + product + "\n"
|
||||
+ "Device hardware name: " + hardware + "\n"
|
||||
+ "ABIs: " + Arrays.toString(abis) + "\n"
|
||||
+ "ABIs (32bit): " + Arrays.toString(abis32Bits) + "\n"
|
||||
+ "ABIs (64bit): " + Arrays.toString(abis64Bits);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.bugreport.model;
|
||||
|
||||
import com.kabouzeid.gramophone.ui.activities.bugreport.model.github.ExtraInfo;
|
||||
|
||||
public class Report {
|
||||
private final String title;
|
||||
|
||||
private final String description;
|
||||
|
||||
private final DeviceInfo deviceInfo;
|
||||
|
||||
private final ExtraInfo extraInfo;
|
||||
|
||||
public Report(String title, String description, DeviceInfo deviceInfo, ExtraInfo extraInfo) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.deviceInfo = deviceInfo;
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description + "\n\n"
|
||||
+ "-\n\n"
|
||||
+ deviceInfo.toMarkdown() + "\n\n"
|
||||
+ extraInfo.toMarkdown();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.bugreport.model.github;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExtraInfo {
|
||||
private final Map<String, String> extraInfo = new LinkedHashMap<>();
|
||||
|
||||
public void put(String key, String value) {
|
||||
extraInfo.put(key, value);
|
||||
}
|
||||
|
||||
public void put(String key, boolean value) {
|
||||
extraInfo.put(key, Boolean.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, double value) {
|
||||
extraInfo.put(key, Double.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, float value) {
|
||||
extraInfo.put(key, Float.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, long value) {
|
||||
extraInfo.put(key, Long.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, int value) {
|
||||
extraInfo.put(key, Integer.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, Object value) {
|
||||
extraInfo.put(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
extraInfo.remove(key);
|
||||
}
|
||||
|
||||
public String toMarkdown() {
|
||||
if (extraInfo.isEmpty()) return "";
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append("Extra info:\n"
|
||||
+ "---\n"
|
||||
+ "<table>\n");
|
||||
for (String key : extraInfo.keySet()) {
|
||||
output.append("<tr><td>")
|
||||
.append(key)
|
||||
.append("</td><td>")
|
||||
.append(extraInfo.get(key))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
output.append("</table>\n");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.bugreport.model.github;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class GithubLogin {
|
||||
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final String apiToken;
|
||||
|
||||
public GithubLogin(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.apiToken = null;
|
||||
}
|
||||
|
||||
public GithubLogin(String apiToken) {
|
||||
this.username = null;
|
||||
this.password = null;
|
||||
this.apiToken = apiToken;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public boolean shouldUseApiToken() {
|
||||
return TextUtils.isEmpty(username) || TextUtils.isEmpty(password);
|
||||
}
|
||||
|
||||
public String getApiToken() {
|
||||
return apiToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.kabouzeid.gramophone.ui.activities.bugreport.model.github;
|
||||
|
||||
public class GithubTarget {
|
||||
private final String username;
|
||||
|
||||
private final String repository;
|
||||
|
||||
public GithubTarget(String username, String repository) {
|
||||
this.username = username;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue