MindSpore掌中宝1.2.0开发完成

pull/11825/head
hukang hwx963878 4 years ago
parent 07b2314b73
commit 4c0dce8272

@ -7,8 +7,8 @@ android {
applicationId "com.mindspore.himindspore"
minSdkVersion 21
targetSdkVersion 30
versionCode 6
versionName "1.1.4"
versionCode 7
versionName "1.2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
@ -53,24 +53,30 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.google.android.material:material:1.2.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.trello.rxlifecycle2:rxlifecycle:2.2.2'
implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.alibaba:arouter-api:1.5.1'
annotationProcessor 'com.alibaba:arouter-compiler:1.5.1'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation project(':posenet')
implementation project(':common')
implementation project(':customView')
implementation project(':imageObject')
implementation project(':styletransfer')
implementation project(':segmentation')

@ -11,7 +11,6 @@
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEM" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.INTERNET" />
<application
@ -22,14 +21,19 @@
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:replace="android:label"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:replace="android:label">
<activity
android:name=".ui.main.MainActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
<meta-data
android:name="com.google.android.actions"
android:resource="@xml/style_file_paths" />
<activity
android:name=".SplashActivity"
android:name=".ui.guide.SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
@ -43,12 +47,12 @@
android:name="androidx.core.content.FileProvider"
android:authorities="com.mindspore.himindspore.fileprovider"
android:exported="false"
tools:replace="android:authorities"
android:grantUriPermissions="true">
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
tools:replace="android:resource"
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/style_file_paths" />
android:resource="@xml/style_file_paths"
tools:replace="android:resource" />
</provider>
</application>

@ -15,10 +15,11 @@
*/
package com.mindspore.himindspore.base;
import android.app.Activity;
import android.os.Bundle;
public abstract class BaseActivity<T extends BasePresenter> extends Activity {
import androidx.appcompat.app.AppCompatActivity;
public abstract class BaseActivity<T extends BasePresenter> extends AppCompatActivity {
protected T presenter;

@ -19,12 +19,11 @@ import android.app.Application;
import com.alibaba.android.arouter.BuildConfig;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mindspore.common.utils.Utils;
public class MyApplication extends Application {
private static final String appKey = "31f0c1ffe8168";
private static final String appSecret = "83e393ced2b9f31771fcb81e1b7a049a";
@Override
public void onCreate() {
@ -34,5 +33,6 @@ public class MyApplication extends Application {
ARouter.openDebug();
}
ARouter.init(this);
Utils.init(this);
}
}

@ -0,0 +1,46 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.bean;
import com.mindspore.customview.tablayout.listener.CustomTabEntity;
public class TabEntity implements CustomTabEntity {
public String title;
public int selectedIcon;
public int unSelectedIcon;
public TabEntity(String title, int selectedIcon, int unSelectedIcon) {
this.title = title;
this.selectedIcon = selectedIcon;
this.unSelectedIcon = unSelectedIcon;
}
@Override
public String getTabTitle() {
return title;
}
@Override
public int getTabSelectedIcon() {
return selectedIcon;
}
@Override
public int getTabUnselectedIcon() {
return unSelectedIcon;
}
}

@ -0,0 +1,93 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.comment;
import com.mindspore.himindspore.ui.college.CollegeFragment;
import com.mindspore.himindspore.ui.experience.ExperienceFragment;
import com.mindspore.himindspore.ui.experience.VisionFragment;
import com.mindspore.himindspore.ui.me.MeFragment;
public class FragmentFactory {
private static FragmentFactory mInstance;
private ExperienceFragment mExperienceFragment;
private CollegeFragment mCollegeFragment;
private MeFragment mMeFragment;
private VisionFragment mVisionFragment;
private FragmentFactory() {
}
public static FragmentFactory getInstance() {
if (mInstance == null) {
synchronized (FragmentFactory.class) {
if (mInstance == null) {
mInstance = new FragmentFactory();
}
}
}
return mInstance;
}
public ExperienceFragment getExperienceFragment() {
if (mExperienceFragment == null) {
synchronized (FragmentFactory.class) {
if (mExperienceFragment == null) {
mExperienceFragment = new ExperienceFragment();
}
}
}
return mExperienceFragment;
}
public CollegeFragment getCollegeFragment() {
if (mCollegeFragment == null) {
synchronized (FragmentFactory.class) {
if (mCollegeFragment == null) {
mCollegeFragment = new CollegeFragment();
}
}
}
return mCollegeFragment;
}
public MeFragment getMeFragment() {
if (mMeFragment == null) {
synchronized (FragmentFactory.class) {
if (mMeFragment == null) {
mMeFragment = new MeFragment();
}
}
}
return mMeFragment;
}
public VisionFragment getVisionFragment() {
if (mVisionFragment == null) {
synchronized (FragmentFactory.class) {
if (mVisionFragment == null) {
mVisionFragment = new VisionFragment();
}
}
}
return mVisionFragment;
}
}

@ -1,3 +1,18 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.net;
import java.io.File;

@ -1,3 +1,18 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.net;
import java.util.concurrent.TimeUnit;

@ -1,3 +1,18 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.net;
import io.reactivex.Observable;

@ -1,3 +1,18 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.net;
public class UpdateInfoBean {

@ -0,0 +1,172 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.college;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mindspore.common.config.MSLinkUtils;
import com.mindspore.common.sp.Preferences;
import com.mindspore.common.utils.Utils;
import com.mindspore.customview.dialog.NoticeDialog;
import com.mindspore.himindspore.R;
import com.mindspore.himindspore.ui.college.adapter.CollegeItemAdapter;
import com.mindspore.himindspore.ui.college.bean.CollegeItemBean;
import java.util.Arrays;
import java.util.List;
public class CollegeFragment extends Fragment implements CollegeItemAdapter.CollegeItemClickListener {
private RecyclerView collegeRecycleView;
private CollegeItemAdapter collegeItemAdapter;
private List<CollegeItemBean> collegeDataList;
private SharedPreferences prefs;
public CollegeFragment() {
// Required empty public constructor
}
public static CollegeFragment newInstance() {
CollegeFragment fragment;
fragment = new CollegeFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_college, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
collegeRecycleView = view.findViewById(R.id.recyclerview);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
collegeItemAdapter = new CollegeItemAdapter(collegeDataList);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
collegeRecycleView.setLayoutManager(layoutManager);
collegeRecycleView.setAdapter(collegeItemAdapter);
collegeItemAdapter.setCollegeItemClickListener(this);
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
prefs = PreferenceManager.getDefaultSharedPreferences(Utils.getApp());
initData();
}
private void initData() {
collegeDataList = Arrays.asList(
new CollegeItemBean(CollegeItemBean.TYPE_LEFT_IMAGE_RIGHT_TEXT,
R.drawable.college_summary_uncheck, R.drawable.college_summary_checked,
getString(R.string.college_summary_title), prefs.getBoolean(Preferences.KEY_COLLEGE_SUMMARY, false)),
new CollegeItemBean(CollegeItemBean.TYPE_LEFT_IMAGE_RIGHT_TEXT,
R.drawable.college_cloud_uncheck, R.drawable.college_cloud_checked,
getString(R.string.college_cloud_title), prefs.getBoolean(Preferences.KEY_COLLEGE_CLOUD, false)),
new CollegeItemBean(CollegeItemBean.TYPE_MIX,
R.drawable.college_quick_uncheck, R.drawable.college_quick_checked,
getString(R.string.college_quick_title), prefs.getBoolean(Preferences.KEY_COLLEGE_QUICK, false)),
new CollegeItemBean(CollegeItemBean.TYPE_LEFT_IMAGE_RIGHT_TEXT,
R.drawable.college_faq_uncheck, R.drawable.college_faq_checked,
getString(R.string.college_faq_title), prefs.getBoolean(Preferences.KEY_COLLEGE_FAQ, false)),
new CollegeItemBean(CollegeItemBean.TYPE_LEFT_IMAGE_RIGHT_TEXT,
R.drawable.college_ask_uncheck, R.drawable.college_ask_checked,
getString(R.string.college_ask_title), prefs.getBoolean(Preferences.KEY_COLLEGE_ASK, false)),
new CollegeItemBean(CollegeItemBean.TYPE_PURE_TEXT,
-1, -1, getString(R.string.college_light_title), false));
}
private void showSumaryDialog() {
NoticeDialog noticeDialog = new NoticeDialog(getActivity());
noticeDialog.setTitleString(getString(R.string.college_dialog_title));
noticeDialog.setContentString(getString(R.string.college_dialog_content));
noticeDialog.setGravity(Gravity.START);
noticeDialog.setShowBottomLogo(true);
noticeDialog.setYesOnclickListener(() -> {
noticeDialog.dismiss();
});
noticeDialog.show();
}
@Override
public void onCollegeItemClickListener(int position) {
switch (position) {
case 0:
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_SUMMARY, true).apply();
collegeDataList.get(0).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_SUMMARY, false));
collegeItemAdapter.notifyData();
showSumaryDialog();
break;
case 1:
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_CLOUD, true).apply();
collegeDataList.get(1).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_CLOUD, false));
collegeItemAdapter.notifyData();
Utils.openBrowser(getActivity(), MSLinkUtils.COLLEGE_MAIN_CLOUD);
break;
case 3:
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_FAQ, true).apply();
collegeDataList.get(3).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_FAQ, false));
collegeItemAdapter.notifyData();
Utils.openBrowser(getActivity(), MSLinkUtils.COLLEGE_MAIN_FAQ);
break;
case 4:
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_ASK, true).apply();
collegeDataList.get(4).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_ASK, false));
collegeItemAdapter.notifyData();
Utils.openBrowser(getActivity(), MSLinkUtils.COLLEGE_MAIN_ASK);
break;
}
}
@Override
public void onCollegeChildItemClickListener(int position) {
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_QUICK_ARRAY[position], true).apply();
boolean isHasCheckedTrain = prefs.getBoolean(Preferences.KEY_COLLEGE_TRAIN, false);
boolean isHasCheckedExecute = prefs.getBoolean(Preferences.KEY_COLLEGE_EXECUTE, false);
boolean isHasCheckedApp = prefs.getBoolean(Preferences.KEY_COLLEGE_APP, false);
boolean isHasCheckedVideo = prefs.getBoolean(Preferences.KEY_COLLEGE_VIDEO, false);
prefs.edit().putBoolean(Preferences.KEY_COLLEGE_QUICK, isHasCheckedTrain && isHasCheckedExecute && isHasCheckedApp && isHasCheckedVideo).apply();
collegeDataList.get(2).setHasChecked(prefs.getBoolean(Preferences.KEY_COLLEGE_QUICK, false));
collegeItemAdapter.notifyData();
Utils.openBrowser(getActivity(), MSLinkUtils.COLLEGE_QUICK_WEB_ARRAY[position]);
}
}

@ -0,0 +1,61 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.college.bean;
public class CollegeItemBean {
private int itemType;
private int imageUncheck;
private int imagechecked;
private String title;
private boolean isHasChecked;
public static final int TYPE_LEFT_IMAGE_RIGHT_TEXT = 1;
public static final int TYPE_MIX = 2;
public static final int TYPE_PURE_TEXT = 3;
public CollegeItemBean(int itemType, int imageUncheck,int imagechecked, String title,boolean isHasChecked) {
this.itemType = itemType;
this.imageUncheck = imageUncheck;
this.imagechecked = imagechecked;
this.title = title;
this.isHasChecked = isHasChecked;
}
public int getItemType() {
return itemType;
}
public int getImageUncheck() {
return imageUncheck;
}
public int getImagechecked() {
return imagechecked;
}
public String getTitle() {
return title;
}
public boolean isHasChecked() {
return isHasChecked;
}
public CollegeItemBean setHasChecked(boolean hasChecked) {
isHasChecked = hasChecked;
return this;
}
}

@ -0,0 +1,79 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.experience;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
import com.mindspore.common.base.adapter.BasePagerAdapter;
import com.mindspore.himindspore.R;
import com.mindspore.himindspore.comment.FragmentFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ExperienceFragment extends Fragment {
private TabLayout tabLayout;
private ViewPager vpContent;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_experience, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
tabLayout = view.findViewById(R.id.tab_layout);
vpContent = view.findViewById(R.id.vp_content);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initData();
}
public void initData() {
List<Fragment> fragmentList = new ArrayList<>();
String[] categoryName = this.getResources().getStringArray(R.array.tab_experience);
fragmentList.add(FragmentFactory.getInstance().getVisionFragment());
BasePagerAdapter adapter = new BasePagerAdapter(getChildFragmentManager(), fragmentList, Arrays.asList(categoryName));
vpContent.setAdapter(adapter);
tabLayout.setupWithViewPager(vpContent);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
vpContent.setOffscreenPageLimit(categoryName.length);
}
}

@ -0,0 +1,110 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.experience;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mindspore.himindspore.R;
/**
* A simple {@link Fragment} subclass.
* Use the {@link VisionFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@Route(path = "/app/VisionFragment")
public class VisionFragment extends Fragment implements View.OnClickListener {
public VisionFragment() {
// Required empty public constructor
}
public static VisionFragment newInstance(String param1, String param2) {
VisionFragment fragment = new VisionFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_vision, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.btn_object).setOnClickListener(this); //onClickPhotoDetection
view.findViewById(R.id.btn_object_camera).setOnClickListener(this); //onClickCameraDetection
view.findViewById(R.id.btn_posenet).setOnClickListener(this); //onClickPoseNet
view.findViewById(R.id.btn_style_transfer).setOnClickListener(this); //onClickStyleTransfer
view.findViewById(R.id.btn_segmentation).setOnClickListener(this); //onClickSegmentation
view.findViewById(R.id.btn_image).setOnClickListener(this); //onClickImage
view.findViewById(R.id.btn_image_garbage).setOnClickListener(this); //onClickGarbage
view.findViewById(R.id.btn_scene).setOnClickListener(this); //onClickSceneDetection
}
@SuppressLint("NonConstantResourceId")
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_object:
ARouter.getInstance().build("/imageobject/ObjectPhotoActivity").navigation();
break;
case R.id.btn_object_camera:
ARouter.getInstance().build("/imageobject/ObjectCameraActivity").navigation();
break;
case R.id.btn_posenet:
ARouter.getInstance().build("/posenet/PosenetMainActivity").navigation();
break;
case R.id.btn_style_transfer:
ARouter.getInstance().build("/styletransfer/StyleMainActivity").navigation();
break;
case R.id.btn_segmentation:
ARouter.getInstance().build("/segmentation/SegmentationMainActivity").navigation();
break;
case R.id.btn_image:
ARouter.getInstance().build("/imageobject/ImageCameraActivity")
.withInt("OPEN_TYPE", 1).navigation();
break;
case R.id.btn_image_garbage:
ARouter.getInstance().build("/imageobject/ImageCameraActivity")
.withInt("OPEN_TYPE", 2).navigation();
break;
case R.id.btn_scene:
ARouter.getInstance().build("/imageobject/ImageCameraActivity")
.withInt("OPEN_TYPE", 3).navigation();
break;
}
}
}

@ -0,0 +1,173 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.guide;
import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import com.mindspore.customview.countdown.CountDownView;
import com.mindspore.himindspore.R;
import com.mindspore.himindspore.base.BaseActivity;
import com.mindspore.himindspore.ui.main.MainActivity;
import java.util.List;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;
public class SplashActivity extends BaseActivity implements EasyPermissions.PermissionCallbacks {
private static final String TAG = "SplashActivity";
private static final String[] PERMISSIONS = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA};
private static final int REQUEST_PERMISSION = 1;
private CountDownView cdvTime;
@Override
protected void init() {
cdvTime = findViewById(R.id.cdv_time);
initCountDownView();
}
private void initCountDownView() {
cdvTime.setTime(3);
cdvTime.start();
cdvTime.setOnLoadingFinishListener(new CountDownView.OnLoadingFinishListener() {
@Override
public void finish() {
Log.e("AAA","setOnLoadingFinishListener");
startPermissionsTask();
}
});
cdvTime.setOnClickListener(view -> {
Log.e("AAA","setOnClickListener");
cdvTime.stop();
startPermissionsTask();
});
}
@Override
public int getLayout() {
return R.layout.activity_splash;
}
@AfterPermissionGranted(REQUEST_PERMISSION)
private void startPermissionsTask() {
if (hasPermissions()) {
setHandler();
} else {
EasyPermissions.requestPermissions(this,
this.getResources().getString(R.string.app_need_permission),
REQUEST_PERMISSION, PERMISSIONS);
}
}
private boolean hasPermissions() {
return EasyPermissions.hasPermissions(this, PERMISSIONS);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
EasyPermissions.onRequestPermissionsResult(requestCode,
permissions, grantResults, SplashActivity.this);
}
@Override
public void onPermissionsGranted(int requestCode, List<String> perms) {
}
@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
if (EasyPermissions.somePermissionPermanentlyDenied(SplashActivity.this, perms)) {
openAppDetails();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == AppSettingsDialog.DEFAULT_SETTINGS_REQ_CODE) {
setHandler();
}
}
private void openAppDetails() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getResources().getString(R.string.app_need_permission));
builder.setPositiveButton(getResources().getString(R.string.app_permission_by_hand), (dialog, which) -> {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.parse("package:" + getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(intent);
});
builder.setNegativeButton(getResources().getString(R.string.cancel), null);
builder.show();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
}
private void setHandler() {
// new Handler().postDelayed(() -> {
// enterMainView();
// }, 3000);
enterMainView();
}
private void enterMainView() {
Log.e("AAA","enterMainView");
Intent intent = new Intent();
intent.setClass(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (cdvTime != null && cdvTime.isShown()) {
cdvTime.stop();
}
}
}

@ -0,0 +1,234 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.main;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.mindspore.common.base.adapter.BasePagerAdapter;
import com.mindspore.customview.dialog.UpdateDialog;
import com.mindspore.customview.tablayout.CommonTabLayout;
import com.mindspore.customview.tablayout.listener.CustomTabEntity;
import com.mindspore.customview.tablayout.listener.OnTabSelectListener;
import com.mindspore.himindspore.R;
import com.mindspore.himindspore.base.BaseActivity;
import com.mindspore.himindspore.comment.FragmentFactory;
import com.mindspore.himindspore.net.FileDownLoadObserver;
import com.mindspore.himindspore.net.UpdateInfoBean;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View {
private static final String TAG = "MainActivity";
private ViewPager mVpHome;
private CommonTabLayout mCtlTable;
private int now_version;
private ProgressDialog progressDialog;
@Override
protected void init() {
presenter = new MainPresenter(this);
mVpHome = findViewById(R.id.vp_home);
mCtlTable = findViewById(R.id.ctl_table);
showPackaeInfo();
initTabLayout();
initViewPager();
getUpdateInfo();
}
@Override
public int getLayout() {
return R.layout.activity_main;
}
private void showPackaeInfo() {
try {
PackageManager packageManager = this.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(this.getPackageName(), 0);
now_version = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
private void initTabLayout() {
ArrayList<CustomTabEntity> mTabEntities = presenter.getTabEntity();
mCtlTable.setTabData(mTabEntities);
mCtlTable.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelect(int position) {
mVpHome.setCurrentItem(position);
}
@Override
public void onTabReselect(int position) {
}
});
}
/**
* ViewPager
*/
private void initViewPager() {
List<Fragment> fragments = new ArrayList<>();
fragments.add(FragmentFactory.getInstance().getExperienceFragment());
fragments.add(FragmentFactory.getInstance().getCollegeFragment());
fragments.add(FragmentFactory.getInstance().getMeFragment());
BasePagerAdapter adapter = new BasePagerAdapter(getSupportFragmentManager(), fragments);
mVpHome.setAdapter(adapter);
mVpHome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (position >= 0) {
mCtlTable.setCurrentTab(position);
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mVpHome.setOffscreenPageLimit(3);
mVpHome.setCurrentItem(0);
}
private void getUpdateInfo() {
presenter.getUpdateInfo();
}
@Override
public void showUpdateResult(UpdateInfoBean bean) {
showUpdate(bean);
}
@Override
public void showFail(String s) {
}
public void downSuccess() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setTitle(getResources().getString(R.string.app_download_success));
builder.setMessage(getResources().getString(R.string.app_need_install));
builder.setCancelable(false);
builder.setPositiveButton(getResources().getString(R.string.confirm), (dialog, which) -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri contentUri = FileProvider.getUriForFile(MainActivity.this, "com.mindspore.himindspore.fileprovider",
new File(getApkPath(), "HiMindSpore.apk"));
intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
} else {
intent.setDataAndType(Uri.fromFile(new File(getApkPath(), "HiMindSpore.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
startActivity(intent);
});
builder.setNegativeButton(getResources().getString(R.string.cancel), (dialog, which) -> {
});
builder.create().show();
}
public void showUpdate(final UpdateInfoBean updateInfo) {
if (now_version != updateInfo.getVersionCode()) {
UpdateDialog updateDialog= new UpdateDialog(this);
updateDialog.setTitleString(getResources().getString(R.string.app_update_lastest) + updateInfo.getVersionName());
updateDialog.setContentString(updateInfo.getMessage());
updateDialog.setYesOnclickListener(() -> downFile());
updateDialog.setNoOnclickListener(() -> updateDialog.dismiss());
updateDialog.show();
}
}
public void downFile() {
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle(getResources().getString(R.string.app_is_loading));
progressDialog.setMessage(getResources().getString(R.string.app_wait));
progressDialog.setProgressNumberFormat("%1d Mb/%2d Mb");
progressDialog.setProgress(0);
progressDialog.show();
presenter.downloadApk(getApkPath(), "HiMindSpore.apk", new FileDownLoadObserver<File>() {
@Override
public void onDownLoadSuccess(File file) {
downSuccess();
}
@Override
public void onDownLoadFail(Throwable throwable) {
Toast.makeText(MainActivity.this, getResources().getString(R.string.app_load_fail), Toast.LENGTH_LONG).show();
}
@Override
public void onProgress(final int progress, final long total) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressDialog.setMax((int) total / 1024 / 1024);
progressDialog.setProgress(progress);
}
});
}
});
Log.d(TAG, "downFile: ");
}
public String getApkPath() {
String directoryPath = "";
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
directoryPath = getExternalFilesDir("apk").getAbsolutePath();
} else {
directoryPath = getFilesDir() + File.separator + "apk";
}
File file = new File(directoryPath);
if (!file.exists()) {
file.mkdirs();
}
return directoryPath;
}
}

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,25 +13,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.mvp;
package com.mindspore.himindspore.ui.main;
import com.mindspore.customview.tablayout.listener.CustomTabEntity;
import com.mindspore.himindspore.net.FileDownLoadObserver;
import com.mindspore.himindspore.net.UpdateInfoBean;
import java.io.File;
import java.util.ArrayList;
public interface MainContract {
interface View {
interface View {
void showUpdateResult(UpdateInfoBean object);
void showFail(String s);
}
interface Presenter {
interface Presenter {
ArrayList<CustomTabEntity> getTabEntity();
void getUpdateInfo();
void downloadApk(String destDir, String fileName, FileDownLoadObserver<File> fileDownLoadObserver);
}
}

@ -1,6 +1,5 @@
package com.mindspore.himindspore.mvp;
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,49 +13,72 @@ package com.mindspore.himindspore.mvp;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.main;
import android.content.res.TypedArray;
import android.util.Log;
import com.mindspore.himindspore.SplashActivity;
import com.mindspore.common.utils.Utils;
import com.mindspore.customview.tablayout.listener.CustomTabEntity;
import com.mindspore.himindspore.R;
import com.mindspore.himindspore.base.BasePresenter;
import com.mindspore.himindspore.bean.TabEntity;
import com.mindspore.himindspore.net.FileDownLoadObserver;
import com.mindspore.himindspore.net.RetrofitHelper;
import com.mindspore.himindspore.net.UpdateInfoBean;
import java.io.File;
import java.util.ArrayList;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainPresenter extends BasePresenter<SplashActivity> implements MainContract.Presenter {
public class MainPresenter extends BasePresenter<MainActivity> implements MainContract.Presenter {
private static final String TAG = "MainPresenter";
private MainContract.View mView;
private RetrofitHelper retrofitHelper;
public MainPresenter(SplashActivity mainActivity) {
this.view = mainActivity;
public MainPresenter(MainContract.View androidView) {
this.mView = androidView;
retrofitHelper = new RetrofitHelper();
}
@Override
public ArrayList<CustomTabEntity> getTabEntity() {
ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
TypedArray mIconUnSelectIds = Utils.getApp().getResources().obtainTypedArray(R.array.main_tab_un_select);
TypedArray mIconSelectIds = Utils.getApp().getResources().obtainTypedArray(R.array.main_tab_select);
String[] mainTitles = Utils.getApp().getResources().getStringArray(R.array.main_tab_title);
for (int i = 0; i < mainTitles.length; i++) {
int unSelectId = mIconUnSelectIds.getResourceId(i, R.drawable.experience_uncheck);
int selectId = mIconSelectIds.getResourceId(i, R.drawable.experience_checked);
mTabEntities.add(new TabEntity(mainTitles[i],selectId , unSelectId));
}
mIconUnSelectIds.recycle();
mIconSelectIds.recycle();
return mTabEntities;
}
@Override
public void getUpdateInfo() {
retrofitHelper.getUpdateInfo().enqueue(new Callback<UpdateInfoBean>() {
@Override
public void onResponse(Call<UpdateInfoBean> call, Response<UpdateInfoBean> response) {
Log.i(TAG, "onResponse" + response.toString());
view.showUpdateResult(response.body());
mView.showUpdateResult(response.body());
}
@Override
public void onFailure(Call<UpdateInfoBean> call, Throwable t) {
Log.e(TAG, "onFailure>>>" + t.toString());
view.showFail(call.toString());
mView.showFail(call.toString());
}
});
}
@ -67,14 +89,8 @@ public class MainPresenter extends BasePresenter<SplashActivity> implements Main
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.observeOn(Schedulers.computation())
.map(new Function<ResponseBody, File>() {
@Override
public File apply(@NonNull ResponseBody responseBody) throws Exception {
return fileDownLoadObserver.saveFile(responseBody, destDir, fileName);
}
})
.map(responseBody -> fileDownLoadObserver.saveFile(responseBody, destDir, fileName))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(fileDownLoadObserver);
}
}

@ -0,0 +1,102 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mindspore.himindspore.ui.me;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.mindspore.common.config.MSLinkUtils;
import com.mindspore.common.utils.Utils;
import com.mindspore.himindspore.R;
public class MeFragment extends Fragment implements View.OnClickListener {
private final String TAG = "MeFragment";
private TextView versionText;
@Override
public View onCreateView(
@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_me, container, false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
versionText = view.findViewById(R.id.me_vision);
view.findViewById(R.id.rl_me_share).setOnClickListener(this);
view.findViewById(R.id.rl_me_thumbsup).setOnClickListener(this);
view.findViewById(R.id.rl_me_official).setOnClickListener(this);
view.findViewById(R.id.rl_me_official_code).setOnClickListener(this);
view.findViewById(R.id.rl_me_qa).setOnClickListener(this);
view.findViewById(R.id.rl_me_version).setOnClickListener(this);
showPackageInfo();
}
public void onClickShare() {
Intent share_intent = new Intent();
share_intent.setAction(Intent.ACTION_SEND);
share_intent.setType("text/plain");
share_intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.title_share));
share_intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.title_share_commend) + MSLinkUtils.ME_APK_URL);
share_intent = Intent.createChooser(share_intent, getString(R.string.title_share));
startActivity(share_intent);
}
private void showPackageInfo() {
try {
PackageManager packageManager = this.getActivity().getPackageManager();
PackageInfo packageInfo = packageManager
.getPackageInfo(this.getActivity().getPackageName(), 0);
versionText.setText("V" + packageInfo.versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.rl_me_share:
onClickShare();
break;
case R.id.rl_me_thumbsup:
Utils.openBrowser(getActivity(), MSLinkUtils.ME_STAR_URL);
break;
case R.id.rl_me_official:
Utils.openBrowser(getActivity(), MSLinkUtils.BASE_URL);
break;
case R.id.rl_me_official_code:
Utils.openBrowser(getActivity(), MSLinkUtils.ME_CODE_URL);
break;
case R.id.rl_me_qa:
Utils.openBrowser(getActivity(), MSLinkUtils.ME_HELP_URL);
break;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save