示例#1
0
 /**
  * Copy debug information about the device to the clipboard
  *
  * @return debugInfo
  */
 public String copyDebugInfo() {
   StringBuilder sb = new StringBuilder();
   // KanjiDroid Version
   sb.append("KanjiDroid Version = ").append(VersionUtils.getPkgVersionName()).append("\n\n");
   // Android SDK
   sb.append("Android Version = " + Build.VERSION.RELEASE).append("\n\n");
   // ACRA install ID
   sb.append("ACRA UUID = ").append(Installation.id(this)).append("\n");
   String debugInfo = sb.toString();
   ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   clipboard.setText(debugInfo);
   return debugInfo;
 }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Timber.d("onCreate()");
    super.onCreate(savedInstanceState);

    Resources res = getResources();
    WebView webView;

    mType = getIntent().getIntExtra(TYPE_EXTRA, TYPE_ABOUT);

    setContentView(R.layout.info);
    final View mainView = findViewById(android.R.id.content);
    Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.toolbar);
    if (toolbar != null) {
      setSupportActionBar(toolbar);
    }

    setTitle(String.format("%s v%s", VersionUtils.getAppName(), VersionUtils.getPkgVersionName()));
    webView = (WebView) findViewById(R.id.info);
    webView.setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
            // Hide the progress indicator when the page has finished loaded
            if (progress == 100) {
              mainView.findViewById(R.id.progress_bar).setVisibility(View.GONE);
            }
          }
        });

    TextView termsAndConditionsView = (TextView) findViewById(R.id.info_terms_and_conditions);
    termsAndConditionsView.setMovementMethod(LinkMovementMethod.getInstance());
    Button continueButton = (Button) findViewById(R.id.info_continue);
    continueButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            if (mType == TYPE_ABOUT) {
              if (CompatHelper.isKindle()) {
                Intent intent =
                    new Intent(
                        "android.intent.action.VIEW",
                        Uri.parse(
                            "http://www.amazon.com/gp/mas/dl/android?p=website.openeng.anki"));
                startActivity(intent);
              } else {
                Info.this.startActivity(
                    new Intent(
                        Intent.ACTION_VIEW, Uri.parse("market://details?id=website.openeng.anki")));
              }
              return;
            }
            setResult(RESULT_OK);
            switch (mType) {
              case TYPE_NEW_VERSION:
                KanjiDroidApp.getSharedPrefs(Info.this.getBaseContext())
                    .edit()
                    .putString("lastVersion", VersionUtils.getPkgVersionName())
                    .commit();
                break;
            }
            finishWithAnimation();
          }
        });

    StringBuilder sb = new StringBuilder();
    switch (mType) {
      case TYPE_ABOUT:
        String[] content = res.getStringArray(R.array.about_content);
        sb.append(
            "<html><body text=\"#000000\" link=\"#E37068\" alink=\"#E37068\" vlink=\"#E37068\">");
        sb.append(
                String.format(
                    content[0],
                    res.getString(R.string.app_name),
                    res.getString(R.string.link_anki)))
            .append("<br/><br/>");
        sb.append(
                String.format(
                    content[1],
                    res.getString(R.string.link_issue_tracker),
                    res.getString(R.string.link_wiki),
                    res.getString(R.string.link_forum)))
            .append("<br/><br/>");
        sb.append(
                String.format(
                    content[2],
                    res.getString(R.string.link_wikipedia_open_source),
                    res.getString(R.string.link_contribution),
                    res.getString(R.string.link_contribution_contributors)))
            .append(" ");
        sb.append(
                String.format(
                    content[3],
                    res.getString(R.string.link_translation),
                    res.getString(R.string.link_donation)))
            .append("<br/><br/>");
        sb.append(
                String.format(
                    content[4],
                    res.getString(R.string.licence_wiki),
                    res.getString(R.string.link_source)))
            .append("<br/><br/>");
        sb.append("</body></html>");
        webView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null);
        ((Button) findViewById(R.id.info_continue)).setText(res.getString(R.string.info_rate));
        Button debugCopy = ((Button) findViewById(R.id.info_later));
        debugCopy.setText(res.getString(R.string.feedback_copy_debug));
        debugCopy.setVisibility(View.VISIBLE);
        debugCopy.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                copyDebugInfo();
              }
            });
        break;

      case TYPE_NEW_VERSION:
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        webView.loadUrl("file:///android_asset/changelog.html");
        // webView.loadUrl("https://ankidroid.org/docs/changelog.html");
        break;

      default:
        finish();
        break;
    }
  }