public MessageAdapter(Context context, int TextViewResourceID, ArrayList<Message> items) {
   super(context, TextViewResourceID, items);
   this.items = items;
   SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
   isMonospaced = sharedPrefs.getBoolean("monospacePref", true);
   mContext = context;
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = getActivity();
    mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    mPreferences.registerOnSharedPreferenceChangeListener(this);
    addPreferencesFromResource(R.layout.tools);

    mResidualFiles = findPreference(RESIDUAL_FILES);
    mOptimDB = findPreference(PREF_OPTIM_DB);

    long mStartTime = mPreferences.getLong(RESIDUAL_FILES, 0);
    mResidualFiles.setSummary("");
    if (mStartTime > 0) mResidualFiles.setSummary(DateUtils.getRelativeTimeSpanString(mStartTime));

    mStartTime = mPreferences.getLong(PREF_OPTIM_DB, 0);
    mOptimDB.setSummary("");
    if (mStartTime > 0) mOptimDB.setSummary(DateUtils.getRelativeTimeSpanString(mStartTime));

    if (Helpers.binExist("dd").equals(NOT_FOUND) || NO_FLASH) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("category_flash_img");
      getPreferenceScreen().removePreference(hideCat);
    }
    if (Helpers.binExist("pm").equals(NOT_FOUND)) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("category_freezer");
      getPreferenceScreen().removePreference(hideCat);
    }
    setRetainInstance(true);
    setHasOptionsMenu(true);
  }
 /**
  * onCreate
  *
  * <p>adds the preferences from the ressourcefile
  */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   addPreferencesFromResource(R.xml.preferences);
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
   prefs.registerOnSharedPreferenceChangeListener(this);
 }
Exemple #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    c = this;
    preferences = PreferenceManager.getDefaultSharedPreferences(c);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.gpu_sgx540);

    gpuCurrent = readFile(Constants.GPU_SGX540);
    seekGpu = (SeekBar) findViewById(R.id.seek_gpu);

    gpu = Arrays.asList(153, 307, 384);
    seekBar(gpu.size() - 1, gpu.indexOf(gpuCurrent));

    /*else{
    seekGpu.setEnabled(false);
    seekIva.setEnabled(false);
    TextView ns = (TextView)findViewById(R.id.not_supported);
    ns.setVisibility(View.VISIBLE);
    }*/
    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    curGpuTxt = (TextView) findViewById(R.id.current_gpu);
    maxGpuTxt = (TextView) findViewById(R.id.max_gpu);
    minGpuTxt = (TextView) findViewById(R.id.min_gpu);

    mhz = getResources().getString(R.string.mhz);
    current = getResources().getString(R.string.current);
    max = getResources().getString(R.string._max);
    min = getResources().getString(R.string._min);
    curGpuTxt.setText(current + ": " + (gpuCurrent) + mhz);
    maxGpuTxt.setText(max + ": " + gpu.get(2) + mhz);
    minGpuTxt.setText(min + ": " + gpu.get(0) + mhz);

    Button cancel = (Button) findViewById(R.id.cancel);
    cancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            finish();
          }
        });
  }
Exemple #5
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.settings);
   this.setTitle(R.string.setting);
   sp = PreferenceManager.getDefaultSharedPreferences(this);
   edit = sp.edit();
   Button widgettheme = (Button) findViewById(R.id.widgettheme);
   Button settime = (Button) findViewById(R.id.settime);
   Button save = (Button) findViewById(R.id.set_save);
   nc = (CheckBox) findViewById(R.id.nightcheck);
   rs = (CheckBox) findViewById(R.id.ringswitch);
   widgettheme.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View Button) {
           AlertDialog.Builder ad =
               new AlertDialog.Builder(Settings.this)
                   .setTitle("选择颜色?")
                   .setItems(
                       color,
                       new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(DialogInterface p1, int p2) {
                           edit.putInt("widgetTextColor", colori[p2]);
                           edit.commit();
                         }
                       });
           ad.show();
         }
       });
   settime.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View Button) {
           Intent set = new Intent(Settings.this, Settime.class);
           startActivity(set);
           return;
         }
       });
   save.setOnClickListener(
       new View.OnClickListener() {
         public void onClick(View Button) {
           save();
           return;
         }
       });
   nc.setChecked(sp.getBoolean("nightmode", false));
   if (sp.getBoolean("timewrong", false) == true) {
     rs.setChecked(false);
     rs.setClickable(false);
   }
 }
 /**
  * onCreateView
  *
  * <p>handles the special case of the serverport entry which is an int....
  */
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
   // prefs.registerOnSharedPreferenceChangeListener(this);
   for (String key : prefs.getAll().keySet()) {
     Preference pref = findPreference(key);
     if (pref == null) continue;
     if (key.equals("serverport")) pref.setSummary("" + prefs.getInt(key, 0));
     else pref.setSummary(prefs.getString(key, key));
   }
   return super.onCreateView(inflater, container, savedInstanceState);
 }
Exemple #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = getActivity();
    mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    mPreferences.registerOnSharedPreferenceChangeListener(this);
    addPreferencesFromResource(R.layout.advanced);

    sreadahead = getResources().getString(R.string.ps_read_ahead, "");

    mReadAhead = (ListPreference) findPreference(PREF_READ_AHEAD);
    mBltimeout = findPreference(PREF_BLTIMEOUT);
    mBltouch = (CheckBoxPreference) findPreference(PREF_BLTOUCH);
    mBln = (CheckBoxPreference) findPreference(PREF_BLN);
    mWifiPM = (CheckBoxPreference) findPreference("pref_wifi_pm");
    mTouchScr = findPreference("touchscr_settings");
    mViber = findPreference("pref_viber");
    mVM = findPreference("vm_settings");

    mDsync = (CheckBoxPreference) findPreference(PREF_DSYNC);

    mPFK = findPreference("pfk_settings");

    mDynamicWriteBackOn = (CheckBoxPreference) findPreference(PREF_DYNAMIC_DIRTY_WRITEBACK);
    mDynamicWriteBackActive = findPreference(PREF_DIRTY_WRITEBACK_ACTIVE);
    mDynamicWriteBackSuspend = findPreference(PREF_DIRTY_WRITEBACK_SUSPEND);

    if (!new File(DSYNC_PATH).exists()) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("dsync");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      mDsync.setChecked(Helpers.readOneLine(DSYNC_PATH).equals("1"));
    }
    if (!new File(PFK_HOME_ENABLED).exists() || !new File(PFK_MENUBACK_ENABLED).exists()) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("pfk");
      getPreferenceScreen().removePreference(hideCat);
    }

    if (!new File(BL_TIMEOUT_PATH).exists()) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("bltimeout");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      mBltimeout.setSummary(Helpers.readOneLine(BL_TIMEOUT_PATH));
    }

    if (!new File(BL_TOUCH_ON_PATH).exists()) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("bltouch");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      mBltouch.setChecked(Helpers.readOneLine(BL_TOUCH_ON_PATH).equals("1"));
    }

    BLN_PATH = Helpers.bln_path();
    if (BLN_PATH == null) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("bln");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      mBln.setChecked(Helpers.readOneLine(BLN_PATH).equals("1"));
    }

    if (no_touchscreen()) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("touch_scr");
      getPreferenceScreen().removePreference(hideCat);
    }

    VIBE_PATH = vib.get_path();

    if (VIBE_PATH == null) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("viber");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      mViber.setSummary(vib.get_val(VIBE_PATH));
    }

    if (!new File(DYNAMIC_DIRTY_WRITEBACK_PATH).exists()) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("cat_dynamic_write_back");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      boolean ison = Helpers.readOneLine(DYNAMIC_DIRTY_WRITEBACK_PATH).equals("1");
      mDynamicWriteBackOn.setChecked(ison);
      mDynamicWriteBackActive.setSummary(Helpers.readOneLine(DIRTY_WRITEBACK_ACTIVE_PATH));
      mDynamicWriteBackSuspend.setSummary(Helpers.readOneLine(DIRTY_WRITEBACK_SUSPEND_PATH));
    }
    WIFIPM_PATH = Helpers.wifipm_path();
    if (WIFIPM_PATH == null) {
      PreferenceCategory hideCat = (PreferenceCategory) findPreference("wifi_pm");
      getPreferenceScreen().removePreference(hideCat);
    } else {
      mWifiPM.setChecked(Helpers.readOneLine(WIFIPM_PATH).equals("1"));
    }
    final String readahead = Helpers.readOneLine(READ_AHEAD_PATH);
    mReadAhead.setValue(readahead);
    mReadAhead.setSummary(getString(R.string.ps_read_ahead, readahead + "  kb"));

    setHasOptionsMenu(true);
  }
  public void onCreate() {
    int flags, screenLightVal = 1;
    Sensor mSensor;
    List<Sensor> sensors;

    if (scanData == null) return; // no ScanData, not possible to run correctly...

    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    try {
      screenLightVal = Integer.parseInt(SP.getString("screenLight", "2"));
    } catch (NumberFormatException nfe) {
    }
    if (screenLightVal == 1) flags = PowerManager.PARTIAL_WAKE_LOCK;
    else if (screenLightVal == 3) flags = PowerManager.FULL_WAKE_LOCK;
    else flags = PowerManager.SCREEN_DIM_WAKE_LOCK;
    wl = pm.newWakeLock(flags, "OpenWLANMap");
    wl.acquire();
    while (myWLocate == null) {
      try {
        myWLocate = new MyWLocate(this);
        break;
      } catch (IllegalArgumentException iae) {
        myWLocate = null;
      }
      try {
        Thread.sleep(100);
      } catch (InterruptedException ie) {
      }
    }

    try {
      scanData.setUploadThres(Integer.parseInt(SP.getString("autoUpload", "0")));
    } catch (NumberFormatException nfe) {
    }
    try {
      scanData.setNoGPSExitInterval(
          Integer.parseInt(SP.getString("noGPSExitInterval", "0")) * 60 * 1000);
    } catch (NumberFormatException nfe) {
    }

    Intent intent = new Intent(this, OWMapAtAndroid.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);

    notification =
        new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.icon)
            .setContentTitle(getResources().getText(R.string.app_name))
            .setContentText("")
            .setContentIntent(pendIntent)
            .build();

    notification.flags |= Notification.FLAG_NO_CLEAR;
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    startForeground(1703, notification);

    getScanData().setService(this);
    getScanData().setmView(new HUDView(this));
    getScanData().getmView().setValue(getScanData().incStoredValues());
    WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT | Gravity.BOTTOM;
    params.setTitle("Load Average");
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(getScanData().getmView(), params);

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
        SensorManager.SENSOR_DELAY_GAME);
    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
        SensorManager.SENSOR_DELAY_GAME);
    sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
    mSensor = sensors.get(0);
    getScanData().getTelemetryData().setAccelMax(mSensor.getMaximumRange());
    telemetryDir = Environment.getExternalStorageDirectory().getPath() + "/telemetry/";
    File dir = new File(telemetryDir);
    dir.mkdir();

    connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // locks the screen in portrait mode
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.downloader);
    mtext = (TextView) findViewById(R.id.mtext);
    progress_text = (TextView) findViewById(R.id.progress_text);
    progress_download = (ProgressBar) findViewById(R.id.progress_download);
    // resume capability

    paused = false;
    resume_pause = (Button) findViewById(R.id.resume);

    // Create and launch the download thread
    downloadThread = new DownloadThread(this);
    downloadThread.start();

    // Create the Handler. It will implicitly bind to the Looper
    // that is internally created for this thread (since it is the UI thread)
    handler = new Handler();

    resume_pause.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (!paused) {
              paused = true;
              resume_pause.setText("Resume");
              // writeProgress(completed_downloads,total_files_to_download);
              downloadThread.requestStop();
              downloadThread = null;

            } else {
              resume_pause.setText("Pause");
              paused = false;

              initial_value = readProgress()[0];
              final_value = links.size();

              for (int i = initial_value; i < links.size(); i++) {
                downloadThread = new DownloadThread(download_photos.this);
                downloadThread.start();
                downloadThread.enqueueDownload(
                    new DownloadTask(
                        links.get(i), path, i + 1, links.size(), download_photos.this));
              }
            }
          }
        });

    // load preferences for this activity
    mPrefs = getSharedPreferences("COMMON", MODE_PRIVATE);

    // This declaration is solely meant for reading the checkbox preference for downloading high res
    // pics.
    SharedPreferences dl_prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    // The global variable is set after reading the  checkbox preference.
    dl_high_res_pics = dl_prefs.getBoolean("download_high_res", false);

    // load fb access token and its expiry values
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);

    if (access_token != null) {
      facebook.setAccessToken(access_token);
    }
    if (expires != 0) {
      facebook.setAccessExpires(expires);
    }

    // get friend_name and album_name from the intent which started this activity
    Intent starting_intent = getIntent();
    album_id = starting_intent.getStringExtra("id");
    album_name = starting_intent.getStringExtra("name");
    friend_name = starting_intent.getStringExtra("friend_name");

    // real album and friend name may contain characters not suitable for file names.
    // regex pattern includes most of the invalid characters in file names
    legal_album_name = album_name.replaceAll("[.\\\\/:*?\"<>|]?[\\\\/:*?\"<>|]*", "");
    legal_friend_name = friend_name.replaceAll("[.\\\\/:*?\"<>|]?[\\\\/:*?\"<>|]*", "");

    // initialise the directory structure for download
    path =
        new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                + "/"
                + getText(R.string.app_name)
                + "/"
                + legal_friend_name
                + "/"
                + legal_album_name);
    if (dl_high_res_pics)
      path = new File(path.toString() + "/" + getText(R.string.folder_name_high_res));

    resume_file = new File(path, "resume.txt");
    // implements actions to done after receiving json object
    class meRequestListener extends BaseRequestListener {
      @Override
      public void onComplete(String response, Object state) {
        try {
          Log.i(TAG, response);
          json = Util.parseJson(response);

          // photos are in the form of a json array
          child = json.getJSONArray("data");

          int total = child.length();

          // contains links to photos
          links = new ArrayList<String>(total);

          // adds link to each photo to our list after replacing the "https" from url
          // DownloadManager does not support https in gingerbread
          for (int i = 0; i < total; i++) {
            photo_json = child.getJSONObject(i);

            if (dl_high_res_pics) {
              JSONArray image_set = photo_json.getJSONArray("images");

              // highest resolution picture has the index zero in the images jsonarray
              JSONObject highest_res_pic = image_set.getJSONObject(0);
              String http_replaced =
                  highest_res_pic.getString("source").replaceFirst("https", "http");
              links.add(i, http_replaced);
            } else {
              // source property of the json object points to the photo's link
              String http_replaced = photo_json.getString("source").replaceFirst("https", "http");
              links.add(i, http_replaced);
            }
          }

          download_photos.this.runOnUiThread(
              new Runnable() {
                public void run() {
                  //	mytask = new DownloadImageTask();
                  //	mytask.execute(links);
                  // start downloading using asynctask
                  // new DownloadImageTask().execute(links);
                  // downloadThread.setPath(path);
                  // downloadThread.setWholeTasks(links.size());
                  if (resume_file.exists()) {

                    initial_value = readProgress()[0];
                    final_value = links.size();
                    // case if the task is already completed
                    if (initial_value == final_value) {
                      completed = true;
                      resume_pause.setVisibility(View.GONE);

                      progress_download.setMax(final_value);
                      progress_download.setProgress(0); // bug in progress bar
                      progress_download.setProgress(initial_value);

                      progress_text.setText("Completed.");
                      mtext.setText(
                          getText(R.string.download_textview_message_1)
                              + " "
                              + path.toString()
                              + ". ");

                    }

                    // case if some of the photos are already downloaded
                    else {
                      progress_download.setMax(links.size());
                      // progress_download.setProgress(0);	//bug in progress bar
                      progress_download.setProgress(initial_value);

                      // N.B if i= initial_value -1, then one image will be downloaded again. so to
                      // save cost we start with i = initial_value
                      for (int i = initial_value; i < links.size(); i++) {
                        mtext.setText(
                            getText(R.string.download_textview_message_1)
                                + " "
                                + path.toString()
                                + ". ");
                        // downloadThread.setRunningTask(i + 1);
                        downloadThread.enqueueDownload(
                            new DownloadTask(
                                links.get(i), path, i + 1, final_value, download_photos.this));
                      }
                    }
                  }

                  // case if the task is entirely new task
                  else {
                    for (int i = 0; i < links.size(); i++) {
                      mtext.setText(
                          getText(R.string.download_textview_message_1)
                              + " "
                              + path.toString()
                              + ". ");
                      // downloadThread.setRunningTask(i + 1);
                      downloadThread.enqueueDownload(
                          new DownloadTask(
                              links.get(i), path, i + 1, links.size(), download_photos.this));
                    }
                  }
                }
              });
        } catch (JSONException ex) {
          Log.e(TAG, "JSONEXception : " + ex.getMessage());
        }
      }
    }

    // makes asynchronous request to facebook graph api
    // the actions to be performed after receiving json response is implemented above

    Bundle parameters = new Bundle();

    // facebook returns only 25 photos when limit is not specified.
    parameters.putString("limit", max_photos_in_album);
    if (!completed) mAsyncRunner.request(album_id + "/photos", parameters, new meRequestListener());

    if (!facebook.isSessionValid()) {
      facebook.authorize(
          this,
          permissions,
          new DialogListener() {

            // save fb access token and its expiry values to prefernces of this activity
            @Override
            public void onComplete(Bundle values) {
              SharedPreferences.Editor editor = mPrefs.edit();
              editor.putString("access_token", facebook.getAccessToken());
              editor.putLong("access_expires", facebook.getAccessExpires());
              editor.commit();
            }

            @Override
            public void onFacebookError(FacebookError error) {
              Log.e(TAG, "Facebook Error : " + error.getMessage());
            }

            @Override
            public void onError(DialogError e) {
              Log.e(TAG, e.getMessage());
            }

            @Override
            public void onCancel() {
              // do nothing LOL :-)
            }
          });
    }
  }