2
2
3
3
import android .app .Activity ;
4
4
import android .app .AlertDialog ;
5
+ import android .content .ActivityNotFoundException ;
5
6
import android .content .DialogInterface ;
6
7
import android .content .Intent ;
8
+ import android .net .Uri ;
7
9
import android .os .Bundle ;
10
+ import android .util .Log ;
8
11
import android .view .Menu ;
9
12
import android .view .MenuItem ;
10
13
import android .widget .ListView ;
11
14
import android .widget .SearchView ;
12
15
16
+ import org .slf4j .helpers .Util ;
17
+
13
18
import java .io .File ;
14
19
15
20
import me .sheimi .android .activities .SheimiFragmentActivity ;
21
+ import me .sheimi .android .utils .FsUtils ;
22
+ import me .sheimi .android .utils .Profile ;
16
23
import me .sheimi .sgit .activities .UserSettingsActivity ;
17
24
import me .sheimi .sgit .activities .explorer .ExploreFileActivity ;
18
25
import me .sheimi .sgit .activities .explorer .ImportRepositoryActivity ;
25
32
26
33
public class RepoListActivity extends SheimiFragmentActivity {
27
34
35
+ private static final String LOGTAG = RepoListActivity .class .getSimpleName ();
36
+ private static final int MAX_UPGRADE_SHOW_TIMES = 4 ;
28
37
private ListView mRepoList ;
29
38
private RepoListAdapter mRepoListAdapter ;
30
39
@@ -41,6 +50,8 @@ protected void onCreate(Bundle savedInstanceState) {
41
50
mRepoListAdapter .queryAllRepo ();
42
51
mRepoList .setOnItemClickListener (mRepoListAdapter );
43
52
mRepoList .setOnItemLongClickListener (mRepoListAdapter );
53
+
54
+ showUpgradeDialog ();
44
55
}
45
56
46
57
@ Override
@@ -151,4 +162,59 @@ public void finish() {
151
162
rawfinish ();
152
163
}
153
164
165
+ // Prompt user to install MGit as SGit is no longer being maintained
166
+ private void showUpgradeDialog () {
167
+
168
+ if (Profile .incUpgradeMesssageShownCount (getApplicationContext ()) > MAX_UPGRADE_SHOW_TIMES ) {
169
+ return ;
170
+ }
171
+
172
+ File repoLocation = FsUtils .getRepoDir (getApplicationContext (),"" );
173
+ String mesg = getString (R .string .dialog_upgrade_message ,
174
+ (repoLocation != null ) ? repoLocation .toString () : getString (R .string .default_repo_path ));
175
+
176
+ new AlertDialog .Builder (this )
177
+ .setMessage (mesg )
178
+ .setPositiveButton (getString (R .string .dialog_upgrade_ok_button ), new DialogInterface .OnClickListener () {
179
+ @ Override
180
+ public void onClick (DialogInterface dialog , int which ) {
181
+ Intent goToMarket = new Intent (Intent .ACTION_VIEW )
182
+ .setData (Uri .parse ("market://details?id=com.manichord.mgit" ));
183
+ try {
184
+ startActivity (goToMarket );
185
+ } catch (ActivityNotFoundException e ) {
186
+ dialog .dismiss ();
187
+ showNoGooglePlayDialog ();
188
+ }
189
+ }
190
+ })
191
+ .setNegativeButton (getString (R .string .dialog_upgrade_cancel_button ), new DialogInterface .OnClickListener () {
192
+ public void onClick (DialogInterface dialog ,int id ) {
193
+ dialog .cancel ();
194
+ }
195
+ })
196
+ .create ().show ();
197
+ }
198
+
199
+ private void showNoGooglePlayDialog () {
200
+ AlertDialog .Builder builder = new AlertDialog .Builder (RepoListActivity .this );
201
+ builder .setMessage (getString (R .string .sorry_play_missing_message ));
202
+ builder .setPositiveButton (getString (R .string .dialog_goto_github_ok_button ), new DialogInterface .OnClickListener () {
203
+ @ Override
204
+ public void onClick (DialogInterface dialog , int which ) {
205
+ Intent goToGithub = new Intent (Intent .ACTION_VIEW )
206
+ .setData (Uri .parse ("https://github.com/maks/MGit/releases" ));
207
+ try {
208
+ startActivity (goToGithub );
209
+ } catch (ActivityNotFoundException e ) {
210
+ Log .e (LOGTAG , "could not show Github url for MGit" , e );
211
+ }
212
+ }
213
+ })
214
+ .setNegativeButton (getString (R .string .dialog_upgrade_cancel_button ), new DialogInterface .OnClickListener () {
215
+ public void onClick (DialogInterface dialog ,int id ) {
216
+ dialog .cancel ();
217
+ }
218
+ }).create ().show ();
219
+ }
154
220
}
0 commit comments