Skip to content

Commit 1e5900c

Browse files
committed
Support adjust bubble size
1 parent 3f1d61f commit 1e5900c

File tree

9 files changed

+57
-5
lines changed

9 files changed

+57
-5
lines changed

app/src/main/java/com/npes87184/s2tdroid/donate/BubbleService.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,18 @@ public class BubbleService extends Service implements FloatingViewListener {
4444

4545
@Override
4646
public int onStartCommand(Intent intent, int flags, int startId) {
47+
int bubbleSize;
48+
4749
if (mFloatingViewManager != null) {
4850
return START_STICKY;
4951
}
5052

5153
prefs = PreferenceManager.getDefaultSharedPreferences(this);
54+
if(prefs.getString(KeyCollection.KEY_BUBBLE_SIZE, "large").equals("large")) {
55+
bubbleSize = 96;
56+
} else {
57+
bubbleSize = 72;
58+
}
5259
final DisplayMetrics metrics = new DisplayMetrics();
5360
final WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
5461
windowManager.getDefaultDisplay().getMetrics(metrics);
@@ -100,13 +107,13 @@ public void onClick(DialogInterface dialog, int which) {
100107
});
101108

102109
mFloatingViewManager = new FloatingViewManager(this, this);
103-
mFloatingViewManager.setFixedTrashIconImage(resize(R.drawable.ic_trash_fixed, 96));
110+
mFloatingViewManager.setFixedTrashIconImage(resize(R.drawable.ic_trash_fixed, bubbleSize));
104111
mFloatingViewManager.setActionTrashIconImage(resize(R.drawable.ic_trash_action, 200));
105112
final FloatingViewManager.Options options = new FloatingViewManager.Options();
106113
options.floatingViewX = (int) convertDpToPixel(512, this);
107114
options.floatingViewY = (int) convertDpToPixel(512, this);
108-
options.floatingViewHeight = (int) convertDpToPixel(96, this);
109-
options.floatingViewWidth = (int) convertDpToPixel(96, this);
115+
options.floatingViewHeight = (int) convertDpToPixel(bubbleSize, this);
116+
options.floatingViewWidth = (int) convertDpToPixel(bubbleSize, this);
110117
options.overMargin = (int) (16 * metrics.density);
111118
mFloatingViewManager.addViewToWindow(iconView, options);
112119

app/src/main/java/com/npes87184/s2tdroid/donate/SettingFragment.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SettingFragment extends PreferenceFragment implements
1515

1616
private Preference mode;
1717
private Preference bubble_mode;
18+
private Preference bubble_size;
1819
private Preference file_name;
1920
private Preference file_sort;
2021
private SharedPreferences prefs;
@@ -55,6 +56,13 @@ public void onCreate(Bundle savedInstanceState) {
5556
bubble_mode.setSummary(getActivity().getString(R.string.auto_detect));
5657
}
5758

59+
bubble_size = findPreference(KeyCollection.KEY_BUBBLE_SIZE);
60+
if(prefs.getString(KeyCollection.KEY_BUBBLE_SIZE, "large").equals("large")) {
61+
bubble_size.setSummary(getActivity().getString(R.string.large));
62+
} else {
63+
bubble_size.setSummary(getActivity().getString(R.string.small));
64+
}
65+
5866
file_name = findPreference(KeyCollection.KEY_FILENAME);
5967
if (prefs.getString(KeyCollection.KEY_FILENAME, getString(R.string.filename_manual_key)).equals(getString(R.string.filename_same_key))) {
6068
file_name.setSummary(getString(R.string.filename_same));
@@ -105,13 +113,19 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
105113
mode.setSummary(getActivity().getString(R.string.auto_detect));
106114
}
107115
} else if (key.equals(KeyCollection.KEY_BUBBLE_MODE)) {
108-
if(prefs.getString(KeyCollection.KEY_BUBBLE_MODE, "0").equals("t2s")) {
116+
if (prefs.getString(KeyCollection.KEY_BUBBLE_MODE, "0").equals("t2s")) {
109117
bubble_mode.setSummary(getActivity().getString(R.string.t2s));
110-
} else if(prefs.getString(KeyCollection.KEY_BUBBLE_MODE, "0").equals("s2t")) {
118+
} else if (prefs.getString(KeyCollection.KEY_BUBBLE_MODE, "0").equals("s2t")) {
111119
bubble_mode.setSummary(getActivity().getString(R.string.s2t));
112120
} else {
113121
bubble_mode.setSummary(getActivity().getString(R.string.auto_detect));
114122
}
123+
} else if (key.equals(KeyCollection.KEY_BUBBLE_SIZE)) {
124+
if(prefs.getString(KeyCollection.KEY_BUBBLE_SIZE, "large").equals("large")) {
125+
bubble_size.setSummary(getActivity().getString(R.string.large));
126+
} else {
127+
bubble_size.setSummary(getActivity().getString(R.string.small));
128+
}
115129
} else if (key.equals(KeyCollection.KEY_FILENAME)) {
116130
if (prefs.getString(KeyCollection.KEY_FILENAME, getString(R.string.filename_manual_key)).equals(getString(R.string.filename_same_key))) {
117131
file_name.setSummary(getString(R.string.filename_same));

app/src/main/java/com/npes87184/s2tdroid/donate/model/KeyCollection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class KeyCollection {
88
public static final String KEY_ENCODING = "encoding";
99
public static final String KEY_MODE = "mode";
1010
public static final String KEY_BUBBLE_MODE = "bubble_mode";
11+
public static final String KEY_BUBBLE_SIZE = "bubble_size";
1112
public static final String KEY_OUTPUT_ENCODING = "output_encoding";
1213
public static final String KEY_INPUT_FILE = "input_file";
1314
public static final String KEY_OUTPUT_FOLDER = "output_folder";
976 Bytes
Loading

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@
4040
<string name="s2t">简转繁</string>
4141
<string name="t2s">繁转简</string>
4242

43+
<string name="small">小</string>
44+
<string name="large">大</string>
45+
4346
<string name="mode">转换模式</string>
4447
<string name="bubble_mode">泡泡转换模式</string>
48+
<string name="bubble_size">泡泡大小</string>
4549
<string name="encode">编码</string>
4650
<string name="normal">一般</string>
4751
<string name="choose_tip">透过选择资料夹来对资料夹中每个档案转换。</string>

app/src/main/res/values-zh-rTW/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@
4040
<string name="s2t">簡轉繁</string>
4141
<string name="t2s">繁轉簡</string>
4242

43+
<string name="small">小</string>
44+
<string name="large">大</string>
45+
4346
<string name="mode">轉換模式</string>
4447
<string name="bubble_mode">泡泡轉換模式</string>
48+
<string name="bubble_size">泡泡大小</string>
4549
<string name="encode">編碼</string>
4650
<string name="normal">一般</string>
4751
<string name="choose_tip">透過選擇資料夾來對資料夾中每個檔案轉換。</string>

app/src/main/res/values/arrays.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
<item>0</item>
4040
</string-array>
4141

42+
<string-array name="bubble_size_entry">
43+
<item>@string/small</item>
44+
<item>@string/large</item>
45+
</string-array>
46+
47+
<string-array name="bubble_size_value">
48+
<item>small</item>
49+
<item>large</item>
50+
</string-array>
51+
4252
<string-array name="file_order_entry">
4353
<item>@string/file_order_name_ascending</item>
4454
<item>@string/file_order_name_descending</item>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@
4848
<string name="s2t">Simple to Traditional</string>
4949
<string name="t2s">Traditional to Simple</string>
5050

51+
<string name="small">Small</string>
52+
<string name="large">Large</string>
53+
5154
<string name="mode">Mode</string>
5255
<string name="bubble_mode">Bubble Mode</string>
56+
<string name="bubble_size">Bubble Size</string>
5357
<string name="encode">Encode</string>
5458
<string name="normal">Normal</string>
5559
<string name="choose_tip">Now, it can choose a directory to transform each file in that directory.</string>

app/src/main/res/xml/setting.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
android:icon="@drawable/outline_edit_black_48"
2121
android:title="@string/bubble_mode"/>
2222

23+
<ListPreference android:entries="@array/bubble_size_entry"
24+
android:entryValues="@array/bubble_size_value"
25+
android:dialogTitle="@string/bubble_size"
26+
android:negativeButtonText="@string/cancel"
27+
android:key="bubble_size"
28+
android:icon="@drawable/outline_filter_center_focus_black_48"
29+
android:title="@string/bubble_size"/>
30+
2331
<ListPreference android:entries="@array/file_name_option_entry"
2432
android:entryValues="@array/file_name_option_value"
2533
android:dialogTitle="@string/filename"

0 commit comments

Comments
 (0)