Exemplo n.º 1
3
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.line_list);

    // Setup the list
    adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item);
    ListView list = (ListView) findViewById(R.id.list);
    list.setAdapter(adapter);
    list.setOnItemClickListener(this);

    // Load Directory
    if (savedInstanceState != null) {
      backStack = savedInstanceState.getParcelableArrayList("BACKSTACK");
    }

    if (backStack == null || backStack.size() == 0) {
      backStack = new ArrayList<BackStackItem>();
      String startPath =
          (startDirectory == null || startDirectory.isEmpty())
              ? Environment.getExternalStorageDirectory().getPath()
              : startDirectory;
      backStack.add(new BackStackItem(startPath, false));
    }

    wrapFiles();
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //
    //	this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main_login);

    mEtAccount = (EditText) findViewById(R.id.mainLoginEditAccount);
    mEtPassword = (EditText) findViewById(R.id.mainLoginEditPassword);
    mBtnLogin = (Button) findViewById(R.id.mainLoginBtn);
    mBtnRegister = (Button) findViewById(R.id.main_btn_register);

    /* this is to render the password edittext font to be default */
    mEtPassword.setTypeface(Typeface.DEFAULT);
    mEtPassword.setTransformationMethod(new PasswordTransformationMethod());

    mBtnLogin.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            MainActivity.this.tryLogin();
          }
        });

    mBtnRegister.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Intent intent0 = new Intent(MainActivity.this, RegisterActivity.class);
            startActivity(intent0);
          }
        });
  }
Exemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // remove title
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main_game);

    allDoneLevels = new ArrayList<>();
    AssetManager am = getResources().getAssets();

    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    final HowdyShadeView howdyShadeView = (HowdyShadeView) this.findViewById(R.id.howdyShadeView);
    final GlowingBoard glowingBoard = (GlowingBoard) this.findViewById(R.id.glowingBoard);
    final HowdyView howdyView = (HowdyView) this.findViewById(R.id.howdyView);
    this.game = new Game();

    boardView.setHowdyShadeView(howdyShadeView);
    boardView.setGlowingBoard(glowingBoard);
    boardView.setHowdyView(howdyView);
    boardView.setOnTouchListener(new BoardGameTouchListener(this));
  }
Exemplo n.º 4
0
  /** Called when the activity is first created */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "LoaderActivity created");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.content);

    // Instantiate custom adapter
    mAdapter = new LoaderAdapter();

    // Handle listview and assign adapter
    mListView = (ListView) findViewById(R.id.content_list_view);
    mListView.setAdapter(mAdapter);
    mListView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
            selectItem(position);
            return true;
          }
        });

    mStatusLabel = (TextView) findViewById(R.id.content_status_label);
    mStatusLabel.setVisibility(View.VISIBLE);

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) showUserHashDialog();
    else refreshMapList();
  }
Exemplo n.º 5
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
      // We can read and write the media

      try {
        url = (String) getIntent().getExtras().get(Intent.EXTRA_TEXT) + "#view:list";
      } catch (Exception e) {
        url = "https://www.dropbox.com/s/8owsfcia59ko76i#view:list";
        // Used for testing if it's not opened from the dropox action menu
        // Obviously what needs to happen here is a message suggesting that the user use the dropbox
        // app, and a textbox in case they've got the url copied.
      }

      showDialog(
          PROGRESS_DIALOG); // Do the work in a separate thread so we can update the UI
                            // simultaneously.

    } else {
      // Can't write files, so show a message and quit.

    }
  }
Exemplo n.º 6
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.c09_overscroll);

    for (int i = 1001; i <= 1003; i++) {
      mItem.add(Integer.toString(i));
    }

    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mItem);

    mList = (ListView) findViewById(R.id.list);
    mList.setAdapter(mAdapter);
  }
Exemplo n.º 7
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();
          }
        });
  }
Exemplo n.º 8
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_showdialog);

    Button btn = (Button) findViewById(R.id.call);
    btn.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            showDialog(SampleDialog);
          }
        });
    Button btn2 = (Button) findViewById(R.id.call2);
    btn2.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            showDialog(QuestionDialog);
          }
        });
  }
Exemplo n.º 9
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    mAppContext = this;
    mMainHandler = new Handler();

    if (!sTryCatchAttached) {
      sTryCatchAttached = true;
      mMainHandler.post(
          new Runnable() {
            public void run() {
              try {
                Looper.loop();
              } catch (Exception e) {
                Log.e(LOG_FILE_NAME, "top level exception", e);
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);
                pw.flush();
                GeckoAppShell.reportJavaCrash(sw.toString());
              }
              // resetting this is kinda pointless, but oh well
              sTryCatchAttached = false;
            }
          });
    }

    SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
    String localeCode = settings.getString(getPackageName() + ".locale", "");
    if (localeCode != null && localeCode.length() > 0) GeckoAppShell.setSelectedLocale(localeCode);

    Log.i(LOG_FILE_NAME, "create");
    super.onCreate(savedInstanceState);

    if (sGREDir == null) sGREDir = new File(this.getApplicationInfo().dataDir);

    getWindow()
        .setFlags(
            mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (cameraView == null) {
      cameraView = new SurfaceView(this);
      cameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    if (surfaceView == null) surfaceView = new GeckoSurfaceView(this);
    else mainLayout.removeAllViews();

    mainLayout = new AbsoluteLayout(this);
    mainLayout.addView(
        surfaceView,
        new AbsoluteLayout.LayoutParams(
            AbsoluteLayout.LayoutParams.MATCH_PARENT, // level 8
            AbsoluteLayout.LayoutParams.MATCH_PARENT,
            0,
            0));

    setContentView(
        mainLayout,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mConnectivityFilter = new IntentFilter();
    mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    mConnectivityReceiver = new GeckoConnectivityReceiver();

    IntentFilter batteryFilter = new IntentFilter();
    batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    mBatteryReceiver = new GeckoBatteryManager();
    registerReceiver(mBatteryReceiver, batteryFilter);

    if (SmsManager.getInstance() != null) {
      SmsManager.getInstance().start();
    }

    GeckoNetworkManager.getInstance().init();

    if (!checkAndSetLaunchState(LaunchState.PreLaunch, LaunchState.Launching)) return;

    checkAndLaunchUpdate();
    mLibLoadThread =
        new Thread(
            new Runnable() {
              public void run() {
                // At some point while loading the gecko libs our default locale gets set
                // so just save it to locale here and reset it as default after the join
                Locale locale = Locale.getDefault();
                GeckoAppShell.loadGeckoLibs(getApplication().getPackageResourcePath());
                Locale.setDefault(locale);
                Resources res = getBaseContext().getResources();
                Configuration config = res.getConfiguration();
                config.locale = locale;
                res.updateConfiguration(config, res.getDisplayMetrics());
              }
            });
    mLibLoadThread.start();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile);
    findViews();
    /*Select Category work */
    final String[] categories = getIntent().getStringArrayExtra("Options");
    ArrayAdapter<String> catadapt;
    catadapt = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
    mCatSpin.setAdapter(catadapt);
    mCatSpin.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
            mChosenCategory = categories[pos];
          }

          public void onNothingSelected(AdapterView<?> parent) {}
        });
    /*Availability selection work*/
    mAvail = (Button) findViewById(R.id.editavail);
    mAvail.setOnClickListener(this);
    /*Submit/Back button work*/
    mSub = (Button) findViewById(R.id.submitbutton);
    mSub.setOnClickListener(this);
    mBack.setOnClickListener(this);
    /*Web View & Camera uploader work*/
    openCam.setOnClickListener(this);
    openWeb.setOnClickListener(this);
    web.getSettings().setJavaScriptEnabled(true);
    web.loadUrl("http://www.monkbananas.com/uploader/index.php");
    // ------Everything below this line was found on StackOverflow--------------------
    web.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView v, String url) {
            web.loadUrl(url);
            return true;
          }
          // The undocumented magic method override
          // Eclipse will swear at you if you try to put @Override here
          // For Android 3.0+
          public void openFileChooser(ValueCallback<Uri> uploadMsg) {

            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("image/*");
            startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
          }

          // For Android 3.0+
          public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
          }

          // For Android 4.1
          public void openFileChooser(
              ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("image/*");
            startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
          }
        });
  }
Exemplo n.º 11
0
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   gv = new GameView(this);
   setContentView(gv);
 }
Exemplo n.º 12
0
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   vw = new MyView(this);
   setContentView(vw);
 }
  @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 :-)
            }
          });
    }
  }