-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
5,419 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
|
||
<activity | ||
android:theme="@style/ProvisionTheme" | ||
android:name=".activity.ProvisionActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:theme="@style/ProvisionTheme" | ||
android:name=".activity.PermissionSettingsActivity" | ||
android:exported="true"/> | ||
|
||
<activity | ||
android:theme="@style/ProvisionTheme" | ||
android:name=".activity.TermsAndStatementActivity" | ||
android:exported="true"/> | ||
|
||
<activity | ||
android:theme="@style/ProvisionTheme" | ||
android:name=".activity.BasicSettingsActivity" | ||
android:exported="true"/> | ||
|
||
<activity | ||
android:theme="@style/ProvisionTheme" | ||
android:name=".activity.CongratulationActivity" | ||
android:exported="true"/> | ||
|
||
<service android:name=".service.ProvisionAnimService" | ||
android:enabled="true" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action | ||
android:name="fan.intent.action.OOBSERVICE" /> | ||
<category | ||
android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
|
||
</manifest> |
158 changes: 158 additions & 0 deletions
158
provision/src/main/java/com/sevtinge/provision/activity/BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package com.sevtinge.provision.activity; | ||
|
||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import androidx.core.content.ContextCompat; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentTransaction; | ||
|
||
import com.sevtinge.provision.R; | ||
import com.sevtinge.provision.utils.OobeUtils; | ||
import com.sevtinge.provision.utils.PageIntercepHelper; | ||
|
||
public abstract class BaseActivity extends ProvisionBaseActivity { | ||
|
||
protected Fragment mFragment; | ||
|
||
private boolean mCheckNewJump = true; | ||
private boolean mIsDisableBack = false; | ||
|
||
private View.OnClickListener mBackListener = _ -> onBackPressed(); | ||
|
||
protected abstract Fragment getFragment(); | ||
protected abstract String getFragmentTag(); | ||
|
||
protected abstract int getLogoDrawableId(); | ||
protected abstract int getPreviewDrawable(); | ||
protected abstract int getTitleStringId(); | ||
protected abstract CharSequence getListDescCharSequence(); | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
if (OobeUtils.isProvisioned(this)) { | ||
setResult(-1); | ||
finish(); | ||
} else { | ||
mIsDisableBack = getIntent().getBooleanExtra("extra_disable_back", false); | ||
FragmentManager fragmentManager = getSupportFragmentManager(); | ||
if (fragmentManager.isDestroyed()) { | ||
setResult(-1); | ||
finish(); | ||
} else { | ||
mFragment = fragmentManager.findFragmentByTag(getFragmentTag()); | ||
if (mFragment == null) { | ||
FragmentTransaction beginTransaction = fragmentManager.beginTransaction(); | ||
mFragment = getFragment(); | ||
beginTransaction.replace(R.id.provision_container, mFragment, getFragmentTag()); | ||
beginTransaction.commit(); | ||
} | ||
if (getTitleStringId() > 0) { | ||
setTitle(getTitleStringId()); | ||
} else { | ||
setTitle(getTitleStringText()); | ||
} | ||
|
||
if (getPreviewDrawable() > 0) { | ||
setPreviewDrawable(getPreviewDrawable()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
protected String getTitleStringText() { | ||
return ""; | ||
} | ||
|
||
protected CharSequence getDescriptionContent() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
if (mTitle != null) { | ||
mTitle.setTextDirection(OobeUtils.isRTL() ? 4 : 3); | ||
int titleStringId = getTitleStringId(); | ||
if (titleStringId > 0) { | ||
mTitle.setText(titleStringId); | ||
} | ||
} | ||
if (mNewBackBtn != null && !mIsDisableBack && !hasPreview()) { | ||
mNewBackBtn.setOnClickListener(mBackListener); | ||
} | ||
if (mFragment != null) { | ||
View description = mFragment.getView().findViewById(R.id.list_description); | ||
if (description != null && (description instanceof TextView)) { | ||
CharSequence listDescCharSequence = getListDescCharSequence(); | ||
if (listDescCharSequence != null) { | ||
description.setTextDirection(OobeUtils.isRTL() ? 4 : 3); | ||
TextView textView = (TextView) description; | ||
textView.setText(listDescCharSequence); | ||
description.setVisibility(View.VISIBLE); | ||
} else { | ||
description.setVisibility(View.GONE); | ||
} | ||
} | ||
View view = mFragment.getView().findViewById(R.id.description); | ||
if (view != null && view instanceof TextView) { | ||
CharSequence descriptionContent = getDescriptionContent(); | ||
if (!TextUtils.isEmpty(descriptionContent)) { | ||
view.setTextDirection(OobeUtils.isRTL() ? 4 : 3); | ||
((TextView) view).setText(descriptionContent); | ||
view.setVisibility(View.VISIBLE); | ||
} else { | ||
view.setVisibility(View.GONE); | ||
} | ||
} | ||
} | ||
} | ||
|
||
protected void additionalProcess() { | ||
setResult(0); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (!mIsDisableBack) { | ||
try { | ||
additionalProcess(); | ||
if (!getSupportFragmentManager().isDestroyed()) { | ||
super.onBackPressed(); | ||
} | ||
if (mFragment != null) { | ||
mFragment.getClass(); | ||
} | ||
} catch (Exception e) { | ||
Log.e("BaseActivity", "ex: " + e.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
protected void setPreviewDrawable(int id) { | ||
if (mImageView != null) { | ||
setPreviewView(ContextCompat.getDrawable(this, id)); | ||
} | ||
} | ||
|
||
public void setCheck(boolean jump) { | ||
mCheckNewJump = jump; | ||
} | ||
|
||
|
||
@Override | ||
public void finish() { | ||
if (PageIntercepHelper.getInstance().isAdapterNewJump(this) && mCheckNewJump) { | ||
PageIntercepHelper.getInstance().sendFinish(this); | ||
setResult(PageIntercepHelper.getInstance().getPlaceHolderCode(this)); | ||
} else { | ||
super.finish(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.