Java Code Examples for androidx.appcompat.widget.Toolbar#setBackgroundColor()

The following examples show how to use androidx.appcompat.widget.Toolbar#setBackgroundColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UCropActivity.java    From EasyPhotos with Apache License 2.0 6 votes vote down vote up
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
Example 2
Source File: PictureMultiCuttingActivity.java    From Matisse-Kotlin with Apache License 2.0 6 votes vote down vote up
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
Example 3
Source File: PermissionsActivity.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_permissions);
	
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	toolbar.setBackgroundColor(getResources().getColor(R.color.bar_overlay));
	setSupportActionBar(toolbar);
	
	getSupportActionBar().setHomeButtonEnabled(true);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	
	getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.activity_background));
	
	isPreviewSetttings = getIntent().getBooleanExtra("previewSettings", false);
	
	if (isPreviewSetttings) {
		getSupportActionBar().setTitle(R.string.pref_build_preview_permissions);
	}
}
 
Example 4
Source File: UCropActivity.java    From PictureSelector with Apache License 2.0 6 votes vote down vote up
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = AppCompatResources.getDrawable(this, mToolbarCancelDrawable).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
Example 5
Source File: CameraPrefsActivity.java    From evercam-android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_settings);

    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    toolbar.setBackgroundColor(getResources().getColor(R.color.dark_gray_background));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    screenWidth = CamerasActivity.readScreenWidth(this);

    getFragmentManager().beginTransaction().replace(R.id.content_frame,
            new MyPreferenceFragment()).commit();
    this.setDefaultKeyMode(DEFAULT_KEYS_DISABLE);
}
 
Example 6
Source File: MainActivity.java    From YouTube-In-Background with MIT License 6 votes vote down vote up
/**
 * Save app theme color in preferences
 */
private void setColors(int backgroundColor, int textColor)
{
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(backgroundColor);
    toolbar.setTitleTextColor(textColor);
    TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
    tabs.setBackgroundColor(backgroundColor);
    tabs.setTabTextColors(textColor, textColor);
    SharedPreferences sp = PreferenceManager
            .getDefaultSharedPreferences(this);
    sp.edit().putInt("BACKGROUND_COLOR", backgroundColor).apply();
    sp.edit().putInt("TEXT_COLOR", textColor).apply();

    initialColors[0] = backgroundColor;
    initialColors[1] = textColor;
}
 
Example 7
Source File: DConnectSettingCompatPageFragmentActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
/**
 * ViewPagerを持つレイアウトを自動的に設定する.
 * サブクラスでオーバーライドする場合は setContentView を<strong>実行しないこと</strong>。
 * 
 * @param savedInstanceState パラメータ
 * @see android.app.Activity#onCreate(Bundle)
 */
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting_page);

    mViewPager = (ViewPager) findViewById(R.id.setting_pager);
    mViewPager.setAdapter(new DConnectFragmentPagerAdapter(getSupportFragmentManager(), this));
    Toolbar toolbar = new Toolbar(this);
    toolbar.setTitle(org.deviceconnect.android.deviceplugin.chromecast.R.string.activity_setting_page_title);
    toolbar.setBackgroundColor(Color.parseColor("#00a0e9"));
    toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
    addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    toolbar.setNavigationIcon(org.deviceconnect.android.deviceplugin.chromecast.R.drawable.close_icon);
    toolbar.setNavigationOnClickListener((view) -> {
        finish();
    });
    setSupportActionBar(toolbar);
}
 
Example 8
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 5 votes vote down vote up
public static void setActivityToolbarPosition(int duration, Toolbar aMainToolbar, Toolbar aDecorativeToolbar, Activity aActivity, float fromToolbarPosition, float toToolbarPosition, float fromMainToolbarPosition, float toMainToolbarPosition) {
    duration = Math.max(duration, 0);

    float distanceToMoveY = toToolbarPosition - fromToolbarPosition;
    float DECORATIVE_TOOLBAR_HEIGHT = -1 * aActivity.getResources().getDimension(R.dimen.additional_toolbar_height);
    float toTranslationY = Math.max(distanceToMoveY, DECORATIVE_TOOLBAR_HEIGHT);

    // We want to make sure the toolbar is as close to the final position as possible without being visible.
    // This ensures that the animation is only running when the toolbar is visible to the user.
    if (aDecorativeToolbar.getY() < DECORATIVE_TOOLBAR_HEIGHT) {
        aDecorativeToolbar.setY(DECORATIVE_TOOLBAR_HEIGHT);
        toTranslationY = (DECORATIVE_TOOLBAR_HEIGHT - toToolbarPosition) * -1;
    }

    Animation moveToolbarAnimation = new TranslateAnimation(0, 0, 0, toTranslationY);
    moveToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    moveToolbarAnimation.setDuration(duration);
    moveToolbarAnimation.setFillAfter(true);

    float toDeltaY = toMainToolbarPosition - fromMainToolbarPosition;
    Animation moveMainToolbarAnimation = new TranslateAnimation(0, 0, 0, toDeltaY);
    moveMainToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    moveMainToolbarAnimation.setDuration(duration);
    moveMainToolbarAnimation.setFillAfter(true);

    aMainToolbar.setBackgroundColor(Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, aActivity));
    aMainToolbar.startAnimation(moveMainToolbarAnimation);
    aDecorativeToolbar.startAnimation(moveToolbarAnimation);
}
 
Example 9
Source File: LicensesActivity.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_licenses);
	
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	toolbar.setBackgroundColor(getResources().getColor(R.color.bar_overlay));
	setSupportActionBar(toolbar);
	
	getSupportActionBar().setHomeButtonEnabled(true);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	
	getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.activity_background));
	
	final TextView content = (TextView) findViewById(R.id.about_licenses_text);
	
	((APDE) getApplication()).getTaskManager().launchTask("loadLicenses", false, this, true, new Task() {
		@Override
		public void run() {
			final String text = APDE.readAssetFile(LicensesActivity.this, "licenses.txt");
			
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					content.setText(text);
				}
			});
		}
		
		@Override
		public CharSequence getTitle() {
			return getResources().getString(R.string.pref_about_licenses);
		}
	});
}
 
Example 10
Source File: LibraryManagerActivity.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_library_manager);
	
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	toolbar.setBackgroundColor(getResources().getColor(R.color.bar_overlay));
	setSupportActionBar(toolbar);
	
	getSupportActionBar().setHomeButtonEnabled(true);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	
	getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.activity_background));
}
 
Example 11
Source File: MessageGroupContacts.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_message_group_members);

    final Bundle bundle = getIntent().getExtras();

    int colorPrimary = BundleKey.colorPrimary.get(bundle);
    int colorStatus = BundleKey.colorPrimaryStatus.get(bundle);

    Toolbar mToolbar = this.findViewById(R.id.message_group_members_toolbar);
    mToolbar.setTitle(getResources().getString(R.string.message_group_contacts));
    mToolbar.setBackgroundColor(colorPrimary);
    getWindow().setStatusBarColor(colorStatus);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    FloatingActionButton mFAB = this.findViewById(R.id.message_group_members_fab);

    mFAB.setOnClickListener(v -> startActivity(new Intent(MessageGroupContacts.this, NewMessageActivity.class).putExtras(bundle)));

    RecyclerView mRecycler = this.findViewById(R.id.message_group_members_recycler);

    List<Friend> friends = Arrays.asList(Friend.lorem, Friend.john);

    LinearLayoutManager mLayoutManager = new LinearLayoutManager(getBaseContext());
    mRecycler.setLayoutManager(mLayoutManager);

    adapter = new FriendsRecyclerHeaderAdapter(friends, this);
    mRecycler.setAdapter(adapter);
    mRecycler.addItemDecoration(new StickyRecyclerHeadersDecoration(adapter));
}
 
Example 12
Source File: MessageActivity.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
private void initToolbar() {
    Toolbar mToolbar = this.findViewById(R.id.message_toolbar);
    mToolbar.setBackgroundColor(contactColorPrimary);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    getWindow().setStatusBarColor(contactColorStatus);

    overlayAttachments = this.findViewById(R.id.fragment_attachments_slide);
    RelativeLayout header = this.findViewById(R.id.message_header);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT
    );
    params.addRule(RelativeLayout.CENTER_VERTICAL);

    switch (typeOfMessage) {
        case 0:
            header.addView(getLayoutInflater().inflate(R.layout.message_header_user, null, true), params);
            header.<CircleImageView>findViewById(R.id.message_header_user_img).setImageResource(imgSRC);
            header.setOnClickListener(v -> startOverLayFriend());
            break;

        default:
            header.addView(getLayoutInflater().inflate(R.layout.message_header_group, null, true), params);
            header.setOnClickListener(v -> startActivity(new Intent(MessageActivity.this, MessageGroupContacts.class).putExtras(SBundle(
                    BundleKey.colorPrimary.map(contactColorPrimary),
                    BundleKey.colorPrimaryStatus.map(contactColorStatus)
            ))));
    }

    TextView mUserName = header.findViewById(R.id.message_header_title);
    mUserName.setText(title);
}
 
Example 13
Source File: FileSendActivity.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_files_send);

    Bundle bundle = getIntent().getExtras();

    int colorPrimary = BundleKey.contactColorPrimary.get(bundle);
    int colorStatus = BundleKey.contactColorStatus.get(bundle);
    String userName = BundleKey.contactName.get(bundle);

    getWindow().setStatusBarColor(colorStatus);

    Toolbar mToolbar = this.findViewById(R.id.files_send_toolbar);
    mToolbar.setBackgroundColor(colorPrimary);
    mToolbar.setTitle(getResources().getString(R.string.files_send_title) + " " + userName);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    RecyclerView mRecycler = this.findViewById(R.id.files_send_recycler);
    List<File> list = Collections.singletonList(File.file);

    LinearLayoutManager mLayoutManager = new LinearLayoutManager(getBaseContext());
    mRecycler.setLayoutManager(mLayoutManager);

    mRecycler.setAdapter(new FileSendActivityAdapter(list));
}
 
Example 14
Source File: AnimationService.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 5 votes vote down vote up
public static void setActivityToolbarPosition(int duration, Toolbar aMainToolbar, Toolbar aDecorativeToolbar, Activity aActivity, float fromToolbarPosition, float toToolbarPosition, float fromMainToolbarPosition, float toMainToolbarPosition) {
	duration = duration < 0 ? 0 : duration;

	float distanceToMoveY = toToolbarPosition - fromToolbarPosition;
	float DECORATIVE_TOOLBAR_HEIGHT = -1 * aActivity.getResources().getDimension(R.dimen.additional_toolbar_height);
	float toTranslationY = (distanceToMoveY < DECORATIVE_TOOLBAR_HEIGHT) ? DECORATIVE_TOOLBAR_HEIGHT : distanceToMoveY;

	// We want to make sure the toolbar is as close to the final position as possible without being visible.
	// This ensures that the animation is only running when the toolbar is visible to the user.
	if(aDecorativeToolbar.getY() < DECORATIVE_TOOLBAR_HEIGHT) {
		aDecorativeToolbar.setY(DECORATIVE_TOOLBAR_HEIGHT);
		toTranslationY = (DECORATIVE_TOOLBAR_HEIGHT - toToolbarPosition) * -1;
	}

	Animation moveToolbarAnimation = new TranslateAnimation(0, 0, 0, toTranslationY);
	moveToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
	moveToolbarAnimation.setDuration(duration);
	moveToolbarAnimation.setFillAfter(true);

	float toDeltaY = toMainToolbarPosition - fromMainToolbarPosition;
	Animation moveMainToolbarAnimation = new TranslateAnimation(0, 0, 0, toDeltaY);
	moveMainToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
	moveMainToolbarAnimation.setDuration(duration);
	moveMainToolbarAnimation.setFillAfter(true);

	aMainToolbar.setBackgroundColor(Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, aActivity));
	aMainToolbar.startAnimation(moveMainToolbarAnimation);
	aDecorativeToolbar.startAnimation(moveToolbarAnimation);
}
 
Example 15
Source File: ScreenStackHeaderConfig.java    From react-native-screens with MIT License 5 votes vote down vote up
public ScreenStackHeaderConfig(Context context) {
  super(context);
  setVisibility(View.GONE);

  mToolbar = new Toolbar(context);
  mDefaultStartInset = mToolbar.getContentInsetStart();
  mDefaultStartInsetWithNavigation = mToolbar.getContentInsetStartWithNavigation();

  // set primary color as background by default
  TypedValue tv = new TypedValue();
  if (context.getTheme().resolveAttribute(android.R.attr.colorPrimary, tv, true)) {
    mToolbar.setBackgroundColor(tv.data);
  }
}
 
Example 16
Source File: BaseActivity.java    From Easy_xkcd with Apache License 2.0 4 votes vote down vote up
/**
 * Sets up the colors of toolbar, status bar and nav drawer
 */
protected void setupToolbar(Toolbar toolbar) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Bitmap ic = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_easy_xkcd_recents);
        int color = themePrefs.getPrimaryColor(false);
        ActivityManager.TaskDescription description = new ActivityManager.TaskDescription("Easy xkcd", ic, color);
        setTaskDescription(description);

        if (!(this instanceof MainActivity)) {
            getWindow().setStatusBarColor(themePrefs.getPrimaryDarkColor());
        }

        int navBarColor;
        int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
        int flagForLightNavBar = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0;
        TypedValue backgroundColor = new TypedValue();
        getTheme().resolveAttribute(android.R.attr.windowBackground, backgroundColor, true);

        if (themePrefs.nightThemeEnabled()) {
            uiOptions = uiOptions & Integer.reverse(flagForLightNavBar);

            if (themePrefs.amoledThemeEnabled()) {
                navBarColor = Color.BLACK;
            } else if (backgroundColor.type >= TypedValue.TYPE_FIRST_COLOR_INT && backgroundColor.type <= TypedValue.TYPE_LAST_COLOR_INT) {
                navBarColor = backgroundColor.data;
            } else {
                navBarColor = Color.BLACK;
            }
        } else {
            uiOptions = uiOptions | flagForLightNavBar;

            if (backgroundColor.type >= TypedValue.TYPE_FIRST_COLOR_INT && backgroundColor.type <= TypedValue.TYPE_LAST_COLOR_INT &&
                    Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                navBarColor = backgroundColor.data;
            } else {
                navBarColor = Color.BLACK;
            }
        }
        getWindow().setNavigationBarColor(navBarColor);
        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setBackgroundColor(themePrefs.getPrimaryColor(false));
    if (themePrefs.amoledThemeEnabled()) {
        toolbar.setPopupTheme(R.style.ThemeOverlay_AmoledBackground);
    }

}
 
Example 17
Source File: MessageRecallActivity.java    From toktok-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recall_message);

    Bundle bundle = getIntent().getExtras();

    int colorPrimary = BundleKey.colorPrimary.get(bundle);
    int colorStatus = BundleKey.colorPrimaryStatus.get(bundle);

    Toolbar mToolbar = this.findViewById(R.id.recall_toolbar);
    mToolbar.setBackgroundColor(colorPrimary);
    getWindow().setStatusBarColor(colorStatus);

    mFAB = this.findViewById(R.id.recall_fab);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    RecyclerView mRecycler = this.findViewById(R.id.recall_recycler);

    List<Message> messages = new ArrayList<>();
    messages.add(new Message(
            MessageType.Delivered,
            "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
            "23th of April",
            R.drawable.lorem
    ));
    for (int i = 0; i < 10; i++) {
        messages.add(new Message(
                MessageType.Delivered,
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                "24th of April",
                R.drawable.lorem
        ));
    }

    mRecycler.setLayoutManager(new LayoutManager(this));

    adapter = new MessageRecallRecyclerAdapter(this, messages, this);

    mRecycler.setAdapter(adapter);
}
 
Example 18
Source File: PostImage.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_post_image);

    imagesList=getIntent().getParcelableArrayListExtra("imagesList");

    if(imagesList.isEmpty()){
        finish();
    }

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("New Image Post");

    int nightModeFlags=getResources().getConfiguration().uiMode& Configuration.UI_MODE_NIGHT_MASK;
    if(nightModeFlags==UI_MODE_NIGHT_NO){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int flags=getWindow().getDecorView().getSystemUiVisibility();
            flags|=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            getWindow().getDecorView().setSystemUiVisibility(flags);
        }
        toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDarkk));
    }

    try {
        getSupportActionBar().setTitle("New Image Post");
    } catch (Exception e) {
        e.printStackTrace();
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    postMap = new HashMap<>();

    pager=findViewById(R.id.pager);
    indicator=findViewById(R.id.indicator);
    indicator_holder=findViewById(R.id.indicator_holder);

    indicator.setDotsClickable(true);
    adapter=new PagerPhotosAdapter(this,imagesList);
    pager.setAdapter(adapter);

    if(imagesList.size()>1){
        indicator_holder.setVisibility(View.VISIBLE);
        indicator.setViewPager(pager);
    }else{
        indicator_holder.setVisibility(GONE);
    }

    mFirestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();
    mCurrentUser = mAuth.getCurrentUser();

    sharedPreferences=getSharedPreferences("uploadservice",MODE_PRIVATE);
    serviceCount=sharedPreferences.getInt("count",0);

    mEditText = findViewById(R.id.text);

    compressor=new Compressor(this)
            .setQuality(85)
            .setCompressFormat(Bitmap.CompressFormat.PNG);

    mDialog = new ProgressDialog(this);
    mStorage=FirebaseStorage.getInstance().getReference();

}
 
Example 19
Source File: GitHistoryActivity.java    From APDE with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_git_history);
	
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	toolbar.setBackgroundColor(getResources().getColor(R.color.bar_overlay));
	setSupportActionBar(toolbar);
	
	getSupportActionBar().setHomeButtonEnabled(true);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	
	getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.activity_background));
	
	//Get a list of commits
	
	repo = new GitRepository(((APDE) getApplicationContext()).getSketchLocation());
	//TODO Implement infinite scrolling with dynamic loading for sketches with lots of commits
	commits = repo.getRecentCommits(-1);
	commitMessages = repo.getRecentCommitMessages(commits, 72);
	commitMessages.add(0, ((APDE) getApplication()).getString(R.string.git_history_local_changes));
	commitMessages.add(((APDE) getApplication()).getString(R.string.git_history_empty_repository));
	
	repo.close();
	
	if (savedInstanceState != null) {
		commitListFragment = (CommitListFragment) getSupportFragmentManager().getFragment(savedInstanceState, "commitList");
		commitDiffFragment = (CommitDiffFragment) getSupportFragmentManager().getFragment(savedInstanceState, "commitDiff");
	}
	
	if (getResources().getBoolean(R.bool.tablet_multi_pane)) {
		if (commitListFragment == null) {
			commitListFragment = new CommitListFragment();
			loadFragment(commitListFragment, R.id.git_history_commit_list_frame, false);
		}
		
		if (commitDiffFragment == null) {
			commitDiffFragment = new CommitDiffFragment();
			loadFragment(commitDiffFragment, R.id.git_history_commit_diff_frame, false);
		}
	} else {
		if (commitListFragment == null) {
			commitListFragment = new CommitListFragment();
			loadFragment(commitListFragment, R.id.git_history_frame, false);
		}
	}
}
 
Example 20
Source File: CommentsActivity.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_post_comments);

    mFirestore = FirebaseFirestore.getInstance();
    mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();

    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Comments");
    int nightModeFlags=getResources().getConfiguration().uiMode& Configuration.UI_MODE_NIGHT_MASK;
    if(nightModeFlags==UI_MODE_NIGHT_NO){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int flags=getWindow().getDecorView().getSystemUiVisibility();
            flags|=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            getWindow().getDecorView().setSystemUiVisibility(flags);
        }
        toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDarkk));
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle("Comments");

    user_image=findViewById(R.id.comment_admin);
    post_desc=findViewById(R.id.comment_post_desc);

    Cursor rs = new UserHelper(this).getData(1);
    rs.moveToFirst();

    String image = rs.getString(rs.getColumnIndex(UserHelper.CONTACTS_COLUMN_IMAGE));

    if (!rs.isClosed()) {
        rs.close();
    }

    Glide.with(this)
            .setDefaultRequestOptions(new RequestOptions().placeholder(R.drawable.default_profile_picture))
            .load(image)
            .into(user_image);

    setupCommentView();

}