コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Sherlock);
    super.onCreate(savedInstanceState);

    // add preferences
    addPreferencesFromResource(R.xml.quran_preferences);

    // special handling for the arabic checkbox
    CheckBoxPreference arabicPreference =
        (CheckBoxPreference) findPreference(Constants.PREF_USE_ARABIC_NAMES);
    mInitiallyIsArabic = arabicPreference.isChecked();
    mIsArabic = mInitiallyIsArabic;
    arabicPreference.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean isArabic = (Boolean) newValue;
            mIsArabic = isArabic;

            Locale lang = (isArabic ? new Locale("ar") : getResources().getConfiguration().locale);
            Locale.setDefault(lang);
            Configuration config = new Configuration();
            config.locale = lang;
            getResources().updateConfiguration(config, getResources().getDisplayMetrics());

            return true;
          }
        });

    // remove the tablet mode preference if it doesn't exist
    if (!QuranScreenInfo.getOrMakeInstance(this).isTablet(this)) {
      Preference tabletModePreference = findPreference(Constants.PREF_TABLET_ENABLED);
      PreferenceCategory category =
          (PreferenceCategory) findPreference(Constants.PREF_DISPLAY_CATEGORY);
      category.removePreference(tabletModePreference);
    }

    Preference advancedPrefs = findPreference(getString(R.string.prefs_advanced_settings));
    advancedPrefs.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            mLoadStorageOptionsTask = new LoadStorageOptionsTask();
            mLoadStorageOptionsTask.execute();
            return false;
          }
        });

    /*
    // can enable this to get logs from users until we move it to
    // a setting. needs READ_LOGS permissions below jellybean. this
    // is a work around until we properly use the Logger framework
    // to roll our own log files.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      mReadLogsTask = new ReadLogsTask();
      mReadLogsTask.execute();
    }
    */

    mListStorageOptions = (ListPreference) findPreference(getString(R.string.prefs_app_location));

    mStorageList = StorageUtils.getAllStorageLocations(getApplicationContext());

    // Hide Advanced Preferences Screen if there is no storage option
    // except for the normal Environment.getExternalStorageDirectory
    if (mStorageList.size() <= 1) {
      Log.d(TAG, "removing advanced settings from preferences");
      getPreferenceScreen().removePreference(advancedPrefs);
    }
  }
コード例 #2
0
    @Override
    protected void onPostExecute(String logs) {
      if (mIsPaused) {
        return;
      }

      Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
      emailIntent.setType("plain/text");

      QuranScreenInfo qsi;
      String body = "\n\n";
      try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        body = pInfo.packageName + " Version: " + pInfo.versionName;
      } catch (Exception e) {
      }

      try {
        body += "\nPhone: " + android.os.Build.MANUFACTURER + " " + android.os.Build.MODEL;
        body +=
            "\nAndroid Version: "
                + android.os.Build.VERSION.CODENAME
                + " "
                + android.os.Build.VERSION.RELEASE;

        qsi = QuranScreenInfo.getOrMakeInstance(QuranPreferenceActivity.this);
        body += "\nDisplay: " + qsi.getWidthParam();
        if (qsi.isTablet(QuranPreferenceActivity.this)) {
          body += ", tablet width: " + qsi.getWidthParam();
        }
        body += "\n";
        body += "max bitmap height: " + qsi.getBitmapMaxHeight() + "\n";

        if (QuranFileUtils.haveAllImages(QuranPreferenceActivity.this, qsi.getWidthParam())) {
          body += "all images found for " + qsi.getWidthParam() + "\n";
        }

        if (qsi.isTablet(QuranPreferenceActivity.this)
            && QuranFileUtils.haveAllImages(
                QuranPreferenceActivity.this, qsi.getTabletWidthParam())) {
          body += "all tablet images found for " + qsi.getTabletWidthParam() + "\n";
        }
      } catch (Exception e) {
      }

      int memClass =
          ((ActivityManager)
                  QuranPreferenceActivity.this.getSystemService(Context.ACTIVITY_SERVICE))
              .getMemoryClass();
      body += "memory class: " + memClass + "\n\n";

      body += "\n\n";
      body += "\nLogs: " + logs;
      body += "\n\n";

      emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
      emailIntent.putExtra(
          android.content.Intent.EXTRA_SUBJECT, getString(R.string.email_logs_subject));
      emailIntent.putExtra(
          android.content.Intent.EXTRA_EMAIL, new String[] {getString(R.string.email_to)});
      startActivity(Intent.createChooser(emailIntent, getString(R.string.send_email)));
    }