Skip to content
This repository was archived by the owner on Oct 26, 2023. It is now read-only.

Commit 420e280

Browse files
authored
Merge pull request #147 from TheAndroidMaster/develop
Version 3.8-beta4
2 parents 073bf51 + 0ee4011 commit 420e280

File tree

63 files changed

+1104
-2405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1104
-2405
lines changed

app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
minSdkVersion 16
1010
targetSdkVersion 27
1111
maxSdkVersion 25
12-
versionCode 39
13-
versionName "3.8-beta3"
12+
versionCode 40
13+
versionName "3.8-beta4"
1414
vectorDrawables.useSupportLibrary = true
1515
resConfigs "ar", "en", "es", "ko", "zh"
1616
}
@@ -50,5 +50,4 @@ dependencies {
5050
implementation 'me.jfenn:attribouter:0.1.2'
5151
implementation 'com.afollestad:async:0.2.3'
5252
implementation 'com.google.code.gson:gson:2.8.4'
53-
5453
}

app/src/main/AndroidManifest.xml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
package="com.james.status">
44

55
<uses-permission android:name="android.permission.INTERNET" />
6-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
77
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8-
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
8+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
99
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
1010
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
11-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
11+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
1212
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
1313
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
1414
<uses-permission android:name="android.permission.BLUETOOTH" />
@@ -21,9 +21,9 @@
2121
android:allowBackup="true"
2222
android:icon="@mipmap/ic_launcher"
2323
android:label="@string/app_name"
24+
android:resizeableActivity="true"
2425
android:supportsRtl="true"
25-
android:theme="@style/AppTheme"
26-
android:resizeableActivity="true">
26+
android:theme="@style/AppTheme">
2727

2828
<activity
2929
android:name=".activities.SplashActivity"
@@ -36,9 +36,13 @@
3636

3737
</activity>
3838

39-
<activity android:name=".activities.MainActivity"/>
39+
<activity android:name=".activities.MainActivity" />
4040

41-
<activity android:name=".activities.AppSettingActivity" />
41+
<activity
42+
android:name=".activities.AppSettingActivity"
43+
android:theme="@style/AppTheme.Transparent"
44+
android:documentLaunchMode="always"
45+
android:excludeFromRecents="true" />
4246

4347
<activity
4448
android:name=".activities.ImagePickerActivity"
@@ -52,7 +56,7 @@
5256
android:name=".activities.NotificationCompatActivity"
5357
android:theme="@style/AppTheme.Transparent" />
5458

55-
<receiver android:name=".receivers.ActivityVisibilitySettingReceiver" />
59+
<receiver android:name=".receivers.ActivityFullScreenSettingReceiver" />
5660

5761
<service android:name=".services.StatusServiceCompat" />
5862

@@ -62,12 +66,12 @@
6266
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
6367

6468
<intent-filter>
65-
<action android:name="android.accessibilityservice.AccessibilityService"/>
69+
<action android:name="android.accessibilityservice.AccessibilityService" />
6670
</intent-filter>
6771

6872
<meta-data
6973
android:name="android.accessibilityservice"
70-
android:resource="@xml/accessibilityservice"/>
74+
android:resource="@xml/accessibilityservice" />
7175

7276
</service>
7377

Lines changed: 9 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,27 @@
11
package com.james.status.activities;
22

3-
import android.content.Intent;
4-
import android.graphics.drawable.ColorDrawable;
3+
import android.content.DialogInterface;
54
import android.os.Bundle;
6-
import android.support.annotation.NonNull;
75
import android.support.annotation.Nullable;
86
import android.support.v7.app.AppCompatActivity;
9-
import android.support.v7.widget.GridLayoutManager;
10-
import android.support.v7.widget.RecyclerView;
11-
import android.support.v7.widget.SwitchCompat;
12-
import android.support.v7.widget.Toolbar;
13-
import android.view.MenuItem;
14-
import android.view.View;
15-
import android.widget.CompoundButton;
16-
import android.widget.ImageView;
177

18-
import com.afollestad.async.Action;
19-
import com.james.status.R;
20-
import com.james.status.adapters.ActivityAdapter;
21-
import com.james.status.data.AppData;
22-
import com.james.status.data.PreferenceData;
23-
import com.james.status.dialogs.ColorPickerDialog;
24-
import com.james.status.dialogs.PreferenceDialog;
25-
import com.james.status.utils.ColorUtils;
8+
import com.james.status.data.AppPreferenceData;
9+
import com.james.status.dialogs.preference.AppPreferenceDialog;
2610

2711
public class AppSettingActivity extends AppCompatActivity {
2812

29-
public final static String EXTRA_APP = "com.james.status.EXTRA_APP";
30-
public final static String EXTRA_ACTIVITY = "com.james.status.EXTRA_ACTIVITY";
31-
32-
private AppData app;
33-
private AppData.ActivityData activity;
34-
private ImageView colorView;
35-
36-
private ActivityAdapter adapter;
13+
public final static String EXTRA_COMPONENT = "com.james.status.EXTRA_COMPONENT";
3714

3815
@Override
3916
protected void onCreate(@Nullable Bundle savedInstanceState) {
4017
super.onCreate(savedInstanceState);
41-
setContentView(R.layout.activity_app_settings);
42-
43-
Intent intent = getIntent();
44-
app = intent.getParcelableExtra(EXTRA_APP);
45-
46-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
47-
final RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
48-
colorView = (ImageView) findViewById(R.id.colorView);
49-
SwitchCompat fullscreenSwitch = (SwitchCompat) findViewById(R.id.fullscreenSwitch);
50-
SwitchCompat notificationSwitch = (SwitchCompat) findViewById(R.id.notificationSwitch);
51-
52-
toolbar.setTitle(app.label);
53-
54-
setSupportActionBar(toolbar);
55-
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
56-
57-
findViewById(R.id.color).setOnClickListener(new View.OnClickListener() {
18+
AppPreferenceDialog dialog = new AppPreferenceDialog(this, new AppPreferenceData(this, getIntent().getStringExtra(EXTRA_COMPONENT)));
19+
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
5820
@Override
59-
public void onClick(View v) {
60-
new Action<Integer>() {
61-
@NonNull
62-
@Override
63-
public String id() {
64-
return "activityColorDialog";
65-
}
66-
67-
@Nullable
68-
@Override
69-
protected Integer run() throws InterruptedException {
70-
return ColorUtils.getPrimaryColor(AppSettingActivity.this, app.getComponentName());
71-
}
72-
73-
@Override
74-
protected void done(@Nullable Integer result) {
75-
ColorPickerDialog dialog = new ColorPickerDialog(AppSettingActivity.this).withAlpha((Boolean) PreferenceData.STATUS_TRANSPARENT_MODE.getValue(AppSettingActivity.this));
76-
dialog.setPreference(app.getIntegerPreference(AppSettingActivity.this, AppData.PreferenceIdentifier.COLOR));
77-
dialog.setDefaultPreference(result != null ? result : (int) PreferenceData.STATUS_COLOR.getValue(AppSettingActivity.this));
78-
dialog.setListener(new PreferenceDialog.OnPreferenceListener<Integer>() {
79-
@Override
80-
public void onPreference(PreferenceDialog dialog, Integer preference) {
81-
app.putPreference(AppSettingActivity.this, AppData.PreferenceIdentifier.COLOR, preference);
82-
colorView.setImageDrawable(new ColorDrawable(preference));
83-
adapter.notifyDataSetChanged();
84-
}
85-
86-
@Override
87-
public void onCancel(PreferenceDialog dialog) {
88-
}
89-
});
90-
dialog.show();
91-
}
92-
}.execute();
93-
}
94-
});
95-
96-
Integer color = app.getIntegerPreference(this, AppData.PreferenceIdentifier.COLOR);
97-
if (color != null) {
98-
colorView.setImageDrawable(new ColorDrawable(color));
99-
} else {
100-
new Action<Integer>() {
101-
@NonNull
102-
@Override
103-
public String id() {
104-
return "activityColor";
105-
}
106-
107-
@Nullable
108-
@Override
109-
protected Integer run() throws InterruptedException {
110-
return ColorUtils.getPrimaryColor(AppSettingActivity.this, app.getComponentName());
111-
}
112-
113-
@Override
114-
protected void done(@Nullable Integer result) {
115-
colorView.setImageDrawable(new ColorDrawable(result != null ? result : (int) PreferenceData.STATUS_COLOR.getValue(AppSettingActivity.this)));
116-
}
117-
}.execute();
118-
}
119-
120-
Boolean isFullscreen = app.getBooleanPreference(this, AppData.PreferenceIdentifier.FULLSCREEN);
121-
fullscreenSwitch.setChecked(isFullscreen != null && isFullscreen);
122-
123-
fullscreenSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
124-
@Override
125-
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
126-
app.putPreference(AppSettingActivity.this, AppData.PreferenceIdentifier.FULLSCREEN, isChecked);
127-
adapter.notifyDataSetChanged();
128-
}
129-
});
130-
131-
Boolean isNotifications = app.getSpecificBooleanPreference(this, AppData.PreferenceIdentifier.NOTIFICATIONS);
132-
notificationSwitch.setChecked(isNotifications == null || isNotifications);
133-
134-
notificationSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
135-
@Override
136-
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
137-
app.putSpecificPreference(AppSettingActivity.this, AppData.PreferenceIdentifier.NOTIFICATIONS, isChecked);
21+
public void onDismiss(DialogInterface dialog) {
22+
finish();
13823
}
13924
});
140-
141-
recycler.setLayoutManager(new GridLayoutManager(this, 1));
142-
recycler.setNestedScrollingEnabled(false);
143-
144-
adapter = new ActivityAdapter(this, app.activities);
145-
recycler.setAdapter(adapter);
146-
147-
if (intent.hasExtra(EXTRA_ACTIVITY)) {
148-
activity = intent.getParcelableExtra(EXTRA_ACTIVITY);
149-
150-
new Action<Integer>() {
151-
@NonNull
152-
@Override
153-
public String id() {
154-
return "activityColorDialog";
155-
}
156-
157-
@Nullable
158-
@Override
159-
protected Integer run() throws InterruptedException {
160-
return ColorUtils.getPrimaryColor(AppSettingActivity.this, activity.getComponentName());
161-
}
162-
163-
@Override
164-
protected void done(@Nullable Integer result) {
165-
if (activity == null) return;
166-
167-
ColorPickerDialog dialog = new ColorPickerDialog(AppSettingActivity.this);
168-
dialog.setPreference(activity.getIntegerPreference(AppSettingActivity.this, AppData.PreferenceIdentifier.COLOR));
169-
dialog.setDefaultPreference(result != null ? result : (int) PreferenceData.STATUS_COLOR.getValue(AppSettingActivity.this));
170-
dialog.setListener(new PreferenceDialog.OnPreferenceListener<Integer>() {
171-
@Override
172-
public void onPreference(PreferenceDialog dialog, Integer preference) {
173-
if (activity != null) {
174-
activity.putPreference(AppSettingActivity.this, AppData.PreferenceIdentifier.COLOR, preference);
175-
adapter.notifyDataSetChanged();
176-
}
177-
}
178-
179-
@Override
180-
public void onCancel(PreferenceDialog dialog) {
181-
}
182-
});
183-
dialog.show();
184-
}
185-
}.execute();
186-
}
187-
}
188-
189-
@Override
190-
public boolean onOptionsItemSelected(MenuItem item) {
191-
switch (item.getItemId()) {
192-
case android.R.id.home:
193-
finish();
194-
break;
195-
}
196-
197-
return super.onOptionsItemSelected(item);
25+
dialog.show();
19826
}
19927
}

app/src/main/java/com/james/status/activities/MainActivity.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.support.annotation.StringRes;
1515
import android.support.design.widget.AppBarLayout;
1616
import android.support.design.widget.BottomSheetBehavior;
17+
import android.support.design.widget.FloatingActionButton;
1718
import android.support.design.widget.TabLayout;
1819
import android.support.v4.content.ContextCompat;
1920
import android.support.v4.view.MenuItemCompat;
@@ -67,9 +68,10 @@ public class MainActivity extends AppCompatActivity implements ViewPager.OnPageC
6768
ImageView expand;
6869
private TextView title, content;
6970
private ImageView icon;
71+
private FloatingActionButton fab;
7072

7173
private BottomSheetBehavior behavior;
72-
private MenuItem resetItem, notificationItem;
74+
private MenuItem resetItem;
7375

7476
private TooManyIconsReceiver tooManyIconsReceiver;
7577

@@ -91,6 +93,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
9193
title = findViewById(R.id.title);
9294
content = findViewById(R.id.content);
9395
icon = findViewById(R.id.tutorialIcon);
96+
fab = findViewById(R.id.fab);
97+
98+
fab.setOnClickListener(new View.OnClickListener() {
99+
@Override
100+
public void onClick(View v) {
101+
if (adapter.getItem(viewPager.getCurrentItem()) instanceof AppPreferenceFragment)
102+
((AppPreferenceFragment) adapter.getItem(viewPager.getCurrentItem())).showDialog();
103+
}
104+
});
94105

95106
ViewCompat.setElevation(bottomSheet, StaticUtils.getPixelsFromDp(10));
96107

@@ -259,7 +270,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
259270
getMenuInflater().inflate(R.menu.menu_main, menu);
260271

261272
resetItem = menu.findItem(R.id.action_reset);
262-
notificationItem = menu.findItem(R.id.action_toggle_notifications);
263273
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
264274

265275
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@@ -316,13 +326,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
316326
if (adapter.getItem(viewPager.getCurrentItem()) instanceof AppPreferenceFragment)
317327
((AppPreferenceFragment) adapter.getItem(viewPager.getCurrentItem())).reset();
318328
break;
319-
case R.id.action_toggle_notifications:
320-
if (adapter.getItem(viewPager.getCurrentItem()) instanceof AppPreferenceFragment) {
321-
boolean isNotifications = ((AppPreferenceFragment) adapter.getItem(viewPager.getCurrentItem())).isNotifications();
322-
((AppPreferenceFragment) adapter.getItem(viewPager.getCurrentItem())).setNotifications(!isNotifications);
323-
item.setTitle(!isNotifications ? R.string.notifications_disable : R.string.notifications_enable);
324-
}
325-
break;
326329
}
327330
return super.onOptionsItemSelected(item);
328331
}
@@ -350,14 +353,13 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
350353

351354
@Override
352355
public void onPageSelected(int position) {
353-
if (resetItem != null && notificationItem != null) {
356+
if (resetItem != null) {
354357
if (adapter.getItem(position) instanceof AppPreferenceFragment) {
358+
fab.show();
355359
resetItem.setVisible(true);
356-
notificationItem.setVisible(true);
357-
notificationItem.setTitle(((AppPreferenceFragment) adapter.getItem(position)).isNotifications() ? R.string.notifications_disable : R.string.notifications_enable);
358360
} else {
361+
fab.hide();
359362
resetItem.setVisible(false);
360-
notificationItem.setVisible(false);
361363
}
362364
}
363365

0 commit comments

Comments
 (0)