version:1.5

fix:
update:增加天气预报详情,增加系统应用模块
This commit is contained in:
2022-01-22 11:53:16 +08:00
parent be302d67e2
commit 2e9b26b100
243 changed files with 1724 additions and 238 deletions

View File

@@ -2,8 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uiui.os"
android:sharedUserId="android.uid.system">
<!-- 清单文件中, 申明监听通话精确状态权限该权限需要android:sharedUserId="android.uid.system" -->
<!-- 清单文件中, 申明监听通话精确状态权限该权限需要android:sharedUserId="android.uid.system" -->
<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
@@ -37,9 +36,12 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activity.EmergencyActivity"
android:name=".activity.weather.WeatherActivity"
android:launchMode="singleTask"
/>
android:screenOrientation="sensorLandscape" />
<activity
android:name=".activity.EmergencyActivity"
android:launchMode="singleTask" />
<activity
android:name=".activity.NoticeActivity"
android:excludeFromRecents="true"
@@ -63,7 +65,7 @@
</service>
<activity
android:name=".activity.MainActivity"
android:name=".activity.main.MainActivity"
android:clearTaskOnLaunch="true"
android:enabled="true"
android:excludeFromRecents="true"
@@ -83,7 +85,8 @@
<category android:name="android.intent.category.LAUNCHER_APP" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <!-- 高德地图 -->
</activity>
<activity android:name=".activity.APPListActivity" /> <!-- 高德地图 -->
<!-- 设置key -->
<meta-data
android:name="com.amap.api.v2.apikey"

View File

@@ -0,0 +1,94 @@
package com.uiui.os.activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.uiui.os.R;
import com.uiui.os.adapter.APPListAdapter;
import com.uiui.os.base.BaseActivity;
import com.uiui.os.bean.AppListInfo;
import com.uiui.os.utils.APKUtils;
import com.uiui.os.utils.BitmapUtils;
import com.uiui.os.view.RecyclerViewSpacesItemDecoration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class APPListActivity extends BaseActivity {
private ImageView back;
private RecyclerView mRecyclerView;
private APPListAdapter adapter;
@Override
public int getLayoutId() {
return R.layout.activity_applist;
}
@Override
public void initView() {
back = findViewById(R.id.iv_back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mRecyclerView = findViewById(R.id.recyclerview);
}
@Override
public void initData() {
List<ApplicationInfo> applicationInfoList = APKUtils.getSystemApp(APPListActivity.this);
PackageManager pm = getPackageManager();
if (null != applicationInfoList) {
List<AppListInfo> appinfoList = new ArrayList<>();
for (ApplicationInfo applicationInfo : applicationInfoList) {
AppListInfo info = new AppListInfo(
applicationInfo.loadLabel(pm).toString(),
applicationInfo.packageName,
BitmapUtils.getIconBitmap(APPListActivity.this, applicationInfo.loadIcon(pm))
);
appinfoList.add(info);
}
HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getRealMetrics(dm);
float density = dm.density; // 屏幕密度0.75 / 1.0 / 1.5
int orientation = 0;
orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 16));//top间距
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 32));//top间距
} else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 50));//top间距
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 100));//top间距
}
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 40));//top间距
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 20));//底部间距
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.LEFT_DECORATION, (int) (density * 20));//左间距
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION, (int) (density * 20));//右间距
adapter = new APPListAdapter(APPListActivity.this);
mRecyclerView.setLayoutManager(new GridLayoutManager(APPListActivity.this, 3));
// rv_list.addItemDecoration(new RecyclerItemDecoration(10, 10, 4));
mRecyclerView.addItemDecoration(new RecyclerViewSpacesItemDecoration(stringIntegerHashMap));
mRecyclerView.setAdapter(adapter);
adapter.setAppListInfos(appinfoList);
}
}
}

View File

@@ -22,6 +22,7 @@ import android.widget.TextView;
import com.uiui.os.R;
import com.uiui.os.bean.BaseResponse;
import com.uiui.os.network.NetInterfaceManager;
import com.uiui.os.utils.ToastUtil;
import java.util.ArrayList;
import java.util.Arrays;
@@ -154,6 +155,11 @@ public class EmergencyActivity extends AppCompatActivity {
phoneListSet.remove(0);
}
}, 2000);
} else {
if (phoneListSet == null) {
ToastUtil.show("没有设置紧急联系人");
finish();
}
}
}

View File

@@ -1,4 +1,4 @@
package com.uiui.os.activity;
package com.uiui.os.activity.main;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -7,7 +7,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.IBinder;
@@ -35,7 +34,6 @@ import com.uiui.os.fragment.AppListFragment;
import com.uiui.os.fragment.BaseFragmentPagerAdapter;
import com.uiui.os.fragment.CustomFragment;
import com.uiui.os.network.NetInterfaceManager;
import com.uiui.os.service.MainService;
import com.uiui.os.utils.APKUtils;
import com.uiui.os.utils.AppUsedTimeUtils;
import com.uiui.os.utils.Utils;

View File

@@ -1,4 +1,4 @@
package com.uiui.os.activity;
package com.uiui.os.activity.main;
import com.uiui.os.base.BasePresenter;
import com.uiui.os.base.BaseView;

View File

@@ -1,4 +1,4 @@
package com.uiui.os.activity;
package com.uiui.os.activity.main;
import android.content.Context;
import android.util.Log;

View File

@@ -0,0 +1,95 @@
package com.uiui.os.activity.weather;
import android.content.res.Resources;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.qweather.sdk.bean.weather.WeatherDailyBean;
import com.uiui.os.R;
import com.uiui.os.adapter.WeatherDayApdapter;
import com.uiui.os.base.BaseActivity;
import com.uiui.os.bean.WeatherDailyJson;
import com.uiui.os.utils.ScreenUtils;
import com.uiui.os.view.HorizontalItemDecoration;
import com.uiui.os.view.RecyclerItemDecoration;
import butterknife.BindView;
import butterknife.ButterKnife;
public class WeatherActivity extends BaseActivity implements WeatherContact.WeatherView {
@BindView(R.id.rv_weather)
RecyclerView rv_weather;
@BindView(R.id.tv_location)
TextView tv_location;
private WeatherPresenter mPresenter;
private WeatherDayApdapter mWeatherDayApdapter;
@Override
public int getLayoutId() {
return R.layout.activity_weather;
}
@Override
public void initView() {
ButterKnife.bind(this);
mPresenter = new WeatherPresenter(this);
mPresenter.attachView(this);
mPresenter.setLifecycle(lifecycleSubject);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
Resources resources = getResources();
rv_weather.setLayoutManager(linearLayoutManager);
rv_weather.addItemDecoration(new HorizontalItemDecoration(30, this));//10表示10dp
// rv_weather.setLayoutManager(new GridLayoutManager(this, 3));
// rv_weather.addItemDecoration(new RecyclerItemDecoration(ScreenUtils.dp2px(resources, 10), ScreenUtils.dp2px(resources, 10), 3));
mWeatherDayApdapter = new WeatherDayApdapter();
rv_weather.setAdapter(mWeatherDayApdapter);
}
@Override
public void initData() {
mPresenter.getLocation();
}
@Override
public void setLocation(String location) {
tv_location.setText(location);
mPresenter.getWeatherCache();
}
@Override
public void setWeatherCache(WeatherDailyBean weatherCache) {
if (weatherCache != null) {
mWeatherDayApdapter.setDailyBeans(weatherCache.getDaily());
}
mPresenter.getWeather();
}
@Override
public void setWeather(WeatherDailyBean weather) {
if (weather != null) {
mWeatherDayApdapter.setDailyBeans(weather.getDaily());
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
mPresenter.detachView();
}
}

View File

@@ -0,0 +1,30 @@
package com.uiui.os.activity.weather;
import com.qweather.sdk.bean.weather.WeatherDailyBean;
import com.uiui.os.base.BasePresenter;
import com.uiui.os.base.BaseView;
import com.uiui.os.bean.AlarmClockData;
import com.uiui.os.bean.WeatherDailyJson;
import java.util.List;
public class WeatherContact {
public interface Presenter extends BasePresenter<WeatherView> {
//获取定位缓存
void getLocation();
//获取天气缓存
void getWeatherCache();
//获取天气
void getWeather();
}
public interface WeatherView extends BaseView {
//设置定位缓存
void setLocation(String location);
//设置天气缓存
void setWeatherCache(WeatherDailyBean weatherCache);
//设置天气
void setWeather(WeatherDailyBean weather);
}
}

View File

@@ -0,0 +1,105 @@
package com.uiui.os.activity.weather;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import com.amap.api.location.AMapLocation;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.qweather.sdk.bean.weather.WeatherDailyBean;
import com.qweather.sdk.view.QWeather;
import com.tencent.mmkv.MMKV;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.uiui.os.bean.AlarmClockData;
import com.uiui.os.bean.BaseResponse;
import com.uiui.os.bean.WeatherDailyJson;
import com.uiui.os.network.NetInterfaceManager;
import com.uiui.os.utils.AlarmUtils;
import com.uiui.os.utils.AmapManager;
import java.lang.reflect.Type;
import java.util.List;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.subjects.BehaviorSubject;
/**
* MainActivity和MainService 的 Presenter
*
* @author jgy02
*/
public class WeatherPresenter implements WeatherContact.Presenter {
private static final String TAG = WeatherPresenter.class.getSimpleName();
private static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING";
private WeatherContact.WeatherView mView;
private Context mContext;
private MMKV mMMKV = MMKV.defaultMMKV();
private BehaviorSubject<ActivityEvent> lifecycle;
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
this.lifecycle = lifecycle;
}
public BehaviorSubject<ActivityEvent> getLifecycle() {
return lifecycle;
}
public WeatherPresenter(Context context) {
this.mContext = context;
Log.e(TAG, "WeatherPresenter: " + context.getClass());
}
@Override
public void attachView(@NonNull WeatherContact.WeatherView view) {
this.mView = view;
}
@Override
public void detachView() {
this.mView = null;
}
@Override
public void getLocation() {
AMapLocation aMapLocation = AmapManager.getInstance().getNowAMapLocation();
String location = "未知";
if (aMapLocation != null) {
location = aMapLocation.getCity() + "\t" + aMapLocation.getDistrict();
}
mView.setLocation(location);
}
@Override
public void getWeatherCache() {
// TODO: 2022/1/21 读取json反序列化排序
String jsonString = mMMKV.decodeString(WEATHER_DAILY_KEY, "");
Type type = new TypeToken<WeatherDailyBean>() {
}.getType();
WeatherDailyBean weatherDailyBean = new Gson().fromJson(jsonString, type);
mView.setWeatherCache(weatherDailyBean);
}
@Override
public void getWeather() {
QWeather.getWeather7D(mContext, AmapManager.getInstance().getLocation(), new QWeather.OnResultWeatherDailyListener() {
@Override
public void onError(Throwable throwable) {
Log.e("getWeather", "onError: " + throwable.getMessage());
mView.setWeather(null);
}
@Override
public void onSuccess(WeatherDailyBean weatherDailyBean) {
String jsonString = new Gson().toJson(weatherDailyBean);
Log.e("getWeather", "onSuccess: " + jsonString);
mMMKV.encode(WEATHER_DAILY_KEY, jsonString);
mView.setWeather(weatherDailyBean);
}
});
}
}

View File

@@ -0,0 +1,77 @@
package com.uiui.os.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.uiui.os.R;
import com.uiui.os.bean.AppListInfo;
import com.uiui.os.utils.APKUtils;
import java.util.List;
public class APPListAdapter extends RecyclerView.Adapter<APPListAdapter.holder> {
private Context mContext;
private List<AppListInfo> mAppListInfos;
public APPListAdapter(Context context) {
this.mContext = context;
}
public APPListAdapter(Context context, List<AppListInfo> list) {
this.mContext = context;
this.mAppListInfos = list;
}
public void setAppListInfos(List<AppListInfo> listInfos) {
this.mAppListInfos = listInfos;
notifyDataSetChanged();
}
@NonNull
@Override
public holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new APPListAdapter.holder(LayoutInflater.from(mContext).inflate(R.layout.item_app, parent, false));
}
@Override
public void onBindViewHolder(@NonNull holder holder, int position) {
final AppListInfo info = mAppListInfos.get(position);
holder.icon.setImageBitmap(info.getIcon());
holder.appname.setText(info.getAppName());
holder.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
APKUtils.openApp(mContext, info.getPackageName());
}
});
}
@Override
public int getItemCount() {
return mAppListInfos == null ? 0 : mAppListInfos.size();
}
class holder extends RecyclerView.ViewHolder {
private ImageView icon;
private TextView appname;
private LinearLayout root;
public holder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(R.id.iv_icon);
appname = itemView.findViewById(R.id.tv_appname);
root = itemView.findViewById(R.id.root);
}
}
}

View File

@@ -0,0 +1,106 @@
package com.uiui.os.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.Image;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.qweather.sdk.bean.weather.WeatherDailyBean;
import com.uiui.os.R;
import java.util.List;
public class WeatherDayApdapter extends RecyclerView.Adapter<WeatherDayApdapter.WeatherHolder> {
private static final String TAG = WeatherDayApdapter.class.getSimpleName();
private List<WeatherDailyBean.DailyBean> mDailyBeans;
private Context mContext;
public void setDailyBeans(List<WeatherDailyBean.DailyBean> dailyBeans) {
this.mDailyBeans = dailyBeans;
notifyDataSetChanged();
}
@NonNull
@Override
public WeatherHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
mContext = parent.getContext();
return new WeatherHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_weather, parent, false));
}
@Override
public void onBindViewHolder(@NonNull WeatherHolder holder, int position) {
WeatherDailyBean.DailyBean dailyBean = mDailyBeans.get(position);
String dateString;
switch (position) {
case 0:
dateString = "今天";
break;
case 1:
dateString = "明天";
break;
case 2:
dateString = "后天";
break;
default:
dateString = dailyBean.getFxDate();
}
holder.tv_date.setText(dateString);
holder.tv_temp.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "");
holder.tv_weather.setText(dailyBean.getTextDay());
String iconDay = dailyBean.getIconDay();
switch (iconDay) {
case "100":
case "150":
holder.iv_bg.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sun));
break;
case "102":
case "152":
holder.iv_bg.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sunny));
break;
default:
holder.iv_bg.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.background_weather_rain));
}
holder.iv_weather.setImageDrawable(getWeatherDrawable(iconDay));
}
private Drawable getWeatherDrawable(String iconName) {
int resID = mContext.getResources().getIdentifier("he" + iconName, "drawable", "com.uiui.os");
if (resID == 0) {
Log.e(TAG, "getView: not found src : " + iconName);
return mContext.getResources().getDrawable(R.drawable.he100);
} else {
return mContext.getResources().getDrawable(resID);
}
}
@Override
public int getItemCount() {
return mDailyBeans == null ? 0 : mDailyBeans.size();
}
static class WeatherHolder extends RecyclerView.ViewHolder {
TextView tv_date;
ImageView iv_weather;
ImageView iv_bg;
TextView tv_weather;
TextView tv_temp;
public WeatherHolder(@NonNull View itemView) {
super(itemView);
tv_date = itemView.findViewById(R.id.tv_date);
iv_weather = itemView.findViewById(R.id.iv_weather);
iv_bg = itemView.findViewById(R.id.iv_bg);
tv_weather = itemView.findViewById(R.id.tv_weather);
tv_temp = itemView.findViewById(R.id.tv_temp);
}
}
}

View File

@@ -0,0 +1,41 @@
package com.uiui.os.bean;
import android.graphics.Bitmap;
import java.io.Serializable;
public class AppListInfo implements Serializable {
String appName;
String packageName;
Bitmap icon;
public AppListInfo(String appName, String packageName, Bitmap icon) {
this.appName = appName;
this.packageName = packageName;
this.icon = icon;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public Bitmap getIcon() {
return icon;
}
public void setIcon(Bitmap icon) {
this.icon = icon;
}
}

View File

@@ -0,0 +1,294 @@
package com.uiui.os.bean;
import com.qweather.sdk.bean.Basic;
import com.qweather.sdk.bean.Refer;
import com.qweather.sdk.bean.base.Code;
import java.io.Serializable;
import java.util.List;
public class WeatherDailyJson implements Serializable {
private static final long serialVersionUID = 1585791680452421396L;
private Code code;
private Basic basic;
private List<DailyJson> daily;
private Refer refer;
public WeatherDailyJson() {
}
public Refer getRefer() {
return this.refer;
}
public void setRefer(Refer var1) {
this.refer = var1;
}
public Code getCode() {
return this.code;
}
public void setCode(Code var1) {
this.code = var1;
}
public Basic getBasic() {
return this.basic;
}
public void setBasic(Basic var1) {
this.basic = var1;
}
public List<DailyJson> getDaily() {
return this.daily;
}
public void setDaily(List<DailyJson> var1) {
this.daily = var1;
}
public static class DailyJson {
String fxDate = "";
String sunrise = "";
String sunset = "";
String moonRise = "";
String moonSet = "";
String moonPhase = "";
String tempMax = "";
String tempMin = "";
String iconDay = "";
String textDay = "";
String iconNight = "";
String textNight = "";
String wind360Day = "";
String windDirDay = "";
String windScaleDay = "";
String windSpeedDay = "";
String wind360Night = "";
String windDirNight = "";
String windScaleNight = "";
String windSpeedNight = "";
String humidity = "";
String precip = "";
String pressure = "";
String vis = "";
String cloud = "";
String uvIndex = "";
public DailyJson() {
}
public String getFxDate() {
return this.fxDate;
}
public void setFxDate(String var1) {
this.fxDate = var1;
}
public String getSunrise() {
return this.sunrise;
}
public void setSunrise(String var1) {
this.sunrise = var1;
}
public String getSunset() {
return this.sunset;
}
public void setSunset(String var1) {
this.sunset = var1;
}
public String getMoonRise() {
return this.moonRise;
}
public void setMoonRise(String var1) {
this.moonRise = var1;
}
public String getMoonSet() {
return this.moonSet;
}
public void setMoonSet(String var1) {
this.moonSet = var1;
}
public String getMoonPhase() {
return this.moonPhase;
}
public void setMoonPhase(String var1) {
this.moonPhase = var1;
}
public String getTempMax() {
return this.tempMax;
}
public void setTempMax(String var1) {
this.tempMax = var1;
}
public String getTempMin() {
return this.tempMin;
}
public void setTempMin(String var1) {
this.tempMin = var1;
}
public String getIconDay() {
return this.iconDay;
}
public void setIconDay(String var1) {
this.iconDay = var1;
}
public String getTextDay() {
return this.textDay;
}
public void setTextDay(String var1) {
this.textDay = var1;
}
public String getIconNight() {
return this.iconNight;
}
public void setIconNight(String var1) {
this.iconNight = var1;
}
public String getTextNight() {
return this.textNight;
}
public void setTextNight(String var1) {
this.textNight = var1;
}
public String getWind360Day() {
return this.wind360Day;
}
public void setWind360Day(String var1) {
this.wind360Day = var1;
}
public String getWindDirDay() {
return this.windDirDay;
}
public void setWindDirDay(String var1) {
this.windDirDay = var1;
}
public String getWindScaleDay() {
return this.windScaleDay;
}
public void setWindScaleDay(String var1) {
this.windScaleDay = var1;
}
public String getWindSpeedDay() {
return this.windSpeedDay;
}
public void setWindSpeedDay(String var1) {
this.windSpeedDay = var1;
}
public String getWind360Night() {
return this.wind360Night;
}
public void setWind360Night(String var1) {
this.wind360Night = var1;
}
public String getWindDirNight() {
return this.windDirNight;
}
public void setWindDirNight(String var1) {
this.windDirNight = var1;
}
public String getWindScaleNight() {
return this.windScaleNight;
}
public void setWindScaleNight(String var1) {
this.windScaleNight = var1;
}
public String getWindSpeedNight() {
return this.windSpeedNight;
}
public void setWindSpeedNight(String var1) {
this.windSpeedNight = var1;
}
public String getHumidity() {
return this.humidity;
}
public void setHumidity(String var1) {
this.humidity = var1;
}
public String getPrecip() {
return this.precip;
}
public void setPrecip(String var1) {
this.precip = var1;
}
public String getPressure() {
return this.pressure;
}
public void setPressure(String var1) {
this.pressure = var1;
}
public String getVis() {
return this.vis;
}
public void setVis(String var1) {
this.vis = var1;
}
public String getCloud() {
return this.cloud;
}
public void setCloud(String var1) {
this.cloud = var1;
}
public String getUvIndex() {
return this.uvIndex;
}
public void setUvIndex(String var1) {
this.uvIndex = var1;
}
}
}

View File

@@ -6,6 +6,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
@@ -28,7 +29,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationListener;
import com.blankj.utilcode.util.NetworkUtils;
import com.google.gson.Gson;
@@ -37,19 +37,20 @@ import com.king.view.circleprogressview.CircleProgressView;
import com.qweather.sdk.bean.base.Code;
import com.qweather.sdk.bean.base.Lang;
import com.qweather.sdk.bean.base.Unit;
import com.qweather.sdk.bean.weather.WeatherHourlyBean;
import com.qweather.sdk.bean.weather.WeatherNowBean;
import com.qweather.sdk.view.QWeather;
import com.tencent.mmkv.MMKV;
import com.uiui.os.BuildConfig;
import com.uiui.os.R;
import com.uiui.os.activity.APPListActivity;
import com.uiui.os.activity.EmergencyActivity;
import com.uiui.os.activity.weather.WeatherActivity;
import com.uiui.os.adapter.AlarmClockAdapter;
import com.uiui.os.adapter.NotificationAdapter;
import com.uiui.os.adapter.SOSNnmberAdapter;
import com.uiui.os.bean.AlarmClockData;
import com.uiui.os.bean.AlarmItem;
import com.uiui.os.bean.BaseResponse;
import com.uiui.os.network.NetInterfaceManager;
import com.uiui.os.utils.AmapManager;
import com.uiui.os.utils.APKUtils;
import com.uiui.os.utils.AppUtil;
@@ -63,9 +64,6 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
/**
@@ -74,6 +72,18 @@ import io.reactivex.rxjava3.disposables.Disposable;
* create an instance of this fragment.
*/
public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkStatusChangedListener {
@BindView(R.id.cl_alarm)
ConstraintLayout cl_alarm;
@BindView(R.id.cl_wifi)
ConstraintLayout cl_wifi;
@BindView(R.id.cl_sos)
ConstraintLayout cl_soso;
@BindView(R.id.cl_allapp)
ConstraintLayout cl_allapp;
@BindView(R.id.cl_weather)
ConstraintLayout cl_weather;
@BindView(R.id.cl_battery)
ConstraintLayout cl_battery;
@BindView(R.id.tv_add)
TextView tv_add;
@BindView(R.id.tv_battery)
@@ -86,24 +96,18 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
TextView tv_temp;
@BindView(R.id.cpv)
CircleProgressView cpv;
@BindView(R.id.cl_alarm)
ConstraintLayout cl_alarm;
@BindView(R.id.iv_charging)
ImageView iv_charging;
@BindView(R.id.recyclerView)
RecyclerView recyclerView;
@BindView(R.id.rv_noti)
RecyclerView rv_noti;
@BindView(R.id.rv_clock)
RecyclerView rv_clock;
@BindView(R.id.wifi_ssid)
TextView wifi_ssid;
@BindView(R.id.cl_wifi)
ConstraintLayout cl_wifi;
@BindView(R.id.iv_sos)
ImageView iv_sos;
@BindView(R.id.rv_sos)
RecyclerView rv_sos;
@BindView(R.id.cl_sos)
ConstraintLayout cl_soso;
@BindView(R.id.iv_note_nodata)
ImageView iv_note_nodata;
@@ -116,7 +120,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
private AlarmClockAdapter alarmClockAdapter;
private SOSNnmberAdapter sosNnmberAdapter;
private MMKV mmkv;
private Context context;
private Context mContext;
private ContentResolver mCRv;
// TODO: Rename parameter arguments, choose names that match
@@ -265,8 +269,8 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
Bundle savedInstanceState) {
// Inflate the layout for this fragment
rootView = inflater.inflate(R.layout.fragment_custom, container, false);
context = rootView.getContext();
mCRv = context.getContentResolver();
mContext = rootView.getContext();
mCRv = mContext.getContentResolver();
ButterKnife.bind(this, rootView);
initView();
initData();
@@ -289,8 +293,8 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
}
});
notificationAdapter = new NotificationAdapter();
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(notificationAdapter);
rv_noti.setLayoutManager(new LinearLayoutManager(getActivity()));
rv_noti.setAdapter(notificationAdapter);
if (isWifiConnect()) {
wifi_ssid.setText(getConnectWifiSsid());
} else {
@@ -317,6 +321,29 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
getActivity().startActivity(intent);
}
});
cl_allapp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getActivity().startActivity(new Intent(getActivity(), APPListActivity.class));
}
});
cl_weather.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getActivity(), WeatherActivity.class));
}
});
cl_battery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = mContext.getPackageManager().resolveActivity(powerUsageIntent, 0);
// check that the Battery app exists on this device
if (resolveInfo != null) {
startActivity(powerUsageIntent);
}
}
});
setAlarm();
refreshMemory();
}
@@ -359,17 +386,13 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
}
private void initAmap() {
AMapLocationClient aMapLocationClient = AmapManager.getInstance().getLocationClient();
aMapLocationClient.stopLocation();
aMapLocationClient.startLocation();
aMapLocationClient.setLocationListener(new AMapLocationListener() {
AmapManager.getInstance().startLocation(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
Log.e(TAG, "onLocationChanged: " + aMapLocation);
if (aMapLocation.getErrorCode() == 0) {
String city = aMapLocation.getCity();
getweather(aMapLocation.getLongitude(), aMapLocation.getLatitude());
tv_location.setText(city);
getweather(aMapLocation.getLongitude(), aMapLocation.getLatitude());
} else {
}
@@ -386,15 +409,16 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
List<AlarmClockData> data = gson.fromJson(jsonString, type);
List<AlarmClockData> showData = data.subList(0, 1);
notificationAdapter.setDataList(data);
recyclerView.setVisibility(View.VISIBLE);
rv_noti.setVisibility(View.VISIBLE);
iv_note_nodata.setVisibility(View.GONE);
} else {
recyclerView.setVisibility(View.GONE);
rv_noti.setVisibility(View.GONE);
iv_note_nodata.setVisibility(View.VISIBLE);
}
}
private void getweather(double longitude, double latitude) {
String location = longitude + "," + latitude;
/**
* 实况天气数据
* @param location 所查询的地区可通过该地区名称、ID、IP和经纬度进行查询经纬度格式经度,纬度
@@ -404,26 +428,52 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
* @param listener 网络访问结果回调
*/
QWeather.getWeatherNow(getActivity(), "" + longitude + "," + latitude, Lang.ZH_HANS, Unit.METRIC, new QWeather.OnResultWeatherNowListener() {
QWeather.getWeatherNow(getActivity(), location, Lang.ZH_HANS, Unit.METRIC, new QWeather.OnResultWeatherNowListener() {
@Override
public void onError(Throwable e) {
Log.e(TAG, "getWeather onError: " + e);
Log.e("getWeatherNow", "onError: " + e);
}
@Override
public void onSuccess(WeatherNowBean weatherBean) {
// Log.e(TAG, "getWeather onSuccess: " + new Gson().toJson(weatherBean));
Log.e("getWeatherNow", "onSuccess: " + new Gson().toJson(weatherBean));
//先判断返回的status是否正确当status正确时获取数据若status不正确可查看status对应的Code值找到原因
if (Code.OK == weatherBean.getCode()) {
WeatherNowBean.NowBaseBean now = weatherBean.getNow();
String imageName = "he" + now.getIcon();
// String imageName = "he" + now.getIcon();
// int resId = getResources().getIdentifier(imageName, "drawable", getActivity().getPackageName());
// iv_pic.setImageDrawable(getActivity().getDrawable(resId));
tv_temp.setText(now.getTemp() + "");
} else {
//在此查看返回数据失败的原因
Code code = weatherBean.getCode();
Log.e(TAG, "failed code: " + code);
Log.e("getWeatherNow", "failed code: " + code);
}
}
});
QWeather.getWeather24Hourly(getActivity(), location, new QWeather.OnResultWeatherHourlyListener() {
@Override
public void onError(Throwable throwable) {
Log.e("getWeather24Hourly", "onError: " + throwable);
}
@Override
public void onSuccess(WeatherHourlyBean weatherHourlyBean) {
Log.e("getWeather24Hourly", "onSuccess: " + new Gson().toJson(weatherHourlyBean));
if (Code.OK == weatherHourlyBean.getCode()) {
List<WeatherHourlyBean.HourlyBean> hourly = weatherHourlyBean.getHourly();
if (hourly != null && hourly.size() != 0) {
WeatherHourlyBean.HourlyBean now = hourly.get(0);
String imageName = "he" + now.getIcon();
int resId = getResources().getIdentifier(imageName, "drawable", getActivity().getPackageName());
iv_pic.setImageDrawable(getActivity().getDrawable(resId));
tv_temp.setText(now.getTemp() + "");
}
} else {
//在此查看返回数据失败的原因
Code code = weatherHourlyBean.getCode();
Log.e("getWeather24Hourly", "failed code: " + code);
}
}
});
@@ -431,7 +481,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
private void killBackgroundApp() {
List<String> pkgList = APKUtils.queryFilterAppList(context);
List<String> pkgList = APKUtils.queryFilterAppList(mContext);
for (String pkg : pkgList) {
if (pkg.equalsIgnoreCase(BuildConfig.APPLICATION_ID)) continue;
killBackgroundProcesses(pkg);
@@ -442,7 +492,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
ActivityManager activityManager;
try {
activityManager = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
mContext.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses(packageName);
Method forceStopPackage = activityManager.getClass()
.getDeclaredMethod("forceStopPackage", String.class);
@@ -457,8 +507,8 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
}
private void refreshMemory() {
long avail = AppUtil.getAvailMemory(context);
long total = AppUtil.getTotalMemory(context);
long avail = AppUtil.getAvailMemory(mContext);
long total = AppUtil.getTotalMemory(mContext);
int x = (int) (((total - avail) / (double) total) * 100);
cpv.setProgressColor(mShaderColors);
cpv.showAnimation(0, x, 1000);

View File

@@ -1,13 +1,10 @@
package com.uiui.os.service;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.IBinder;
import android.os.PowerManager;
import android.text.TextUtils;
@@ -17,11 +14,10 @@ import android.util.Log;
import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.DownloadTask;
import com.blankj.utilcode.util.ImageUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.uiui.os.BuildConfig;
import com.uiui.os.activity.MainContact;
import com.uiui.os.activity.MainPresenter;
import com.uiui.os.activity.main.MainContact;
import com.uiui.os.activity.main.MainPresenter;
import com.uiui.os.activity.NoticeActivity;
import com.uiui.os.base.BaseService;
import com.uiui.os.bean.AlarmClockData;
@@ -34,12 +30,8 @@ import com.uiui.os.utils.AppUsedTimeUtils;
import com.uiui.os.utils.ToastUtil;
import com.uiui.os.utils.Utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.List;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
@@ -58,6 +50,7 @@ import okhttp3.RequestBody;
public class MainService extends BaseService implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
private static final String TAG = MainService.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
public static MainPresenter mPresenter;
public MainService() {

View File

@@ -29,9 +29,71 @@ public class APKUtils {
this.add("com.sprd.sprdnote");
this.add("com.android.deskclock");
this.add("com.alldocube.store");
this.add("com.android.uiuios");
}};
private static HashSet<String> showPackageName = new HashSet<String>() {{
this.add("com.android.dialer");
this.add("com.android.gallery3d");
this.add("com.android.settings");
this.add("com.android.messaging");
this.add("com.android.camera2");
}};
private static String TAG = APKUtils.class.getSimpleName();
public static ArrayList<ApplicationInfo> getSystemApp(Context context) {
PackageManager pm = context.getPackageManager();
// 查询所有已经安装的应用程序
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除但还有安装目录的
ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
// 通过getPackageManager()的queryIntentActivities方法遍历,得到所有能打开的app的packageName
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
Set<String> allowPackages = new HashSet();
for (ResolveInfo resolveInfo : resolveinfoList) {
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.packageName);
allowPackages.add(resolveInfo.activityInfo.packageName);
}
for (ApplicationInfo app : appInfos) {
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) > 0)//通过flag排除系统应用会将电话、短信也排除掉
{
if (allowPackages.contains(app.packageName) && !showPackageName.contains(app.packageName)) {
applicationInfos.add(app);
}
} else {
// if(app.uid > 10000){//通过uid排除系统应用在一些手机上效果不好
// applicationInfos.add(app);
// }
// if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
//// if (allowPackages.contains(app.packageName)) {
// applicationInfos.add(app);
// }
}
}
applicationInfos.sort(new Comparator<ApplicationInfo>() {
@Override
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
}
});
applicationInfos.sort(new Comparator<ApplicationInfo>() {
@Override
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
if ((o1.flags & ApplicationInfo.FLAG_SYSTEM) <= (o2.flags & ApplicationInfo.FLAG_SYSTEM)) {
return 1;
} else {
return -1;
}
}
});
return applicationInfos;
}
public static ArrayList<ApplicationInfo> queryFilterAppInfo(Context context) {
PackageManager pm = context.getPackageManager();
@@ -52,22 +114,25 @@ public class APKUtils {
}
for (ApplicationInfo app : appInfos) {
// if((app.flags & ApplicationInfo.FLAG_SYSTEM) <= 0)//通过flag排除系统应用会将电话、短信也排除掉
// {
// applicationInfos.add(app);
// }
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) > 0)//通过flag排除系统应用会将电话、短信也排除掉
{
if (showPackageName.contains(app.packageName)) {
applicationInfos.add(app);
}
} else {
// if(app.uid > 10000){//通过uid排除系统应用在一些手机上效果不好
// applicationInfos.add(app);
// }
if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
// if (allowPackages.contains(app.packageName)) {
applicationInfos.add(app);
applicationInfos.add(app);
}
}
}
applicationInfos.sort(new Comparator<ApplicationInfo>() {
@Override
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(),o2.loadLabel(pm).toString());
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
}
});

View File

@@ -1,5 +1,6 @@
package com.uiui.os.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
@@ -7,12 +8,22 @@ import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tencent.mmkv.MMKV;
import java.lang.reflect.Type;
public class AmapManager {
private String TAG = AmapManager.class.getSimpleName();
private static final String AMAPLOCATION_JSON_KEY = "AMAPLOCATION_JSON_STRING";
@SuppressLint("StaticFieldLeak")
private static AmapManager sInstance;
private Context mContext;
public static AMapLocationClient locationClient = null;
private String TAG = AmapManager.class.getSimpleName();
private MMKV mMMKV = MMKV.defaultMMKV();
private AMapLocationClient locationClient = null;
private AMapLocation nowAMapLocation;
private AmapManager(Context context) {
this.mContext = context;
@@ -22,7 +33,6 @@ public class AmapManager {
if (sInstance == null) {
sInstance = new AmapManager(context);
}
}
public static AmapManager getInstance() {
@@ -57,7 +67,6 @@ public class AmapManager {
//设置定位模式为AMapLocationMode.Hight_Accuracy高精度模式。
//设置定位监听
locationClient.setLocationListener(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
//errCode等于0代表定位成功其他的为定位失败具体的可以参照官网定位错误码说明
@@ -75,4 +84,45 @@ public class AmapManager {
locationClient.startLocation();
Log.e(TAG, "initAmap: " + "startLocation");
}
public AMapLocation getNowAMapLocation() {
if (nowAMapLocation == null) {
String aMapLocationjson = mMMKV.decodeString(AMAPLOCATION_JSON_KEY, "");
Type type = new TypeToken<AMapLocation>() {
}.getType();
AMapLocation aMapLocation = new Gson().fromJson(aMapLocationjson, type);
return aMapLocation;
}
return this.nowAMapLocation;
}
public void startLocation(AMapLocationListener aMapLocationListener) {
initAmap();
locationClient.stopLocation();
locationClient.startLocation();
locationClient.setLocationListener(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
Log.e(TAG, "onLocationChanged: " + aMapLocation.toStr());
if (aMapLocation.getErrorCode() == 0) {
nowAMapLocation = aMapLocation;
mMMKV.encode(AMAPLOCATION_JSON_KEY, aMapLocation.toStr());
} else {
mMMKV.encode(AMAPLOCATION_JSON_KEY, "");
}
aMapLocationListener.onLocationChanged(aMapLocation);
}
});
}
public String getLocation() {
AMapLocation aMapLocation = getNowAMapLocation();
if (aMapLocation == null) {
return "0,0";
} else {
String location = aMapLocation.getLongitude() + "," + aMapLocation.getLatitude();
Log.e(TAG, "getLocation: " + location);
return location;
}
}
}

View File

@@ -11,12 +11,14 @@ public class IconUtils {
this.add("com.android.calculator2");//计算器
this.add("com.android.calendar");//日历
this.add("com.android.camera");//相机
this.add("com.mediatek.camera");//相机
this.add("com.android.camera2");//相机
this.add("com.android.contacts");//通讯录
this.add("com.android.deskclock");//时钟
this.add("com.android.dialer");//电话
this.add("com.android.dialer");//电话
this.add("com.android.gallery3d");//图库
this.add("com.android.mms");//信息
this.add("com.android.mms.ui");//信息
this.add("com.android.messaging");//信息
this.add("com.android.music");//音乐
@@ -25,6 +27,7 @@ public class IconUtils {
this.add("com.android.settings");//设置
this.add("com.android.soundrecorder");//录音机
this.add("com.android.stk.StkMain");//sim卡
this.add("com.android.stk");//sim卡
this.add("com.android.vdieo");//视频
this.add("com.mediatek.filemanager");//文件管理
this.add("com.android.documentsui");//下载
@@ -40,6 +43,7 @@ public class IconUtils {
this.add("com_android_calendar");
this.add("com_android_camera");
this.add("com_android_camera");
this.add("com_android_camera");
this.add("com_android_contacts");
this.add("com_android_deskclock");
this.add("com_android_dialer");
@@ -47,12 +51,14 @@ public class IconUtils {
this.add("com_android_gallery3d_app");
this.add("com_android_mms_ui");
this.add("com_android_mms_ui");
this.add("com_android_mms_ui");
this.add("com_android_music");
this.add("com_android_providers_downloads_ui");
this.add("com_android_quicksearchbox");
this.add("com_android_settings");
this.add("com_android_soundrecorder");
this.add("com_android_stk_stkmain");
this.add("com_android_stk_stkmain");
this.add("com_android_vdieo");
this.add("com_mediatek_filemanager");
this.add("com_mediatek_filemanager");

View File

@@ -0,0 +1,32 @@
package com.uiui.os.utils;
import android.content.Context;
import android.content.res.Resources;
public class ScreenUtils {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
public static int dp2px(Resources resources, float dp) {
final float scale = resources.getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
public static int sp2px(Resources resources, float sp) {
final float scale = resources.getDisplayMetrics().scaledDensity;
return (int) (sp * scale);
}
}

View File

@@ -0,0 +1,41 @@
package com.uiui.os.view;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* 定义水平方向的距离
*/
public class HorizontalItemDecoration extends RecyclerView.ItemDecoration {
private int space;//定义2个Item之间的距离
public HorizontalItemDecoration(int space, Context mContext) {
this.space = dip2px(space, mContext);
}
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
int totalCount = parent.getAdapter().getItemCount();
if (position == 0) {//第一个
outRect.left = space;
outRect.right = space / 2;
} else if (position == totalCount - 1) {//最后一个
outRect.left = space / 2;
outRect.right = space;
} else {//中间其它的
outRect.left = space / 2;
outRect.right = space / 2;
}
}
public int dip2px(float dpValue, Context context) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
}

View File

@@ -0,0 +1,39 @@
package com.uiui.os.view;
import android.graphics.Rect;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
public class RecyclerItemDecoration extends RecyclerView.ItemDecoration {
private int itemSpaceLeft;
private int itemSpaceCenter;
private int itemNum;
public RecyclerItemDecoration(int itemSpaceLeft, int itemSpaceCenter, int itemNum) {
this.itemSpaceLeft = itemSpaceLeft;
this.itemSpaceCenter = itemSpaceCenter;
this.itemNum = itemNum;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getResources().getDisplayMetrics().widthPixels;
//int position = parent.getChildAdapterPosition(view);
if (parent.getChildCount() > 0) {
if (position % itemNum == 0) { //最左边Item
outRect.left = itemSpaceLeft;
outRect.right = itemSpaceCenter / 3;
} else if (position % itemNum == itemNum - 1) { //最右边Item
outRect.left = itemSpaceCenter / 3;
outRect.right = itemSpaceLeft;
} else { //中间Item
outRect.left = itemSpaceCenter / 3;
outRect.right = itemSpaceCenter / 3;
}
}
}
}

View File

@@ -0,0 +1,41 @@
package com.uiui.os.view;
import android.graphics.Rect;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import java.util.HashMap;
public class RecyclerViewSpacesItemDecoration extends RecyclerView.ItemDecoration {
private final HashMap<String, Integer> mSpaceValueMap;
public static final String TOP_DECORATION = "top_decoration";
public static final String BOTTOM_DECORATION = "bottom_decoration";
public static final String LEFT_DECORATION = "left_decoration";
public static final String RIGHT_DECORATION = "right_decoration";
public RecyclerViewSpacesItemDecoration(final HashMap<String, Integer> mSpaceValueMap) {
this.mSpaceValueMap = mSpaceValueMap;
}
@Override
public void getItemOffsets(final Rect outRect, final View view, final RecyclerView parent,
final RecyclerView.State state) {
if (mSpaceValueMap.get(TOP_DECORATION) != null) {
outRect.top = mSpaceValueMap.get(TOP_DECORATION);
}
if (mSpaceValueMap.get(LEFT_DECORATION) != null) {
outRect.left = mSpaceValueMap.get(LEFT_DECORATION);
}
if (mSpaceValueMap.get(RIGHT_DECORATION) != null) {
outRect.right = mSpaceValueMap.get(RIGHT_DECORATION);
}
if (mSpaceValueMap.get(BOTTOM_DECORATION) != null) {
outRect.bottom = mSpaceValueMap.get(BOTTOM_DECORATION);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 46 KiB

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