Creating single config activity controller

This commit is contained in:
Michael Wain 2024-12-11 03:10:14 +03:00
parent e04adc7fbc
commit 12dfe42379
6 changed files with 54 additions and 2 deletions

View File

@ -78,6 +78,7 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
ControllerManager.putController(new MainActivityController()); ControllerManager.putController(new MainActivityController());
this.controller = (MainActivityController) ControllerManager.getController(ControllerId.MainActivityController); this.controller = (MainActivityController) ControllerManager.getController(ControllerId.MainActivityController);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);

View File

@ -9,18 +9,33 @@ import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import com.alterdekim.fridaapp.R; import com.alterdekim.fridaapp.R;
import com.alterdekim.fridaapp.controller.ControllerId;
import com.alterdekim.fridaapp.controller.ControllerManager;
import com.alterdekim.fridaapp.controller.SingleConfigActivityController;
public class SingleConfigActivity extends AppCompatActivity { public class SingleConfigActivity extends AppCompatActivity {
private static final String TAG = SingleConfigActivity.class.getSimpleName();
private SingleConfigActivityController controller;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
EdgeToEdge.enable(this); EdgeToEdge.enable(this);
setContentView(R.layout.activity_single_config); setContentView(R.layout.activity_single_config);
ControllerManager.putController(new SingleConfigActivityController());
this.controller = (SingleConfigActivityController) ControllerManager.getController(ControllerId.SingleConfigActivityController);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets; return insets;
}); });
} }
} }

View File

@ -1,5 +1,6 @@
package com.alterdekim.fridaapp.controller; package com.alterdekim.fridaapp.controller;
public enum ControllerId { public enum ControllerId {
MainActivityController MainActivityController,
SingleConfigActivityController
} }

View File

@ -12,6 +12,7 @@ import androidx.room.Room;
import com.alterdekim.fridaapp.R; import com.alterdekim.fridaapp.R;
import com.alterdekim.fridaapp.activity.MainActivity; import com.alterdekim.fridaapp.activity.MainActivity;
import com.alterdekim.fridaapp.activity.SingleConfigActivity;
import com.alterdekim.fridaapp.room.AppDatabase; import com.alterdekim.fridaapp.room.AppDatabase;
import com.alterdekim.fridaapp.room.Config; import com.alterdekim.fridaapp.room.Config;
import com.alterdekim.fridaapp.service.FridaService; import com.alterdekim.fridaapp.service.FridaService;
@ -63,6 +64,10 @@ public class MainActivityController implements IController {
view_switch.setUseMaterialThemeColors(true); view_switch.setUseMaterialThemeColors(true);
view_switch.setOnCheckedChangeListener((compoundButton, b) -> toggleVpn(view_switch, config, b)); view_switch.setOnCheckedChangeListener((compoundButton, b) -> toggleVpn(view_switch, config, b));
view_name.setText(config.getTitle()); view_name.setText(config.getTitle());
view_name.setOnClickListener(view -> {
Intent intent = new Intent(this.mainActivity, SingleConfigActivity.class);
this.mainActivity.startActivity(intent);
});
if( iter.hasNext() ) this.mainActivity.getCfg_list().addView(inflater.inflate(R.layout.single_divider, this.mainActivity.getCfg_list(), false)); if( iter.hasNext() ) this.mainActivity.getCfg_list().addView(inflater.inflate(R.layout.single_divider, this.mainActivity.getCfg_list(), false));
} }
}) })

View File

@ -0,0 +1,18 @@
package com.alterdekim.fridaapp.controller;
import androidx.appcompat.app.AppCompatActivity;
public class SingleConfigActivityController implements IController {
private static final String TAG = SingleConfigActivityController.class.getSimpleName();
@Override
public ControllerId getControllerId() {
return ControllerId.SingleConfigActivityController;
}
@Override
public void onCreateGUI(AppCompatActivity activity) {
}
}

View File

@ -22,11 +22,13 @@
android:textColor="@color/grey" android:textColor="@color/grey"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="normal" /> android:textStyle="normal" />
<TextView <TextView
android:id="@+id/interface_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start" android:layout_gravity="start"
android:text="de.yaml" android:text="yaml"
android:textAllCaps="false" android:textAllCaps="false"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="14sp" android:textSize="14sp"
@ -40,7 +42,9 @@
android:textColor="@color/grey" android:textColor="@color/grey"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="normal" /> android:textStyle="normal" />
<TextView <TextView
android:id="@+id/public_key"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start" android:layout_gravity="start"
@ -58,7 +62,9 @@
android:textColor="@color/grey" android:textColor="@color/grey"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="normal" /> android:textStyle="normal" />
<TextView <TextView
android:id="@+id/address"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start" android:layout_gravity="start"
@ -76,7 +82,9 @@
android:textColor="@color/grey" android:textColor="@color/grey"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="normal" /> android:textStyle="normal" />
<TextView <TextView
android:id="@+id/endpoint"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start" android:layout_gravity="start"
@ -103,6 +111,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout <LinearLayout
android:id="@+id/switch_all"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
@ -121,6 +130,7 @@
</LinearLayout> </LinearLayout>
<!-- android:background="@drawable/layout_swr" --> <!-- android:background="@drawable/layout_swr" -->
<LinearLayout <LinearLayout
android:id="@+id/switch_dis"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"> android:layout_weight="1">
@ -145,12 +155,14 @@
android:layout_weight="1"> android:layout_weight="1">
<LinearLayout <LinearLayout
android:id="@+id/apps_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" /> android:orientation="vertical" />
</ScrollView> </ScrollView>
<Button <Button
android:id="@+id/add_app"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_gravity="center" android:layout_gravity="center"