Skip to content

Commit

Permalink
3.233
Browse files Browse the repository at this point in the history
  • Loading branch information
WangDaYeeeeee committed Jan 20, 2019
1 parent e1ba535 commit ffa1d81
Show file tree
Hide file tree
Showing 86 changed files with 1,939 additions and 439 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "wangdaye.com.geometricweather"
minSdkVersion 19
targetSdkVersion 28
versionCode 2231
versionName "2.231"
versionCode 2233
versionName "2.233"
}
buildTypes {
release {
Expand Down
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2231,"versionName":"2.231","enabled":true,"outputFile":"GeometricWeather 2.231.apk","fullName":"release","baseName":"release"},"path":"GeometricWeather 2.231.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2233,"versionName":"2.233","enabled":true,"outputFile":"GeometricWeather 2.233.apk","fullName":"release","baseName":"release"},"path":"GeometricWeather 2.233.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -76,37 +76,50 @@ public static GeometricWeather getInstance() {
public static final int WIDGET_DAY_WEEK_PENDING_INTENT_CODE_CALENDAR = 33;
// clock + day (vertical).
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_WEATHER = 41;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK = 42;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_1 = 43;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_2 = 44;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_REFRESH = 45;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_REFRESH = 42;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_LIGHT = 43;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_NORMAL = 44;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_BLACK = 45;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_1_LIGHT = 46;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_2_LIGHT = 47;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_1_NORMAL = 48;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_2_NORMAL = 49;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_1_BLACK = 50;
public static final int WIDGET_CLOCK_DAY_VERTICAL_PENDING_INTENT_CODE_CLOCK_2_BLACK = 51;
// clock + day (horizontal).
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_WEATHER = 51;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_CLOCK = 52;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_REFRESH = 53;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_CALENDAR = 54;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_WEATHER = 61;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_REFRESH = 62;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_CALENDAR = 63;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_CLOCK_LIGHT = 64;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_CLOCK_NORMAL = 65;
public static final int WIDGET_CLOCK_DAY_HORIZONTAL_PENDING_INTENT_CODE_CLOCK_BLACK = 66;
// clock + day + details.
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_WEATHER = 61;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_CLOCK = 62;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_REFRESH = 63;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_CALENDAR = 64;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_WEATHER = 71;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_REFRESH = 72;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_CALENDAR = 73;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_CLOCK_LIGHT = 74;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_CLOCK_NORMAL = 75;
public static final int WIDGET_CLOCK_DAY_DETAILS_PENDING_INTENT_CODE_CLOCK_BLACK = 76;
// clock + day + week.
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_WEATHER = 71;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_CLOCK = 72;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_REFRESH = 73;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_CALENDAR = 74;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_WEATHER = 81;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_REFRESH = 82;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_CALENDAR = 83;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_CLOCK_LIGHT = 84;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_CLOCK_NORMAL = 85;
public static final int WIDGET_CLOCK_DAY_WEEK_PENDING_INTENT_CODE_CLOCK_BLACK = 86;
// text.
public static final int WIDGET_TEXT_PENDING_INTENT_CODE_WEATHER = 81;
public static final int WIDGET_TEXT_PENDING_INTENT_CODE_REFRESH = 82;
public static final int WIDGET_TEXT_PENDING_INTENT_CODE_CALENDAR = 83;
public static final int WIDGET_TEXT_PENDING_INTENT_CODE_WEATHER = 91;
public static final int WIDGET_TEXT_PENDING_INTENT_CODE_REFRESH = 92;
public static final int WIDGET_TEXT_PENDING_INTENT_CODE_CALENDAR = 93;

@Override
public void onCreate() {
super.onCreate();
initialize();

String processName = getProcessName();
if (!TextUtils.isEmpty(processName)
&& processName.equals(this.getPackageName())) {
initialize();
resetDayNightMode();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void onUpdateCompleted(Location location, Weather weather, Weather old, b
@Override
public void onPollingCompleted() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(this, locationList);
ShortcutsManager.refreshShortcutsInNewThread(this, locationList);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setDelayTask(parameters, failed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void onUpdateCompleted(Location location, Weather weather, Weather old, b
@Override
public void onPollingCompleted() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(this, locationList);
ShortcutsManager.refreshShortcutsInNewThread(this, locationList);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
setDelayTask(failed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private AboutAppTranslator(String name, String email, int flagResId) {
}

public static List<AboutAppTranslator> buildTranslatorList() {
List<AboutAppTranslator> list = new ArrayList<>(12);
List<AboutAppTranslator> list = new ArrayList<>(13);
list.add(new AboutAppTranslator("Mehmet Saygin Yilmaz", "[email protected]", R.drawable.flag_tr));
list.add(new AboutAppTranslator("Ali D.", "[email protected]", R.drawable.flag_tr));
list.add(new AboutAppTranslator("benjamin Tourrel", "[email protected]", R.drawable.flag_fr));
Expand All @@ -35,6 +35,7 @@ public static List<AboutAppTranslator> buildTranslatorList() {
list.add(new AboutAppTranslator("Jurre Tas", "[email protected]", R.drawable.flag_nl));
list.add(new AboutAppTranslator("Jörg Meinhardt", "[email protected]", R.drawable.flag_de));
list.add(new AboutAppTranslator("Olivér Paróczai", "[email protected]", R.drawable.flag_hu));
list.add(new AboutAppTranslator("Fabio Raitz", "[email protected]", R.drawable.flag_br));
return list;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Weather() {
}

public boolean isValid(float hours) {
return System.currentTimeMillis() - base.timeStamp < hours * 60 * 60 * 1000;
return Math.abs(System.currentTimeMillis() - base.timeStamp) < hours * 60 * 60 * 1000;
}

public static Weather buildWeatherPrimaryData(WeatherEntity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ public void requestLocation(Context context, @NonNull LocationCallback callback)
@Override
public void onResponse(Call<BaiduIPLocationResult> call, Response<BaiduIPLocationResult> response) {
if (response.isSuccessful() && response.body() != null) {
Result result = new Result();
try {
Result result = new Result();

result.district = response.body().getContent().getAddress_detail().getDistrict();
result.city = response.body().getContent().getAddress_detail().getCity();
result.province = response.body().getContent().getAddress_detail().getProvince();
result.country = "中国";
result.latitude = response.body().getContent().getPoint().getY();
result.longitude = response.body().getContent().getPoint().getX();
result.inChina = true;
result.district = response.body().getContent().getAddress_detail().getDistrict();
result.city = response.body().getContent().getAddress_detail().getCity();
result.province = response.body().getContent().getAddress_detail().getProvince();
result.country = "中国";
result.latitude = response.body().getContent().getPoint().getY();
result.longitude = response.body().getContent().getPoint().getX();
result.inChina = true;

callback.onCompleted(result);
} else {
callback.onCompleted(null);
callback.onCompleted(result);
return;
} catch (Exception ignore) {
// do nothing.
}
}
callback.onCompleted(null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.List;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
Expand Down Expand Up @@ -59,7 +58,7 @@ public class AccuWeatherService extends WeatherService {
public AccuWeatherService() {
OkHttpClient client = getClientBuilder()
.addInterceptor(new GzipInterceptor())
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
// .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build();
client.dispatcher().setMaxRequestsPerHost(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean onMove(@NonNull RecyclerView recyclerView,
adapter.moveData(fromPosition, toPosition);
DatabaseHelper.getInstance(ManageActivity.this).writeLocationList(adapter.itemList);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(ManageActivity.this, adapter.itemList);
ShortcutsManager.refreshShortcutsInNewThread(ManageActivity.this, adapter.itemList);
}

((LocationAdapter.ViewHolder) viewHolder)
Expand Down Expand Up @@ -127,7 +127,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(this, adapter.itemList);
ShortcutsManager.refreshShortcutsInNewThread(this, adapter.itemList);
}
break;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ private void deleteLocation(int position) {
new CancelDeleteListener(location),
new DeleteSnackbarCallback(location));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(ManageActivity.this, adapter.itemList);
ShortcutsManager.refreshShortcutsInNewThread(ManageActivity.this, adapter.itemList);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class MainActivity extends GeoActivity
public static final int MANAGE_ACTIVITY = 2;

public static final int MESSAGE_WHAT_STARTUP_SERVICE = 1;
public static final int MESSAGE_REFRESH_REMOTE_VIEWS = 2;

public static final String KEY_MAIN_ACTIVITY_LOCATION = "MAIN_ACTIVITY_LOCATION";

Expand Down Expand Up @@ -130,7 +131,6 @@ protected void onStart() {
initData();
initWidget();
reset();
startupService();
} else {
// reread cache and check if there are new data available through background service.
Weather old = locationNow.weather;
Expand Down Expand Up @@ -421,6 +421,8 @@ private void setDarkMode(boolean dayTime) {

indicator.setCurrentIndicatorColor(ContextCompat.getColor(this, R.color.colorAccent));
indicator.setIndicatorColor(ContextCompat.getColor(this, R.color.colorTextSubtitle));

refreshBackgroundViews();
}
}
}
Expand All @@ -434,13 +436,32 @@ private void refreshLocation(Location location) {
}
}

private void refreshBackgroundViews() {
startupService();
if (locationNow.equals(locationList.get(0))) {
refreshRemoteViews();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcutsInNewThread(this, locationList);
}
}

private void startupService() {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
handler.obtainMessage(MESSAGE_WHAT_STARTUP_SERVICE).sendToTarget();
}
}, 1500);
}, 2000);
}

private void refreshRemoteViews() {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
handler.obtainMessage(MESSAGE_REFRESH_REMOTE_VIEWS).sendToTarget();
}
}, 1000);
}

// permission.
Expand All @@ -465,6 +486,12 @@ private void requestLocationPermission() {
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permission, @NonNull int[] grantResult) {
super.onRequestPermissionsResult(requestCode, permission, grantResult);
if (grantResult.length == 0) {
if (locationNow.isLocal()) {
locationHelper.requestLocation(this, locationNow, this);
}
return;
}
switch (requestCode) {
case LOCATION_PERMISSIONS_REQUEST_CODE:
if (grantResult[0] == PackageManager.PERMISSION_GRANTED) {
Expand Down Expand Up @@ -668,12 +695,10 @@ public void requestWeatherSuccess(@Nullable Weather weather, @Nullable History h
}
refreshLocation(locationNow);

refreshBackgroundViews();

setRefreshing(false);
buildUI();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutsManager.refreshShortcuts(this, locationList);
}
startupService();
} else {
setRefreshing(false);
}
Expand Down Expand Up @@ -707,15 +732,18 @@ public void requestWeatherFailed(@NonNull Location requestLocation) {
public void handleMessage(Message message) {
switch (message.what) {
case MESSAGE_WHAT_STARTUP_SERVICE:
WidgetUtils.refreshWidgetInNewThread(this, locationList.get(0));
NotificationUtils.refreshNotificationInNewThread(this, locationList.get(0));
ThreadManager.getInstance().execute(new Runnable() {
@Override
public void run() {
BackgroundManager.resetAllBackgroundTask(MainActivity.this, false);
}
});
break;

case MESSAGE_REFRESH_REMOTE_VIEWS:
WidgetUtils.refreshWidgetInNewThread(this, locationList.get(0));
NotificationUtils.refreshNotificationInNewThread(this, locationList.get(0));
break;
}
}
}
Loading

0 comments on commit ffa1d81

Please sign in to comment.