Skip to content

Commit

Permalink
Set fit system to backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
captainepoch committed Dec 2, 2024
1 parent be5b92e commit 30da901
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.keylesspalace.tusky;

import static org.koin.java.KoinJavaComponent.inject;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -50,7 +51,6 @@
import java.util.HashMap;
import java.util.List;
import kotlin.Lazy;
import static org.koin.java.KoinJavaComponent.inject;
import timber.log.Timber;

public abstract class BaseActivity extends AppCompatActivity {
Expand Down Expand Up @@ -92,6 +92,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
requesters = new HashMap<>();
}

@Override
public void setContentView(View view) {
super.setContentView(view);

view.setFitsSystemWindows(true);
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(HuskyApplication.getLocaleManager().setLocale(base));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.keylesspalace.tusky.appstore.StatusComposedEvent;
import com.keylesspalace.tusky.components.compose.ComposeActivity;
import static com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions;
import com.keylesspalace.tusky.databinding.ActivitySavedTootBinding;
import com.keylesspalace.tusky.db.AppDatabase;
import com.keylesspalace.tusky.db.TootDao;
import com.keylesspalace.tusky.db.TootEntity;
Expand All @@ -56,7 +57,9 @@
public final class SavedTootActivity extends BaseActivity
implements SavedTootAdapter.SavedTootAction
{
// ui

// UI
private ActivitySavedTootBinding binding;
private SavedTootAdapter adapter;
private BackgroundMessageView errorMessageView;
private List<TootEntity> toots = new ArrayList<>();
Expand All @@ -76,9 +79,10 @@ protected void onCreate(Bundle savedInstanceState) {
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
.subscribe((__) -> this.fetchToots());

setContentView(R.layout.activity_saved_toot);
binding = ActivitySavedTootBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

Toolbar toolbar = findViewById(R.id.toolbar);
Toolbar toolbar = binding.includedToolbar.toolbar;
setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar();
if(bar != null) {
Expand All @@ -87,8 +91,8 @@ protected void onCreate(Bundle savedInstanceState) {
bar.setDisplayShowHomeEnabled(true);
}

RecyclerView recyclerView = findViewById(R.id.recyclerView);
errorMessageView = findViewById(R.id.errorMessageView);
RecyclerView recyclerView = binding.recyclerView;
errorMessageView = binding.errorMessageView;
recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/* Copyright 2017 Andrew Dawson
/*
* Husky -- A Pleroma client for Android
*
* This file is a part of Tusky.
* Copyright (C) 2022 The Husky Developers
* Copyright (C) 2017 Andrew Dawson
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.keylesspalace.tusky;

Expand All @@ -24,12 +29,14 @@
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.keylesspalace.tusky.databinding.ActivityViewTagBinding;
import com.keylesspalace.tusky.fragment.TimelineFragment;
import java.util.Collections;

public class ViewTagActivity extends BottomSheetActivity {

private static final String HASHTAG = "hashtag";
private ActivityViewTagBinding binding;

public static Intent getIntent(Context context, String tag) {
Intent intent = new Intent(context, ViewTagActivity.class);
Expand All @@ -40,11 +47,12 @@ public static Intent getIntent(Context context, String tag) {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_tag);
binding = ActivityViewTagBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

String hashtag = getIntent().getStringExtra(HASHTAG);

Toolbar toolbar = findViewById(R.id.toolbar);
Toolbar toolbar = binding.includedToolbar.toolbar;
setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar();

Expand All @@ -56,7 +64,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
Fragment fragment = TimelineFragment.newHashtagInstance(Collections.singletonList(hashtag));
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.replace(binding.fragmentContainer.getId(), fragment);
fragmentTransaction.commit();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/* Copyright 2017 Andrew Dawson
/*
* Husky -- A Pleroma client for Android
*
* This file is a part of Tusky.
* Copyright (C) 2022 The Husky Developers
* Copyright (C) 2017 Andrew Dawson
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.keylesspalace.tusky;

Expand All @@ -24,6 +29,7 @@
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentTransaction;
import com.keylesspalace.tusky.databinding.ActivityViewThreadBinding;
import com.keylesspalace.tusky.fragment.ViewThreadFragment;

public class ViewThreadActivity extends BottomSheetActivity {
Expand All @@ -44,15 +50,16 @@ public static Intent startIntent(Context context, String id, String url) {
private static final String FRAGMENT_TAG = "ViewThreadFragment_";

private int revealButtonState = REVEAL_BUTTON_HIDDEN;

private ActivityViewThreadBinding binding;
private ViewThreadFragment fragment;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_thread);
binding = ActivityViewThreadBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

Toolbar toolbar = findViewById(R.id.toolbar);
Toolbar toolbar = binding.includedToolbar.toolbar;
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
Expand All @@ -70,7 +77,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment, FRAGMENT_TAG + id);
fragmentTransaction.replace(binding.fragmentContainer.getId(), fragment, FRAGMENT_TAG + id);
fragmentTransaction.commit();
}

Expand Down
4 changes: 3 additions & 1 deletion husky/app/src/main/res/layout/activity_saved_toot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
android:layout_height="match_parent"
tools:context="com.keylesspalace.tusky.AccountListActivity">

<include layout="@layout/toolbar_basic" />
<include
android:id="@+id/includedToolbar"
layout="@layout/toolbar_basic" />

<RelativeLayout
android:layout_width="match_parent"
Expand Down
6 changes: 4 additions & 2 deletions husky/app/src/main/res/layout/activity_view_tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
android:layout_height="match_parent"
tools:context="com.keylesspalace.tusky.ViewTagActivity">

<include layout="@layout/toolbar_basic" />
<include
android:id="@+id/includedToolbar"
layout="@layout/toolbar_basic" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
Expand All @@ -17,4 +19,4 @@

<include layout="@layout/item_status_bottom_sheet"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
6 changes: 4 additions & 2 deletions husky/app/src/main/res/layout/activity_view_thread.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
android:layout_height="match_parent"
tools:context="com.keylesspalace.tusky.ViewThreadActivity">

<include layout="@layout/toolbar_basic" />
<include
android:id="@+id/includedToolbar"
layout="@layout/toolbar_basic" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
Expand All @@ -17,4 +19,4 @@

<include layout="@layout/item_status_bottom_sheet"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 comments on commit 30da901

Please sign in to comment.