lay out the skeleton of SetupWizardActivity
This commit is contained in:
parent
c2d7c45db5
commit
2b544a223b
|
@ -43,6 +43,11 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Setup Wizard -->
|
||||
<activity android:name=".ui.SetupWizardActivity"
|
||||
android:theme="@style/SuwThemeMaterial.Light"
|
||||
android:launchMode="singleTask" />
|
||||
|
||||
<!-- The Settings activity -->
|
||||
<activity android:name=".ui.SettingsActivity"
|
||||
android:label="@string/settings" />
|
||||
|
|
|
@ -102,16 +102,17 @@ public class MainActivity extends AppCompatActivity {
|
|||
finish();
|
||||
} else if (!mStorage.getBoolean(LocalStorageManager.PREF_HAS_SETUP)) {
|
||||
// Reset the authentication key first
|
||||
AuthenticationUtility.reset();
|
||||
//AuthenticationUtility.reset();
|
||||
// If not set up yet, we have to provision the profile first
|
||||
new AlertDialog.Builder(this)
|
||||
/*new AlertDialog.Builder(this)
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.first_run_alert)
|
||||
.setPositiveButton(R.string.first_run_alert_continue,
|
||||
(dialog, which) -> setupProfile())
|
||||
.setNegativeButton(R.string.first_run_alert_cancel,
|
||||
(dialog, which) -> finish())
|
||||
.show();
|
||||
.show();*/
|
||||
startActivity(new Intent(this, SetupWizardActivity.class));
|
||||
} else {
|
||||
// Initialize the settings
|
||||
SettingsManager.getInstance().applyAll();
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package net.typeblog.shelter.ui;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.setupwizardlib.SetupWizardLayout;
|
||||
import com.android.setupwizardlib.view.NavigationBar;
|
||||
|
||||
import net.typeblog.shelter.R;
|
||||
|
||||
public class SetupWizardActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setup_wizard);
|
||||
switchToFragment(new WelcomeFragment());
|
||||
}
|
||||
|
||||
private<T extends BaseWizardFragment> void switchToFragment(T fragment) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.setup_wizard_container, fragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
private static abstract class BaseWizardFragment extends Fragment implements NavigationBar.NavigationBarListener {
|
||||
protected SetupWizardActivity mActivity = null;
|
||||
protected SetupWizardLayout mWizard = null;
|
||||
|
||||
protected abstract int getLayoutResource();
|
||||
|
||||
@Override
|
||||
public void onNavigateBack() {
|
||||
// For sub-classes to implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
// For sub-classes to implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
mActivity = (SetupWizardActivity) getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mActivity = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(getLayoutResource(), container, false);
|
||||
mWizard = view.findViewById(R.id.wizard);
|
||||
mWizard.getNavigationBar().setNavigationBarListener(this);
|
||||
mWizard.setLayoutBackground(ContextCompat.getDrawable(inflater.getContext(), R.color.colorAccent));
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
protected static abstract class TextWizardFragment extends BaseWizardFragment {
|
||||
protected abstract int getTextRes();
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
TextView tv = view.findViewById(R.id.setup_wizard_generic_text);
|
||||
tv.setText(getTextRes());
|
||||
}
|
||||
}
|
||||
|
||||
public static class WelcomeFragment extends TextWizardFragment {
|
||||
@Override
|
||||
protected int getLayoutResource() {
|
||||
return R.layout.fragment_setup_wizard_generic_text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTextRes() {
|
||||
return R.string.setup_wizard_welcome_text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mWizard.setHeaderText(R.string.setup_wizard_welcome);
|
||||
mWizard.getNavigationBar().getBackButton().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
8
app/src/main/res/layout/activity_setup_wizard.xml
Normal file
8
app/src/main/res/layout/activity_setup_wizard.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/setup_wizard_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.SetupWizardActivity" />
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.android.setupwizardlib.SetupWizardLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/wizard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/setup_wizard_generic_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="40dp" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</com.android.setupwizardlib.SetupWizardLayout>
|
|
@ -8,6 +8,10 @@
|
|||
<string name="device_admin_explanation">Shelter needs to become Device Admin in order to perform its isolation tasks.</string>
|
||||
<string name="camera_proxy_activity">Choose an Image File</string>
|
||||
|
||||
<!-- Setup Wizard -->
|
||||
<string name="setup_wizard_welcome">Welcome to Shelter</string>
|
||||
<string name="setup_wizard_welcome_text">Shelter is an application to help you run other applications in an isolated profile. It does so by making use of the <b>Work Profile</b> feature of Android.\n\nClick "Next", and we will provide you with more information about Shelter, and guide you through the setup process.</string>
|
||||
|
||||
<!-- Notifications -->
|
||||
<string name="notifications_important">Shelter Important</string>
|
||||
<string name="finish_provision_title">Click here to finish setting up Shelter</string>
|
||||
|
|
Loading…
Reference in a new issue