@TargetApi(Build.VERSION_CODES.LOLLIPOP)
 private void toolbarSetElevation(float elevation) {
   // setElevation() only works on Lollipop
   if (AndroidUtils.isLollipop()) {
     tToolbar.setElevation(elevation);
   }
 }
  @Override
  public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    ActionBar mActionBar = getSupportActionBar();

    int color = getResources().getColor(R.color.toolbar_green);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      // Overview color
      MainActivity.this.setTaskDescription(
          new ActivityManager.TaskDescription(
              "Linode",
              AndroidHelper.drawableToBitmap(getResources().getDrawable(R.mipmap.ic_launcher)),
              color));
    }

    if (mActionBar != null) {
      toolbar.setBackgroundColor(color);
      drawer
          .getDrawerLayout()
          .setStatusBarBackgroundColor(
              AndroidHelper.darkenColor(getResources().getColor(R.color.toolbar_green), 0.8f));

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        toolbar.setElevation(8);
      }
    }
  }
Esempio n. 3
0
 private void setToolbarElevation(Toolbar toolbar) {
   // If L, hide the fake shadow
   if (Build.VERSION.SDK_INT >= 21) {
     toolbar.setElevation(14);
     findViewById(R.id.main_shadow).setVisibility(View.GONE);
   }
 }
  private void configureToolbar() {
    Toolbar toolbar = getToolbar();
    if (toolbar != null) {
      //            toolbar.setBackgroundColor(Color.parseColor("#1d1d25"));
      toolbar.setTitleTextColor(Color.WHITE);
      //            toolbar.setBackgroundColor(Color.TRANSPARENT);
      //            toolbar.setBottom(Color.WHITE);
      //            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
      //                Window window = getActivity().getWindow();
      //                window.setStatusBarColor(Color.parseColor("#1d1d25"));
      //            }
      Drawable drawable = null;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        drawable =
            getResources()
                .getDrawable(R.drawable.dap_wallet_asset_issuer_action_bar_gradient_colors, null);
        toolbar.setElevation(0);
      } else {
        drawable =
            getResources()
                .getDrawable(R.drawable.dap_wallet_asset_issuer_action_bar_gradient_colors);
      }

      toolbar.setBackground(drawable);
    }
  }
 private void updateActionBar() {
   getSupportActionBar().setTitle(currentSection.getTitleResId());
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
     //noinspection ResourceType
     toolbar.setElevation(
         currentSection.extendsAppBar()
             ? 0f
             : getResources().getDimension(R.dimen.toolbar_elevation));
   }
 }
 private void configureToolbar() {
   Toolbar toolbar = getToolbar();
   if (toolbar != null) {
     toolbar.setTitleTextColor(Color.WHITE);
     Drawable drawable = null;
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
       drawable =
           getResources()
               .getDrawable(R.drawable.dap_wallet_asset_issuer_action_bar_gradient_colors, null);
       toolbar.setElevation(0);
     } else {
       drawable =
           getResources()
               .getDrawable(R.drawable.dap_wallet_asset_issuer_action_bar_gradient_colors);
     }
     toolbar.setBackground(drawable);
   }
 }
  @SuppressLint("NewApi")
  public void onCreate(Bundle savedInstanceState) {
    // getWindow().requestFeature(Window.FEATURE_PROGRESS);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Website");
    if (Build.VERSION.SDK_INT >= 21) {
      toolbar.setElevation(25);
    }

    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    web();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {

      _executor = Executors.newFixedThreadPool(2);

      setHasOptionsMenu(true);
      // setting up  module

      moduleManager = appSession.getModuleManager();
      errorManager = appSession.getErrorManager();

      intraUserSubAppSession = appSession;

      try {
        intraUserWalletSettings =
            moduleManager.loadAndGetSettings(intraUserSubAppSession.getAppPublicKey());
      } catch (Exception e) {
        intraUserWalletSettings = null;
      }

      if (intraUserSubAppSession.getAppPublicKey() != null) // the identity not exist yet
      {
        if (intraUserWalletSettings == null) {
          intraUserWalletSettings = new IntraUserWalletSettings();
          intraUserWalletSettings.setIsPresentationHelpEnabled(true);
          intraUserSubAppSession
              .getModuleManager()
              .persistSettings(intraUserSubAppSession.getAppPublicKey(), intraUserWalletSettings);
        }
      }

      mNotificationsCount = moduleManager.getIntraUsersWaitingYourAcceptanceCount();
      new FetchCountTask().execute();

      toolbar = getToolbar();
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        toolbar.setElevation(10);
      }

      // consult net work status

      _executor.submit(
          new Runnable() {
            @Override
            public void run() {
              try {
                handler.postDelayed(
                    new Runnable() {
                      public void run() {
                        NetworkStatus networkStatus = null;
                        try {
                          networkStatus = getFermatNetworkStatus();
                        } catch (CantGetCommunicationNetworkStatusException e) {
                          e.printStackTrace();
                        }
                        switch (networkStatus) {
                          case CONNECTED:
                            // setUpReferences();
                            break;
                          case DISCONNECTED:
                            showErrorFermatNetworkDialog();
                            break;
                        }
                      }
                    },
                    500);
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          });

      // getting location and setting device locacion
      location = moduleManager.getLocationManager();

      if (location == null) {
        //  showErrorGPS();
        Toast.makeText(getActivity(), "Please, turn ON your GPS", Toast.LENGTH_SHORT);
      }

      IntraUserLoginIdentity identity = moduleManager.getActiveIntraUserIdentity();

      distance = identity.getAccuracy();

      // turnGPSOn();

    } catch (Exception ex) {
      CommonLogger.exception(TAG, ex.getMessage(), ex);
      errorManager.reportUnexpectedUIException(
          UISource.ACTIVITY, UnexpectedUIExceptionSeverity.CRASH, ex);
    }
  }
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    // Assign Toolbar to the activity
    tToolbar = (Toolbar) findViewById(R.id.tToolbar);
    setSupportActionBar(tToolbar);
    getSupportActionBar().setTitle(R.string.app_name);

    // RecyclerView with sample data
    rvCities = (RecyclerView) findViewById(R.id.rvCities);
    rvCities.setLayoutManager(new LinearLayoutManager(this));
    rvCities.setAdapter(new CitiesAdapter(CityUtils.CITIES));

    if (savedInstanceState != null) {
      if (AndroidUtils.isLollipop()) {
        tToolbar.setElevation(savedInstanceState.getFloat(STATE_TOOLBAR_ELEVATION));
      }
      tToolbar.setTranslationY(savedInstanceState.getFloat(STATE_TOOLBAR_TRANSLATION_Y));
      verticalOffset = savedInstanceState.getInt(STATE_VERTICAL_OFFSET);
      scrollingOffset = savedInstanceState.getInt(STATE_SCROLLING_OFFSET);
      rvCities
          .getLayoutManager()
          .onRestoreInstanceState(savedInstanceState.getParcelable(STATE_RECYCLER_VIEW));
    }

    // We need to detect scrolling changes in the RecyclerView
    rvCities.addOnScrollListener(
        new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
              if (scrollingOffset > 0) {
                if (verticalOffset > tToolbar.getHeight()) {
                  toolbarAnimateHide();
                } else {
                  toolbarAnimateShow(verticalOffset);
                }
              } else if (scrollingOffset < 0) {
                if (tToolbar.getTranslationY() < tToolbar.getHeight() * -0.6
                    && verticalOffset > tToolbar.getHeight()) {
                  toolbarAnimateHide();
                } else {
                  toolbarAnimateShow(verticalOffset);
                }
              }
            }
          }

          @Override
          public final void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            verticalOffset = rvCities.computeVerticalScrollOffset();
            scrollingOffset = dy;
            int toolbarYOffset = (int) (dy - tToolbar.getTranslationY());
            tToolbar.animate().cancel();
            if (scrollingOffset > 0) {
              if (toolbarYOffset < tToolbar.getHeight()) {
                if (verticalOffset > tToolbar.getHeight()) {
                  toolbarSetElevation(TOOLBAR_ELEVATION);
                }
                tToolbar.setTranslationY(-toolbarYOffset);
              } else {
                toolbarSetElevation(0);
                tToolbar.setTranslationY(-tToolbar.getHeight());
              }
            } else if (scrollingOffset < 0) {
              if (toolbarYOffset < 0) {
                if (verticalOffset <= 0) {
                  toolbarSetElevation(0);
                }
                tToolbar.setTranslationY(0);
              } else {
                if (verticalOffset > tToolbar.getHeight()) {
                  toolbarSetElevation(TOOLBAR_ELEVATION);
                }
                tToolbar.setTranslationY(-toolbarYOffset);
              }
            }
          }
        });
  }
Esempio n. 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);

    //  Find the toolbar in XML
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    //  Set it's title text color to white
    toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
    //  Change activity's action bar to toolbar
    setSupportActionBar(toolbar);

    LinodeApi.init(getBaseContext(), this);

    initImageLoader();

    accountHeader = buildHeader();

    //  Set up a new drawer builder
    drawer =
        new DrawerBuilder()
            .withActivity(this) //  Bind it to this activity
            .withToolbar(toolbar) //  Bind it to the toolbar attached to this activity
            .withAccountHeader(accountHeader)
            .withTranslucentNavigationBar(true) //  Disable translucent navigation menu/bar
            .addDrawerItems( //  Add our drawer items
                //  Regular drawer items
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.server) //  Icon
                    .withSelectedIcon(R.drawable.server_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item1)) //  Title
                    .withIdentifier(1) //  ID = 1
                    .withTextColor(Color.parseColor("#444444")) //  Text color
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.sitemap)
                    .withSelectedIcon(R.drawable.sitemap_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item2))
                    .withIdentifier(2) //  ID = 2
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.dns)
                    .withSelectedIcon(R.drawable.dns_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item3))
                    .withIdentifier(3) //  ID = 3
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.library)
                    .withSelectedIcon(R.drawable.library_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item4))
                    .withIdentifier(4) //  ID = 4
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),

                //  Divider
                new DividerDrawerItem(),

                //  Small/secondary drawer items
                new SecondaryDrawerItem()
                    .withIcon(R.drawable.account)
                    .withSelectedIcon(
                        R.drawable
                            .account_tinted) //  Tinted icon; not mandatory since this won't be
                                             // highlighted
                    .withName(getResources().getString(R.string.item5))
                    .withIdentifier(5) //  ID = 5
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green))
                    .withSelectable(false), //  Not a fragment; don't highlight
                new SecondaryDrawerItem()
                    .withIcon(R.drawable.information)
                    .withSelectedIcon(R.drawable.information_tinted)
                    .withName(getResources().getString(R.string.item6))
                    .withIdentifier(6) //  ID = 6
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green))
                    .withSelectable(false), //  Not a fragment; don't highlight
                new SecondaryDrawerItem()
                    .withIcon(R.drawable.logout)
                    .withSelectedIcon(R.drawable.logout_tinted)
                    .withName(getResources().getString(R.string.item7))
                    .withIdentifier(7) //  ID = 7
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green))
                    .withSelectable(false) //  Not a fragment; don't highlight
                )
            //  Attach onClickListeners for each drawer item (not dividers!)
            .withOnDrawerItemClickListener(
                new Drawer.OnDrawerItemClickListener() {

                  @Override
                  public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {

                    if (drawerItem != null) {
                      //   update the main content by replacing fragments
                      Fragment fragment = new LinodesFragment();
                      FragmentManager fragmentManager = getFragmentManager();

                      switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                          fragment = new LinodesFragment();
                          break;
                        case 2:
                          fragment = new NodesFragment();
                          break;
                        case 3:
                          fragment = new DNSFragment();
                          break;
                        case 4:
                          fragment = new LibraryFragment();
                          break;
                        case 5:
                          // Account
                          Toast.makeText(getBaseContext(), "Demo Only", Toast.LENGTH_SHORT).show();
                          break;
                        case 6:
                          // About
                          Intent about = new Intent(MainActivity.this, AboutActivity.class);
                          startActivity(about);
                          break;
                        case 7:
                          // Log out
                          Toast.makeText(getBaseContext(), "Demo Only", Toast.LENGTH_SHORT).show();
                          break;
                      }
                      fragmentManager
                          .beginTransaction()
                          .replace(R.id.content_frame, fragment)
                          .commit();

                      if (drawerItem instanceof Nameable) {
                        setTitle(
                            ((Nameable) drawerItem).getName().getText(getApplicationContext()));
                      }
                    }

                    return false;
                  }
                })
            .withFireOnInitialOnClick(true)
            .withSavedInstance(savedInstanceState)
            .build();

    //  Set a custom shadow that overlays the main content when the drawer opens
    drawer.getDrawerLayout().setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    ActionBar mActionBar = getSupportActionBar();

    int color = getResources().getColor(R.color.toolbar_green);

    if (mActionBar != null) {
      toolbar.setBackgroundColor(color);
      drawer
          .getDrawerLayout()
          .setStatusBarBackgroundColor(
              AndroidHelper.darkenColor(getResources().getColor(R.color.toolbar_green), 0.8f));

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        toolbar.setElevation(8);
        getWindow()
            .setNavigationBarColor(
                AndroidHelper.darkenColor(getResources().getColor(R.color.toolbar_green), 0.8f));
      }
    }
  }