예제 #1
0
  @Override
  protected void prepare(Activity context, LinearLayout items) {

    final RedditPost post = getArguments().getParcelable("post");

    items.addView(
        propView(
            context,
            R.string.props_title,
            StringEscapeUtils.unescapeHtml4(post.title.trim()),
            true));
    items.addView(propView(context, R.string.props_author, post.author, false));
    items.addView(
        propView(context, R.string.props_url, StringEscapeUtils.unescapeHtml4(post.url), false));
    items.addView(
        propView(
            context,
            R.string.props_created,
            RRTime.formatDateTime(post.created_utc * 1000, context),
            false));

    if (post.edited instanceof Long) {
      items.addView(
          propView(
              context,
              R.string.props_edited,
              RRTime.formatDateTime((Long) post.edited * 1000, context),
              false));
    } else {
      items.addView(propView(context, R.string.props_edited, R.string.props_never, false));
    }

    items.addView(propView(context, R.string.props_subreddit, post.subreddit, false));
    items.addView(
        propView(
            context,
            R.string.props_score,
            String.format(
                "%d (%d %s, %d %s)",
                post.score,
                post.ups,
                context.getString(R.string.props_up),
                post.downs,
                context.getString(R.string.props_down)),
            false));
    items.addView(
        propView(context, R.string.props_num_comments, String.valueOf(post.num_comments), false));

    if (post.selftext != null && post.selftext.length() > 0) {
      items.addView(
          propView(
              context,
              R.string.props_self_markdown,
              StringEscapeUtils.unescapeHtml4(post.selftext),
              false));
    }
  }
예제 #2
0
 /**
  * Request the facebook authentication
  *
  * @param activity
  * @param activityCode the result code which will be handled on the onActivityResult method
  */
 public static void loginRequest(Activity activity, int activityCode) {
   Facebook mFb = FacebookProvider.getFacebook();
   if (!mFb.isSessionValid()) {
     mFb.authorize(
         activity,
         activity.getResources().getStringArray(R.array.share_facebook_permissions),
         activityCode,
         new LoginDialogListener(activity.getApplicationContext()));
   }
 }
예제 #3
0
  public void onCreate(final Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    super.onCreate(savedInstanceState);

    final Intent intent = getIntent();

    final String html = intent.getStringExtra("html");
    final String title = intent.getStringExtra("title");
    setTitle(title);

    if (html == null) {
      BugReportActivity.handleGlobalError(this, "No HTML");
    }

    webView = WebViewFragment.newInstanceHtml(html);

    setContentView(View.inflate(this, R.layout.main_single, null));

    getSupportFragmentManager().beginTransaction().add(R.id.main_single_frame, webView).commit();
  }
예제 #4
0
 public ActionMode startActionMode(ActionMode.Callback callback) {
   if (mActivity != null) {
     return mActivity.startActionMode(callback);
   }
   throw new RuntimeException(
       "HoloEverywhere.ListView (" + this + ") don't have reference on Activity");
 }
 /** {@inheritDoc} */
 @Override
 protected void onPause() {
   super.onPause();
   if (MusicUtils.isPlaying() && ApolloUtils.isApplicationSentToBackground(this)) {
     MusicUtils.startBackgroundService(this);
   }
 }
예제 #6
0
 @Override
 protected void onResume() {
   super.onResume();
   if (!mDisableMusic) {
     PlaybackService.play();
   }
 }
 /** {@inheritDoc} */
 @Override
 protected void onDestroy() {
   super.onDestroy();
   // Unbind from the service
   if (mService != null) {
     MusicUtils.unbindFromService(mToken);
     mToken = null;
   }
 }
 /** {@inheritDoc} */
 @Override
 protected void onNewIntent(final Intent intent) {
   super.onNewIntent(intent);
   final String query = intent.getStringExtra(SearchManager.QUERY);
   mFilterString = !TextUtils.isEmpty(query) ? query : null;
   // Set the prefix
   mAdapter.setPrefix(mFilterString);
   getSupportLoaderManager().restartLoader(0, null, this);
 }
예제 #9
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   if (mCreatedByThemeManager) {
     savedInstanceState = instanceState(savedInstanceState);
     savedInstanceState.putBoolean("SlidingActivityHelper.open", false);
     savedInstanceState.putBoolean("SlidingActivityHelper.secondary", false);
   }
   super.onPostCreate(savedInstanceState);
 }
 private DatePickerDialog getDatePickerDialog(boolean create) {
   if (mDatePickerDialog == null && create) {
     mDatePickerDialog = DatePickerDialog.newInstance(mCallback, mYear, mMonth, mDay);
     mDatePickerDialog.setForceNotShow(true);
     final FragmentManager fm = Activity.extract(getContext(), true).getSupportFragmentManager();
     final FragmentTransaction ft = fm.beginTransaction();
     ft.add(mDatePickerDialog, getClass().getName() + "@" + getKey());
     ft.commitAllowingStateLoss();
     fm.executePendingTransactions();
   }
   return mDatePickerDialog;
 }
예제 #11
0
  @SuppressWarnings("deprecation")
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(new Bundle()); // XXX: Simple ugly fix.

    mGaInstance = GoogleAnalytics.getInstance(this);
    mGaTracker = mGaInstance.getTracker("UA-39295928-1");

    setContentView(R.layout.activity_sign_listing);

    Display display = getWindowManager().getDefaultDisplay();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
      Point size = new Point();
      display.getSize(size);
      screenWidth = size.x;
      screenHeight = size.y;
    } else {
      screenWidth = display.getWidth();
      screenHeight = display.getHeight();
    }

    screenSize =
        getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

    switch (screenSize) {
      case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
      case Configuration.SCREENLAYOUT_SIZE_SMALL:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
      default:
        break;
    }

    // Load local json
    new LoadHelper().execute();

    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.fragment_container, new PagerFragment())
        .commit();

    // If we are on a tablet the details fragment should be added
    if (screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE
        || screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE) {
      detFragment = new SignDetailFragment();
      getSupportFragmentManager().beginTransaction().add(R.id.sign_detail, detFragment).commit();
    }
  }
예제 #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    mFirstRun = savedInstanceState == null;
    // This line restore instance state when we are change theme and
    // activity restarts
    savedInstanceState = instanceState(savedInstanceState);
    super.onCreate(savedInstanceState);

    mCreatedByThemeManager =
        getIntent().getBooleanExtra(ThemeManager.KEY_CREATED_BY_THEME_MANAGER, false);
    if (mCreatedByThemeManager) {
      mFirstRun = false;
    }

    if (savedInstanceState != null) {
      mDisableMusic = savedInstanceState.getBoolean(KEY_DISABLE_MUSIC, false);
      mCurrentPage = savedInstanceState.getInt(KEY_PAGE, 0);
    }

    final ActionBar ab = getSupportActionBar();
    ab.setTitle(R.string.library_name);

    setContentView(R.layout.content);

    final SlidingMenuA addonSM = requireSlidingMenu();
    final SlidingMenu sm = addonSM.getSlidingMenu();

    View menu = findViewById(R.id.menu);
    if (menu == null) {
      // Phone
      mStaticSlidingMenu = true;
      ab.setDisplayHomeAsUpEnabled(true);
      addonSM.setBehindContentView(makeMenuView(savedInstanceState));
      addonSM.setSlidingActionBarEnabled(true);
      sm.setBehindWidth(computeMenuWidth());
      sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
      sm.setSlidingEnabled(true);
    } else {
      // Tablet
      mStaticSlidingMenu = false;
      addonSM.setBehindContentView(new View(this)); // dummy view
      sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
      sm.setSlidingEnabled(false);
      prepareMenuView(menu, savedInstanceState);
    }

    getSupportFragmentManager().addOnBackStackChangedListener(this);
  }
예제 #13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.dp.familyorganaizer.R.layout.family_journal);

    btn_new_msg = (Button) findViewById(com.dp.familyorganaizer.R.id.btn_new_msg);
    btn_new_msg.setOnClickListener(this);

    btn_edit_msg = (Button) findViewById(com.dp.familyorganaizer.R.id.btn_edit_msg);
    btn_edit_msg.setOnClickListener(this);

    btn_delete_msg = (Button) findViewById(com.dp.familyorganaizer.R.id.btn_delete_msg);
    btn_delete_msg.setOnClickListener(this);

    //			txtview = (TextView) findViewById(com.dp.familyorganaizer.R.id.txtview);
    //			txtview.setText("Hello there!");
    //			txtview.setOnClickListener(this);
  }
예제 #14
0
 public void onBackPressed() {
   Crouton.cancelAllCroutons();
   super.onBackPressed();
 }
예제 #15
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putBoolean(KEY_DISABLE_MUSIC, mDisableMusic);
   outState.putInt(KEY_PAGE, mCurrentPage);
 }
 /** {@inheritDoc} */
 @Override
 protected void onResume() {
   super.onResume();
   MusicUtils.killForegroundService(this);
 }
예제 #17
0
 /**
  * Do not override this method. Use {@link #onPreInit(Holo, Bundle)} and {@link #onPostInit(Holo,
  * Bundle)}
  */
 protected void onInit(Holo config, Bundle savedInstanceState) {
   if (mInited) {
     throw new IllegalStateException("This instance was already inited");
   }
   mInited = true;
   if (config == null) {
     config = createConfig(savedInstanceState);
   }
   if (config == null) {
     config = Holo.defaultConfig();
   }
   onPreInit(config, savedInstanceState);
   if (!config.ignoreApplicationInstanceCheck && !(getApplication() instanceof Application)) {
     String text = "Application instance isn't HoloEverywhere.\n";
     if (getApplication().getClass() == android.app.Application.class) {
       text +=
           "Put attr 'android:name=\"org.holoeverywhere.app.Application\"'"
               + " in <application> tag of AndroidManifest.xml";
     } else {
       text +=
           "Please sure that you extend "
               + getApplication().getClass()
               + " from a org.holoeverywhere.app.Application";
     }
     throw new IllegalStateException(text);
   }
   getLayoutInflater().setFragmentActivity(this);
   if (this instanceof Activity) {
     Activity activity = (Activity) this;
     if (config.requireRoboguice) {
       activity.addon(Activity.ADDON_ROBOGUICE);
     }
     if (config.requireSlider) {
       activity.addon(Activity.ADDON_SLIDER);
     }
     if (config.requireSherlock) {
       activity.addonSherlock();
     }
     final SparseIntArray windowFeatures = config.windowFeatures;
     if (windowFeatures != null) {
       for (int i = 0; i < windowFeatures.size(); i++) {
         if (windowFeatures.valueAt(i) > 0) {
           requestWindowFeature((long) windowFeatures.keyAt(i));
         }
       }
     }
     ThemeManager.applyTheme(activity, mLastThemeResourceId == 0);
     if (!config.ignoreThemeCheck && ThemeManager.getThemeType(this) == ThemeManager.INVALID) {
       throw new HoloThemeException(activity);
     }
     TypedArray a =
         obtainStyledAttributes(
             new int[] {android.R.attr.windowActionBarOverlay, R.attr.windowActionBarOverlay});
     if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
       requestWindowFeature((long) Window.FEATURE_ACTION_BAR_OVERLAY);
     }
     a.recycle();
   }
   onPostInit(config, savedInstanceState);
   lockAttaching();
 }
예제 #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);
    getSupportActionBar().setTitle(R.string.post_captcha_title);

    super.onCreate(savedInstanceState);

    final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true);
    setContentView(loadingView);

    final RedditAccount selectedAccount =
        RedditAccountManager.getInstance(this).getAccount(getIntent().getStringExtra("username"));

    final CacheManager cm = CacheManager.getInstance(this);

    RedditAPI.newCaptcha(
        cm,
        new APIResponseHandler.NewCaptchaResponseHandler(this) {
          @Override
          protected void onSuccess(final String captchaId) {

            final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId);

            cm.makeRequest(
                new CacheRequest(
                    captchaUrl,
                    RedditAccountManager.getAnon(),
                    null,
                    Constants.Priority.CAPTCHA,
                    0,
                    CacheRequest.DownloadType.FORCE,
                    Constants.FileType.CAPTCHA,
                    false,
                    false,
                    true,
                    CaptchaActivity.this) {
                  @Override
                  protected void onCallbackException(Throwable t) {
                    BugReportActivity.handleGlobalError(CaptchaActivity.this, t);
                  }

                  @Override
                  protected void onDownloadNecessary() {}

                  @Override
                  protected void onDownloadStarted() {
                    loadingView.setIndeterminate(R.string.download_downloading);
                  }

                  @Override
                  protected void onFailure(
                      RequestFailureType type,
                      Throwable t,
                      StatusLine status,
                      String readableMessage) {
                    final RRError error =
                        General.getGeneralErrorForFailure(
                            CaptchaActivity.this, type, t, status, url.toString());
                    General.showResultDialog(CaptchaActivity.this, error);
                    finish();
                  }

                  @Override
                  protected void onProgress(long bytesRead, long totalBytes) {
                    loadingView.setProgress(
                        R.string.download_downloading,
                        (float) ((double) bytesRead / (double) totalBytes));
                  }

                  @Override
                  protected void onSuccess(
                      final CacheManager.ReadableCacheFile cacheFile,
                      long timestamp,
                      UUID session,
                      boolean fromCache,
                      String mimetype) {

                    final Bitmap image;
                    try {
                      image = BitmapFactory.decodeStream(cacheFile.getInputStream());
                    } catch (IOException e) {
                      BugReportActivity.handleGlobalError(CaptchaActivity.this, e);
                      return;
                    }

                    new Handler(Looper.getMainLooper())
                        .post(
                            new Runnable() {
                              public void run() {

                                final LinearLayout ll = new LinearLayout(CaptchaActivity.this);
                                ll.setOrientation(LinearLayout.VERTICAL);

                                final ImageView captchaImg = new ImageView(CaptchaActivity.this);
                                ll.addView(captchaImg);
                                final LinearLayout.LayoutParams layoutParams =
                                    (LinearLayout.LayoutParams) captchaImg.getLayoutParams();
                                layoutParams.setMargins(20, 20, 20, 20);
                                layoutParams.height = General.dpToPixels(context, 100);
                                captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER);

                                final EditText captchaText = new EditText(CaptchaActivity.this);
                                ll.addView(captchaText);
                                ((LinearLayout.LayoutParams) captchaText.getLayoutParams())
                                    .setMargins(20, 0, 20, 20);
                                captchaText.setInputType(
                                    android.text.InputType.TYPE_CLASS_TEXT
                                        | android.text.InputType
                                            .TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                                        | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);

                                captchaImg.setImageBitmap(image);

                                final Button submitButton = new Button(CaptchaActivity.this);
                                submitButton.setText(R.string.post_captcha_submit_button);
                                ll.addView(submitButton);
                                ((LinearLayout.LayoutParams) submitButton.getLayoutParams())
                                    .setMargins(20, 0, 20, 20);
                                ((LinearLayout.LayoutParams) submitButton.getLayoutParams())
                                        .gravity =
                                    Gravity.RIGHT;
                                ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).width =
                                    LinearLayout.LayoutParams.WRAP_CONTENT;

                                submitButton.setOnClickListener(
                                    new View.OnClickListener() {
                                      public void onClick(View v) {
                                        final Intent result = new Intent();
                                        result.putExtra("captchaId", captchaId);
                                        result.putExtra(
                                            "captchaText", captchaText.getText().toString());
                                        setResult(RESULT_OK, result);
                                        finish();
                                      }
                                    });

                                final ScrollView sv = new ScrollView(CaptchaActivity.this);
                                sv.addView(ll);
                                setContentView(sv);
                              }
                            });
                  }
                });
          }

          @Override
          protected void onCallbackException(Throwable t) {
            BugReportActivity.handleGlobalError(CaptchaActivity.this, t);
          }

          @Override
          protected void onFailure(
              RequestFailureType type, Throwable t, StatusLine status, String readableMessage) {
            final RRError error =
                General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, null);
            General.showResultDialog(CaptchaActivity.this, error);
            finish();
          }

          @Override
          protected void onFailure(APIFailureType type) {
            final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type);
            General.showResultDialog(CaptchaActivity.this, error);
            finish();
          }
        },
        selectedAccount,
        this);
  }
  /** {@inheritDoc} */
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Title bar shows up in gingerbread, I'm too tired to figure out why.
    if (!ApolloUtils.hasHoneycomb()) {
      requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    // Initialze the theme resources
    mResources = new ThemeUtils(this);
    // Set the overflow style
    mResources.setOverflowStyle(this);

    // Fade it in
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

    // Control the media volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Bind Apollo's service
    mToken = MusicUtils.bindToService(this, this);

    // Theme the action bar
    final ActionBar actionBar = getSupportActionBar();
    mResources.themeActionBar(actionBar, getString(R.string.app_name));
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set the layout
    setContentView(R.layout.grid_base);

    // Give the background a little UI
    final FrameLayout background = (FrameLayout) findViewById(R.id.grid_base_container);
    background.setBackgroundDrawable(getResources().getDrawable(R.drawable.pager_background));

    // Get the query
    final String query = getIntent().getStringExtra(SearchManager.QUERY);
    mFilterString = !TextUtils.isEmpty(query) ? query : null;

    // Action bar subtitle
    mResources.setSubtitle("\"" + mFilterString + "\"");

    // Initialize the adapter
    mAdapter = new SearchAdapter(this);
    // Set the prefix
    mAdapter.setPrefix(mFilterString);
    // Initialze the list
    mGridView = (GridView) findViewById(R.id.grid_base);
    // Bind the data
    mGridView.setAdapter(mAdapter);
    // Recycle the data
    mGridView.setRecyclerListener(new RecycleHolder());
    // Seepd up scrolling
    mGridView.setOnScrollListener(this);
    mGridView.setOnItemClickListener(this);
    if (ApolloUtils.isLandscape(this)) {
      mGridView.setNumColumns(TWO);
    } else {
      mGridView.setNumColumns(ONE);
    }
    // Prepare the loader. Either re-connect with an existing one,
    // or start a new one.
    getSupportLoaderManager().initLoader(0, null, this);
  }
예제 #20
0
 public final void setActivity(Activity activity) {
   mActivity = activity;
   if (mActivity != null) {
     mActivity.addOnWindowFocusChangeListener(this);
   }
 }
예제 #21
0
 @Override
 protected void onPause() {
   PlaybackService.pause(false);
   super.onPause();
 }
예제 #22
0
 @Override
 public void onStop() {
   super.onStop();
   EasyTracker.getInstance().activityStop(this);
 }
예제 #23
0
 public void onDestroy() {
   Crouton.cancelAllCroutons();
   super.onDestroy();
 }
예제 #24
0
  @Override
  public void onBackPressed() {

    if (General.onBackPressed() && !webView.onBackButtonPressed()) super.onBackPressed();
  }
예제 #25
0
  @SuppressLint("NewApi")
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    screenSize =
        getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

    switch (screenSize) {
      case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        return;
      case Configuration.SCREENLAYOUT_SIZE_SMALL:
        return;
      default:
        break;
    }

    if (screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE
        || screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE) {
      // Tablet
      showLoader();
      detFragment = new SignDetailFragment();
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.sign_detail, detFragment)
          .commit();
      hideLoader();
    } /*else {
      	//Handset
      	Class<? extends Fragment> c = getSupportFragmentManager().findFragmentById(R.id.fragment_container).getClass();
      	if(c.equals(SignDetailFragment.class)){
      		showLoader();
      		detFragment = new SignDetailFragment();
      		//Add to container
      		getSupportFragmentManager().popBackStack();
      		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      		transaction.replace(R.id.fragment_container, detFragment);
      		transaction.addToBackStack(null);
      		transaction.commit();
      		hideLoader();
      	}
      }*/

    ListView metaList = (ListView) findViewById(R.id.metaList);
    if (metaList != null) {
      RelativeLayout.LayoutParams params;
      if (newConfig.orientation == 1) {
        params =
            new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.BELOW, R.id.myVideoView);
      } else if (newConfig.orientation == 2) {
        params =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
        params.addRule(RelativeLayout.RIGHT_OF, R.id.myVideoView);
      } else {
        Log.e("MA", "Should not be here...");
        params =
            new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
      }
      metaList.setLayoutParams(params);
    } else {
      Log.i("MA", "metaList is null");
    }
  }