Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
android:theme="@style/OrbotActivityTheme" />

<activity
android:theme="@style/OrbotActivityMaterialTheme"
android:name=".ui.v3onionservice.OnionServiceActivity"
android:label="@string/v3_hosted_services" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ListView;
import android.widget.RadioButton;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;

import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import org.torproject.android.R;
Expand All @@ -31,7 +31,8 @@ public class OnionServiceActivity extends BaseActivity {
private static final String BASE_WHERE_SELECTION_CLAUSE = OnionServiceColumns.CREATED_BY_USER + "=";
private static final String BUNDLE_KEY_SHOW_USER_SERVICES = "show_user_key";
private static final int REQUEST_CODE_READ_ZIP_BACKUP = 347;
private RadioButton radioShowUserServices;
private MaterialButton btnShowUserServices;
private MaterialButton btnShowAppServices;
private FloatingActionButton fab;
private ContentResolver mContentResolver;
private OnionV3ListAdapter mAdapter;
Expand All @@ -44,10 +45,10 @@ public void onCreate(Bundle bundle) {
setContentView(R.layout.activity_hosted_services);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

Toolbar toolbar = findViewById(R.id.toolbar);
MaterialToolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
var sab = getSupportActionBar();
if (sab != null) sab.setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(v -> getOnBackPressedDispatcher().onBackPressed());

mLayoutRoot = findViewById(R.id.hostedServiceCoordinatorLayout);
fab = findViewById(R.id.fab);
Expand All @@ -59,11 +60,27 @@ public void onCreate(Bundle bundle) {

ListView onionList = findViewById(R.id.onion_list);

radioShowUserServices = findViewById(R.id.radioUserServices);
RadioButton radioShowAppServices = findViewById(R.id.radioAppServices);
boolean showUserServices = radioShowAppServices.isChecked() || bundle == null || bundle.getBoolean(BUNDLE_KEY_SHOW_USER_SERVICES, false);
if (showUserServices) radioShowUserServices.setChecked(true);
else radioShowAppServices.setChecked(true);
btnShowUserServices = findViewById(R.id.radioUserServices);
btnShowAppServices = findViewById(R.id.radioAppServices);

btnShowUserServices.setOnClickListener(v -> {
btnShowUserServices.setBackgroundColor(ContextCompat.getColor(this, R.color.orbot_btn_enabled_purple));
btnShowAppServices.setBackgroundColor(ContextCompat.getColor(this, R.color.orbot_btn_disable_grey));
filterServices(true);
});

btnShowAppServices.setOnClickListener(v -> {
btnShowUserServices.setBackgroundColor(ContextCompat.getColor(this, R.color.orbot_btn_disable_grey));
btnShowAppServices.setBackgroundColor(ContextCompat.getColor(this, R.color.orbot_btn_enabled_purple));
filterServices(false);
});

boolean showUserServices = btnShowAppServices.isChecked() || bundle == null || bundle.getBoolean(BUNDLE_KEY_SHOW_USER_SERVICES, false);
if (showUserServices) {
btnShowUserServices.setChecked(true);
} else {
btnShowAppServices.setChecked(true);
}
filterServices(showUserServices);
onionList.setAdapter(mAdapter);
onionList.setOnItemClickListener((parent, view, position, id) -> {
Expand Down Expand Up @@ -98,9 +115,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
}

@Override
protected void onSaveInstanceState(@NonNull Bundle icicle) {
super.onSaveInstanceState(icicle);
icicle.putBoolean(BUNDLE_KEY_SHOW_USER_SERVICES, radioShowUserServices.isChecked());
protected void onSaveInstanceState(@NonNull Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putBoolean(BUNDLE_KEY_SHOW_USER_SERVICES, btnShowUserServices.isChecked());
}

@Override
Expand All @@ -122,14 +139,6 @@ protected void onActivityResult(int requestCode, int result, Intent data) {
}
}

public void onRadioButtonClick(View view) {
int id = view.getId();
if (id == R.id.radioUserServices)
filterServices(true);
else if (id == R.id.radioAppServices)
filterServices(false);
}

private class OnionServiceObserver extends ContentObserver {

OnionServiceObserver(Handler handler) {
Expand All @@ -138,7 +147,7 @@ private class OnionServiceObserver extends ContentObserver {

@Override
public void onChange(boolean selfChange) {
filterServices(radioShowUserServices.isChecked()); // updates adapter
filterServices(btnShowUserServices.isChecked());
showBatteryOptimizationsMessageIfAppropriate();
}
}
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/layout/activity_hosted_services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>
android:layout_height="?attr/actionBarSize"
android:background="@color/new_background"
app:titleTextColor="@android:color/white"
app:titleCentered="true" />

</com.google.android.material.appbar.AppBarLayout>

Expand All @@ -28,7 +31,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginEnd="@dimen/fab_margin"
android:tint="@android:color/black"
app:fabSize="normal"
app:backgroundTint="@color/progress_bar_purple"
Expand Down
34 changes: 19 additions & 15 deletions app/src/main/res/layout/layout_hs_list_view_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,39 @@
tools:context="org.torproject.android.ui.v3onionservice.OnionServiceActivity"
tools:showIn="@layout/activity_hosted_services">


<TextView
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:text="@string/service_type" />

<RadioGroup
android:paddingStart="-5dp"
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggleButtonGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:orientation="horizontal"
tools:ignore="RtlSymmetry">
app:singleSelection="true">

<RadioButton
<com.google.android.material.button.MaterialButton
android:id="@+id/radioUserServices"
android:layout_width="140dp"
style="@style/SegmentedButtonStyle"
android:backgroundTint="@color/orbot_btn_enabled_purple"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClick"
android:text="@string/user_services" />
android:layout_weight="1"
android:text="@string/user_services"
app:cornerRadius="10dp" />

<RadioButton
<com.google.android.material.button.MaterialButton
android:id="@+id/radioAppServices"
android:layout_width="140dp"
style="@style/SegmentedButtonStyle"
android:backgroundTint="@color/orbot_btn_disable_grey"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClick"
android:text="@string/app_services" />
</RadioGroup>
android:layout_weight="1"
android:text="@string/app_services"
app:cornerRadius="10dp" />
</com.google.android.material.button.MaterialButtonToggleGroup>

<ListView
android:id="@+id/onion_list"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
<style name="BottomSheetRadio" parent="android:Widget.CompoundButton.RadioButton">
<item name="buttonTint">@color/menu_header</item>
</style>

<style name="SegmentedButtonStyle" parent="Widget.MaterialComponents.Button">
<item name="android:foreground">?attr/selectableItemBackground</item>
<item name="android:textColor">@color/panel_background_main</item>
<item name="android:textAppearance">@style/TextAppearance.Material3.TitleMedium</item>
</style>

</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<item name="colorPrimaryDark">@color/new_background_secondary</item>
</style>

<style name="OrbotActivityMaterialTheme" parent="Theme.MaterialComponents.NoActionBar">
<item name="android:statusBarColor">@color/new_background_secondary</item>
<item name="android:windowBackground">@color/new_background_secondary</item>
<item name="android:windowIsFloating">false</item>
<item name="colorPrimary">@color/new_background_secondary</item>
<item name="colorPrimaryDark">@color/new_background_secondary</item>
</style>

<style name="OrbotDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:background">@color/new_background_secondary</item>
<item name="android:textColor">@android:color/white</item>
Expand Down